From: Bill Erickson Date: Thu, 16 Jan 2020 21:22:04 +0000 (-0500) Subject: LPXXX Ang catalog search highlighting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flpxxx-ang-cat-search-highlight;p=working%2FEvergreen.git LPXXX Ang catalog search highlighting Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts index 465a0af281..83d66c0654 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts @@ -31,7 +31,7 @@ export class BibRecordSummary { holdCount: number; bibCallNumber: string; net: NetService; - displayHighlights: {[name: string]: string} = {}; + displayHighlights: {[name: string]: string | string[]} = {}; constructor(record: IdlObject, orgId: number, orgDepth: number) { this.id = Number(record.id()); diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index cbc89c94df..ffc8d9c53c 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -228,10 +228,19 @@ export class CatalogService { (Object.keys(hlMap).length > 0)) { } else { return Promise.resolve(); } - return this.net.requestWithParamList( + // Returns bib IDs or metabib IDs depending on the search type. + // If we have metabib IDs, map them to bib IDs for highlighting. + let ids = ctx.currentResultIds(); + if (ctx.termSearch.groupByMetarecord) { + ids = ids.map(mrId => + ctx.result.records.filter(r => mrId === r.metabibId)[0].id + ); + } + + return this.net.requestWithParamList( // API is list-based 'open-ils.search', 'open-ils.search.fetch.metabib.display_field.highlight', - [hlMap].concat(ctx.currentResultIds()) + [hlMap].concat(ids) ).pipe(map(fields => { if (fields.length === 0) { return; } @@ -240,15 +249,24 @@ export class CatalogService { const summary = ctx.result.records.filter(r => r.id === fields[0].source)[0]; + const highlights = summary.displayHighlights; + fields.forEach(field => { const dfMap = this.cmfMap[field.field].display_field_map(); if (!dfMap) { return; } - summary.displayHighlights[dfMap.name()] = field.highlight; + + if (dfMap.multi() === 't') { + if (!highlights[dfMap.name()]) { + highlights[dfMap.name()] = []; + } + highlights[dfMap.name()].push(field.highlight); + } else { + highlights[dfMap.name()] = field.highlight; + } }); })).toPromise(); } - fetchFacets(ctx: CatalogSearchContext): Promise { if (!ctx.result) { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts index 86501fc10f..849e627218 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts @@ -61,7 +61,7 @@ export class StaffCatalogService { } if (!this.searchContext.pager.limit) { - this.searchContext.pager.limit = this.defaultSearchLimit || 20; + this.searchContext.pager.limit = this.defaultSearchLimit || 10; } } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html index ee93fb0b6f..8bfbb7abb0 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html @@ -1,20 +1,13 @@ + - - - {{summary.display[field]}} - - - + + + , + -
@@ -59,19 +52,19 @@
@@ -107,37 +99,55 @@
Phys. Desc.: - {{[].concat(summary.display.physical_description).join(', ')}} + +
Edition: + *ngTemplateOutlet="displayField;context:{field: 'edition'}">
-
Publisher: {{summary.display.publisher}}
+
Publisher: + + +
-
Pub Date: {{summary.display.pubdate}}
+
Pub Date: + + +
ISBN: - {{[].concat(summary.display.isbn).join(', ')}}
+ + +
UPC: - {{[].concat(summary.display.upc).join(', ')}}
+ + +
ISSN: - {{[].concat(summary.display.issn).join(', ')}}
+ + +
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts index 69f4dd05f9..b79363c279 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts @@ -121,6 +121,24 @@ export class ResultRecordComponent implements OnInit, OnDestroy { return this.basket.removeRecordIds([this.summary.id]); } } + + // Returns an array of -wrapped display values. + // Items are span-wrapped for display consistency between raw + // values and search highlight values. + getDisplayValues(field: string): string[] { + const highlights = this.summary.displayHighlights[field]; + if (highlights) { + if (Array.isArray(highlights)) { + return highlights; + } else { + return [highlights]; + } + } else { + let value = this.summary.display[field]; + if (!Array.isArray(value)) { value = [value]; } + return value.map(v => `${v}`); + } + } }