From: Mike Rylander Date: Thu, 16 Jan 2020 21:57:04 +0000 (-0500) Subject: start work on search form X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=de71d66b42d59e46beedee1e84eeeb8c6c095d9b;p=working%2FEvergreen.git start work on search form - IDL-based field selector - conditional selection of search inputs Signed-off-by: Mike Rylander --- 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 d1d43eeb9e..33d6487ef4 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 @@ -5,6 +5,38 @@
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
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 9e92d5b46d..fc71497942 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 @@ -2,6 +2,8 @@ import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core'; import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {Router, ActivatedRoute} 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'; import {LineitemResultsComponent} from './lineitem-results.component'; import {PurchaseOrderResultsComponent} from './purchase-order-results.component'; import {InvoiceResultsComponent} from './invoice-results.component'; @@ -13,6 +15,12 @@ import {PicklistResultsComponent} from './picklist-results.component'; export class AcqSearchComponent implements OnInit, AfterViewInit { + selectedSearchTerm: String; + selectedSearchOp: String; + + hints = ["jub", "acqpl", "acqpo", "acqinv", "acqlid"]; + availableSearchTerms = {}; + searchTermDatatypes = {}; searchType = ''; validSearchTypes = ['lineitems', 'purchaseorders', 'invoices', 'selectionlists']; defaultSearchType = 'lineitems'; @@ -23,9 +31,15 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { constructor( private router: Router, private route: ActivatedRoute, + private pcrud: PcrudService, + private idl: IdlService, ) {} ngOnInit() { + var self = this; + this.selectedSearchTerm = ''; + this.selectedSearchOp = ''; + const searchTypeParam = this.route.snapshot.paramMap.get('searchtype'); if (searchTypeParam) { @@ -42,6 +56,39 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { this.router.navigate(['/staff', 'acq', 'search', $event.nextId]); } }; + + this.hints.forEach( + function(hint) { + var o = {}; + o['__label'] = self.idl.classes[hint].label; + o['__fields'] = []; + self.idl.classes[hint].fields.forEach( + function(field) { + if (!field.virtual) { + o['__fields'].push(field.name); + o[field.name] = { + "label": field.label, "datatype": field.datatype + }; + self.searchTermDatatypes[hint+':'+field.name] = field.datatype; + } + } + ); + self.availableSearchTerms[hint] = o; + } + ); + + this.hints.push('acqlia'); + this.availableSearchTerms['acqlia'] = {"__label": this.idl.classes.acqlia.label, "__fields": []}; + this.pcrud.retrieveAll("acqliad", {"order_by": {"acqliad": "id"}}) + .subscribe(liad => { + this.availableSearchTerms['acqlia']['__fields'].push(''+liad.id()); + this.availableSearchTerms['acqlia'][liad.id()] = { + "label": liad.description(), + "datatype": "text" + }; + this.searchTermDatatypes['acqlia:'+liad.id()] = 'text'; + }); + } ngAfterViewInit() {}