LP #1169569 - Provide a way to override default sorting in monograph parts user/dpearl/partord
authorDan Pearl <dpearl@cwmars.org>
Fri, 9 May 2014 20:43:28 +0000 (16:43 -0400)
committerDan Pearl <dpearl@cwmars.org>
Wed, 10 Sep 2014 17:12:47 +0000 (13:12 -0400)
    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 <dpearl@cwmars.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
Open-ILS/src/sql/Pg/010.schema.biblio.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.parts-sorting.sql [new file with mode: 0644]
Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2
Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js
docs/RELEASE_NOTES_NEXT/Cataloging/monographic_parts_ordering [new file with mode: 0644]

index c91a9b6..cc8ce7a 100644 (file)
@@ -2926,6 +2926,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="record" reporter:datatype="link"/>
                        <field name="label" reporter:datatype="text"/>
                        <field name="label_sortkey" reporter:datatype="text"/>
+                        <field name="sort_order" reporter:datatype="int"/>
                </fields>
                <links>
                        <link field="record" reltype="has_a" key="id" map="" class="bre"/>
index 1dc306e..f2d5c4f 100644 (file)
@@ -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'}
         ],
index 22c0966..9bd9bab 100644 (file)
@@ -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) {
index 4ce54ae..a6943f2 100644 (file)
@@ -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 (file)
index 0000000..5a260a2
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2014  C/W MARS Inc.
+ * Daniel Pearl <dpearl@cwmars.org>
+ *
+ * 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;
+
index dfc89cc..66cf57b 100644 (file)
@@ -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')});
     });
 </script>
 [% END %]
index 0b16308..4e6cd97 100644 (file)
@@ -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 (file)
index 0000000..0170bb0
--- /dev/null
@@ -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.
+