-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';
export class AcqSearchFormComponent implements OnInit, AfterViewInit {
+ @Input() initialSearchTerms: AcqSearchTerm[] = [];
+
@Output() searchSubmitted = new EventEmitter<AcqSearchTerm[]>();
hints = ['jub', 'acqpl', 'acqpo', 'acqinv', 'acqlid'];
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() {}
<div class="col-lg-12">
<ngb-tabset #acqSearchTabs [activeId]="searchType" (tabChange)="onTabChange($event)">
<ngb-tab title="Line Items Search" i18n-title id="lineitems">
- <ng-template ngbTabContent><eg-lineitem-results></eg-lineitem-results></ng-template>
+ <ng-template ngbTabContent><eg-lineitem-results [initialSearchTerms]="urlSearchTerms"></eg-lineitem-results></ng-template>
</ngb-tab>
<ngb-tab title="Purchase Orders Search" i18n-title id="purchaseorders">
- <ng-template ngbTabContent><eg-purchase-order-results></eg-purchase-order-results></ng-template>
+ <ng-template ngbTabContent><eg-purchase-order-results [initialSearchTerms]="urlSearchTerms"></eg-purchase-order-results></ng-template>
</ngb-tab>
<ngb-tab title="Invoices Search" i18n-title id="invoices">
- <ng-template ngbTabContent><eg-invoice-results></eg-invoice-results></ng-template>
+ <ng-template ngbTabContent><eg-invoice-results [initialSearchTerms]="urlSearchTerms"></eg-invoice-results></ng-template>
</ngb-tab>
<ngb-tab title="Selection Lists Search" i18n-title id="selectionlists">
- <ng-template ngbTabContent><eg-picklist-results></eg-picklist-results></ng-template>
+ <ng-template ngbTabContent><eg-picklist-results [initialSearchTerms]="urlSearchTerms"></eg-picklist-results></ng-template>
</ngb-tab>
</ngb-tabset>
</div>
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';
validSearchTypes = ['lineitems', 'purchaseorders', 'invoices', 'selectionlists'];
defaultSearchType = 'lineitems';
- searchTerms: AcqSearchTerm[] = [];
+ urlSearchTerms: AcqSearchTerm[] = [];
onTabChange: ($event: NgbTabChangeEvent) => void;
@ViewChild('acqSearchTabs', { static: true }) tabs: NgbTabset;
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;
this.onTabChange = ($event) => {
if (this.validSearchTypes.includes($event.nextId)) {
this.searchType = $event.nextId;
+ this.urlSearchTerms = [];
this.router.navigate(['/staff', 'acq', 'search', $event.nextId]);
}
};
-<eg-acq-search-form (searchSubmitted)="doSearch($event)"></eg-acq-search-form>
+<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"></eg-acq-search-form>
<ng-template #inv_identTmpl let-invoice="row">
<a href="/eg/staff/acq/legacy/invoice/view/{{invoice.id()}}"
-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';
})
export class InvoiceResultsComponent implements OnInit {
+ @Input() initialSearchTerms: AcqSearchTerm[] = [];
+
gridSource: GridDataSource;
@ViewChild('acqSearchInvoicesGrid', { static: true }) invoiceResultsGrid: GridComponent;
@ViewChild('printfail', { static: true }) private printfail: AlertDialogComponent;
-<eg-acq-search-form (searchSubmitted)="doSearch($event)"></eg-acq-search-form>
+<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"></eg-acq-search-form>
<ng-template #idTmpl let-lineitem="row">
<a *ngIf="lineitem.purchase_order()" href="/eg/staff/acq/legacy/po/view/{{lineitem.purchase_order()}}?focus_li={{lineitem.id()}}"
target="_blank" i18n>Purchase Order</a></li>
<li><a href="/eg/staff/acq/requests/lineitem/{{lineitem.id()}}"
target="_blank" i18n>Requests</a></li>
- <li>Invoices TODO; awaits Angular invoice search</li>
+ <li>
+ <a routerLink="/staff/acq/search/invoices" [queryParams]="{f: 'jub:id', val1: lineitem.id()}"
+ target="_blank" i18n>Invoices</a></li>
<li *ngIf="lineitem.queued_record()">
<a routerLink="/staff/cat/vandelay/queue/bib/{{lineitem.queued_record().queue()}}"
target="_blank" i18n>Queue</a></li>
-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';
})
export class LineitemResultsComponent implements OnInit {
+ @Input() initialSearchTerms: AcqSearchTerm[] = [];
+
gridSource: GridDataSource;
@ViewChild('acqSearchLineitemsGrid', { static: true }) lineitemResultsGrid: GridComponent;
-<eg-acq-search-form (searchSubmitted)="doSearch($event)"></eg-acq-search-form>
+<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"></eg-acq-search-form>
<eg-string #createSelectionListString i18n-text text="Selection List Created">
</eg-string>
-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';
})
export class PicklistResultsComponent implements OnInit {
+ @Input() initialSearchTerms: AcqSearchTerm[] = [];
+
gridSource: GridDataSource;
@ViewChild('acqSearchPicklistsGrid', { static: true }) picklistResultsGrid: GridComponent;
@ViewChild('picklistCreateDialog', { static: true }) picklistCreateDialog: PicklistCreateDialogComponent;
-<eg-acq-search-form (searchSubmitted)="doSearch($event)"></eg-acq-search-form>
+<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"></eg-acq-search-form>
<ng-template #nameTmpl let-purchaseorder="row">
<a href="/eg/staff/acq/legacy/po/view/{{purchaseorder.id()}}"
-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';
})
export class PurchaseOrderResultsComponent implements OnInit {
+ @Input() initialSearchTerms: AcqSearchTerm[] = [];
+
gridSource: GridDataSource;
@ViewChild('acqSearchPurchaseOrdersGrid', { static: true }) purchaseOrderResultsGrid: GridComponent;