Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom JavaScript setting for metadata editing #8723

Merged
merged 11 commits into from
Sep 21, 2022
3 changes: 3 additions & 0 deletions doc/release-notes/8722-custom-script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## New DB Settings

- :ControlledVocabularyCustomJavaScript
15 changes: 15 additions & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2958,3 +2958,18 @@ The URL of an LDN Inbox to which the LDN Announce workflow step will send messag
++++++++++++++++++++++++++

The list of parent dataset field names for which the LDN Announce workflow step should send messages. See :doc:`/developers/workflows` for details.

:ControlledVocabularyCustomJavaScript
+++++++++++++++++++++++++++++++++++++

We can have controlled vocabulary as a list locally (with optionally translated values). But if the list is large and needs to be maintained, it is more advantageous to have, for example, a lookup functionality that allows to search for the values at an external service. We can have external controlled vocabularies with "skosmos" protocol (or other, using URI bound terms), but this is an overkill for a simple list (enumeration) for one field (e.g., author name using author lookup) that does not have any translations or URIs.

A more desirable solution is to allow a custom JavaScript to control values of specific fields.

To specify a custom script ``/covoc/js/covoc.js`` to be loaded:

``curl -X PUT -d '/covoc/js/covoc.js' http://localhost:8080/api/admin/settings/:ControlledVocabularyCustomJavaScript``

To remove the custom script:

``curl -X PUT -d '' http://localhost:8080/api/admin/settings/:ControlledVocabularyCustomJavaScript``
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ public List<String> getVocabScripts( Map<Long, JsonObject> cvocConf) {
for(JsonObject jo: cvocConf.values()) {
scripts.add(jo.getString("js-url"));
}
String customScript = settingsService.getValueForKey(SettingsServiceBean.Key.ControlledVocabularyCustomJavaScript);
if (customScript != null && !customScript.isEmpty()) {
scripts.add(customScript);
}
return Arrays.asList(scripts.toArray(new String[0]));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ Whether Harvesting (OAI) service is enabled
/**
* LDN Inbox Allowed Hosts - a comma separated list of IP addresses allowed to submit messages to the inbox
*/
LDNMessageHosts
LDNMessageHosts,
/*
* Allow a custom JavaScript to control values of specific fields.
*/
ControlledVocabularyCustomJavaScript
;

@Override
Expand Down