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

FEAT #11271 TIME 1 add entities tree select input in indexing form

parent d7de663a
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ import { IndexationComponent } from './indexation/indexation.compon
{ path: 'saveNumericPackage', canActivate: [AppGuard], component: SaveNumericPackageComponent },
{ path: 'separators/print', canActivate: [AppGuard], component: PrintSeparatorComponent },
{ path: 'signatureBook/users/:userId/groups/:groupId/baskets/:basketId/resources/:resId', canActivate: [AppGuard],component: SignatureBookComponent },
{ path: 'indexing/:group', canActivate: [AppGuard],component: IndexationComponent },
{ path: 'indexing/:groupId', canActivate: [AppGuard],component: IndexationComponent },
{ path: '**', redirectTo: 'home', pathMatch: 'full' },
], { useHash: true }),
],
......
......@@ -19,7 +19,7 @@
comme modèle</button>
</div>
<div class="indexing-form-container">
<app-indexing-form *ngIf="currentIndexingModel.id !== undefined" #indexingForm [indexingFormId]="currentIndexingModel.id"></app-indexing-form>
<app-indexing-form *ngIf="currentIndexingModel.id !== undefined" #indexingForm [groupId]="currentGroupId" [indexingFormId]="currentIndexingModel.id"></app-indexing-form>
</div>
<div class="actions-indexing-form">
<button mat-button class="button-form-primary" [matMenuTriggerFor]="menu" style="flex:1;margin-right:20px;">
......
......@@ -38,6 +38,7 @@ export class IndexationComponent implements OnInit {
indexingModels: any[] = [];
currentIndexingModel: any = {};
currentGroupId: number;
constructor(
private route: ActivatedRoute,
......@@ -56,6 +57,7 @@ export class IndexationComponent implements OnInit {
this.headerService.setHeader("Enregistrement d'un courrier");
this.route.params.subscribe(params => {
this.currentGroupId = params['groupId'];
this.http.get("../../rest/indexingModels").pipe(
tap((data: any) => {
//
......
......@@ -59,8 +59,7 @@
<mat-select [formControl]="arrFormControl[field.identifier]"
[placeholder]="field.system ? lang[field.type + 'Input'] : lang.defaultValue">
<mat-option *ngIf="adminMode"></mat-option>
<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 *ngFor="let value of field.values" [value]="value.id" [title]="value.title !== undefined ? value.title : value.label" [disabled]="value.disabled" [class.opt-group]="value.isTitle" [style.color]="value.color" [innerHTML]="value.label">
</mat-option>
</mat-select>
</mat-form-field>
......
......@@ -25,6 +25,7 @@ export class IndexingFormComponent implements OnInit {
loading: boolean = true;
@Input('indexingFormId') indexingFormId: number;
@Input('groupId') groupId: number;
@Input('admin') adminMode: boolean;
fieldCategories: any[] = ['mail', 'contact', 'process', 'classement'];
......@@ -291,16 +292,60 @@ export class IndexingFormComponent implements OnInit {
elem.endDate = '_TODAY';
} else
if (elem.identifier === 'destination') {
elem.values = [
{
label : 'test',
id: 1
},
{
label : 'plus',
id: 2
}
];
if (this.adminMode) {
this.http.get("../../rest/indexing/entities").pipe(
tap((data: any) => {
let title = '';
elem.values = data.entities.map((entity: any) => {
title = entity.entity_label;
for (let index = 0; index < entity.level; index++) {
entity.entity_label = '&nbsp;&nbsp;&nbsp;&nbsp;' + entity.entity_label;
}
return {
id: entity.id,
title: title,
label: entity.entity_label,
disabled: false
}
});
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
} else {
this.http.get("../../rest/indexing/" + this.groupId + "/entities").pipe(
tap((data: any) => {
let title = '';
let defaultVal = data.entities.filter((entity: any) => entity.enabled === true && entity.id === elem.default_value);
elem.default_value = defaultVal.length > 0 ? defaultVal[0].id : '';
this.arrFormControl[elem.identifier].setValue(defaultVal.length > 0 ? defaultVal[0].id : '');
elem.values = data.entities.map((entity: any) => {
title = entity.entity_label;
for (let index = 0; index < entity.level; index++) {
entity.entity_label = '&nbsp;&nbsp;&nbsp;&nbsp;' + entity.entity_label;
}
return {
id: entity.id,
title: title,
label: entity.entity_label,
disabled: !entity.enabled
}
});
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
} else
if (elem.identifier === 'arrivalDate') {
elem.startDate = 'docDate';
......@@ -351,6 +396,7 @@ export class IndexingFormComponent implements OnInit {
arrValues.push({
id: doctype.doctypes_first_level_id,
label: doctype.doctypes_first_level_label,
disabled: true,
isTitle: true,
color: doctype.css_style
});
......@@ -358,6 +404,7 @@ export class IndexingFormComponent implements OnInit {
arrValues.push({
id: doctype.doctypes_second_level_id,
label: doctype.doctypes_second_level_label,
disabled: true,
isTitle: true,
color: doctype.css_style
});
......@@ -366,7 +413,8 @@ export class IndexingFormComponent implements OnInit {
return {
id: info.type_id,
label: info.description,
isTitle: false
disabled: false,
isTitle: false,
}
}));
}
......
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