LP1837802: Add records to shared record buckets from the Staff Catalog
authorJane Sandberg <sandbej@linnbenton.edu>
Wed, 18 Mar 2020 00:34:01 +0000 (17:34 -0700)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 25 Aug 2020 20:12:31 +0000 (16:12 -0400)
To test:
1) As User A, create a bucket.
2) As User B, search in the Staff Catalog, and add some items to your
basket.
3) As User B, click Basket Actions, and choose add Basket to Bucket
4) Click on the "Shared Bucket" tab and enter the id of User A's bucket

Some potential scenarios to test:
* Trying to add to a bucket that does not exist
* Trying to add to an unshared bucket when User B does not have the
VIEW_CONTAINER permission
* Trying to add to existing and new buckets as before

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/share/buckets/bucket-dialog.component.html
Open-ILS/src/eg2/src/app/staff/share/buckets/bucket-dialog.component.ts

index de4d29c..5c33108 100644 (file)
     </button>
   </div>
   <div class="modal-body">
-    <div class="row">
-      <div class="col-lg-3 font-weight-bold" i18n>Name of existing bucket</div>
-      <div class="col-lg-5">
-        <eg-combobox [entries]="formatBucketEntries()"
-          (onChange)="bucketChanged($event)"
-          placeholder="Existing Bucket..." i18n-placeholder>
-        </eg-combobox>
-      </div>
-      <div class="col-lg-4">
-        <button class="btn btn-info" (click)="addToSelected()" i18n
-          [disabled]="!selectedBucket">
-          Add To Selected Bucket
-        </button>
-      </div>
-    </div>
-    <div class="row mt-3">
-      <div class="col-lg-3 font-weight-bold" i18n>Name of new bucket</div>
-      <div class="col-lg-5">
-        <input type="text" class="form-control"
-          placeholder="New Bucket Name..."
-          i18n-placeholder
-          [(ngModel)]="newBucketName"/>
-      </div>
-      <div class="col-lg-4">
-        <button class="btn btn-info" (click)="addToNew()" i18n
-          [disabled]="!newBucketName">
-          Add To New Bucket
-        </button>
-      </div>
-    </div>
-    <div class="row mt-3">
-      <div class="col-lg-3 font-weight-bold" i18n>New bucket description</div>
-      <div class="col-lg-5">
-        <textarea size="3" type="text" class="form-control"
-          placeholder="Optional New Bucket Description..."
-          i18n-placeholder
-          [(ngModel)]="newBucketDesc">
-        </textarea>
-      </div>
-    </div>
+    <ngb-tabset>
+      <ngb-tab title="Existing bucket" i18n-title>
+        <ng-template ngbTabContent>
+          <div class="row">
+            <div class="col-lg-3 font-weight-bold" i18n>Name of existing bucket</div>
+            <div class="col-lg-5">
+              <eg-combobox [entries]="formatBucketEntries()"
+                (onChange)="bucketChanged($event)"
+                placeholder="Existing Bucket..." i18n-placeholder>
+              </eg-combobox>
+            </div>
+            <div class="col-lg-4">
+              <button class="btn btn-info" (click)="addToSelected()" i18n
+                [disabled]="!selectedBucket">
+                Add To Selected Bucket
+              </button>
+            </div>
+          </div>
+        </ng-template>
+      </ngb-tab>
+      <ngb-tab title="New bucket" i18n-title>
+        <ng-template ngbTabContent>
+          <div class="row mt-3">
+            <div class="col-lg-3 font-weight-bold" i18n>Name of new bucket</div>
+            <div class="col-lg-5">
+              <input type="text" class="form-control"
+                placeholder="New Bucket Name..."
+                i18n-placeholder
+                [(ngModel)]="newBucketName"/>
+            </div>
+            <div class="col-lg-4">
+              <button class="btn btn-info" (click)="addToNew()" i18n
+                [disabled]="!newBucketName">
+                Add To New Bucket
+              </button>
+            </div>
+          </div>
+          <div class="row mt-3">
+            <div class="col-lg-3 font-weight-bold" i18n>New bucket description</div>
+            <div class="col-lg-5">
+              <textarea size="3" type="text" class="form-control"
+                placeholder="Optional New Bucket Description..."
+                i18n-placeholder
+                [(ngModel)]="newBucketDesc">
+              </textarea>
+            </div>
+          </div>
+        </ng-template>
+      </ngb-tab>
+      <ngb-tab title="Shared bucket" i18n-title>
+        <ng-template ngbTabContent>
+          <div class="row">
+            <div class="col-lg-3 font-weight-bold" i18n>ID of shared bucket</div>
+            <div class="col-lg-5">
+              <input type="number" class="form-control"
+                [(ngModel)]="sharedBucketId"/>
+            </div>
+            <div class="col-lg-4">
+              <button class="btn btn-info" (click)="addToShared()" i18n
+                [disabled]="!sharedBucketId">
+                Add To Shared Bucket
+              </button>
+            </div>
+          </div>
+        </ng-template>
+      </ngb-tab>
+    </ngb-tabset>
   </div>
 </ng-template>
