LP#1775466 Catalog record MarkFor actions
authorBill Erickson <berickxx@gmail.com>
Fri, 22 Jun 2018 19:09:36 +0000 (15:09 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 5 Sep 2018 14:05:23 +0000 (10:05 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/string/string.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html

index 7ba9a40..f092a7e 100644 (file)
@@ -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<any>;
 
+    // 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
index b8de7cb..8c1a421 100644 (file)
@@ -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 (file)
index 0000000..41c87bc
--- /dev/null
@@ -0,0 +1,50 @@
+
+<eg-string key="catalog.record.toast.conjoined" 
+  i18n-text text="Conjoined Record Target Set"></eg-string>
+<eg-string key="catalog.record.toast.overlay" 
+  i18n-text text="Record Overlay Target Set"></eg-string>
+<eg-string key="catalog.record.toast.holdTransfer" 
+  i18n-text text="Hold Transfer Target Set"></eg-string>
+<eg-string key="catalog.record.toast.volumeTransfer" 
+  i18n-text text="Volume Transfer Target Set"></eg-string>
+<eg-string key="catalog.record.toast.cleared" 
+  text="Record Marks Cleared"></eg-string>
+
+<div class="row ml-0 mr-0">
+
+  <div ngbDropdown placement="bottom-right">
+    <button class="btn btn-primary" id="actionsForDd" 
+      ngbDropdownToggle i18n>Mark For...</button>
+    <div ngbDropdownMenu aria-labelledby="actionsForDd">
+      <button class="dropdown-item" (click)="mark('conjoined')">
+        <span i18n>
+          Conjoined Items<ng-container *ngIf="targets.conjoined.current"> 
+            (Currently {{targets.conjoined.current}})</ng-container>
+        </span>
+      </button>
+      <button class="dropdown-item" (click)="mark('overlay')">
+        <span i18n>
+          Overlay Target<ng-container *ngIf="targets.overlay.current"> 
+            (Currently {{targets.overlay.current}})</ng-container>
+        </span>
+      </button>
+      <button class="dropdown-item" (click)="mark('holdTransfer')">
+        <span i18n>
+          Title Hold Transfer<ng-container *ngIf="targets.holdTransfer.current"> 
+            (Currently {{targets.holdTransfer.current}})</ng-container>
+        </span>
+      </button>
+      <button class="dropdown-item" (click)="mark('volumeTransfer')">
+        <span i18n>
+          Volume Transfer<ng-container *ngIf="targets.volumeTransfer.current"> 
+            (Currently {{targets.volumeTransfer.current}})</ng-container>
+        </span>
+      </button>
+      <button class="dropdown-item" (click)="clearMarks()">
+        <span i18n>Reset Record Marks</span>
+      </button>
+    </div>
+  </div>
+
+</div>
+
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 (file)
index 0000000..d888b63
--- /dev/null
@@ -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));
+    }
+}
+
+
index 263375b..66fe2b9 100644 (file)
@@ -1,9 +1,17 @@
 
 <div id="staff-catalog-record-container">
-  <div id='staff-catalog-bib-navigation'>
-    <div *ngIf="searchContext.isSearchable()">
-      <eg-catalog-record-pagination [recordId]="recordId">
-      </eg-catalog-record-pagination>
+  <div class="row ml-0 mr-0">
+    <div id='staff-catalog-bib-navigation'>
+      <div *ngIf="searchContext.isSearchable()">
+        <eg-catalog-record-pagination [recordId]="recordId">
+        </eg-catalog-record-pagination>
+      </div>
+    </div>
+    <!-- push the actions component to the right -->
+    <div class="flex-1"></div>
+    <div id='staff-catalog-bib-navigation'>
+      <eg-catalog-record-actions [recordId]="recordId">
+      </eg-catalog-record-actions>
     </div>
   </div>
   <div id='staff-catalog-bib-summary-container' class='mt-1'>