From 621b895def1a5bce7e0398f668b907314b79c127 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 2 Jan 2020 16:31:31 -0500 Subject: [PATCH] LP1858138 Sandbox example of simple grid filtering Adds a trimmed down grid example demonstrating consistent filtering and link selector display for auto and manual fields without requiring any additional grid markup to define basic column behevior. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../app/staff/sandbox/sandbox.component.html | 12 ++++++++ .../app/staff/sandbox/sandbox.component.ts | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index ed1b5813b4..26da699522 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -404,3 +404,15 @@ +
+

Grid Stock Selector Display and Filtering

+ + + + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 0dc8ee05f6..b295fce48e 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -63,6 +63,7 @@ export class SandboxComponent implements OnInit { btSource: GridDataSource = new GridDataSource(); acpSource: GridDataSource = new GridDataSource(); + eventsDataSource: GridDataSource = new GridDataSource(); editSelected: (rows: IdlObject[]) => void; @ViewChild('acpGrid', { static: true }) acpGrid: GridComponent; @ViewChild('acpEditDialog', { static: true }) editDialog: FmRecordEditorComponent; @@ -228,6 +229,33 @@ export class SandboxComponent implements OnInit { }); }; + this.eventsDataSource.getRows = (pager: Pager, sort: any[]) => { + + const orderEventsBy: any = {atevdef: 'name'}; + if (sort.length) { + orderEventsBy.atevdef = sort[0].name + ' ' + sort[0].dir; + } + + const base: Object = {}; + base[this.idl.classes['atevdef'].pkey] = {'!=' : null}; + const query: any = new Array(); + query.push(base); + + Object.keys(this.eventsDataSource.filters).forEach(key => { + Object.keys(this.eventsDataSource.filters[key]).forEach(key2 => { + query.push(this.eventsDataSource.filters[key][key2]); + }); + }); + + return this.pcrud.search('atevdef', query, { + flesh: 1, + flesh_fields: {atevdef: ['hook', 'validator', 'reactor']}, + offset: pager.offset, + limit: pager.limit, + order_by: orderEventsBy + }); + }; + this.editSelected = (idlThings: IdlObject[]) => { // Edit each IDL thing one at a time -- 2.43.2