Commit 8d67c38a authored by Alex ORLUC's avatar Alex ORLUC

FEAT #11902 TIME 2 front reconcile action

parent a2cc0fbf
......@@ -909,9 +909,9 @@ export class ActionsService {
data: this.setDatasActionToSend()
});
dialogRef.afterClosed().pipe(
/* tap((resIds: any) => {
this.unlockResourceAfterActionModal(resIds);
}),*/
tap(() => {
this.stopRefreshResourceLock();
}),
filter((resIds: any) => !this.functions.empty(resIds)),
tap((resIds: any) => {
this.endAction(resIds);
......
......@@ -13,35 +13,37 @@
<b *ngIf="data.resIds.length === 1" color="primary" class="highlight">{{data.resource.chrono}}</b>
<b *ngIf="data.resIds.length > 1" color="primary" class="highlight">{{data.resIds.length}}
{{lang.elements}}</b> ?
<div class="alert-message alert-message-info" role="alert" style="margin-top: 30px;max-width: 100%;"
[innerHTML]="lang.reconcileMsg">
</div>
<div class="alert-message alert-message-info" role="alert" style="margin-top: 30px;max-width: 100%;"
[innerHTML]="lang.selectMailToReconcile + ' : '">
</div>
<div class="col-md-12">
<div *ngIf="resourcesErrors.length > 0" class="alert-message alert-message-danger mailList"
style="max-width: 100%;">
<p>
{{lang.canNotMakeAction}} :
</p>
<ul>
<li *ngFor="let ressource of resourcesErrors">
<b>{{ressource.alt_identifier}}</b> : {{lang[ressource.reason]}}
</li>
</ul>
</div>
</div>
<div *ngIf="resourcesErrors.length > 0" class="alert-message alert-message-danger mailList"
role="alert">
<p>
{{lang.canNotMakeAction}} :
</p>
<ul>
<li *ngFor="let ressource of resourcesErrors">
<b>{{ressource.alt_identifier}}</b> : {{lang[ressource.reason]}}
</li>
</ul>
<div *ngIf="!noResourceToProcess" class="col-md-12">
<div class="alert-message alert-message-info" role="alert" style="max-width: 100%;"
[innerHTML]="data.resIds.length === 1 ? lang.reconcileMsg : lang.reconcileMsg + '<br/>' + lang.reconcileMsg2">
</div>
</div>
<div class="col-md-12">
<div *ngIf="!noResourceToProcess" class="col-md-12">
<app-criteria-tool (searchUrlGenerated)="launchSearch($event)"
[defaultCriteria]="['resourceField','contactField']"></app-criteria-tool>
<search-adv-list #appSearchAdvList [singleMode]="true"></search-adv-list>
<search-adv-list #appSearchAdvList [singleMode]="true" [excludeRes]="data.resIds"></search-adv-list>
</div>
</ng-container>
</div>
</div>
<span class="divider-modal"></span>
<div mat-dialog-actions class="actions">
<button mat-raised-button mat-button color="primary" [disabled]="loading || (appSearchAdvList !== undefined && appSearchAdvList.getSelectedRessources().length === 0)"
<button mat-raised-button mat-button color="primary"
[disabled]="loading || (appSearchAdvList !== undefined && appSearchAdvList.getSelectedRessources().length === 0) || noResourceToProcess"
(click)="onSubmit()">{{lang.validate}}</button>
<button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{lang.cancel}}</button>
</div>
......
......@@ -24,6 +24,7 @@ export class ReconcileActionComponent implements OnInit {
searchUrl: string = '';
resourcesErrors: any[] = [];
selectedRes: number[] = [];
noResourceToProcess: boolean = false;
constructor(
public http: HttpClient,
......@@ -47,16 +48,17 @@ export class ReconcileActionComponent implements OnInit {
this.resourcesErrors = [];
return new Promise((resolve, reject) => {
this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkReconcile', { resources: this.data.resIds })
this.http.post('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkReconcile', { resources: this.data.resIds, })
.subscribe((data: any) => {
if(!this.functions.empty(data.resourcesInformations.error)) {
this.resourcesErrors = data.resourcesInformations.error;
}
if (data.resourcesInformations.success) {
data.resourcesInformations.success.forEach((value: any) => {
this.selectedRes.push(value);
this.selectedRes.push(value.res_id);
});
}
this.noResourceToProcess = this.resourcesErrors.length === this.data.resIds.length;
resolve(true);
}, (err: any) => {
this.notify.handleSoftErrors(err);
......@@ -66,18 +68,21 @@ export class ReconcileActionComponent implements OnInit {
}
executeAction() {
console.log(this.appSearchAdvList.getSelectedRessources());
/*this.http.put(this.data.processActionRoute, { resources: this.selectedRes }).pipe(
tap(() => {
this.dialogRef.close(this.selectedRes);
this.http.put(this.data.processActionRoute, { resources: this.selectedRes, data: {resId : this.appSearchAdvList.getSelectedRessources()[0]} }).pipe(
tap((data: any) => {
if (data !== null && !this.functions.empty(data.errors)) {
this.notify.error(data.errors);
} else {
this.dialogRef.close(this.selectedRes);
}
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();*/
).subscribe();
}
launchSearch(value: any) {
......
......@@ -26,7 +26,7 @@
</mat-header-cell>
<mat-cell *matCellDef="let row" style="width: 70px;flex: initial;">
<mat-checkbox color="primary" [checked]="this.selectedRes.indexOf(row.resId) !== -1" (change)="toggleRes($event,row)"
(click)="$event.stopPropagation();" [disabled]="row.resId == currentResId">
(click)="$event.stopPropagation();" [disabled]="excludeRes.indexOf(row.resId) > -1">
</mat-checkbox>
</mat-cell>
</ng-container>
......
......@@ -38,8 +38,10 @@ export class SearchAdvListComponent implements OnInit {
searchResource = new FormControl();
@Input('search') search: string = '';
@Input('currentResId') currentResId: number;
@Input('singleMode') singleMode: boolean = false;
@Input('excludeRes') excludeRes: number[] = [];
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ViewChild('tableResourceListSort', { static: true }) sort: MatSort;
......@@ -134,11 +136,11 @@ export class SearchAdvListComponent implements OnInit {
this.selectedRes = [];
if (e.checked) {
this.data.forEach((element: any) => {
if (element['resId'] != this.currentResId) {
if (this.excludeRes.indexOf(element['resId']) === -1) {
element['checked'] = true;
}
});
let selectResEnabled = this.allResInSearch.filter(elem => elem != this.currentResId)
let selectResEnabled = this.allResInSearch.filter(elem => this.excludeRes.indexOf(elem) === -1)
this.selectedRes = JSON.parse(JSON.stringify(selectResEnabled));
} else {
this.data.forEach((element: any) => {
......
......@@ -9,7 +9,7 @@
<mat-dialog-content>
<app-criteria-tool (searchUrlGenerated)="launchSearch($event)"
[defaultCriteria]="['resourceField','contactField']"></app-criteria-tool>
<search-adv-list #appSearchAdvList [currentResId]="data.resId"></search-adv-list>
<search-adv-list #appSearchAdvList [excludeRes]="[data.resId]"></search-adv-list>
</mat-dialog-content>
<span class="divider-modal"></span>
<div mat-dialog-actions class="actions">
......
......@@ -1623,5 +1623,6 @@ export const LANG_EN = {
"actionsHistory" : "Actions history",
"noActionProcessed": "No action processed",
"reconcileMsg": "The mails will be converted into <b>signed version</b> and linked to selected new mail.",
"reconcileMsg2": "If an <b>outgoing mail</b> is selected, only the <b>last mail</b> will be converted into signed version. The others will be <b>removed</b> !",
"selectMailToReconcile": "Please, select a mail to reconcile",
};
......@@ -1662,5 +1662,6 @@ export const LANG_FR = {
"actionsHistory" : "Historique des actions",
"noActionProcessed": "Aucune action effectuée",
"reconcileMsg": "Les courriers seront convertis en tant que <b>version signée</b> et liés au courrier qui sera sélectionnée.",
"reconcileMsg2": "Si vous sélectionnez un <b>courrier départ</b>, seul le <b>dernier courrier</b> sera converti en tant de version signée. Les autres seront <b>supprimés</b> !",
"selectMailToReconcile": "Veuillez sélectionner le courrier cible de la reconciliation",
};
......@@ -1648,5 +1648,6 @@ export const LANG_NL = {
"actionsHistory" : "Actions history", //_TO_TRANSLATE
"noActionProcessed": "No action processed", //_TO_TRANSLATE
"reconcileMsg": "The mails will be converted into <b>signed version</b> and linked to selected new mail.", //_TO_TRANSLATE
"reconcileMsg2": "If an <b>outgoing mail</b> is selected, only the <b>last mail</b> will be converted into signed version. The others will be <b>removed</b> !", //_TO_TRANSLATE
"selectMailToReconcile": "Please, select a mail to reconcile", //_TO_TRANSLATE
};
Markdown is supported
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