User Tools

Site Tools


newdevs:code:add-library-setting

New Developers Working Group

Adding a Library Setting

These instructions cover how to add a library setting to the database. The example is for adding a library setting that can be reference by the Hemlock app. Setting types are in config.org_unit_setting_type.

To-dos:

  1. Add instructions about how to reference the setting in other places in the code.
  2. Add instructions on writing seed data for contributing back to the community.

1. Determine the setting group and add one if necessary

Setting groups are listed in the table config.settings_group. If none of the listed groups are appropriate, you can add one to the table like so:

INSERT INTO config.settings_group
(name, label)
VALUES
('hemlock', 'Hemlock App');

2. Determine if you need to add an fm_class

If you are referencing something that exists in another table, you may need this. Most library settings don't have one. This is not necessary for our example.

Run the following for a list of settings where fm_class is used:

SELECT * FROM config.org_unit_setting_type
WHERE fm_class IS NOT NULL;

3. Determine the datatype for the value

Currently used datatypes are:

  • array
  • bool
  • currency
  • integer
  • interval
  • link
  • string

You can look at examples similar to the setting you want to add to determine the datatype. For our example, the most other settings pointing to external URLs use the string datatype, so this is what we will use.

4. Add a reference to VIEW or UPDATE permissions if necessary

If there are permissions related to your setting, you can point to them in the view_perm and update_perm columns. There are no related permissions for our example.

5. Add the setting type to the table

Once you determine what fields need to be referenced, you can add your new setting type to the table.

INSERT INTO config.org_unit_setting_type
(name, label, grp, description, datatype)
VALUES
('hemlock.events_calendar_url', 'Events calendar URL to display in the Hemlock app', 'hemlock', 'Direct link to library's events calendar for display in the Hemlock app.', 'string');

You should now be able to add a new library setting via the GUI or via the actor.org_unit_setting table.

newdevs/code/add-library-setting.txt · Last modified: 2023/02/06 10:12 by jventuro

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.