basket actions
authorBill Erickson <berickxx@gmail.com>
Tue, 13 Nov 2018 17:54:53 +0000 (12:54 -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/share/catalog/basket.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts
Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html
Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html

index 7db2749..99c8c24 100644 (file)
@@ -94,6 +94,10 @@ export class BasketService {
 
         return this.setRecordIds(wantedIds); // OK if empty
     }
+
+    removeAllRecordIds(): Promise<number[]> {
+        return this.setRecordIds([]);
+    }
 }
 
 
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html
new file mode 100644 (file)
index 0000000..be1f5bb
--- /dev/null
@@ -0,0 +1,23 @@
+
+<div class="row">
+  <div class="col-lg-4 pr-1">
+    <div class="float-right">
+      <a routerLink="/staff/catalog/basket" class="label-with-material-icon">
+        <span class="material-icons">shopping_basket</span>
+        <span i18n>({{basketCount()}})</span>
+      </a>
+    </div>
+  </div>
+  <div class="col-lg-8 pl-1">
+    <select class="form-control" 
+        [(ngModel)]="basketAction" (change)="applyAction()">
+      <option value='' [disabled]="true" i18n>Basket Actions...</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="clear"  [disabled]="true" i18n>Clear Bucket</option>
+    </select>
+  </div>
+</div>
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts
new file mode 100644 (file)
index 0000000..d79d309
--- /dev/null
@@ -0,0 +1,48 @@
+import {Component, OnInit} from '@angular/core';
+import {BasketService} from '@eg/share/catalog/basket.service';
+import {Subscription} from 'rxjs/Subscription';
+import {Router} from '@angular/router';
+
+@Component({
+  selector: 'eg-catalog-basket-actions',
+  templateUrl: 'basket-actions.component.html'
+})
+export class BasketActionsComponent implements OnInit {
+
+    basketAction: string;
+
+    constructor(
+        private router: Router,
+        private basket: BasketService
+    ) {
+        this.basketAction = '';
+    }
+
+    ngOnInit() {
+    }
+
+    basketCount(): number {
+        return this.basket.recordCount();
+    }
+
+    applyAction() {
+        console.debug('Performing basket action', this.basketAction);
+
+        switch(this.basketAction) {
+            case 'view':
+                this.router.navigate(['/staff/catalog/basket']);
+                break;
+
+            case 'clear':
+                this.basket.removeAllRecordIds();
+                break;
+        }
+
+        // Resetting basketAction inside its onchange handler
+        // prevents the new value from propagating to Angular
+        // Reset after the current thread.
+        setTimeout(() => this.basketAction = ''); // reset
+    }
+}
+
+
index 20e17a0..e490da2 100644 (file)
@@ -14,6 +14,7 @@ import {StaffCatalogService} from './catalog.service';
 import {RecordPaginationComponent} from './record/pagination.component';
 import {RecordActionsComponent} from './record/actions.component';
 import {HoldingsService} from '@eg/staff/share/holdings.service';
+import {BasketActionsComponent} from './basket-actions.component';
 
 @NgModule({
   declarations: [
@@ -26,7 +27,8 @@ import {HoldingsService} from '@eg/staff/share/holdings.service';
     ResultFacetsComponent,
     ResultPaginationComponent,
     RecordPaginationComponent,
-    RecordActionsComponent
+    RecordActionsComponent,
+    BasketActionsComponent
   ],
   imports: [
     StaffCommonModule,
index 1f2ba30..d37981b 100644 (file)
@@ -35,7 +35,7 @@
         <input type='checkbox' [(ngModel)]="allRecsSelected" 
             (change)="toggleAllRecsSelected()"/>
         <span class="pl-1" i18n>Select {{searchContext.pager.rowNumber(0)}} - 
-          {{searchContext.pager.rowNumber(searchContext.pager.limit - 1)}}
+          {{searchContext.pager.rowNumber(searchContext.currentResultIds().length - 1)}}
         </span>
       </label>
     </div>
index c4efdb2..f402ea4 100644 (file)
@@ -28,6 +28,7 @@ export class ResultsComponent implements OnInit, OnDestroy {
 
     searchSub: Subscription;
     routeSub: Subscription;
+    basketSub: Subscription;
 
     constructor(
         private route: ActivatedRoute,
@@ -64,11 +65,16 @@ export class ResultsComponent implements OnInit, OnDestroy {
         // After each completed search, update the record selector.
         this.searchSub = this.cat.onSearchComplete.subscribe(
             ctx => this.applyRecordSelection());
+
+        // Watch for basket changes applied by other components.
+        this.basketSub = this.basket.onChange.subscribe(
+            () => this.applyRecordSelection());
     }
 
     ngOnDestroy() {
         this.routeSub.unsubscribe();
         this.searchSub.unsubscribe();
+        this.basketSub.unsubscribe();
     }
 
     // Apply the select-all checkbox when all visible records
@@ -108,13 +114,9 @@ export class ResultsComponent implements OnInit, OnDestroy {
             switch (pageCount) {
                 case 1:
                     return this.searchContext.result.records[0];
-                case 2:
-                    return this.searchContext.result.records[0]
-                        && this.searchContext.result.records[1];
                 default:
                     return this.searchContext.result.records[0]
-                        && this.searchContext.result.records[1]
-                        && this.searchContext.result.records[2];
+                        && this.searchContext.result.records[1];
             }
         }
 
index b604c71..0d77715 100644 (file)
@@ -149,17 +149,7 @@ TODO focus search input
       </div>
     </div>
     <div class="col-lg-3">
-      <!--
-      <div *ngIf="searchIsActive()">
-        <div class="progress">
-          <div class="progress-bar progress-bar-striped active w-100"
-            role="progressbar" aria-valuenow="100" 
-            aria-valuemin="0" aria-valuemax="100">
-            <span class="sr-only" i18n>Searching..</span>
-          </div>
-        </div>
-      </div>
-      -->
+      <eg-catalog-basket-actions></eg-catalog-basket-actions>
     </div>
   </div>
   <div class="row pt-2" *ngIf="showAdvanced()">