From dd4ab6503b6895609641e5efe21bcfc1a88bf59c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 7 Feb 2020 18:41:03 -0500 Subject: [PATCH] enable results grid sorting TODO: deal with sorting provider, user, and OU columns by the relevant code or username Signed-off-by: Galen Charlton --- .../src/app/staff/acq/search/acq-search.service.ts | 31 +++++++++++++++++++++- .../acq/search/invoice-results.component.html | 1 + .../acq/search/lineitem-results.component.html | 6 ++--- .../acq/search/picklist-results.component.html | 3 ++- .../search/purchase-order-results.component.html | 1 + 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts index aedaeb2049..2474f71e08 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts @@ -9,6 +9,13 @@ import {Pager} from '@eg/share/util/pager'; import {IdlObject} from '@eg/core/idl.service'; import {EventService} from '@eg/core/event.service'; +const baseIdlClass = { + lineitem: 'jub', + purchase_order: 'acqpo', + picklist: 'acqpl', + invoice: 'acqinv' +}; + const defaultSearch = { lineitem: { jub: [{ @@ -221,7 +228,7 @@ export class AcqSearchService { const gridSource = new GridDataSource(); this.fetchAttrDefs().then(() => { - gridSource.getRows = (pager: Pager) => { + gridSource.getRows = (pager: Pager, sort: any[]) => { // don't do a search the very first time we // get invoked, which is during initialization; we'll @@ -238,6 +245,28 @@ export class AcqSearchService { opts['offset'] = pager.offset; opts['limit'] = pager.limit; opts['au_by_id'] = true; + + if (sort.length > 0) { + opts['order_by'] = []; + sort.forEach(sort_clause => { + if (searchType === 'lineitem' && + ['title', 'author'].indexOf(sort_clause.name) > -1) { + opts['order_by'].push({ + class: 'acqlia', + field: 'attr_value', + direction: sort_clause.dir + }); + opts['order_by_attr'] = sort_clause.name; + } else { + opts['order_by'].push({ + class: baseIdlClass[searchType], + field: sort_clause.name, + direction: sort_clause.dir + }); + } + }); + } + return this.net.request( 'open-ils.acq', 'open-ils.acq.' + searchType + '.unified_search', diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html index e5823a4a14..632eb9fa30 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html @@ -25,6 +25,7 @@ persistKey="acq.search.invoices" [stickyHeader]="true" [filterable]="true" + [sortable]="true" idlClass="acqinv" [dataSource]="gridSource"> - - - + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html index 9994ec2178..f63d691dc2 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html @@ -34,6 +34,7 @@ persistKey="acq.search.selectionlists" [stickyHeader]="true" [filterable]="true" + [sortable]="true" idlClass="acqpl" [dataSource]="gridSource"> - + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html index 14c6d96785..d29b959bfd 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html @@ -20,6 +20,7 @@ persistKey="acq.search.purchaseorders" [stickyHeader]="true" [filterable]="true" + [sortable]="true" idlClass="acqpo" [dataSource]="gridSource"> -- 2.11.0