From 5e20320b40f1736a17dfdc3070d1f8d61e652319 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 8 Dec 2017 12:34:30 -0500 Subject: [PATCH] LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- .../src/app/share/catalog/catalog.service.ts | 24 ++++++++-- .../src/app/staff/catalog/catalog.module.ts | 4 +- .../app/staff/catalog/record/record.component.html | 55 +++++++++++++++++++--- .../app/staff/catalog/record/record.component.ts | 11 ++--- .../app/staff/catalog/result/record.component.css | 4 ++ .../app/staff/catalog/result/record.component.html | 34 +++++++------ .../staff/catalog/result/results.component.html | 8 ++-- .../app/staff/catalog/result/results.component.ts | 13 +---- .../app/staff/catalog/search-form.component.css | 4 ++ .../app/staff/catalog/search-form.component.html | 2 +- 10 files changed, 111 insertions(+), 48 deletions(-) diff --git a/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts b/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts index 02e67e076f..daf978331c 100644 --- a/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts @@ -45,6 +45,12 @@ export class EgCatalogService { ccvmMap: {[ccvm:string] : EgIdlObject[]} = {}; cmfMap: {[cmf:string] : EgIdlObject} = {}; + // Keep a reference to the most recently retrieved facet data, + // since facet data is consistent across a given search. + // No need to re-fetch with every page of search data. + lastFacetData: any; + lastFacetKey: string; + constructor( private net: EgNetService, private org: EgOrgService, @@ -76,7 +82,7 @@ export class EgCatalogService { ctx.searchState = CatalogSearchState.COMPLETE; let promises = []; - result.ids.forEach(blob => { + result.ids.forEach((blob, idx) => { promises.push( this.getBibSummary(blob[0], ctx.searchOrg.id(), @@ -84,7 +90,8 @@ export class EgCatalogService { ctx.org.root().ou_type().depth() : ctx.searchOrg.ou_type().depth() ).then( - summary => ctx.result.records.push(summary) + // idx maintains result sort order + summary => ctx.result.records[idx] = summary ) ); }); @@ -96,7 +103,13 @@ export class EgCatalogService { fetchFacets(ctx: CatalogSearchContext): Promise { - if (!ctx.result) return Promise.resolve(); + if (!ctx.result) + return Promise.reject('Cannot fetch facets without results'); + + if (this.lastFacetKey == ctx.result.facet_key) { + ctx.result.facetData = this.lastFacetData; + return Promise.resolve(); + } return new Promise((resolve, reject) => { this.net.request('open-ils.search', @@ -128,7 +141,8 @@ export class EgCatalogService { }; }); - ctx.result.facetData = facetData; + this.lastFacetKey = ctx.result.facet_key; + this.lastFacetData = ctx.result.facetData = facetData; resolve(); }); }) @@ -246,7 +260,7 @@ export class EgCatalogService { while(node = result.iterateNext()) { response.ccvms[node.getAttribute('name')] = { - code : node.getAttribute('value'), + code : node.textContent, label : node.getAttribute('coded-value') } } diff --git a/Open-ILS/webby-src/src/app/staff/catalog/catalog.module.ts b/Open-ILS/webby-src/src/app/staff/catalog/catalog.module.ts index e5d65f39e8..72e4e4f037 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/webby-src/src/app/staff/catalog/catalog.module.ts @@ -13,6 +13,7 @@ import {ResultPaginationComponent} from './result/pagination.component'; import {ResultFacetsComponent} from './result/facets.component'; import {ResultRecordComponent} from './result/record.component'; import {StaffCatalogService} from './staff-catalog.service'; +import {StaffRecordService} from './record/record.service'; @NgModule({ declarations: [ @@ -33,7 +34,8 @@ import {StaffCatalogService} from './staff-catalog.service'; EgUnapiService, EgCatalogService, EgCatalogUrlService, - StaffCatalogService + StaffCatalogService, + StaffRecordService ] }) diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.html b/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.html index c1e383e022..13d805d3c2 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.html @@ -1,13 +1,56 @@
- RECORD {{recordId}} -
-
SMALL
-
MED
-
asdf
-
asdfsada
+ + +
+
+ Record Summary + +
+
+
    +
  • +
    +
    Title
    +
    {{staffRecord.bibSummary.title}}
    +
    Edition
    +
    {{staffRecord.bibSummary.edition}}
    +
    TCN
    +
    {{staffRecord.bibSummary.tcn_value}}
    +
    Created By
    +
    + {{staffRecord.bibSummary.creator.usrname()}} +
    +
    +
  • +
  • +
    +
    Author
    +
    {{staffRecord.bibSummary.author}}
    +
    Pubdate
    +
    {{staffRecord.bibSummary.pubdate}}
    +
    Database ID
    +
    {{staffRecord.bibSummary.id}}
    +
    Last Edited By
    +
    + {{staffRecord.bibSummary.editor.usrname()}} +
    +
    +
  • +
+
+
diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.ts b/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.ts index d3672305c9..21a9a4b486 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/record.component.ts @@ -5,6 +5,7 @@ import {EgIdlObject} from '@eg/core/idl'; import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {StaffCatalogService} from '../staff-catalog.service'; +import {StaffRecordService} from './record.service'; @Component({ selector: 'eg-catalog-record', @@ -16,18 +17,16 @@ export class RecordComponent implements OnInit { recordId: number; searchContext: CatalogSearchContext; - // Cache record creator/editor since this will likely be a - // reasonably small set of data w/ lots of repitition. - userCache: {[id:number] : EgIdlObject} = {}; - constructor( private route: ActivatedRoute, private pcrud: EgPcrudService, - private staffCat: StaffCatalogService + private staffCat: StaffCatalogService, + private staffRecord: StaffRecordService ) {} ngOnInit() { - this.recordId = +this.route.snapshot.paramMap.get('id'); + this.searchContext = this.staffCat.searchContext; + this.staffRecord.setRecord(+this.route.snapshot.paramMap.get('id')); } } diff --git a/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.css b/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.css index f8f36e679f..ff8aab33f4 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.css +++ b/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.css @@ -19,3 +19,7 @@ align-items: center; } +.card-body { + padding: 7px; +} + diff --git a/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.html b/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.html index 63571f3de3..1bc7c312e7 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.html +++ b/Open-ILS/webby-src/src/app/staff/catalog/result/record.component.html @@ -17,6 +17,9 @@
+ + #{{index + 1 + searchContext.pager.offset}} + {{bibSummary.title || ' '}} @@ -33,9 +36,11 @@
+ - {{bibSummary.ccvms.icon_format.label}} @@ -59,15 +64,21 @@
-
-
+
-
-
- TCN: {{bibSummary.tcn_value}} -
+
+ TCN: {{bibSummary.tcn_value}}
-
+
+
+
+ Holds: {{bibSummary.holdCount}} +
+
+
+
+
+
Created {{bibSummary.create_date | date:'shortDate'}} by @@ -81,12 +92,7 @@
-
-
- Holds: {{bibSummary.holdCount}} -
-
-
+
Edited {{bibSummary.edit_date | date:'shortDate'}} by +

Search Results ({{searchContext.result.count}})

@@ -18,8 +18,10 @@
- - +
+ + +
diff --git a/Open-ILS/webby-src/src/app/staff/catalog/result/results.component.ts b/Open-ILS/webby-src/src/app/staff/catalog/result/results.component.ts index f2d1b307e2..c1b1c25b0c 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/result/results.component.ts +++ b/Open-ILS/webby-src/src/app/staff/catalog/result/results.component.ts @@ -18,8 +18,6 @@ import {EgIdlObject} from '@eg/core/idl'; export class ResultsComponent implements OnInit { searchContext: CatalogSearchContext; - facetCache: any; - facetKey: string; // Cache record creator/editor since this will likely be a // reasonably small set of data w/ lots of repitition. @@ -60,16 +58,7 @@ export class ResultsComponent implements OnInit { if (!this.searchContext.query[0]) return; this.cat.search(this.searchContext).then(ok => { - // Only need to fetch facets once per search - // TODO: move last-facet cache to this.cat.fetchFacets; - if (this.facetKey == this.searchContext.result.facet_key) { - this.searchContext.result.facetData = this.facetCache; - } else { - this.cat.fetchFacets(this.searchContext).then(ok => {; - this.facetKey = this.searchContext.result.facet_key; - this.facetCache = this.searchContext.result.facetData; - }); - } + this.cat.fetchFacets(this.searchContext); this.fleshSearchResults(); }); } diff --git a/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.css b/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.css index 09e2da9b02..f67d8fa0c7 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.css +++ b/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.css @@ -3,3 +3,7 @@ .checkbox label { margin-bottom: .1rem; } + +#staffcat-search-form { + border-bottom: 2px dashed rgba(0,0,0,.225); +} diff --git a/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.html b/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.html index a51d6c88e6..42c512f034 100644 --- a/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/webby-src/src/app/staff/catalog/search-form.component.html @@ -1,7 +1,7 @@ -
+
-- 2.11.0