Commit 45ad0717 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Merge branch '38-list-search-type-integration' into 'develop'

Resolve "List search-type integration"

Closes #38

See merge request !25
parents f229f279 e3a9af86
Pipeline #2925 passed with stages
in 7 minutes and 42 seconds
......@@ -19,14 +19,15 @@
</select>
</td>
<td>
<select *ngIf="criteriaForm.controls.search_type.value
&& criteriaForm.controls.search_type.value != 'between'
&& criteriaForm.controls.search_type.value != 'between-date'
&& criteriaForm.controls.search_type.value != 'json'"
class="form-control" name="operator" (change)="operatorOnChange($event.target.value)"
[formControl]="criteriaForm.controls.operator">
<select *ngIf="criteriaForm.controls.search_type.value && criteriaForm.controls.search_type.value != 'between'
&& criteriaForm.controls.search_type.value != 'between-date' && criteriaForm.controls.search_type.value != 'json'
&& criteriaForm.controls.search_type.value != 'list'"
class="form-control"
name="operator"
[formControl]="criteriaForm.controls.operator"
(change)="operatorOnChange($event.target.value)">
<option></option>
<option *ngFor="let operator of operatorList" [value]="operator.value">{{operator.label}}</option>
<option *ngFor="let operator of operatorList" [value]="operator.value">{{ operator.label }}</option>
</select>
</td>
<td>
......@@ -48,7 +49,8 @@
|| (criteriaForm.controls.operator.value && criteriaForm.controls.search_type.value == 'time')
|| (criteriaForm.controls.operator.value && criteriaForm.controls.search_type.value == 'date-time')
|| criteriaForm.controls.search_type.value == 'between'
|| criteriaForm.controls.search_type.value == 'between-date'"
|| criteriaForm.controls.search_type.value == 'between-date'
|| criteriaForm.controls.search_type.value == 'list'"
type="text" class="form-control" name="min"
[placeholder]="getMinValuePlaceholder(criteriaForm.controls.search_type.value)"
[formControl]="criteriaForm.controls.min">
......@@ -62,7 +64,8 @@
|| (criteriaForm.controls.operator.value && criteriaForm.controls.search_type.value == 'time')
|| (criteriaForm.controls.operator.value && criteriaForm.controls.search_type.value == 'date-time')
|| criteriaForm.controls.search_type.value == 'between'
|| criteriaForm.controls.search_type.value == 'between-date'"
|| criteriaForm.controls.search_type.value == 'between-date'
|| criteriaForm.controls.search_type.value == 'list'"
type="text" class="form-control" name="placeholder_min"
[placeholder]="getMinValuePlaceholder(criteriaForm.controls.search_type.value)"
[formControl]="criteriaForm.controls.placeholder_min">
......
......@@ -41,7 +41,9 @@ export class TrCriteriaComponent {
modalRef: BsModalRef;
constructor(private modalService: BsModalService) { }
readonly searchTypesWithOperator: string[] = [
'field', 'select', 'select-multiple', 'datalist', 'radio', 'checkbox', 'date', 'time', 'date-time'
];
_attribute: Attribute;
optionList: Option[] = [];
......@@ -58,12 +60,14 @@ export class TrCriteriaComponent {
criteria_display: new FormControl()
});
generateOptionListValues(template: TemplateRef<any>) {
constructor(private modalService: BsModalService) { }
generateOptionListValues(template: TemplateRef<any>): void {
this.generateOptionList.emit(this._attribute);
this.modalRef = this.modalService.show(template);
}
confirmGeneratedOptionList() {
confirmGeneratedOptionList(): void {
let newOptionList: Option[] = [];
for (let i = 0; i < this.optionListGenerated.length; i++) {
newOptionList.push({
......@@ -76,21 +80,21 @@ export class TrCriteriaComponent {
this.modalRef.hide();
}
criteriaFamilyOnChange(id: string) {
criteriaFamilyOnChange(id: string): void {
if (id === '') {
this.criteriaForm.controls.id_criteria_family.setValue(null);
this.searchTypeOnChange('');
}
}
searchTypeOnChange(type: string) {
searchTypeOnChange(type: string): void {
if (type === '') {
this.criteriaForm.controls.search_type.setValue(null);
this.operatorOnChange('');
}
}
operatorOnChange(operator: string) {
operatorOnChange(operator: string): void {
if (operator === '') {
this.criteriaForm.controls.operator.setValue(null);
this.criteriaForm.controls.min.setValue(null);
......
......@@ -34,10 +34,14 @@
</tr>
</app-table-design>
<app-table-criteria *ngSwitchCase="'criteria'">
<tr *ngFor="let attribute of attributeList" criteria [attribute]="attribute"
<tr *ngFor="let attribute of attributeList"
criteria
[attribute]="attribute"
[optionListGenerated]="optionListGenerated"
[criteriaFamilyList]="criteriaFamilyList" [searchTypeList]="getSettingsSelectOptions('search_type')"
[operatorList]="getSettingsSelectOptions('operator')" (save)="editAttribute.emit($event)"
[criteriaFamilyList]="criteriaFamilyList"
[searchTypeList]="getSettingsSelectOptions('search_type')"
[operatorList]="getSettingsSelectOptions('operator')"
(save)="editAttribute.emit($event)"
(generateOptionList)="generateAttributeOptionList.emit($event)">
</tr>
</app-table-criteria>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment