From: Bill Erickson Date: Thu, 16 Jan 2020 18:23:15 +0000 (-0500) Subject: LPXXX Ang catalog search highlighting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=da557262944c13a4c918dc5b18d9bc8a6bb1360c;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 b2058e7aed..465a0af281 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,6 +31,7 @@ export class BibRecordSummary { holdCount: number; bibCallNumber: string; net: NetService; + displayHighlights: {[name: 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 2aaaf1f3ae..cbc89c94df 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 @@ -215,6 +215,40 @@ export class CatalogService { })).toPromise(); } + fetchFieldHighlights(ctx: CatalogSearchContext): Promise { + + let hlMap; + + // Extract the highlight map. Not all searches have them. + if ((hlMap = ctx.result) && + (hlMap = hlMap.global_summary) && + (hlMap = hlMap.query_struct) && + (hlMap = hlMap.additional_data) && + (hlMap = hlMap.highlight_map) && + (Object.keys(hlMap).length > 0)) { + } else { return Promise.resolve(); } + + return this.net.requestWithParamList( + 'open-ils.search', + 'open-ils.search.fetch.metabib.display_field.highlight', + [hlMap].concat(ctx.currentResultIds()) + ).pipe(map(fields => { + if (fields.length === 0) { return; } + + // Each 'fields' collection is an array of highlighted + // fields for a given bib record. + const summary = + ctx.result.records.filter(r => r.id === fields[0].source)[0]; + + fields.forEach(field => { + const dfMap = this.cmfMap[field.field].display_field_map(); + if (!dfMap) { return; } + summary.displayHighlights[dfMap.name()] = field.highlight; + }); + })).toPromise(); + } + + fetchFacets(ctx: CatalogSearchContext): Promise { if (!ctx.result) { @@ -312,14 +346,15 @@ export class CatalogService { } fetchCmfs(): Promise { - // At the moment, we only need facet CMFs. if (Object.keys(this.cmfMap).length) { return Promise.resolve(); } return new Promise((resolve, reject) => { this.pcrud.search('cmf', - {facet_field : 't'}, {}, {atomic: true, anonymous: true} + {'-or': [{facet_field : 't'}, {display_field: 't'}]}, + {flesh: 1, flesh_fields: {cmf: ['display_field_map']}}, + {atomic: true, anonymous: true} ).subscribe( cmfs => { cmfs.forEach(c => this.cmfMap[c.id()] = c); diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.css b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.css index 3d753f4e42..c688a6df66 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.css +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.css @@ -1,7 +1,7 @@ /** - * Force the jacket image column to consume a consistent amount of - * horizontal space, while allowing some room for the browser to + * Force the jacket image column to consume a consistent amount of + * horizontal space, while allowing some room for the browser to * render the correct aspect ratio. */ .record-jacket-div { @@ -13,3 +13,14 @@ max-height: 158px; max-width: 100px; } + +.oils_SH { + font-weight: bolder; + background-color: #99ff99; +} + +.oils_SH.identifier { + font-weight: bolder; + background-color: #42b0f4; +} + 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 a27c1bdf34..ee93fb0b6f 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 @@ -4,6 +4,19 @@ egDateFilter's --> + + {{summary.display[field]}} + + + + + + + -
Edition: {{summary.display.edition}}
+
Edition: + + +
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 b46e4ca0ba..69f4dd05f9 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 @@ -1,4 +1,4 @@ -import {Component, OnInit, OnDestroy, Input} from '@angular/core'; +import {Component, OnInit, OnDestroy, Input, ViewEncapsulation} from '@angular/core'; import {Subscription} from 'rxjs'; import {Router, ParamMap} from '@angular/router'; import {OrgService} from '@eg/core/org.service'; @@ -14,7 +14,8 @@ import {BasketService} from '@eg/share/catalog/basket.service'; @Component({ selector: 'eg-catalog-result-record', templateUrl: 'record.component.html', - styleUrls: ['record.component.css'] + styleUrls: ['record.component.css'], + encapsulation: ViewEncapsulation.None // required for search highlighting }) export class ResultRecordComponent implements OnInit, OnDestroy { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts index 869eff2e79..cc6581eb33 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts @@ -99,7 +99,9 @@ export class ResultsComponent implements OnInit, OnDestroy { .then(ok => { this.cat.fetchFacets(this.searchContext); this.cat.fetchBibSummaries(this.searchContext) - .then(ok2 => this.fleshSearchResults()); + .then(_ => + this.cat.fetchFieldHighlights(this.searchContext)) + .then(_ => this.fleshSearchResults()); }); } }