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>
<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"/>
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'}
],
}
}
},
- order_by =>[{class=>'bmp', field=>'label_sortkey'}]
+ order_by =>[{class=>'bmp', field=>'sort_order'},{class=>'bmp', field=>'label_sortkey'}]
};
if(defined $pickup_lib) {
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)
);
--- /dev/null
+/*
+ * 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;
+
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']"
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 %]
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 */
--- /dev/null
+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.
+