LPXXX Angular Volcopy
authorBill Erickson <berickxx@gmail.com>
Fri, 19 Jun 2020 18:11:31 +0000 (14:11 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 19 Jun 2020 18:11:31 +0000 (14:11 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts
Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts

index 789f657..3086135 100644 (file)
 
     <div class="border rounded m-1">
       <eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
-      <div class="batch-header font-weight-bold p-2" i18n>Item Alerts</div>
+      <div class="batch-header font-weight-bold p-2" i18n>Add Item Alerts</div>
       <div class="p-1">
         <button class="btn btn-outline-dark" (click)="openCopyAlerts()" i18n>
           Item Alerts
index db3bcda..723638c 100644 (file)
@@ -277,13 +277,19 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
     }
 
     openCopyAlerts() {
-        // TODO: support for new copies
-        this.copyAlertsDialog.copyIds = this.context.copyList().map(c => c.id());
+        this.copyAlertsDialog.inPlaceMode = true;
         this.copyAlertsDialog.mode = 'create';
         this.copyAlertsDialog.open({size: 'lg'}).subscribe(
-            modified => {
-                if (modified) {
-                    console.log('notes modified');
+            newAlert => {
+                if (newAlert) {
+                    this.context.copyList().forEach(copy => {
+                        const a = this.idl.clone(newAlert);
+                        a.isnew(true);
+                        a.copy(copy.id());
+                        if (!copy.copy_alerts()) { copy.copy_alerts([]); }
+                        copy.copy_alerts().push(a);
+                        copy.ischanged(true);
+                    });
                 }
             }
         );
index 44f6db4..4dc6574 100644 (file)
@@ -105,6 +105,8 @@ export class VolEditComponent implements OnInit {
             );
         });
 
+        if (Object.keys(this.bibParts).length === 0) { return; }
+
         this.pcrud.search('bmp',
             {record: Object.keys(this.bibParts), deleted: 'f'})
         .subscribe(
index 045fda9..ff1473f 100644 (file)
     <div class="row m-2 p-2 border border-dark rounded bg-faint">
       <div class="col-lg-12 d-flex">
         <div class="flex-1"> </div>
-        <button class="btn btn-outline-dark" 
-          [disabled]="!context.isSaveable()" (click)="save()" i18n>Save</button>
+        <button class="btn btn-outline-dark" (click)="save()" i18n>Save</button>
         <button class="btn btn-outline-dark ml-2" 
-          [disabled]="!context.isSaveable()"
           (click)="save(true)" i18n>Save &amp; Exit</button>
       </div>
     </div>
index 52e89be..687066f 100644 (file)
@@ -98,7 +98,8 @@ export class RecordActionsComponent implements OnInit {
     // TODO: Support adding like call numbers by getting selected
     // call numbers from the holdings grid.
     addHoldings() {
-        this.holdings.spawnAddHoldingsUi(this.recId);
+        // -1 == create new call number
+        this.holdings.spawnAddHoldingsUi(this.recId, null, [{callnumber: -1}]);
     }
 
 }
index 439c546..06951b8 100644 (file)
@@ -41,6 +41,11 @@ export class CopyAlertsDialogComponent
         return this._mode;
     }
 
+    // If true, no attempt is made to save the new alerts to the
+    // database.  It's assumed this takes place in the calling code.
+    // This is useful for creating alerts for new copies.
+    @Input() inPlaceMode = false;
+
     // In 'create' mode, we may be adding notes to multiple copies.
     copies: IdlObject[];
     // In 'manage' mode we only handle a single copy.
@@ -78,7 +83,7 @@ export class CopyAlertsDialogComponent
         this.newAlert = this.idl.create('aca');
         this.newAlert.create_staff(this.auth.user().id());
 
-        if (this.copyIds.length === 0) {
+        if (this.copyIds.length === 0 && !this.inPlaceMode) {
             return throwError('copy ID required');
         }
 
@@ -117,6 +122,9 @@ export class CopyAlertsDialogComponent
     }
 
     getCopies(): Promise<any> {
+
+        if (this.inPlaceMode) { return Promise.resolve(); }
+
         return this.pcrud.search('acp', {id: this.copyIds}, {}, {atomic: true})
         .toPromise().then(copies => {
             this.copies = copies;
@@ -149,6 +157,11 @@ export class CopyAlertsDialogComponent
     addNew() {
         if (!this.newAlert.alert_type()) { return; }
 
+        if (this.inPlaceMode) {
+            this.close(this.newAlert);
+            return;
+        }
+
         const alerts: IdlObject[] = [];
         this.copies.forEach(c => {
             const a = this.idl.clone(this.newAlert);
index ccfd79b..f907b3b 100644 (file)
@@ -62,7 +62,8 @@ export class HoldingsService {
                 return;
             }
             setTimeout(() => {
-                const url = `/eg2/staff/cat/volcopy/edit/session/${key}`;
+                const tab = hideVols ? 'attrs' : 'holdings';
+                const url = `/eg2/staff/cat/volcopy/${tab}/session/${key}`;
                 window.open(url, '_blank');
             });
         });