From: Lebbeous Fogle-Weekley Date: Tue, 5 Jul 2011 18:22:38 +0000 (-0400) Subject: Provide sorters for browse axes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3fd2e7e750745f49e10083c98f23eba749dd8a1e;p=evergreen%2Fjoelewis.git Provide sorters for browse axes Make the default bib result sorter 'titlesort' for every browse axis, which is what makes sense if you think about it. Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 5816331970..7b621a9f96 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1855,11 +1855,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + diff --git a/Open-ILS/src/sql/Pg/011.schema.authority.sql b/Open-ILS/src/sql/Pg/011.schema.authority.sql index 3e6fda07b0..8b2a52815a 100644 --- a/Open-ILS/src/sql/Pg/011.schema.authority.sql +++ b/Open-ILS/src/sql/Pg/011.schema.authority.sql @@ -54,6 +54,7 @@ CREATE TABLE authority.thesaurus ( CREATE TABLE authority.browse_axis ( code TEXT PRIMARY KEY, name TEXT UNIQUE NOT NULL, -- i18n + sorter TEXT REFERENCES config.record_attr_definition (name) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, description TEXT ); diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index b2451991d5..0082b83d41 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -9476,11 +9476,11 @@ INSERT INTO authority.control_set_authority_field (id, control_set, main_entry, (71, 1, 11, '485', 'ivwxyz4', oils_i18n_gettext('71','See Also Tracing -- Form Subdivision','acsaf','name')), (72, 1, 12, '448', 'aivwxyz4', oils_i18n_gettext('72','See Also Tracing -- Chronological Term','acsaf','name')); -INSERT INTO authority.browse_axis (code,name,description) VALUES - ('title','Title','Title axis'), - ('author','Author','Author axis'), - ('subject','Subject','Subject axis'), - ('topic','Topic','Topic Subject axis'); +INSERT INTO authority.browse_axis (code,name,description,sorter) VALUES + ('title','Title','Title axis','titlesort'), + ('author','Author','Author axis','titlesort'), + ('subject','Subject','Subject axis','titlesort'), + ('topic','Topic','Topic Subject axis','titlesort'); INSERT INTO authority.browse_axis_authority_field_map (axis,field) VALUES ('author', 1 ), diff --git a/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js b/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js index 3583d66d3b..990583f19e 100644 --- a/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js +++ b/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js @@ -42,7 +42,7 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) { "abaafm": "_browse_field_map_list" }); - openils.AuthorityControlSet._browse_axis_by_name = {}; + openils.AuthorityControlSet._browse_axis_by_code = {}; dojo.forEach( openils.AuthorityControlSet._browse_axis_list, function (ba) { ba.maps( dojo.filter( @@ -50,7 +50,7 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) { function (m) { return m.axis() == ba.code() } ) ); - openils.AuthorityControlSet._browse_axis_by_name[ba.code()] = ba; + openils.AuthorityControlSet._browse_axis_by_code[ba.code()] = ba; }); // loop over each acs @@ -199,6 +199,10 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) { return this.controlSet(thes.control_set()); }, + browseAxisByCode: function(code) { + return openils.AuthorityControlSet._browse_axis_by_code[code]; + }, + bibFieldByTag: function (x) { var me = this; return dojo.filter( @@ -213,15 +217,15 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) { bibFieldBrowseAxes : function (t) { var blist = []; - for (var bname in openils.AuthorityControlSet._browse_axis_by_name) { + for (var bcode in openils.AuthorityControlSet._browse_axis_by_code) { dojo.forEach( - openils.AuthorityControlSet._browse_axis_by_name[bname].maps(), + openils.AuthorityControlSet._browse_axis_by_code[bcode].maps(), function (m) { if (dojo.filter( m.field().bib_fields(), function (b) { return b.tag() == t } ).length > 0 - ) blist.push(bname); + ) blist.push(bcode); } ); } diff --git a/Open-ILS/web/opac/skin/default/js/authbrowse.js b/Open-ILS/web/opac/skin/default/js/authbrowse.js index e1b144245a..5e0f7107cf 100644 --- a/Open-ILS/web/opac/skin/default/js/authbrowse.js +++ b/Open-ILS/web/opac/skin/default/js/authbrowse.js @@ -31,7 +31,7 @@ function doAuthorityBrowse(axis, term, page, per_page) { "content": {"format": "marcxml"}, "preventCache": true, "load": function(doc) { - displayAuthorityRecords(doc); + displayAuthorityRecords(axis, doc); setPagingLinks(axis, term, page, per_page); } }); @@ -167,7 +167,7 @@ function renderAuthorityRecord(m, control_set, auth_id) { * records, display each one in a table using the apporiate control set to * determine which fields to show. */ -function displayAuthorityRecords(doc) { +function displayAuthorityRecords(axis, doc) { if (!acs_helper) acs_helper = new openils.AuthorityControlSet(); @@ -181,7 +181,6 @@ function displayAuthorityRecords(doc) { var records = dojo.query("record", doc); last_fetched_length = records.length; - console.log("length here is " + last_fetched_length); dojo.forEach( records, @@ -202,11 +201,11 @@ function displayAuthorityRecords(doc) { ); } ); - displayRecordCounts(auth_ids); + displayRecordCounts(axis, auth_ids); swapCanvas(dojo.byId("canvas_main")); } -function displayRecordCounts(auth_ids) { +function displayRecordCounts(axis, auth_ids) { fieldmapper.standardRequest( ["open-ils.cat", "open-ils.cat.authority.records.count_linked_bibs"], { "params": [auth_ids], @@ -215,7 +214,7 @@ function displayRecordCounts(auth_ids) { if ((r = openils.Util.readResponse(r))) { dojo.forEach(r, function(blob) { if (blob.bibs > 0) { - displayRecordCount(blob.authority, blob.bibs); + displayRecordCount(axis, blob.authority, blob.bibs); } }); } @@ -224,7 +223,7 @@ function displayRecordCounts(auth_ids) { ); } -function displayRecordCount(id, count) { +function displayRecordCount(axis, id, count) { /* 1) put record count where we can see it */ dojo.query("#authority_" + id + " .authority-count-holder")[0].innerHTML = "(" + count + ")"; /* XXX i18n ? */ @@ -239,6 +238,10 @@ function displayRecordCount(id, count) { args[PARAM_LOCATION] = depthSelGetNewLoc(); args[PARAM_TERM] = "identifier|authority_id[" + id + "]"; + var axis_obj = acs_helper.browseAxisByCode(axis); + if (axis_obj.sorter()) + args[PARAM_TERM] += " sort(" + axis_obj.sorter() + ")"; + dojo.create( "a", { "innerHTML": span.innerHTML, diff --git a/Open-ILS/web/templates/default/conify/global/cat/authority/browse_axis.tt2 b/Open-ILS/web/templates/default/conify/global/cat/authority/browse_axis.tt2 index fc31b6ea49..8834b02bfb 100644 --- a/Open-ILS/web/templates/default/conify/global/cat/authority/browse_axis.tt2 +++ b/Open-ILS/web/templates/default/conify/global/cat/authority/browse_axis.tt2 @@ -13,7 +13,7 @@ dojoType="openils.widget.AutoGrid" autoHeight="true" defaultCellWidth="'auto'" - fieldOrder="['code','name','description']" + fieldOrder="['code','name','description','sorter']" suppressEditFields="['id']" query="{id: '*'}" fmClass="aba" @@ -25,6 +25,9 @@ dojo.require("openils.widget.AutoGrid"); function my_init() { + aba_grid.overrideWidgetArgs.sorter = { + "dijitArgs": {"query": {"sorter": "t"}} + }; aba_grid.loadAll({"order_by": {"aba": "code"}}); }