From 857e6dca9a93117246f4756fe82a33fa667c46e9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 22 Jun 2018 15:09:36 -0400 Subject: [PATCH] LP#1775466 Catalog record MarkFor actions Signed-off-by: Bill Erickson --- .../eg2/src/app/share/string/string.component.ts | 21 +++++- .../eg2/src/app/staff/catalog/catalog.module.ts | 2 + .../staff/catalog/record/actions.component.html | 50 +++++++++++++ .../app/staff/catalog/record/actions.component.ts | 85 ++++++++++++++++++++++ .../app/staff/catalog/record/record.component.html | 16 +++- 5 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts diff --git a/Open-ILS/src/eg2/src/app/share/string/string.component.ts b/Open-ILS/src/eg2/src/app/share/string/string.component.ts index 7ba9a409a8..f092a7ef5f 100644 --- a/Open-ILS/src/eg2/src/app/share/string/string.component.ts +++ b/Open-ILS/src/eg2/src/app/share/string/string.component.ts @@ -21,10 +21,19 @@ import {StringService} from '@eg/share/string/string.service'; export class StringComponent implements OnInit { + // Storage key for future reference by the string service @Input() key: string; + + // Interpolation context @Input() ctx: any; + + // String template to interpolate @Input() template: TemplateRef; + // Static text -- no interpolation performed. + // This supersedes 'template' + @Input() text: string; + constructor(private elm: ElementRef, private strings: StringService) { this.elm = elm; this.strings = strings; @@ -36,12 +45,20 @@ export class StringComponent implements OnInit { if (this.key) { this.strings.register({ key: this.key, - resolver: (ctx: any) => this.current(ctx) + resolver: (ctx: any) => { + if (this.text) { + // When passed text that does not require any + // interpolation, just return it as-is. + return Promise.resolve(this.text); + } else { + // Interpolate + return this.current(ctx); + } + } }); } } - // Apply the new context if provided, give our container a // chance to update, then resolve with the current string. // NOTE: talking to the native DOM element is not so great, but 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 b8de7cb29e..8c1a421150 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 @@ -16,6 +16,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 {RecordActionsComponent} from './record/actions.component'; import {MarcViewComponent} from './record/marc-view.component'; @NgModule({ @@ -30,6 +31,7 @@ import {MarcViewComponent} from './record/marc-view.component'; ResultFacetsComponent, ResultPaginationComponent, RecordPaginationComponent, + RecordActionsComponent, MarcViewComponent ], imports: [ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html new file mode 100644 index 0000000000..41c87bc38b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html @@ -0,0 +1,50 @@ + + + + + + + +
+ +
+ +
+ + + + + +
+
+ +
+ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts new file mode 100644 index 0000000000..d888b636db --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts @@ -0,0 +1,85 @@ +import {Component, OnInit, Input} from '@angular/core'; +import {Router} from '@angular/router'; +import {StoreService} from '@eg/core/store.service'; +import {CatalogService} from '@eg/share/catalog/catalog.service'; +import {CatalogSearchContext} from '@eg/share/catalog/search-context'; +import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service'; +import {StaffCatalogService} from '../catalog.service'; +import {StringService} from '@eg/share/string/string.service'; +import {ToastService} from '@eg/share/toast/toast.service'; + +@Component({ + selector: 'eg-catalog-record-actions', + templateUrl: 'actions.component.html' +}) +export class RecordActionsComponent implements OnInit { + + recId: number; + initDone = false; + searchContext: CatalogSearchContext; + + targets = { + conjoined: { + key: 'eg.cat.marked_conjoined_record', + current: null + }, + overlay: { + key: 'eg.cat.marked_overlay_record', + current: null + }, + holdTransfer: { + key: 'eg.circ.hold.title_transfer_target', + current: null + }, + volumeTransfer: { + key: 'eg.cat.marked_volume_transfer_record', + current: null + } + }; + + @Input() set recordId(recId: number) { + this.recId = recId + if (this.initDone) { + // Fire any record specific actions here + } + } + + constructor( + private router: Router, + private store: StoreService, + private strings: StringService, + private toast: ToastService, + private cat: CatalogService, + private catUrl: CatalogUrlService, + private staffCat: StaffCatalogService, + ) {} + + ngOnInit() { + this.initDone = true; + + Object.keys(this.targets).forEach(name => { + const target = this.targets[name]; + target.current = this.store.getLocalItem(target.key); + }); + } + + mark(name: string) { + const target = this.targets[name]; + target.current = this.recId; + this.store.setLocalItem(target.key, this.recId); + this.strings.interpolate('catalog.record.toast.' + name) + .then(txt => this.toast.success(txt)); + } + + clearMarks() { + Object.keys(this.targets).forEach(name => { + const target = this.targets[name]; + target.current = null; + this.store.removeLocalItem(target.key); + }); + this.strings.interpolate('catalog.record.toast.cleared') + .then(txt => this.toast.success(txt)); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html index 263375bc91..66fe2b9eb2 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html @@ -1,9 +1,17 @@
-
-
- - +
+
+
+ + +
+
+ +
+
+ +
-- 2.11.0