From: Bill Erickson Date: Tue, 11 Dec 2018 01:33:44 +0000 (-0500) Subject: LP#1806087 Catalog pub date filter X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7fcf22a6a603f8fa549fe0051fbe54eb9115b430;p=working%2FEvergreen.git LP#1806087 Catalog pub date filter Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts index 42432ee2a0..ff1d773881 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts @@ -80,17 +80,12 @@ export class CatalogUrlService { params.joinOp = []; params.matchOp = []; - if (ts.format) { - params.format = ts.format; - } - - if (ts.available) { - params.available = ts.available; - } - - if (ts.hasBrowseEntry) { - params.hasBrowseEntry = ts.hasBrowseEntry; - } + ['format', 'available', 'hasBrowseEntry', 'date1', 'date2', 'dateOp'] + .forEach(field => { + if (ts[field]) { + params[field] = ts[field]; + } + }); ts.query.forEach((val, idx) => { if (val !== '') { @@ -192,22 +187,26 @@ export class CatalogUrlService { const ts = context.termSearch; if (params.has('hasBrowseEntry')) { + + // Browse entry display is (currently) a standalone filter. + // Other filters could be applied if needed. ts.hasBrowseEntry = params.get('hasBrowseEntry'); } else if (params.has('query')) { - if (params.has('format')) { - ts.format = params.get('format'); - } - - if (params.get('available')) { - ts.available = Boolean(params.get('available')); - } + // Scalars + ['format', 'available', 'date1', 'date2', 'dateOp'] + .forEach(field => { + if (params.has(field)) { + ts[field] = params.get(field); + } + }); + // Arrays ['query', 'fieldClass', 'joinOp', 'matchOp'].forEach(field => { const arr = params.getAll(field); if (params.has(field)) { - ts[field] = params.getAll(field); // array + ts[field] = params.getAll(field); } }); diff --git a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts index 51aa72d56c..64698a4832 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts @@ -109,6 +109,9 @@ export class CatalogTermContext { copyLocations: string[]; // ID's, but treated as strings in the UI. isMetarecord: boolean; // TODO hasBrowseEntry: string; // "entryId,fieldId" + date1: number; + date2: number; + dateOp: string; // before, after, between, is reset() { this.query = ['']; @@ -120,6 +123,9 @@ export class CatalogTermContext { this.copyLocations = ['']; this.format = ''; this.hasBrowseEntry = ''; + this.date1 = null; + this.date2 = null; + this.dateOp = 'is'; } isSearchable(): boolean { @@ -152,7 +158,6 @@ export class CatalogTermContext { this.facetFilters.push(facet); } } - } @@ -356,6 +361,24 @@ export class CatalogSearchContext { str += ' sort(' + parts[0] + ')'; } + if (ts.date1 && ts.dateOp) { + switch (ts.dateOp) { + case 'is': + str += ` date1(${ts.date1})`; + break; + case 'before': + str += ` before(${ts.date1})`; + break; + case 'after': + str += ` after(${ts.date1})`; + break; + case 'between': + if (ts.date2) { + str += ` between(${ts.date1},${ts.date2})`; + } + } + } + // ------- // Compile boolean sub-query components if (str.length) { str += ' '; } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/browse.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/browse.component.ts index 41bf67ab19..67e5eed1f1 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/browse.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/browse.component.ts @@ -24,7 +24,5 @@ export class BrowseComponent implements OnInit { this.searchForm.searchTab = 'browse'; } - - ngAfterViewInit() { } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html index 34e11f716d..8b6cc8ce15 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html @@ -194,6 +194,24 @@ TODO focus search input +
+
+
+ + + + +
+
+