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

FIX #11271 TIME 1:20 add load actions list

parent e27cbd4f
No related branches found
No related tags found
No related merge requests found
......@@ -30,23 +30,27 @@
[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;">
<span class="menu-label">
Enregistrer (par défaut)
</span>
<i class="fa fa-chevron-down menu-icon"></i></button>
<mat-menu #menu="matMenu" [class]="'menuForm'">
<button mat-menu-item>Action 2</button>
<button mat-menu-item>Action 3</button>
</mat-menu>
<button mat-button *ngIf="!appService.getViewMode()" class="button-form-primary"
style="width: 150px;align-items: center;justify-content: center;text-align: center;display: flex;"
(click)="onSubmit()">{{lang.validate}}</button>
<button mat-icon-button *ngIf="appService.getViewMode()" class="button-form-primary"
(click)="onSubmit()">
<mat-icon class="fa fa-check"></mat-icon>
</button>
<ng-container *ngIf="actionsList.length > 0">
<button mat-button class="button-form-primary" [matMenuTriggerFor]="menu"
style="flex:1;margin-right:20px;">
<span class="menu-label" [innerHTML]="selectedAction.label">
</span>
<i class="fa fa-chevron-down menu-icon"></i></button>
<mat-menu #menu="matMenu" [class]="'menuForm'">
<ng-container *ngFor="let action of actionsList">
<button mat-menu-item *ngIf="action.id !== selectedAction.id" (click)="selectAction(action)"
[innerHTML]="action.label"></button>
</ng-container>
</mat-menu>
<button mat-button *ngIf="!appService.getViewMode()" class="button-form-primary"
style="width: 150px;align-items: center;justify-content: center;text-align: center;display: flex;"
(click)="onSubmit()">{{lang.validate}}</button>
<button mat-icon-button *ngIf="appService.getViewMode()" class="button-form-primary"
(click)="onSubmit()">
<mat-icon class="fa fa-check"></mat-icon>
</button>
</ng-container>
<div class="emptyAction" *ngIf="actionsList.length === 0" [innerHTML]="lang.noAvaiblableAction"></div>
</div>
</ng-container>
<div *ngIf="indexingModels.length === 0" class="emptyModel" [innerHTML]="lang.noAvailableIndexingModel"></div>
......
......@@ -98,4 +98,11 @@
padding-left: 0px;
padding-right: 0px;
}
}
.emptyAction {
color: $warn;
font-size: 14px;
text-align: center;
// opacity: 0.3;
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import { FiltersListService } from '../../service/filtersList.service';
import { Overlay } from '@angular/cdk/overlay';
import { AppService } from '../../service/app.service';
import { IndexingFormComponent } from './indexing-form/indexing-form.component';
import { tap, finalize, catchError } from 'rxjs/operators';
import { tap, finalize, catchError, map } from 'rxjs/operators';
import { of } from 'rxjs';
@Component({
......@@ -40,6 +40,9 @@ export class IndexationComponent implements OnInit {
currentIndexingModel: any = {};
currentGroupId: number;
actionsList: any[] = [];
selectedAction: any = {};
constructor(
private route: ActivatedRoute,
public http: HttpClient,
......@@ -67,7 +70,29 @@ export class IndexationComponent implements OnInit {
setTimeout(() => {
this.sidenavLeft.open();
}, 400);
}
}
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
this.http.get("../../rest/indexing/" + this.currentGroupId + "/actions").pipe(
map((data: any) => {
data.actions = data.actions.map((action: any, index: number) => {
return {
id : action.id,
label : index === 0 ? action.label_action + '&nbsp;<b>(' + this.lang.default + ')</b>' : action.label_action,
component : action.component,
default : index === 0 ? true : false
}
});
return data;
}),
tap((data: any) => {
this.selectedAction = data.actions[0];
this.actionsList = data.actions;
}),
finalize(() => this.loading = false),
catchError((err: any) => {
......@@ -76,20 +101,26 @@ export class IndexationComponent implements OnInit {
})
).subscribe();
},
(err: any) => {
this.notify.handleErrors(err);
});
(err: any) => {
this.notify.handleErrors(err);
});
}
onSubmit() {
if (this.indexingForm.isValidForm()) {
alert('Form OK !');
alert(this.selectedAction.component + '() déclenchée');
} else {
alert('Veuillez corriger les erreurs.');
}
}
loadIndexingModel(indexingModel: any) {
this.currentIndexingModel = indexingModel;
this.indexingForm.loadForm(indexingModel.id);
}
selectAction(action: any) {
this.selectedAction = action;
}
}
\ No newline at end of file
......@@ -1129,4 +1129,5 @@ export const LANG_EN = {
"fieldNotExist" : "Field not exist",
"saveAsModel" : "Save as Model",
"noAvailableIndexingModel" : "No indexing model found<br /><br /><small>Please create a model in Administation > Indexing model</small>",
"noAvaiblableAction" : "<b>No available action</b>, please set an action in <b>Administration > User groups > Mail indexing</b>.",
};
......@@ -1166,4 +1166,5 @@ export const LANG_FR = {
"fieldNotExist" : "Le champ n'existe pas",
"saveAsModel" : "Enregistrer comme modèle",
"noAvailableIndexingModel" : "Aucun modèle d'enregistrement disponible<br /><br /><small>Veuillez créer un modèle depuis Administation > Modèle d'enregistrement</small>",
"noAvaiblableAction" : "<b>Aucune action disponible</b>, veuillez paramétrer une action dans <b>Administration > Groupes d'utilisateur > Enregistrement de courrier</b>.",
};
......@@ -1155,4 +1155,5 @@ export const LANG_NL = {
"fieldNotExist" : "Field not exist", //_TO_TRANSLATE
"saveAsModel" : "Save as Model", //_TO_TRANSLATE
"noAvailableIndexingModel" : "No indexing model found<br /><br /><small>Please create a model in Administation > Indexing model</small>", //_TO_TRANSLATE
"noAvaiblableAction" : "<b>No available action</b>, please set an action in <b>Administration > User groups > Mail indexing</b>.", //_TO_TRANSLATE
};
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