<div class="col-lg-2">
<button class="form-control btn btn-success" (click)="submitSearch()" type="submit" i18n>Search</button>
</div>
- <div class="col-lg-7"></div>
+ <div class="col-lg-5"></div>
+ <div class="col-lg-2">
+ <input class="form-check-input" type="checkbox" id="retrieve-immediately"
+ (change)="saveRunImmediately()"
+ [ngModelOptions]="{standalone: true}" [(ngModel)]="runImmediately"/>
+ <label for="retrieve-immediately" class="form-check-label" i18n>Retrieve Results Immediately</label>
+ </div>
<div class="col-lg-3">
<button class="form-control btn btn-primary" (click)="saveSearchAsDefault()" type="button" i18n>Set As Default {{searchTypeLabel}} Search</button>
</div>
@Input() initialSearchTerms: AcqSearchTerm[] = [];
@Input() defaultSearchSetting = '';
+ @Input() runImmediatelySetting = '';
@Input() searchTypeLabel = '';
@Output() searchSubmitted = new EventEmitter<AcqSearch>();
validSearchTypes = ['lineitems', 'purchaseorders', 'invoices', 'selectionlists'];
defaultSearchType = 'lineitems';
searchConjunction = 'all';
+ runImmediately = false;
searchTerms: AcqSearchTerm[] = [];
ngOnInit() {
const self = this;
- this.hints.forEach(
- function(hint) {
- const 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;
- if (field.datatype === 'link') {
- self.searchFieldLinkedClasses[hint + ':' + field.name] = field.class;
+ this.store.getItem(this.runImmediatelySetting).then(val => {
+ this.runImmediately = val
+
+ this.hints.forEach(
+ function(hint) {
+ const 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;
+ if (field.datatype === 'link') {
+ self.searchFieldLinkedClasses[hint + ':' + field.name] = field.class;
+ }
}
}
+ );
+ self.availableSearchFields[hint] = o;
+ }
+ );
+
+ this.hints.push('acqlia');
+ this.availableSearchFields['acqlia'] = {'__label': this.idl.classes.acqlia.label, '__fields': []};
+ this.pcrud.retrieveAll('acqliad', {'order_by': {'acqliad': 'id'}})
+ .subscribe(liad => {
+ this.availableSearchFields['acqlia']['__fields'].push('' + liad.id());
+ this.availableSearchFields['acqlia'][liad.id()] = {
+ label: liad.description(),
+ datatype: 'text'
+ };
+ this.searchTermDatatypes['acqlia:' + liad.id()] = 'text';
+ });
+
+ if (this.initialSearchTerms.length > 0) {
+ this.searchTerms = JSON.parse(JSON.stringify(this.initialSearchTerms)); // deep copy
+ this.submitSearch(); // if we've been passed an initial search, e.g., via a URL, assume
+ // we want the results immediately regardless of the workstation
+ // setting
+ } else {
+ this.store.getItem(this.defaultSearchSetting).then(
+ defaultSearch => {
+ if (defaultSearch) {
+ this.searchTerms = JSON.parse(JSON.stringify(defaultSearch.terms));
+ this.searchConjunction = defaultSearch.conjunction;
+ } else {
+ this.addSearchTerm();
+ }
+ if (this.runImmediately) {
+ this.submitSearch();
+ }
}
);
- self.availableSearchFields[hint] = o;
}
- );
-
- this.hints.push('acqlia');
- this.availableSearchFields['acqlia'] = {'__label': this.idl.classes.acqlia.label, '__fields': []};
- this.pcrud.retrieveAll('acqliad', {'order_by': {'acqliad': 'id'}})
- .subscribe(liad => {
- this.availableSearchFields['acqlia']['__fields'].push('' + liad.id());
- this.availableSearchFields['acqlia'][liad.id()] = {
- label: liad.description(),
- datatype: 'text'
- };
- this.searchTermDatatypes['acqlia:' + liad.id()] = 'text';
});
-
- if (this.initialSearchTerms.length > 0) {
- this.searchTerms = JSON.parse(JSON.stringify(this.initialSearchTerms)); // deep copy
- this.submitSearch();
- } else {
- this.store.getItem(this.defaultSearchSetting).then(
- defaultSearch => {
- if (defaultSearch) {
- this.searchTerms = JSON.parse(JSON.stringify(defaultSearch.terms));
- this.searchConjunction = defaultSearch.conjunction;
- this.submitSearch();
- } else {
- this.addSearchTerm();
- }
- }
- );
- }
}
ngAfterViewInit() {}
}
submitSearch() {
- this.searchSubmitted.emit({
- terms: this.searchTerms,
- conjunction: this.searchConjunction
+ // tossing setTimeout here to ensure that the
+ // grid data source is fully initialized
+ setTimeout(() => {
+ this.searchSubmitted.emit({
+ terms: this.searchTerms,
+ conjunction: this.searchConjunction
+ });
});
}
conjunction: this.searchConjunction
});
}
+ saveRunImmediately() {
+ return this.store.setItem(this.runImmediatelySetting, this.runImmediately);
+ }
}
import {Injectable} from '@angular/core';
+import {empty} from 'rxjs';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
import {GridDataSource} from '@eg/share/grid/grid';
_terms: AcqSearchTerm[] = [];
_conjunction = 'all';
attrDefs: {[code: string]: IdlObject};
+ firstRun = true;
constructor(
private net: NetService,
private pcrud: PcrudService
) {
this.attrDefs = {};
+ this.firstRun = true;
}
fetchAttrDefs(): Promise<void> {
setSearch(search: AcqSearch) {
this._terms = search.terms;
this._conjunction = search.conjunction;
+ this.firstRun = false;
}
generateAcqSearch(searchType, filters): any {
this.fetchAttrDefs().then(() => {
gridSource.getRows = (pager: Pager) => {
+ // don't do a search the very first time we
+ // get invoked, which is during initialization; we'll
+ // let components higher up the change decide whether
+ // to submit a search
+ if (this.firstRun) {
+ this.firstRun = false;
+ return empty();
+ }
+
const currentSearch = this.generateAcqSearch(searchType, gridSource.filters);
const opts = { ...searchOptions[searchType] };
<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"
- i18n-searchTypeLabel searchTypeLabel="Invoice" defaultSearchSetting="eg.acq.search.default.invoices"></eg-acq-search-form>
+ i18n-searchTypeLabel searchTypeLabel="Invoice" runImmediatelySetting="eg.acq.search.invoices.run_immediately"
+ defaultSearchSetting="eg.acq.search.default.invoices"></eg-acq-search-form>
<ng-template #inv_identTmpl let-invoice="row">
<a href="/eg/staff/acq/legacy/invoice/view/{{invoice.id()}}"
<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"
- i18n-searchTypeLabel searchTypeLabel="Line Item" defaultSearchSetting="eg.acq.search.default.lineitems"></eg-acq-search-form>
+ i18n-searchTypeLabel searchTypeLabel="Line Item" runImmediatelySetting="eg.acq.search.lineitems.run_immediately"
+ defaultSearchSetting="eg.acq.search.default.lineitems"></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()}}"
<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"
- i18n-searchTypeLabel searchTypeLabel="Selection List" defaultSearchSetting="eg.acq.search.default.selectionlists"></eg-acq-search-form>
+ i18n-searchTypeLabel searchTypeLabel="Selection List" runImmediatelySetting="eg.acq.search.selectionlists.run_immediately"
+ defaultSearchSetting="eg.acq.search.default.selectionlists"></eg-acq-search-form>
<eg-string #createSelectionListString i18n-text text="Selection List Created">
</eg-string>
<eg-acq-search-form (searchSubmitted)="doSearch($event)" [initialSearchTerms]="initialSearchTerms"
- i18n-searchTypeLabel searchTypeLabel="Purchase Order" defaultSearchSetting="eg.acq.search.default.purchaseorders"></eg-acq-search-form>
+ i18n-searchTypeLabel searchTypeLabel="Purchase Order" runImmediatelySetting="eg.acq.search.purchaseorders.run_immediately"
+ defaultSearchSetting="eg.acq.search.default.purchaseorders"></eg-acq-search-form>
<ng-template #nameTmpl let-purchaseorder="row">
<a href="/eg/staff/acq/legacy/po/view/{{purchaseorder.id()}}"
'Acquisitions Default Search: Selection Lists',
'cwst', 'label')
);
+
+INSERT INTO config.workstation_setting_type
+ (name, grp, datatype, label)
+VALUES (
+ 'eg.acq.search.lineitems.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.lineitems.run_immediately',
+ 'Acquisitions Search: Immediately Search Lineitems',
+ 'cwst', 'label')
+), (
+ 'eg.acq.search.purchaseorders.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.purchaseorders.run_immediately',
+ 'Acquisitions Search: Immediately Search Purchase Orders',
+ 'cwst', 'label')
+), (
+ 'eg.acq.search.invoices.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.invoices.run_immediately',
+ 'Acquisitions Search: Immediately Search Invoices',
+ 'cwst', 'label')
+), (
+ 'eg.acq.search.selectionlists.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.selectionlists.run_immediately',
+ 'Acquisitions Search: Immediately Search Selection Lists',
+ 'cwst', 'label')
+);
--- /dev/null
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.workstation_setting_type
+ (name, grp, datatype, label)
+VALUES (
+ 'eg.acq.search.lineitems.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.lineitems.run_immediately',
+ 'Acquisitions Search: Immediately Search Lineitems',
+ 'cwst', 'label')
+), (
+ 'eg.acq.search.purchaseorders.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.purchaseorders.run_immediately',
+ 'Acquisitions Search: Immediately Search Purchase Orders',
+ 'cwst', 'label')
+), (
+ 'eg.acq.search.invoices.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.invoices.run_immediately',
+ 'Acquisitions Search: Immediately Search Invoices',
+ 'cwst', 'label')
+), (
+ 'eg.acq.search.selectionlists.run_immediately', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.acq.search.selectionlists.run_immediately',
+ 'Acquisitions Search: Immediately Search Selection Lists',
+ 'cwst', 'label')
+);
+
+COMMIT;