selectedSearchTerm: String;
selectedSearchOp: String;
- hints = ["jub", "acqpl", "acqpo", "acqinv", "acqlid"];
+ hints = ['jub', 'acqpl', 'acqpo', 'acqinv', 'acqlid'];
availableSearchTerms = {};
searchTermDatatypes = {};
searchType = '';
) {}
ngOnInit() {
- var self = this;
+ const self = this;
this.selectedSearchTerm = '';
this.selectedSearchOp = '';
this.hints.forEach(
function(hint) {
- var o = {};
+ const o = {};
o['__label'] = self.idl.classes[hint].label;
o['__fields'] = [];
self.idl.classes[hint].fields.forEach(
if (!field.virtual) {
o['__fields'].push(field.name);
o[field.name] = {
- "label": field.label, "datatype": field.datatype
+ label: field.label,
+ datatype: field.datatype
};
- self.searchTermDatatypes[hint+':'+field.name] = field.datatype;
+ self.searchTermDatatypes[hint + ':' + field.name] = field.datatype;
}
}
);
);
this.hints.push('acqlia');
- this.availableSearchTerms['acqlia'] = {"__label": this.idl.classes.acqlia.label, "__fields": []};
- this.pcrud.retrieveAll("acqliad", {"order_by": {"acqliad": "id"}})
+ 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']['__fields'].push('' + liad.id());
this.availableSearchTerms['acqlia'][liad.id()] = {
- "label": liad.description(),
- "datatype": "text"
+ label: liad.description(),
+ datatype: 'text'
};
- this.searchTermDatatypes['acqlia:'+liad.id()] = 'text';
+ this.searchTermDatatypes['acqlia:' + liad.id()] = 'text';
});
}
};
const operatorMap = {
- "!=": "__not",
- ">": "__gte",
- ">=": "__gte",
- "<=": "__lte",
- "<": "__lte",
- "startswith": "__starts",
- "endswith": "__ends",
- "like": "__fuzzy",
-}
+ '!=': '__not',
+ '>': '__gte',
+ '>=': '__gte',
+ '<=': '__lte',
+ '<': '__lte',
+ 'startswith': '__starts',
+ 'endswith': '__ends',
+ 'like': '__fuzzy',
+};
@Injectable()
export class AcqSearchService {
Object.keys(filters).forEach(filterField => {
filters[filterField].forEach(condition => {
const searchTerm: Object = {};
- let filterOp = "=";
- let filterVal = "";
- if (Object.keys(condition).some(x => x === "-not")) {
- filterOp = Object.keys(condition["-not"][filterField])[0];
- filterVal = condition["-not"][filterField][filterOp];
- searchTerm["__not"] = true;
+ let filterOp = '=';
+ let filterVal = '';
+ if (Object.keys(condition).some(x => x === '-not')) {
+ filterOp = Object.keys(condition['-not'][filterField])[0];
+ filterVal = condition['-not'][filterField][filterOp];
+ searchTerm['__not'] = true;
} else {
filterOp = Object.keys(condition[filterField])[0];
filterVal = condition[filterField][filterOp];
- if (filterOp === "like" && filterVal.length > 1) {
- if (filterVal[0] === "%" && filterVal[filterVal.length - 1] === "%") {
+ if (filterOp === 'like' && filterVal.length > 1) {
+ if (filterVal[0] === '%' && filterVal[filterVal.length - 1] === '%') {
filterVal = filterVal.slice(1, filterVal.length - 1);
- } else if (filterVal[filterVal.length - 1] === "%") {
+ } else if (filterVal[filterVal.length - 1] === '%') {
filterVal = filterVal.slice(0, filterVal.length - 1);
- filterOp = "startswith";
- } else if (filterVal[0] === "%") {
+ filterOp = 'startswith';
+ } else if (filterVal[0] === '%') {
filterVal = filterVal.slice(1);
- filterOp = "endswith";
+ filterOp = 'endswith';
}
}
}
}
printSelectedInvoices(rows: IdlObject[]) {
- var that = this;
- var html = "<style type='text/css'>.acq-invoice-" +
- "voucher {page-break-after:always;}" +
- "</style>\n";
+ const that = this;
+ let html = '<style type="text/css">.acq-invoice-' +
+ 'voucher {page-break-after:always;}' +
+ '</style>\n';
this.net.request(
'open-ils.acq',
'open-ils.acq.invoice.print.html',
cloneList() {
const picklist = this.idl.create('acqpl');
- picklist.owner(this.auth.user().id())
- picklist.name(this.selectionListName)
+ picklist.owner(this.auth.user().id());
+ picklist.name(this.selectionListName);
this.net.request(
'open-ils.acq',
'open-ils.acq.picklist.clone',
createList() {
const picklist = this.idl.create('acqpl');
- picklist.owner(this.auth.user().id())
- picklist.name(this.selectionListName)
+ picklist.owner(this.auth.user().id());
+ picklist.name(this.selectionListName);
this.net.request(
'open-ils.acq',
'open-ils.acq.picklist.create',
}
deleteLists() {
- var that = this;
- var observables = [];
+ const that = this;
+ const observables = [];
this.grid.context.getSelectedRows().forEach(function(r) {
observables.push( that.deleteList(r) );
});
}
mergeLists() {
- var that = this;
+ const that = this;
this.net.request(
'open-ils.acq',
'open-ils.acq.picklist.merge',
this.auth.token(), this.leadList,
- this.selectedLists.map( list => list.id() ).filter(function(p) { return p != that.leadList; })
+ this.selectedLists.map( list => list.id() ).filter(function(p) { return p !== that.leadList; })
).subscribe(
(res) => {
if (this.evt.parse(res)) {
ngOnInit() {
this.gridSource = this.acqSearch.getAcqSearchDataSource('picklist');
- this.perm.hasWorkPermHere(['CREATE_PICKLIST','UPDATE_PICKLIST','VIEW_PICKLIST']).
+ this.perm.hasWorkPermHere(['CREATE_PICKLIST', 'UPDATE_PICKLIST', 'VIEW_PICKLIST']).
then(perms => this.permissions = perms);
this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0);