From: Bill Erickson Date: Fri, 8 Dec 2017 21:24:03 +0000 (-0500) Subject: LP#626157 Ang2 experiments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8d268281880b268d36c04ccff271e25126e57f66;p=working%2FEvergreen.git LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- 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 daf978331c..b1311af868 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 @@ -201,7 +201,7 @@ export class EgCatalogService { * Bib record via UNAPI as mods (for now) with holdings summary * and record attributes. */ - getBibSummary(bibId: number, orgId: number, depth: number): Promise { + getBibSummary(bibId: number, orgId?: number, depth?: number): Promise { return new Promise((resolve, reject) => { this.unapi.getAsXmlDocument({ target: 'bre', 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 72e4e4f037..fb3c559d6f 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 @@ -9,6 +9,7 @@ import {EgCatalogComponent} from './catalog.component'; import {SearchFormComponent} from './search-form.component'; import {ResultsComponent} from './result/results.component'; import {RecordComponent} from './record/record.component'; +import {EgBibSummaryComponent} from '../share/bib-summary.component'; import {ResultPaginationComponent} from './result/pagination.component'; import {ResultFacetsComponent} from './result/facets.component'; import {ResultRecordComponent} from './result/record.component'; @@ -20,6 +21,7 @@ import {StaffRecordService} from './record/record.service'; EgCatalogComponent, ResultsComponent, RecordComponent, + EgBibSummaryComponent, SearchFormComponent, ResultRecordComponent, ResultFacetsComponent, 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 13d805d3c2..0bc3f35015 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,56 +1,7 @@
- - - -
-
- 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 21a9a4b486..f7f7af8bff 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 @@ -6,6 +6,7 @@ import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {StaffCatalogService} from '../staff-catalog.service'; import {StaffRecordService} from './record.service'; +import {EgBibSummaryComponent} from '../../share/bib-summary.component'; @Component({ selector: 'eg-catalog-record', @@ -25,8 +26,9 @@ export class RecordComponent implements OnInit { ) {} ngOnInit() { + this.recordId = +this.route.snapshot.paramMap.get('id'); this.searchContext = this.staffCat.searchContext; - this.staffRecord.setRecord(+this.route.snapshot.paramMap.get('id')); + this.staffRecord.setRecord(this.recordId); } } diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/record.service.ts b/Open-ILS/webby-src/src/app/staff/catalog/record/record.service.ts new file mode 100644 index 0000000000..224ba06cb9 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/catalog/record/record.service.ts @@ -0,0 +1,54 @@ +import {Injectable} from '@angular/core'; +import {Router, ActivatedRoute} from '@angular/router'; +import {EgOrgService} from '@eg/core/org'; +import {EgCatalogService} from '@eg/share/catalog/catalog.service'; +import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; +import {CatalogSearchContext} from '@eg/share/catalog/search-context'; +import {StaffCatalogService} from '../staff-catalog.service'; +import {EgPcrudService} from '@eg/core/pcrud'; + +/** + * Shared bits needed by the staff version of the catalog. + */ + +@Injectable() +export class StaffRecordService { + + recordId: number; + bibSummary: any; // TODO: bib summary class + searchContext: CatalogSearchContext; + + constructor( + private router: Router, + private route: ActivatedRoute, + private org: EgOrgService, + private pcrud: EgPcrudService, + private cat: EgCatalogService, + private staffCat: StaffCatalogService, + private catUrl: EgCatalogUrlService + ) { } + + setRecord(id: number): void { + this.recordId = id; + this.searchContext = this.staffCat.searchContext; + + this.cat.getBibSummary( + this.recordId, + this.searchContext.searchOrg.id(), + this.searchContext.searchOrg.ou_type().depth() + ).then(summary => { + this.bibSummary = summary; + this.pcrud.search('au', {id: [summary.creator, summary.editor]}) + .subscribe(user => { + if (user.id() == summary.creator) + summary.creator = user; + if (user.id() == summary.editor) + summary.editor = user; + }) + + // probably other stuff + }); + } +} + + 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 42c512f034..6955f2835c 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 @@ -66,15 +66,18 @@ TODO focus search input
@@ -134,13 +137,16 @@ TODO focus search input
-
-
-
- Searching.. -
+ +
+
+
+
+
+
+ Searching..
diff --git a/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.css b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.css new file mode 100644 index 0000000000..bec1012f5b --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.css @@ -0,0 +1,8 @@ +.eg-bib-summary { +} +.eg-bib-summary .card-body { + padding: .25rem; +} +.eg-bib-summary .list-group-item { + padding: .25rem; +} diff --git a/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.html b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.html new file mode 100644 index 0000000000..05737d8544 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.html @@ -0,0 +1,52 @@ + +
+
+ Record Summary + +
+
+
    +
  • +
    +
    Title:
    +
    {{summary.title}}
    +
    Edition:
    +
    {{summary.edition}}
    +
    TCN:
    +
    {{summary.tcn_value}}
    +
    Created By:
    +
    + {{summary.creator.usrname()}} +
    +
    +
  • +
  • +
    +
    Author:
    +
    {{summary.author}}
    +
    Pubdate:
    +
    {{summary.pubdate}}
    +
    Database ID:
    +
    {{summary.id}}
    +
    Last Edited By:
    +
    + {{summary.editor.usrname()}} +
    +
    +
  • +
  • +
    +
    Bib Call #:
    +
    {{summary.callNumber}}
    +
    Record Owner:
    +
    TODO
    +
    Created On:
    +
    {{summary.create_date | date:'shortDate'}}
    +
    Last Edited On:
    +
    {{summary.edit_date | date:'shortDate'}}
    +
    +
  • +
+
+
+ diff --git a/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.ts b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.ts new file mode 100644 index 0000000000..41990af205 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.ts @@ -0,0 +1,70 @@ +import {Component, OnInit, Input} from '@angular/core'; +import {EgNetService} from '@eg/core/net'; +import {EgPcrudService} from '@eg/core/pcrud'; +import {EgCatalogService} from '@eg/share/catalog/catalog.service'; + +@Component({ + selector: 'eg-bib-summary', + styleUrls: ['bib-summary.component.css'], + templateUrl: 'bib-summary.component.html' +}) +export class EgBibSummaryComponent implements OnInit { + + // If provided, the record will be fetched by the component. + @Input() recordId: number; + + // Otherwise, we'll use the provided bib summary object. + summary: any; + @Input() set bibSummary(s: any) { + if (s) { + this.summary = s; + this.fetchBibCallNumber(); + } + } + + constructor( + private cat: EgCatalogService, + private net: EgNetService, + private pcrud: EgPcrudService + ) {} + + ngOnInit() { + if (this.recordId) this.loadSummary(); + } + + loadSummary(): void { + this.cat.getBibSummary(this.recordId).then(summary => { + this.summary = summary; + this.fetchBibCallNumber(); + + // Flesh the user data + this.pcrud.search('au', {id: [summary.creator, summary.editor]}) + .subscribe(user => { + if (user.id() == summary.creator) + summary.creator = user; + if (user.id() == summary.editor) + summary.editor = user; + }) + }); + } + + fetchBibCallNumber(): void { + if (!this.summary || this.summary.callNumber) return; + + // TODO labelClass = cat.default_classification_scheme YAOUS + let labelClass = 1; + + this.net.request( + 'open-ils.cat', + 'open-ils.cat.biblio.record.marc_cn.retrieve', + this.summary.id, labelClass + ).subscribe(cnArray => { + if (cnArray && cnArray.length > 0) { + let key1 = Object.keys(cnArray[0])[0]; + this.summary.callNumber = cnArray[0][key1]; + } + }); + } +} + +