LP1929741 Standalone brief record UI
authorBill Erickson <berickxx@gmail.com>
Wed, 30 Jun 2021 20:36:20 +0000 (16:36 -0400)
committerJane Sandberg <js7389@princeton.edu>
Sun, 2 Oct 2022 15:02:49 +0000 (08:02 -0700)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Open-ILS/src/eg2/src/app/staff/acq/lineitem/brief-record.component.html
Open-ILS/src/eg2/src/app/staff/acq/lineitem/brief-record.component.ts
Open-ILS/src/eg2/src/app/staff/acq/picklist/routing.module.ts

index 0dbe6db..7308e1c 100644 (file)
@@ -1,10 +1,26 @@
 
-<h3 class="m-2" i18n>Add A Brief Record</h3>
+<ng-container *ngIf="targetPicklist || targetPo">
+  <h3 class="m-2" i18n>Add A Brief Record</h3>
+</ng-container>
+<ng-container *ngIf="!targetPicklist &&! targetPo">
+  <eg-staff-banner i18n-bannerText bannerText="New Brief Record">
+  </eg-staff-banner>
+</ng-container>
 
-<div class="d-flex w-50 m-2" *ngFor="let attr of attrs">
-  <div class="flex-1">{{attr.description()}}</div>
-  <div class="flex-3">
-    <input class="form-control" type="text" [(ngModel)]="values[attr.id()]"/>
+<div class="w-50 m-2">
+  <div class="d-flex mt-2" *ngIf="!targetPicklist && !targetPo">
+    <div class="flex-1" i18n>Add To Selection List</div>
+    <div class="flex-3">
+      <eg-combobox [(ngModel)]="selectedPl" idlClass="acqpl"
+        [allowFreeText]="true" placeholder="Select List..." i18n-placeHolder>
+      </eg-combobox>
+    </div>
+  </div>
+  <div class="d-flex mt-2" *ngFor="let attr of attrs">
+    <div class="flex-1">{{attr.description()}}</div>
+    <div class="flex-3">
+      <input class="form-control" type="text" [(ngModel)]="values[attr.id()]"/>
+    </div>
   </div>
 </div>
 
index 623d305..c210369 100644 (file)
@@ -2,9 +2,11 @@ import {Component, OnInit, Input, Output} from '@angular/core';
 import {ActivatedRoute, Router, ParamMap} from '@angular/router';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
+import {EventService} from '@eg/core/event.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {AuthService} from '@eg/core/auth.service';
 import {LineitemService} from './lineitem.service';
+import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 
 const MARC_NS = 'http://www.loc.gov/MARC21/slim';
 
@@ -29,12 +31,16 @@ export class BriefRecordComponent implements OnInit {
     attrs: IdlObject[] = [];
     values: {[attr: string]: string} = {};
 
+    // From the inline PL selector
+    selectedPl: ComboboxEntry;
+
     constructor(
         private router: Router,
         private route: ActivatedRoute,
         private idl: IdlService,
         private auth: AuthService,
         private net: NetService,
+        private evt: EventService,
         private pcrud: PcrudService,
         private liService: LineitemService
     ) { }
@@ -87,6 +93,37 @@ export class BriefRecordComponent implements OnInit {
     }
 
     save() {
+        this.saveManualPicklist()
+        .then(ok => { if (ok) { this.createLineitem(); } });
+    }
+
+    saveManualPicklist(): Promise<boolean> {
+        if (!this.selectedPl) { return Promise.resolve(false); }
+
+        if (!this.selectedPl.freetext) {
+            // An existing PL was selected
+            this.targetPicklist = this.selectedPl.id;
+            return Promise.resolve(true);
+        }
+
+        const pl = this.idl.create('acqpl');
+        pl.name(this.selectedPl.label);
+        pl.owner(this.auth.user().id());
+
+        return this.net.request(
+            'open-ils.acq',
+            'open-ils.acq.picklist.create', this.auth.token(), pl).toPromise()
+
+        .then(plId => {
+            const evt = this.evt.parse(plId);
+            if (evt) { alert(evt); return false; }
+            this.targetPicklist = plId;
+            return true;
+        });
+    }
+
+    createLineitem() {
+
         const xml = this.compile();
 
         const li = this.idl.create('jub');
@@ -104,12 +141,25 @@ export class BriefRecordComponent implements OnInit {
 
         this.net.request('open-ils.acq',
             'open-ils.acq.lineitem.create', this.auth.token(), li
-        ).toPromise().then(_ => {
+        ).toPromise().then(liId => {
+
+            const evt = this.evt.parse(liId);
+            if (evt) { alert(evt); return; }
+
             this.liService.activateStateChange.emit();
-            this.router.navigate(['../'], {
-                relativeTo: this.route,
-                queryParamsHandling: 'merge'
-            });
+
+            if (this.selectedPl) {
+                // Brief record was added to a picklist that is not
+                // currently focused in the UI.  Jump to it.
+                const url = `/staff/acq/picklist/${this.targetPicklist}`;
+                this.router.navigate([url], {fragment: liId});
+            } else {
+
+                this.router.navigate(['../'], {
+                    relativeTo: this.route,
+                    queryParamsHandling: 'merge'
+                });
+            }
         });
     }
 }
index f641e51..d943cab 100644 (file)
@@ -10,6 +10,9 @@ import {BriefRecordComponent} from '../lineitem/brief-record.component';
 import {LineitemHistoryComponent} from '../lineitem/history.component';
 
 const routes: Routes = [{
+    path: 'brief-record',
+    component: BriefRecordComponent
+}, {
   path: ':picklistId',
   component: PicklistComponent,
   children : [{