From: Galen Charlton Date: Sun, 19 Jan 2020 21:58:07 +0000 (-0500) Subject: implement passing search form parameters via URL X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e4d95dbbc054824065f60c27edb184f6a39e3000;p=working%2FEvergreen.git implement passing search form parameters via URL TODO: avoid double-search on page startup TODO: consider having the LI search results flesh invoice_entries so that the invoice link can be displayed only when it would display results Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts index 9b9211728d..c745c01151 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, AfterViewInit, Output, EventEmitter} from '@angular/core'; +import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter} from '@angular/core'; import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {Router, ActivatedRoute} from '@angular/router'; import {StaffCommonModule} from '@eg/staff/common.module'; @@ -14,6 +14,8 @@ import {AcqSearchTerm} from './acq-search.service'; export class AcqSearchFormComponent implements OnInit, AfterViewInit { + @Input() initialSearchTerms: AcqSearchTerm[] = []; + @Output() searchSubmitted = new EventEmitter(); hints = ['jub', 'acqpl', 'acqpo', 'acqinv', 'acqlid']; @@ -71,7 +73,12 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit { this.searchTermDatatypes['acqlia:' + liad.id()] = 'text'; }); - this.addSearchTerm(); + if (this.initialSearchTerms.length > 0) { + this.searchTerms = JSON.parse(JSON.stringify(this.initialSearchTerms)); // deep copy + this.submitSearch(); + } else { + this.addSearchTerm(); + } } ngAfterViewInit() {} diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html index cc2e9525fd..d5d5a4d4a9 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html @@ -8,16 +8,16 @@
- + - + - + - +
diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts index 8e3546d6b0..e083c25c43 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts @@ -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} from '@angular/router'; +import {Router, ActivatedRoute, ParamMap} 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'; @@ -20,7 +20,7 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { validSearchTypes = ['lineitems', 'purchaseorders', 'invoices', 'selectionlists']; defaultSearchType = 'lineitems'; - searchTerms: AcqSearchTerm[] = []; + urlSearchTerms: AcqSearchTerm[] = []; onTabChange: ($event: NgbTabChangeEvent) => void; @ViewChild('acqSearchTabs', { static: true }) tabs: NgbTabset; @@ -34,7 +34,32 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { private route: ActivatedRoute, private pcrud: PcrudService, private idl: IdlService, - ) {} + ) { + this.route.queryParamMap.subscribe((params: ParamMap) => { + const fields = params.getAll('f'); + const ops = params.getAll('op'); + const values1 = params.getAll('val1'); + const values2 = params.getAll('val2'); + fields.forEach((f, idx) => { + const term: AcqSearchTerm = { + field: f, + op: '', + value1: '', + value2: '' + }; + if (idx < ops.length) { + term.op = ops[idx]; + } + if (idx < values1.length) { + term.value1 = values1[idx]; + } + if (idx < values2.length) { + term.value2 = values2[idx]; + } + this.urlSearchTerms.push(term); + }); + }); + } ngOnInit() { const self = this; @@ -53,6 +78,7 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { this.onTabChange = ($event) => { if (this.validSearchTypes.includes($event.nextId)) { this.searchType = $event.nextId; + this.urlSearchTerms = []; this.router.navigate(['/staff', 'acq', 'search', $event.nextId]); } }; diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html index cb15329a8b..0f778bc50d 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html @@ -1,4 +1,4 @@ - + + Purchase Order
  • Requests
  • -
  • Invoices TODO; awaits Angular invoice search
  • +
  • + Invoices
  • Queue
  • diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts index 1a611968ae..1518f9b29d 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, Input, ViewChild} from '@angular/core'; import {Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; @@ -18,6 +18,8 @@ import {AcqSearchFormComponent} from './acq-search-form.component'; }) export class LineitemResultsComponent implements OnInit { + @Input() initialSearchTerms: AcqSearchTerm[] = []; + gridSource: GridDataSource; @ViewChild('acqSearchLineitemsGrid', { static: true }) lineitemResultsGrid: GridComponent; diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html index 4d9cdc9105..c66fbfd6f1 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.html @@ -1,4 +1,4 @@ - + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts index 77454864e7..606eff8df8 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, Input, ViewChild} from '@angular/core'; import {Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; @@ -25,6 +25,8 @@ import {AcqSearchFormComponent} from './acq-search-form.component'; }) export class PicklistResultsComponent implements OnInit { + @Input() initialSearchTerms: AcqSearchTerm[] = []; + gridSource: GridDataSource; @ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent; @ViewChild('picklistCreateDialog', { static: true }) picklistCreateDialog: PicklistCreateDialogComponent; diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html index 4ceda8a4ff..b9e83a525d 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/purchase-order-results.component.html @@ -1,4 +1,4 @@ - +