+<eg-confirm-dialog #confirmAddToShared
+  i18n-dialogTitle i18n-dialogBody
+  dialogTitle="Confirm Add to Shared Bucket"
+  dialogBody="Add to shared bucket named '{{sharedBucketName}}'?">
+</eg-confirm-dialog>
index 1300f0f..b743edd 100644 (file)
@@ -1,4 +1,6 @@
-import {Component, OnInit, Input, Renderer2} from '@angular/core';
+import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core';
+import {throwError} from 'rxjs';
+import {switchMap} from 'rxjs/operators';
 import {NetService} from '@eg/core/net.service';
 import {IdlService} from '@eg/core/idl.service';
 import {EventService} from '@eg/core/event.service';
@@ -6,6 +8,7 @@ import {ToastService} from '@eg/share/toast/toast.service';
 import {AuthService} from '@eg/core/auth.service';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
 import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
+import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 
 /**
@@ -20,6 +23,8 @@ import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 export class BucketDialogComponent extends DialogComponent implements OnInit {
 
     selectedBucket: number;
+    sharedBucketId: number;
+    sharedBucketName: string;
     newBucketName: string;
     newBucketDesc: string;
     buckets: any[];
@@ -37,6 +42,8 @@ export class BucketDialogComponent extends DialogComponent implements OnInit {
     bucketFmClass: 'ccb' | 'ccnb' | 'cbreb' | 'cub';
     targetField: string;
 
+    @ViewChild('confirmAddToShared', {static: true}) confirmAddToShared: ConfirmDialogComponent;
+
     constructor(
         private modal: NgbModal, // required for passing to parent
         private renderer: Renderer2,
@@ -65,6 +72,8 @@ export class BucketDialogComponent extends DialogComponent implements OnInit {
 
     reset() {
         this.selectedBucket = null;
+        this.sharedBucketId = null;
+        this.sharedBucketName = '';
         this.newBucketName = '';
         this.newBucketDesc = '';
 
@@ -102,6 +111,25 @@ export class BucketDialogComponent extends DialogComponent implements OnInit {
         this.addToBucket(this.selectedBucket);
     }
 
+    addToShared() {
+        this.net.request('open-ils.actor',
+            'open-ils.actor.container.flesh',
+            this.auth.token(), this.bucketClass,
+            this.sharedBucketId)
+        .pipe(switchMap((resp) => {
+            const evt = this.evt.parse(resp);
+            if (evt) {
+                this.toast.danger(evt.toString());
+                return throwError(evt);
+            } else {
+                this.sharedBucketName = resp.name();
+                return this.confirmAddToShared.open();
+            }
+        })).subscribe(() => {
+            this.addToBucket(this.sharedBucketId);
+        });
+    }
+
     bucketChanged(entry: ComboboxEntry) {
         if (entry) {
             this.selectedBucket = entry.id;
@@ -194,3 +222,4 @@ export class BucketDialogComponent extends DialogComponent implements OnInit {
 
 
 
+