From feccb070d2ea5a4e97abd4e5924d9e29aeebb920 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Mon, 16 Mar 2020 15:32:05 +0100
Subject: [PATCH] FEAT #12091 TIME 0:30 disable button immediatly after click
 on validate

---
 src/frontend/app/indexation/indexation.component.ts | 8 +++++++-
 src/frontend/app/process/process.component.ts       | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts
index c2130b84f46..1db9f30fa07 100644
--- a/src/frontend/app/indexation/indexation.component.ts
+++ b/src/frontend/app/indexation/indexation.component.ts
@@ -94,7 +94,7 @@ export class IndexationComponent implements OnInit {
         this._activatedRoute.queryParamMap.subscribe((paramMap: ParamMap) => {
             const refresh = paramMap.get('refresh');
             this.headerService.injectInSideBarLeft(this.adminMenuTemplate, this.viewContainerRef, 'adminMenu', 'form');
-            this.headerService.sideBarButton = {icon: 'fa fa-home', label: this.lang.backHome, route : '/home'};
+            this.headerService.sideBarButton = { icon: 'fa fa-home', label: this.lang.backHome, route: '/home' };
             if (refresh) {
                 this.appDocumentViewer.templateListForm.reset();
                 this.appDocumentViewer.file = {
@@ -187,6 +187,7 @@ export class IndexationComponent implements OnInit {
 
     onSubmit() {
         if (this.indexingForm.isValidForm()) {
+            this.actionService.loading = true;
             const formatdatas = this.formatDatas(this.indexingForm.getDatas());
 
             formatdatas['modelId'] = this.currentIndexingModel.master !== null ? this.currentIndexingModel.master : this.currentIndexingModel.id;
@@ -204,6 +205,11 @@ export class IndexationComponent implements OnInit {
                         this.dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.lang.noFile, msg: this.lang.noFileMsg } });
 
                         this.dialogRef.afterClosed().pipe(
+                            tap((data: string) => {
+                                if (data !== 'ok') {
+                                    this.actionService.loading = false;
+                                }
+                            }),
                             filter((data: string) => data === 'ok'),
                             tap(() => {
                                 this.actionService.launchIndexingAction(this.selectedAction, this.headerService.user.id, this.currentGroupId, formatdatas);
diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts
index 8a518e400ee..f9f0a3d4034 100755
--- a/src/frontend/app/process/process.component.ts
+++ b/src/frontend/app/process/process.component.ts
@@ -571,12 +571,14 @@ export class ProcessComponent implements OnInit {
 
     async processAction() {
         if (this.indexingForm.isValidForm()) {
+            this.actionService.loading = true;
             if (this.isToolModified()) {
                 const dialogRef = this.openConfirmModification();
                 dialogRef.afterClosed().pipe(
                     tap((data: string) => {
                         if (data !== 'ok') {
                             this.refreshTool();
+                            this.actionService.loading = false;
                         }
                     }),
                     filter((data: string) => data === 'ok'),
@@ -590,6 +592,7 @@ export class ProcessComponent implements OnInit {
                     }),
                     catchError((err: any) => {
                         this.notify.handleSoftErrors(err);
+                        this.actionService.loading = false;
                         return of(false);
                     })
                 ).subscribe();
-- 
GitLab