<div class="ml-auto mr-3"><a i18n href="/eg/staff/acq/legacy/search/unified">Legacy Search Interface</a></div>
</div>
<div class="row">
+ <div class="col-lg-3">
+ <select class="form-control" id="selected-search-term" [ngModelOptions]="{standalone: true}" [(ngModel)]="selectedSearchTerm">
+ <option disabled="disabled" i18n>Select Search Field</option>
+ <optgroup *ngFor="let g of hints" label="{{availableSearchTerms[g]['__label']}}">
+ <option *ngFor="let o of availableSearchTerms[g]['__fields']" value="{{g}}:{{o}}">
+ {{availableSearchTerms[g][o].label}}
+ </option>
+ </optgroup>
+ </select>
+ </div>
+ <div class="col-lg-3">
+ <select class="form-control" id="selected-search-op" [ngModelOptions]="{standalone: true}" [(ngModel)]="selectedSearchOp">
+ <option i18n value="">is</option>
+ <option i18n value="__not">is NOT</option>
+ <option i18n value="__fuzzy" [disabled]="searchTermDatatypes[selectedSearchTerm] != 'text'">contains</option>
+ <option i18n value="__not,__fuzzy" [disabled]="searchTermDatatypes[selectedSearchTerm] != 'text'">does NOT contain</option>
+ <option i18n value="__lte" [disabled]="searchTermDatatypes[selectedSearchTerm] != 'timestamp'">is on or BEFORE</option>
+ <option i18n value="__gte" [disabled]="searchTermDatatypes[selectedSearchTerm] != 'timestamp'">is on or AFTER</option>
+ <option i18n value="__in">matches a term from a file</option>
+ </select>
+ </div>
+ <div class="col-lg-3">
+ </div>
+</div>
+<div class="row">
+ <div class="col-lg-2">
+ <button class="form-control" i18n>Add Search Term</button>
+ </div>
+</div>
+<div class="row">
+</div>
+<div class="row">
<div class="col-lg-12">
<ngb-tabset #acqSearchTabs [activeId]="searchType" (tabChange)="onTabChange($event)" type="pills">
<ngb-tab title="Line Items Search" i18n-title id="lineitems">
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';
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';
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) {
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() {}