From c6c3223f585b9f3c36a2d46d1a828dbcd376709a Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Wed, 22 Jun 2011 14:04:14 -0400 Subject: [PATCH] Add bib field editor. Also make all the editors written so far... ... for authority control sets-related objects do the right thing to help users create/edit new child objects linked to the right parent table without extra effort. Signed-off-by: Lebbeous Fogle-Weekley --- .../web/js/dojo/openils/authority/nls/authority.js | 3 +- Open-ILS/web/js/ui/default/cat/authority/common.js | 25 ++++++++ .../cat/authority/control_set_authority_field.tt2 | 30 ++++++--- .../cat/authority/control_set_bib_field.tt2 | 71 ++++++++++++++++++++++ .../templates/default/cat/authority/thesaurus.tt2 | 8 ++- 5 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 Open-ILS/web/templates/default/cat/authority/control_set_bib_field.tt2 diff --git a/Open-ILS/web/js/dojo/openils/authority/nls/authority.js b/Open-ILS/web/js/dojo/openils/authority/nls/authority.js index 9fef6025d6..4c448c87a9 100644 --- a/Open-ILS/web/js/dojo/openils/authority/nls/authority.js +++ b/Open-ILS/web/js/dojo/openils/authority/nls/authority.js @@ -18,5 +18,6 @@ "MERGE_RESULT_SUCCESS": "Record merge is complete.", "THESAURI": "Thesauri (${0})", "AUTHORITY_FIELDS": "Authority Fields (${0})", - "CONTROL_SET_METADATA": "(${0}) ${1} / ${2}" + "CONTROL_SET_METADATA": "(${0}) ${1} / ${2}", + "AUTHORITY_FIELD_METADATA": "${3} (${1} ‡${2}) ${4}" } diff --git a/Open-ILS/web/js/ui/default/cat/authority/common.js b/Open-ILS/web/js/ui/default/cat/authority/common.js index d8d8a37a7c..bb30b4800f 100644 --- a/Open-ILS/web/js/ui/default/cat/authority/common.js +++ b/Open-ILS/web/js/ui/default/cat/authority/common.js @@ -1,3 +1,4 @@ +/* To be used by interfaces for editing child tables of acs. */ function render_control_set_metadata(control_set) { var anchor = dojo.byId("control-set-metadata"); anchor.href = oilsBasePath + "/cat/authority/control_set?focus=" + @@ -9,3 +10,27 @@ function render_control_set_metadata(control_set) { ); openils.Util.show("control-set-metadata-holder"); } + +/* To be used by interfaces for editing child tables of acsaf. They not + * only want to know what acsaf they belong to, but for convenience they + * should also have handy the acs id to which their parent acsaf belongs, + * so they can provide the most helpful "back" link. + */ +function render_authority_field_metadata(authority_field, control_set_id) { + var anchor = dojo.byId("authority-field-metadata"); + var href = oilsBasePath + + "/cat/authority/control_set_authority_field?focus=" + + authority_field.id(); + if (control_set_id) href += "&acs=" + control_set_id; + + anchor.href = href; + anchor.innerHTML = dojo.string.substitute( + localeStrings.AUTHORITY_FIELD_METADATA, [ + "id", "tag", "sf_list", "name", "description" + ].map(function(k) { + var v = authority_field[k](); + return (v == null) ? "" : v; + }) + ); + openils.Util.show("authority-field-metadata-holder"); +} diff --git a/Open-ILS/web/templates/default/cat/authority/control_set_authority_field.tt2 b/Open-ILS/web/templates/default/cat/authority/control_set_authority_field.tt2 index 6bf734edf1..740d408ace 100644 --- a/Open-ILS/web/templates/default/cat/authority/control_set_authority_field.tt2 +++ b/Open-ILS/web/templates/default/cat/authority/control_set_authority_field.tt2 @@ -1,7 +1,4 @@ [% WRAPPER default/base.tt2 %] - [% ctx.page_title = "Configure Authority Authority Fields" %]
@@ -27,7 +24,7 @@ editOnEnter="true"> - + @@ -73,6 +70,22 @@ ); } + function get_just_id(row_index, item) { + if (item) return this.grid.store.getValue(item, "id"); + } + + function format_bib_fields(id) { + if (id) { + var text = acsaf_cache[id].bib_fields().map( + function(f) { return f.tag(); } + ).sort().join(", "); + var href = "control_set_bib_field?"; + if (control_set) + href += "acs=" + control_set.id() + "&"; + href += "acsaf=" + id; + return "" + text + ""; + } + } function my_init() { cgi = new openils.CGI(); @@ -82,10 +95,11 @@ if (control_set) { control_set = pcrud.retrieve("acs", control_set); render_control_set_metadata(control_set); - /* XXX TODO - when browsing by control_set, make it impossible to - create/edit acsaf objects with any other control_set. - */ + + acsaf_grid.overrideEditWidgets.control_set = + new dijit.form.TextBox({"disabled": true}); + acsaf_grid.overrideEditWidgets.control_set.shove = + {"create": control_set.id()}; } acsaf_grid.onPostCreate = function(o) { acsaf_cache[o.id()] = o; }; diff --git a/Open-ILS/web/templates/default/cat/authority/control_set_bib_field.tt2 b/Open-ILS/web/templates/default/cat/authority/control_set_bib_field.tt2 new file mode 100644 index 0000000000..6cca21b9ff --- /dev/null +++ b/Open-ILS/web/templates/default/cat/authority/control_set_bib_field.tt2 @@ -0,0 +1,71 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = "Configure Authority Control Set Bib Fields" %] +
+
+
Control Set Bib Fields
+
+ + +
+
+ +
+ +
+
+
+ + +[% END %] diff --git a/Open-ILS/web/templates/default/cat/authority/thesaurus.tt2 b/Open-ILS/web/templates/default/cat/authority/thesaurus.tt2 index 7f4106607d..5e4c2bde3c 100644 --- a/Open-ILS/web/templates/default/cat/authority/thesaurus.tt2 +++ b/Open-ILS/web/templates/default/cat/authority/thesaurus.tt2 @@ -1,7 +1,4 @@ [% WRAPPER default/base.tt2 %] - [% ctx.page_title = "Configure Authority Thesauri" %]
@@ -53,6 +50,11 @@ control_set = pcrud.retrieve("acs", control_set); where.control_set = control_set.id(); render_control_set_metadata(control_set); + + at_grid.overrideEditWidgets.control_set = + new dijit.form.TextBox({"disabled": true}); + at_grid.overrideEditWidgets.control_set.shove = + {"create": control_set.id()}; } at_grid.loadAll({"order_by": {"at": "code"}}, where); -- 2.11.0