From a969b30a03bd6e2ab93d352b5fceccd8420b6983 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 3 May 2021 12:36:03 +0200 Subject: [PATCH] enable loading state in api creation, success page update --- .../core/components/home/home.component.scss | 15 -- src/app/core/services/api.service.ts | 9 +- src/app/core/services/poll.service.ts | 4 +- .../administration.component.ts | 2 +- .../base-config/base-config.component.html | 17 +-- .../administration/form/form.component.html | 89 +++++++----- .../administration/form/form.component.scss | 9 ++ .../administration/form/form.component.ts | 11 +- .../success/success.component.html | 136 ++++++++++-------- .../success/success.component.scss | 6 + .../success/success.component.ts | 8 +- src/styles/partials/_forms.scss | 2 + src/styles/partials/_main.scss | 19 +++ 13 files changed, 196 insertions(+), 131 deletions(-) diff --git a/src/app/core/components/home/home.component.scss b/src/app/core/components/home/home.component.scss index c31440bb..05590871 100644 --- a/src/app/core/components/home/home.component.scss +++ b/src/app/core/components/home/home.component.scss @@ -6,21 +6,6 @@ .subtitle { min-height: 4em; } - .creation, - .search { - min-height: 20em; - max-width: 40em; - margin-bottom: 10em; - margin-left: auto; - margin-right: auto; - .title { - margin-bottom: 2em; - } - .button { - border: 0; - } - } - .poll-list { margin: 2em 0; } diff --git a/src/app/core/services/api.service.ts b/src/app/core/services/api.service.ts index cc495cb2..14f752fb 100644 --- a/src/app/core/services/api.service.ts +++ b/src/app/core/services/api.service.ts @@ -32,7 +32,6 @@ export class ApiService { private readonly usersPollsEndpoint = apiEndpoints.users.polls.name; private readonly usersPollsSendEmailEndpoint = apiEndpoints.users.polls.sendEmail.name; private baseHref: string; - private loading = false; constructor(private http: HttpClient, private loader: LoaderService, private toastService: ToastService) { this.baseHref = apiBaseHref; @@ -99,13 +98,13 @@ export class ApiService { console.log('Error', error.message); } console.log(error.config); - this.loading = false; + this.loader.setStatus(false); } public async createPoll(poll: Poll): Promise { // this.loader.setStatus(true); console.log('createPoll config', poll); - + this.loader.setStatus(true); return this.axiosInstance.post( `${this.baseHref}${currentApiRoutes['api_new_poll']}`, poll, @@ -310,12 +309,12 @@ export class ApiService { ///////////////////// public async sendEmailToUserOfItsPollsList(email: string): Promise { - if (this.loading) { + if (this.loader.isLoading) { return; } // If user is not authenticated: the list of polls is send to user's email by the backend. try { - this.loading; + this.loader.setStatus(false); await this.axiosInstance.get( `${this.usersEndpoint}/${email}${this.usersPollsEndpoint}${this.usersPollsSendEmailEndpoint}` ); diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 983bcfe7..220e87b7 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -31,7 +31,9 @@ export class PollService implements Resolve { private uuidService: UuidService, private titleService: Title, private toastService: ToastService - ) {} + ) { + this._poll.next(new Poll()); + } /** * auto fetch a poll when route is looking for one in the administration pattern diff --git a/src/app/features/administration/administration.component.ts b/src/app/features/administration/administration.component.ts index 720a359e..56024019 100644 --- a/src/app/features/administration/administration.component.ts +++ b/src/app/features/administration/administration.component.ts @@ -10,7 +10,7 @@ import { Poll } from '../../core/models/poll.model'; styleUrls: ['./administration.component.scss'], }) export class AdministrationComponent implements OnInit, OnDestroy { - public poll: Poll = new Poll(); + public poll: Poll; private routeSubscription: Subscription; constructor(private route: ActivatedRoute) {} diff --git a/src/app/features/administration/form/base-config/base-config.component.html b/src/app/features/administration/form/base-config/base-config.component.html index 625f2af0..2adc91b0 100644 --- a/src/app/features/administration/form/base-config/base-config.component.html +++ b/src/app/features/administration/form/base-config/base-config.component.html @@ -6,16 +6,15 @@


- errors: -
-			form.errors :
-				{{ form.controls.title.errors | json }}
-			
+ + + + + + + + Ce champ est requis diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index a1b71fcf..0e9442fc 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -7,52 +7,65 @@ {{ 'creation.title' | translate }} -
- - -
+ + + +

{{ 'creation.want' | translate }}

- - - -
-

- - Précédent - -

-

- - Suivant - -

+
+ +
+
+ + - - - - - - + + +
+
+
+ + +
+