implement additional navigation links
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 21 Jan 2020 01:02:32 +0000 (20:02 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 21 Jan 2020 01:02:32 +0000 (20:02 -0500)
Along the way, also:

- make the acq search components react to route and route query
  param changes
- add user_id and ws_ou to the Angular and AngularJS nav bars

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.html
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts
Open-ILS/src/eg2/src/app/staff/nav.component.html
Open-ILS/src/eg2/src/app/staff/nav.component.ts
Open-ILS/src/templates/staff/navbar.tt2
Open-ILS/web/js/ui/default/staff/services/navbar.js

index 3a5e477..72143a0 100644 (file)
@@ -37,6 +37,7 @@
       <input [(ngModel)]="t.value1" type="number" *ngIf="searchTermDatatypes[t.field] == 'int'" class="form-control" />
       <input [(ngModel)]="t.value1" type="number" *ngIf="searchTermDatatypes[t.field] == 'money'" class="form-control" />
       <eg-org-select *ngIf="searchTermDatatypes[t.field] == 'org_unit'"
+        [initialOrgId]="t.value1"
         (onChange)="setOrgUnitSearchValue($event, t)">
       </eg-org-select>
       <eg-combobox *ngIf="searchTermDatatypes[t.field] == 'link'"
index e083c25..7eb21d8 100644 (file)
@@ -1,6 +1,6 @@
 import {Component, OnInit, AfterViewInit, ViewChild, ViewChildren, QueryList} from '@angular/core';
 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
-import {Router, ActivatedRoute, ParamMap} from '@angular/router';
+import {Router, ActivatedRoute, ParamMap, NavigationEnd} from '@angular/router';
 import {StaffCommonModule} from '@eg/staff/common.module';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {PcrudService} from '@eg/core/pcrud.service';
@@ -36,6 +36,7 @@ export class AcqSearchComponent implements OnInit, AfterViewInit {
         private idl: IdlService,
     ) {
         this.route.queryParamMap.subscribe((params: ParamMap) => {
+            this.urlSearchTerms = [];
             const fields = params.getAll('f');
             const ops = params.getAll('op');
             const values1 = params.getAll('val1');
@@ -52,13 +53,25 @@ export class AcqSearchComponent implements OnInit, AfterViewInit {
                 }
                 if (idx < values1.length) {
                     term.value1 = values1[idx];
+                    if (term.value1 === 'null') {
+                        // convert the string 'null' to a true
+                        // null value, mostly for the benefit of the
+                        // open invoices navigation link
+                        term.value1 = null;
+                    }
                 }
                 if (idx < values2.length) {
                     term.value2 = values2[idx];
                 }
                 this.urlSearchTerms.push(term);
+                this.ngOnInit(); // TODO: probably overkill
             });
         });
+        this.router.events.subscribe(routeEvent => {
+            if (routeEvent instanceof NavigationEnd) {
+                this.ngOnInit(); // TODO: probably overkill
+            }
+        });
     }
 
     ngOnInit() {
index 34d8503..120cae1 100644 (file)
           </a>
           <div class="dropdown-divider"></div>
           <a class="dropdown-item" 
-            href="/eg/staff/acq/legacy/search/unified?ca=pl">
+            routerLink="/staff/acq/search/selectionlists"
+            [queryParams]="{f: 'acqpl:owner', val1: user_id()}">
             <span class="material-icons">view_list</span>
             <span i18n>My Selection Lists</span>
           </a>
             <span i18n>Load MARC Order Records</span>
           </a>
           <a class="dropdown-item" 
-            href="/eg/staff/acq/legacy/search/unified?ca=po">
+            routerLink="/staff/acq/search/purchaseorders"
+            [queryParams]="{f: ['acqpo:ordering_agency','acqpo:state'], val1: [ws_ou(), 'on-order']}">
             <span class="material-icons">shopping_cart</span>
             <span i18n>Purchase Orders</span>
           </a>
             <span i18n>Claim-Ready Items</span>
           </a>
           <a class="dropdown-item" 
-            href="/eg/staff/acq/legacy/search/unified?ca=inv">
+            routerLink="/staff/acq/search/invoices"
+            [queryParams]="{f: ['acqinv:receiver', 'acqinv:close_date'], val1: [ws_ou(), null]}">
             <span class="material-icons">attach_money</span>
             <span i18n>Open Invoices</span>
           </a>
index f143727..1497870 100644 (file)
@@ -60,10 +60,18 @@ export class StaffNavComponent implements OnInit {
         return this.auth.user() ? this.auth.user().usrname() : '';
     }
 
+    user_id() {
+        return this.auth.user() ? this.auth.user().id() : '';
+    }
+
     workstation() {
         return this.auth.user() ? this.auth.workstation() : '';
     }
 
+    ws_ou() {
+        return this.auth.user() ? this.auth.user().ws_ou() : '';
+    }
+
     setLocale(locale: any) {
         this.locale.setLocale(locale.code());
     }
index 818cde4..731926f 100644 (file)
           </li>
           <li class="divider"></li>
           <li>
-            <a href="./acq/legacy/search/unified?ca=pl" target="_self">
+            <a href="/eg2/staff/acq/search/selectionlists?f=acqpl:owner&val1={{user_id}}" target="_self">
               <span class="glyphicon glyphicon-list"></span>
               [% l('My Selection Lists') %]
             </a>
             </a>
           </li>
           <li>
-            <a href="./acq/legacy/search/unified?ca=po" target="_self">
+            <a href="/eg2/staff/acq/search/purchaseorders?f=acqpo:ordering_agency&f=acqpo:state&val1={{ws_ou}}&val1=on-order" target="_self">
               <span class="glyphicon glyphicon-shopping-cart"></span>
               [% l('Purchase Orders') %]
             </a>
             </a>
           </li>
           <li>
-            <a href="./acq/legacy/search/unified?ca=inv" target="_self">
+            <a href="/eg2/staff/acq/search/invoices?f=acqinv:receiver&f=acqinv:close_date&val1={{ws_ou}}&val1=null" target="_self">
               <span class="glyphicon glyphicon-usd"></span>
               [% l('Open Invoices') %]
             </a>
index b6ff1d3..9c01748 100644 (file)
@@ -108,6 +108,8 @@ angular.module('egCoreMod')
                         if (egCore.auth.user()) {
                             $scope.op_changed = egCore.auth.OCtoken() ? true : false;
                             $scope.username = egCore.auth.user().usrname();
+                            $scope.user_id = egCore.auth.user().id();
+                            $scope.ws_ou = egCore.auth.user().ws_ou();
                             $scope.workstation = egCore.auth.workstation();
 
                             egCore.org.settings([