From 543dcb9609f4e9f5fb1840f6a30f5e39c12d045e Mon Sep 17 00:00:00 2001
From: Alicia de Dios Fuente <Alicia.DeDiosFuente@unige.ch>
Date: Tue, 10 Sep 2019 17:36:10 +0200
Subject: [PATCH] fix: display spinner on deposit submission

---
 .../deposit-create.routable.html              | 26 ++++++++++++-------
 .../shared-abstract-create.routable.ts        | 14 +++++++++-
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/src/app/features/deposit/components/routables/deposit-create/deposit-create.routable.html b/src/app/features/deposit/components/routables/deposit-create/deposit-create.routable.html
index f32772e39..c0c05fa46 100644
--- a/src/app/features/deposit/components/routables/deposit-create/deposit-create.routable.html
+++ b/src/app/features/deposit/components/routables/deposit-create/deposit-create.routable.html
@@ -1,9 +1,17 @@
-<dlcm-deposit-form #formPresentational
-                   (submitChange)="create($event)"
-                   [languages]="languagesObs | async"
-                   [licenses]="licensesObs | async"
-                   [submissionPolicies]="submissionPoliciesObs | async"
-                   [preservationPolicies]="preservationPoliciesObs | async"
-                   [organizationalUnits]="organizationalUnitsObs | async"
-                   [listPersons]="listPersonObs | async"
-></dlcm-deposit-form>
+<div class="wrapper">
+  <div class="spinner-wrapper"
+       *ngIf="(isLoadingObs | async)"
+  >
+    <mat-spinner></mat-spinner>
+  </div>
+  <dlcm-deposit-form #formPresentational
+                     (submitChange)="create($event)"
+                     [languages]="languagesObs | async"
+                     [licenses]="licensesObs | async"
+                     [submissionPolicies]="submissionPoliciesObs | async"
+                     [preservationPolicies]="preservationPoliciesObs | async"
+                     [organizationalUnits]="organizationalUnitsObs | async"
+                     [listPersons]="listPersonObs | async"
+  ></dlcm-deposit-form>
+</div>
+
diff --git a/src/app/shared/components/routables/shared-abstract-create/shared-abstract-create.routable.ts b/src/app/shared/components/routables/shared-abstract-create/shared-abstract-create.routable.ts
index 51c389590..eff27f154 100644
--- a/src/app/shared/components/routables/shared-abstract-create/shared-abstract-create.routable.ts
+++ b/src/app/shared/components/routables/shared-abstract-create/shared-abstract-create.routable.ts
@@ -1,20 +1,32 @@
-import {OnInit} from "@angular/core";
+import {
+  OnInit,
+  Output,
+} from "@angular/core";
 import {SharedAbstractCrudRoutable} from "@app/shared/components/routables/shared-abstract-crud/shared-abstract-crud.routable";
 import {Store} from "@ngxs/store";
+import {
+  BehaviorSubject,
+  Observable,
+} from "rxjs";
 import {
   ModelFormControlEvent,
+  ObservableUtil,
   ResourceActionHelper,
   ResourceNameSpace,
   ResourceStateModel,
+  StoreUtil,
 } from "solidify-frontend";
 import {LocalStateEnum} from "../../../enums/local-state.enum";
 
 export abstract class SharedAbstractCreateRoutable<TResourceModel, UResourceStateModel extends ResourceStateModel<TResourceModel>> extends SharedAbstractCrudRoutable<UResourceStateModel> implements OnInit {
+  isLoadingObs: Observable<boolean>;
+
   protected constructor(protected store: Store,
                         protected state: LocalStateEnum,
                         private resourceActionNameSpace: ResourceNameSpace,
                         protected parentState?: LocalStateEnum) {
     super(state, parentState);
+    this.isLoadingObs = this.store.select(s => StoreUtil.isLoadingState(super.getState(s)));
   }
 
   create(modelFormControlEvent: ModelFormControlEvent<TResourceModel>): void {
-- 
GitLab