From 194583b5d19e7719c2aac09c714761de4b6f5897 Mon Sep 17 00:00:00 2001 From: Dan Pearl Date: Fri, 9 May 2014 16:43:28 -0400 Subject: [PATCH] LP #1169569 - Provide a way to override default sorting in monograph parts In the occasion that the current label_sortkey mechanism does not provide correct results, allow explicit ordering in monograph_parts overriding derived label_sortkey. The database schema change as part of this source change would need to be part of an upgrade script. Signed-off-by: Dan Pearl --- Open-ILS/examples/fm_IDL.xml | 1 + .../src/perlmods/lib/OpenILS/Application/AppUtils.pm | 2 ++ .../perlmods/lib/OpenILS/Application/Search/Biblio.pm | 2 +- Open-ILS/src/sql/Pg/010.schema.biblio.sql | 1 + Open-ILS/src/sql/Pg/upgrade/XXXX.parts-sorting.sql | 19 +++++++++++++++++++ .../templates/conify/global/biblio/monograph_part.tt2 | 4 ++-- .../staff_client/server/cat/volume_copy_creator.js | 4 ++-- .../Cataloging/monographic_parts_ordering | 15 +++++++++++++++ 8 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.parts-sorting.sql create mode 100644 docs/RELEASE_NOTES_NEXT/Cataloging/monographic_parts_ordering diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index c91a9b61db..cc8ce7aa8e 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2926,6 +2926,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 1dc306eec4..f2d5c4fc16 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -2048,6 +2048,8 @@ sub basic_opac_copy_query { order_by => [ {class => 'aou', field => 'name'}, {class => 'acn', field => 'label_sortkey'}, + {class => 'bmp', field => 'sort_order'}, + {class => 'bmp', field => 'label_sortkey'}, {class => 'acp', field => 'copy_number'}, {class => 'acp', field => 'barcode'} ], diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 22c0966966..9bd9babbe4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2639,7 +2639,7 @@ sub rec_hold_parts { } } }, - order_by =>[{class=>'bmp', field=>'label_sortkey'}] + order_by =>[{class=>'bmp', field=>'sort_order'},{class=>'bmp', field=>'label_sortkey'}] }; if(defined $pickup_lib) { diff --git a/Open-ILS/src/sql/Pg/010.schema.biblio.sql b/Open-ILS/src/sql/Pg/010.schema.biblio.sql index 4ce54ae96b..a6943f2cbf 100644 --- a/Open-ILS/src/sql/Pg/010.schema.biblio.sql +++ b/Open-ILS/src/sql/Pg/010.schema.biblio.sql @@ -98,6 +98,7 @@ CREATE TABLE biblio.monograph_part ( record BIGINT NOT NULL REFERENCES biblio.record_entry (id), label TEXT NOT NULL, label_sortkey TEXT NOT NULL, + sort_order INT NOT NULL DEFAULT 0, CONSTRAINT record_label_unique UNIQUE (record,label) ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.parts-sorting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.parts-sorting.sql new file mode 100644 index 0000000000..5a260a2403 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.parts-sorting.sql @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2014 C/W MARS Inc. + * Daniel Pearl + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +BEGIN; + ALTER TABLE biblio.monograph_part ADD COLUMN sort_order INTEGER NOT NULL DEFAULT 0; +COMMIT; + diff --git a/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 b/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 index dfc89cccbd..66cf57b915 100644 --- a/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 +++ b/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 @@ -16,7 +16,7 @@ dojoType="openils.widget.AutoGrid" hidePaginator='true' autoHeight='true' - fieldOrder="['label']" + fieldOrder="['sort_order','label']" displayLimit=0 suppressFields="['id','record','label_sortkey']" suppressEditFields="['id','label_sortkey']" @@ -37,7 +37,7 @@ openils.Util.addOnLoad( function() { monoPartGrid.overrideEditWidgets.record = new dijit.form.TextBox({"disabled": true}); monoPartGrid.overrideEditWidgets.record.shove = { create : cgi.param('r') }; - monoPartGrid.loadAll({order_by : [{class : 'bmp', field : 'label_sortkey'}]}, {record : cgi.param('r')}); + monoPartGrid.loadAll({order_by : [{class : 'bmp', field : 'sort_order'},{class : 'bmp', field : 'label_sortkey'}]}, {record : cgi.param('r')}); }); [% END %] diff --git a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js index 0b16308cd7..4e6cd97ae6 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js +++ b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js @@ -205,9 +205,9 @@ function my_init() { dojo.require('openils.PermaCrud'); g.pcrud = new openils.PermaCrud({'authtoken':ses()}); - g.parts = g.pcrud.search('bmp',{'record':g.doc_id},{'order_by': { 'bmp' : 'label_sortkey' } }); + g.parts = g.pcrud.search('bmp',{'record':g.doc_id},{'order_by': [{'class': 'bmp', 'field' : 'sort_order'}, + {'class': 'bmp', 'field' : 'label_sortkey'}] }); g.parts_hash = util.functional.convert_object_list_to_hash( g.parts ); - /***********************************************************************************************************/ /* For the batch drop downs */ diff --git a/docs/RELEASE_NOTES_NEXT/Cataloging/monographic_parts_ordering b/docs/RELEASE_NOTES_NEXT/Cataloging/monographic_parts_ordering new file mode 100644 index 0000000000..0170bb0117 --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Cataloging/monographic_parts_ordering @@ -0,0 +1,15 @@ +Ordering Monograph Parts +^^^^^^^^^^^^^^^^^^^^^^^^ +Sometimes the default ordering of monograph parts results in a list that +is difficult to use. Now, you have the ability to provide an explicit +ordering when necessary. + +A new column, sort_order, has been added to the list in the Monograph Parts screen. +You can edit the entry with any integer (even negative). By default, the value is +zero. When displaying the list, the parts will be displayed in ascending order by +sort_order (as the primary sort), and within groups with identical sort_order values, +the sorting will occur as it previously occured.. + +This will be useful if you wish to provide, say, an Index part and ensure that it is +listed first. In this case, you could give it a sort_order of -100. + -- 2.11.0