Skip to content
Snippets Groups Projects
Verified Commit 37362823 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #11271 TIME 1:30 add data cat + doctypes in indexing form

parent fa748fd7
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@
<textarea matInput [(ngModel)]="field.default_value"
[placeholder]="field.system ? lang[field.type + 'Input'] : lang.defaultValue"
matTextareaAutosize matAutosizeMinRows="1" cdkAutosizeMaxRows="6"
[disabled]="field.system"></textarea>
[disabled]="field.system && adminMode"></textarea>
</mat-form-field>
</ng-container>
<ng-container *ngIf="field.type === 'integer'">
......@@ -59,9 +59,9 @@
<mat-form-field class="input-form" floatLabel="never">
<mat-select
[placeholder]="field.system ? lang[field.type + 'Input'] : lang.defaultValue"
[(ngModel)]="field.default_value" [disabled]="field.system">
<mat-option *ngFor="let value of field.values" [value]="value">
{{value}}
[(ngModel)]="field.default_value" [disabled]="field.system && adminMode">
<mat-option *ngFor="let value of field.values" [value]="value.id" [title]="value.label" [disabled]="value.isTitle" [class.opt-group]="value.isTitle" [style.color]="value.color">
{{value.label}}
</mat-option>
</mat-select>
</mat-form-field>
......@@ -70,14 +70,14 @@
<mat-form-field class="input-form" floatLabel="never" (click)="picker.open()">
<input matInput [matDatepicker]="picker"
[placeholder]="field.system ? lang[field.type + 'Input'] : lang.defaultValue"
[(ngModel)]="field.default_value" [disabled]="field.system">
[(ngModel)]="field.default_value" [disabled]="field.system && adminMode">
<mat-datepicker-toggle matSuffix [for]="picker">
</mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</ng-container>
<ng-container *ngIf="field.type === 'radio'">
<mat-radio-group class="radio-form" color="primary" [disabled]="field.system"
<mat-radio-group class="radio-form" color="primary" [disabled]="field.system && adminMode"
[(ngModel)]="field.default_value">
<mat-radio-button *ngFor="let value of field.values" [value]="value">
{{value}}
......@@ -86,7 +86,7 @@
</ng-container>
<ng-container *ngIf="field.type === 'checkbox'">
<div class="input-form checkbox-form">
<mat-selection-list #shoes class="div-list" [disabled]="field.system"
<mat-selection-list #shoes class="div-list" [disabled]="field.system && adminMode"
[(ngModel)]="field.default_value">
<mat-list-option *ngFor="let value of field.values" [value]="value"
checkboxPosition="before">
......@@ -94,7 +94,7 @@
</mat-list-option>
</mat-selection-list>
</div>
<mat-chip-list class="checkbox-selected-list" [disabled]="field.system">
<mat-chip-list class="checkbox-selected-list" [disabled]="field.system && adminMode">
<mat-chip *ngFor="let chip of shoes.selectedOptions.selected" selected>
{{chip.value}}
</mat-chip>
......
......@@ -140,6 +140,9 @@
height: auto;
}
}
.opt-group {
font-weight: bold;
}
.button-form-primary {
background: $primary;
......
......@@ -244,6 +244,8 @@ export class IndexingFormComponent implements OnInit {
this.fieldCategories.forEach(element => {
this['indexingModels_' + element + 'Clone'] = JSON.parse(JSON.stringify(this['indexingModels_' + element]));
});
this.initElemForm();
}),
finalize(() => this.loading = false),
catchError((err: any) => {
......@@ -330,4 +332,61 @@ export class IndexingFormComponent implements OnInit {
this['indexingModels_' + element] = JSON.parse(JSON.stringify(this['indexingModels_' + element + 'Clone']));
});
}
initElemForm() {
this.fieldCategories.forEach(element => {
this['indexingModels_' + element].forEach((elem: any) => {
if (elem.identifier === 'category_id') {
this.http.get("../../rest/categories").pipe(
tap((data: any) => {
elem.values = data.categories;
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
if (elem.identifier === 'doctype') {
this.http.get("../../rest/doctypes").pipe(
tap((data: any) => {
let arrValues: any[] = [];
data.structure.forEach((doctype: any) => {
if (doctype['doctypes_second_level_id'] === undefined) {
arrValues.push({
id: doctype.doctypes_first_level_id,
label: doctype.doctypes_first_level_label,
isTitle: true,
color: doctype.css_style
});
} else if (doctype['description'] === undefined) {
arrValues.push({
id: doctype.doctypes_second_level_id,
label: doctype.doctypes_second_level_label,
isTitle: true,
color: doctype.css_style
});
arrValues = arrValues.concat(data.structure.filter((info: any) => info.doctypes_second_level_id === doctype.doctypes_second_level_id && info.description !== undefined).map((info: any) => {
return {
id: info.type_id,
label: info.description,
isTitle: false
}
}));
}
});
elem.values = arrValues;
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
});
});
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment