1 |
50169
|
argiro.kok
|
import {Component, Input, Output, EventEmitter, ElementRef} from '@angular/core';
|
2 |
|
|
import {Observable} from 'rxjs/Observable';
|
3 |
|
|
import { Subject } from 'rxjs/Subject';
|
4 |
50586
|
argiro.kok
|
import {ActivatedRoute} from '@angular/router';
|
5 |
50169
|
argiro.kok
|
|
6 |
|
|
import {AdvancedField, OPERATOR} from '../searchUtils/searchHelperClasses.class';
|
7 |
|
|
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
8 |
|
|
import {Dates} from '../../utils/string-utils.class';
|
9 |
50586
|
argiro.kok
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
10 |
50169
|
argiro.kok
|
|
11 |
|
|
@Component({
|
12 |
|
|
selector: 'advanced-search-form',
|
13 |
|
|
templateUrl: 'advancedSearchForm.component.html'
|
14 |
|
|
})
|
15 |
|
|
export class AdvancedSearchFormComponent {
|
16 |
|
|
@Input() entityType;
|
17 |
|
|
@Input() fieldIds: string[];
|
18 |
|
|
@Input() fieldIdsMap;
|
19 |
|
|
@Input() selectedFields:AdvancedField[];
|
20 |
|
|
@Input() isDisabled: boolean = false;
|
21 |
53353
|
argiro.kok
|
@Input() simpleSearchLink;
|
22 |
|
|
@Input() pageTitle;
|
23 |
50169
|
argiro.kok
|
@Output() queryChange = new EventEmitter();
|
24 |
|
|
newFieldId:string;
|
25 |
|
|
newFieldName:string;
|
26 |
|
|
fieldList:{[id:string]:any[]} = {};
|
27 |
|
|
public searchFields:SearchFields = new SearchFields();
|
28 |
50586
|
argiro.kok
|
properties:EnvProperties;
|
29 |
50169
|
argiro.kok
|
public operators: [{name:string, id:string}] = this.searchFields.ADVANCED_SEARCH_OPERATORS;
|
30 |
50586
|
argiro.kok
|
constructor (private route: ActivatedRoute) {
|
31 |
50169
|
argiro.kok
|
}
|
32 |
|
|
|
33 |
|
|
ngOnInit() {
|
34 |
50586
|
argiro.kok
|
this.route.data
|
35 |
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
36 |
|
|
this.properties = data.envSpecific;
|
37 |
|
|
|
38 |
|
|
});
|
39 |
50169
|
argiro.kok
|
for(var i = 0; i < this.fieldIds.length; i++){
|
40 |
|
|
this.fieldList[this.fieldIds[i]]=[];
|
41 |
|
|
}
|
42 |
|
|
this.newFieldId = this.fieldIds[0];
|
43 |
|
|
this.newFieldName = this.fieldIdsMap[this.newFieldId].name;
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
queryChanged() {
|
47 |
|
|
this.queryChange.emit({
|
48 |
|
|
// selectedFields: this.selectedFields,
|
49 |
|
|
// selectedQuantifiers: this.selectedQuantifiers,
|
50 |
|
|
// keywords: this.keywords
|
51 |
|
|
});
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
addField() {
|
55 |
|
|
this.newFieldId = this.fieldIds[0];
|
56 |
|
|
var type = this.fieldIdsMap[this.newFieldId].type;
|
57 |
|
|
if(type == "boolean"){
|
58 |
|
|
this.selectedFields.push(new AdvancedField(this.newFieldId,this.fieldIdsMap[this.newFieldId].param, this.fieldIdsMap[this.newFieldId].name, type, "true", "and"));
|
59 |
|
|
}else{
|
60 |
|
|
this.selectedFields.push(new AdvancedField(this.newFieldId, this.fieldIdsMap[this.newFieldId].param,this.fieldIdsMap[this.newFieldId].name, type, "", "and"));
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
removeField(index: number) {
|
66 |
|
|
this.selectedFields.splice(index, 1);
|
67 |
|
|
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
fieldOperatorChanged(index: number, operatorId: string, operatorName: string) {
|
71 |
|
|
this.selectedFields[index].operatorId = operatorId;
|
72 |
|
|
this.selectedFields[index].operatorName = operatorName;
|
73 |
|
|
}
|
74 |
|
|
validateDate(index: number, value: string){
|
75 |
|
|
this.selectedFields[index].valid = Dates.isValidYear(value);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
fieldIdsChanged(index: number, fieldId:string ) {
|
79 |
|
|
console.log("Field index::"+index + " " + this.selectedFields[index].id + " function id:" +fieldId);
|
80 |
|
|
|
81 |
|
|
var id= this.fieldIds[0];
|
82 |
|
|
this.selectedFields[index].name = this.fieldIdsMap[id].name;
|
83 |
|
|
this.selectedFields[index].type = this.fieldIdsMap[id].type;
|
84 |
|
|
this.selectedFields[index].value = "";
|
85 |
|
|
this.selectedFields[index].param = this.fieldIdsMap[id].param;
|
86 |
|
|
|
87 |
|
|
var id =fieldId;//this.selectedFields[index].id;
|
88 |
|
|
this.selectedFields[index].name = this.fieldIdsMap[id].name;
|
89 |
|
|
this.selectedFields[index].type = this.fieldIdsMap[id].type;
|
90 |
|
|
this.selectedFields[index].value = "";
|
91 |
|
|
this.selectedFields[index].param = this.fieldIdsMap[id].param;
|
92 |
|
|
if(this.fieldIdsMap[id].type == "boolean"){
|
93 |
|
|
this.selectedFields[index].value = "true";
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
|
|
valueChanged($event,index:number){
|
97 |
|
|
this.selectedFields[index].value = $event.value;
|
98 |
|
|
}
|
99 |
|
|
listUpdated($event,fieldId:number){
|
100 |
|
|
this.fieldList[fieldId] = $event.value;
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
}
|