From 4e9a53fd6713af32c0b1dcc9940d7dcf2bfea464 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 1 Jun 2018 17:50:07 -0400 Subject: [PATCH] LP#1775466 Catalog MARC HTML view tab Signed-off-by: Bill Erickson --- .../eg2/src/app/staff/catalog/catalog.module.ts | 4 +- .../staff/catalog/record/marc-view.component.ts | 63 ++++++++++++++++++++++ .../app/staff/catalog/record/record.component.html | 15 +++++- 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/marc-view.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 3d3d3132e2..a4b4f614d3 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -15,6 +15,7 @@ import {ResultFacetsComponent} from './result/facets.component'; import {ResultRecordComponent} from './result/record.component'; import {StaffCatalogService} from './catalog.service'; import {RecordPaginationComponent} from './record/pagination.component'; +import {MarcViewComponent} from './record/marc-view.component'; @NgModule({ declarations: [ @@ -27,7 +28,8 @@ import {RecordPaginationComponent} from './record/pagination.component'; ResultRecordComponent, ResultFacetsComponent, ResultPaginationComponent, - RecordPaginationComponent + RecordPaginationComponent, + MarcViewComponent ], imports: [ EgStaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/marc-view.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/marc-view.component.ts new file mode 100644 index 0000000000..aa8677e54b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/marc-view.component.ts @@ -0,0 +1,63 @@ +import {Component, OnInit, Input, ElementRef} from '@angular/core'; +import {EgNetService} from '@eg/core/net.service'; +import {StaffCatalogService} from '../catalog.service'; +import {EgOrgService} from '@eg/core/org.service'; + +@Component({ + selector: 'eg-catalog-marc-view', + // bulk of display is generated from MARC HTML + template: '
' +}) +export class MarcViewComponent implements OnInit { + + recId: number; + initDone = false; + + @Input() set recordId(id: number) { + this.recId = id; + // Only force new data collection when recordId() + // is invoked after ngInit() has already run. + if (this.initDone) { + this.collectData(); + } + } + + constructor( + private elm: ElementRef, + private net: EgNetService, + private staffCat: StaffCatalogService + ) {} + + ngOnInit() { + this.initDone = true; + this.collectData(); + } + + collectData() { + if (!this.recId) { return; } + this.fetchMarcHtml(); + } + + fetchMarcHtml() { + this.net.request( + 'open-ils.search', + 'open-ils.search.biblio.record.html', + this.recId, false + + ).subscribe(html => { + + // Remove those pesky non-i8n labels / actions. + // Note: for printing, use the browser print page + // option. The end result is the same. + html = html.replace( + /