Implement add basket to bucket
authorBill Erickson <berickxx@gmail.com>
Thu, 15 Nov 2018 22:14:14 +0000 (17:14 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 30 Nov 2018 16:34:20 +0000 (11:34 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html
Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts
Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.html
Open-ILS/src/eg2/src/app/staff/share/buckets/record-bucket-dialog.component.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Container.pm

index aa69477..ca47c66 100644 (file)
@@ -1,3 +1,5 @@
+<eg-record-bucket-dialog #addBasketToBucketDialog>
+</eg-record-bucket-dialog>
 
 <div class="row">
   <div class="col-lg-4 pr-1">
         [disabled]="!basketCount()"
         [(ngModel)]="basketAction" (change)="applyAction()">
       <option value='' [disabled]="true" i18n>Basket Actions...</option>
-      <option value="view" i18n>View Basket</option>
+      <option value="view"   i18n>View Basket</option>
       <option value="hold"   [disabled]="true" i18n>Place Hold</option>
       <option value="print"  [disabled]="true" i18n>Print Title Details</option>
       <option value="email"  [disabled]="true" i18n>Email Title Details</option>
-      <option value="bucket" [disabled]="true" i18n>Add Basket to Bucket</option>
+      <option value="bucket" i18n>Add Basket to Bucket</option>
       <option value="clear"  [disabled]="true" i18n>Clear Basket</option>
     </select>
   </div>
index fd225f1..90f0e72 100644 (file)
@@ -1,7 +1,9 @@
-import {Component, OnInit} from '@angular/core';
+import {Component, OnInit, ViewChild} from '@angular/core';
 import {BasketService} from '@eg/share/catalog/basket.service';
 import {Subscription} from 'rxjs/Subscription';
 import {Router} from '@angular/router';
+import {RecordBucketDialogComponent} 
+    from '@eg/staff/share/buckets/record-bucket-dialog.component';
 
 @Component({
   selector: 'eg-catalog-basket-actions',
@@ -11,6 +13,9 @@ export class BasketActionsComponent implements OnInit {
 
     basketAction: string;
 
+    @ViewChild('addBasketToBucketDialog')
+        addToBucketDialog: RecordBucketDialogComponent;
+
     constructor(
         private router: Router,
         private basket: BasketService
@@ -38,6 +43,14 @@ export class BasketActionsComponent implements OnInit {
             case 'clear':
                 this.basket.removeAllRecordIds();
                 break;
+
+            case 'bucket':
+                this.basket.getRecordIds().then(ids => {
+                    this.addToBucketDialog.recordId = ids;
+                    this.addToBucketDialog.open({size: 'lg'});
+                });
+                break;
+
         }
 
         // Resetting basketAction inside its onchange handler
index d37981b..3019b33 100644 (file)
   </div>
 </div>
 
-
 <!-- header, pager, and list of records -->
 <div id="staff-catalog-results-container" *ngIf="searchHasResults()">
   <div class="row">
-    <div class="col-lg-2"><!--match pagination margin-->
+    <div class="col-lg-2" *ngIf="!searchContext.basket">
       <h3 i18n>Search Results ({{searchContext.result.count}})</h3>
     </div>
+    <div class="col-lg-2" *ngIf="searchContext.basket">
+      <h3 i18n>Basket View</h3>
+    </div>
     <div class="col-lg-2">
-      <label class="checkbox">
+      <label class="checkbox" *ngIf="!searchContext.basket">
         <input type='checkbox' [(ngModel)]="allRecsSelected" 
             (change)="toggleAllRecsSelected()"/>
         <span class="pl-1" i18n>Select {{searchContext.pager.rowNumber(0)}} - 
   </div>
   <div>
     <div class="row mt-2">
-      <div class="col-lg-2">
+      <div class="col-lg-2" *ngIf="!searchContext.basket">
         <eg-catalog-result-facets></eg-catalog-result-facets>
       </div>
-      <div class="col-lg-10">
+      <div
+        [ngClass]="{'col-lg-10': !searchContext.basket, 'col-lg-12': searchContext.basket}">
         <div *ngIf="shouldStartRendering()">
           <div *ngFor="let summary of searchContext.result.records; let idx = index">
             <div *ngIf="summary">
index 52a26f2..edb0564 100644 (file)
@@ -95,6 +95,9 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
     formEnter(source) {
         this.searchContext.pager.offset = 0;
 
+        // Form searches override basket displays.
+        this.searchContext.basket = null;
+
         switch (source) {
 
             case 'query': // main search form query input
index f5e4c94..550dac9 100644 (file)
@@ -1,6 +1,11 @@
 <ng-template #dialogContent>
   <div class="modal-header bg-info">
-    <h4 class="modal-title" i18n>Add To Record #{{recId}} to Bucket</h4>
+    <h4 class="modal-title">
+        <span *ngIf="recIds.length == 1" i18n>
+            Add To Record #{{recIds[0]}} to Bucket</span>
+        <span *ngIf="recIds.length != 1" i18n>
+            Add {{recIds.length}} Record(s) to Bucket</span>
+    </h4>
     <button type="button" class="close" 
       i18n-aria-label aria-label="Close" 
       (click)="dismiss('cross_click')">
index 1f127b4..61a3923 100644 (file)
@@ -24,9 +24,9 @@ export class RecordBucketDialogComponent
     newBucketDesc: string;
     buckets: any[];
 
-    recId: number;
-    @Input() set recordId(id: number) {
-        this.recId = id;
+    recIds: number[];
+    @Input() set recordId(id: number | number[]) {
+        this.recIds = [].concat(id);
     }
 
     constructor(
@@ -85,15 +85,19 @@ export class RecordBucketDialogComponent
         });
     }
 
-    // Add the record to the selected existing bucket
+    // Add the record(s) to the bucket with provided ID.
     addToBucket(id: number) {
-        const item = this.idl.create('cbrebi');
-        item.bucket(id);
-        item.target_biblio_record_entry(this.recId);
+        const items = [];
+        this.recIds.forEach(recId => {
+            const item = this.idl.create('cbrebi');
+            item.bucket(id);
+            item.target_biblio_record_entry(recId);
+            items.push(item);
+        });
         this.net.request(
             'open-ils.actor',
             'open-ils.actor.container.item.create',
-            this.auth.token(), 'biblio', item
+            this.auth.token(), 'biblio', items
         ).subscribe(resp => {
             const evt = this.evt.parse(resp);
             if (evt) {
index badb134..0af60f2 100644 (file)
@@ -350,6 +350,10 @@ sub item_create {
     return $e->die_event unless $e->checkauth;
     my $items = (ref $item eq 'ARRAY') ? $item : [$item];
 
+    # Elect an item to be the source of the bucket we will
+    # add all items to.
+    $item = $items->[0];
+
     my ( $bucket, $evt ) = $apputils->fetch_container_e($e, $item->bucket, $class);
     return $evt if $evt;