Avoid sorting editable funds to the front of the fund list when there
are no org units at which the user has the ADMIN_ACQ_FUND permission.
Otherwise, we are sorting on an empty 'IN' list in pcrud, which results
in an error.
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
year = year || fundFilterYearSelect.attr('value');
cachedFunds = [];
+ var order_by = [{'class' : 'acqf', field : 'name'}];
+
+ if (adminPermOrgs.length) {
+ // sort funds I can edit to the front
+ order_by.unshift({
+ 'class' : 'acqf',
+ field : 'org',
+ compare : {'in' : adminPermOrgs},
+ direction : 'desc'
+ });
+ }
+
lfGrid.loadAll(
- {
+ {
flesh : 1,
flesh_fields : {acqf : fundFleshFields},
-
- // by default, sort funds I can edit to the front
- order_by : [
- { 'class' : 'acqf',
- field : 'org',
- compare : {'in' : adminPermOrgs},
- direction : 'desc'
- },
- { 'class' : 'acqf',
- field : 'name'
- }
- ]
+ order_by : order_by,
}, {
year : year,
org : fieldmapper.aou.descendantNodeList(contextOrg, true)