From f2e21334964f07de402e487fa1217e8d7006c3ed Mon Sep 17 00:00:00 2001 From: HardiReady Date: Tue, 17 Jul 2018 10:07:12 +0200 Subject: [PATCH] * Suppress enter key action in critical forms (CC-39) * Add spinner service --- static/src/app/app.component.html | 2 +- static/src/app/app.component.ts | 18 +++++++++---- static/src/app/app.module.ts | 4 ++- .../edit-decoration.component.html | 3 ++- .../ranks/edit-rank/edit-rank.component.html | 3 ++- .../user-interface/spinner/spinner.service.ts | 19 +++++++++++++ .../edit-squad/edit-squad.component.html | 3 ++- .../campaign-submit.component.html | 9 ++----- .../campaign-submit.component.ts | 27 +++++++++---------- .../war/war-edit/war-edit.component.html | 9 ++----- .../war/war-edit/war-edit.component.ts | 13 ++++----- .../war/war-submit/war-submit.component.html | 3 ++- .../users/edit-user/edit-user.component.html | 5 ++-- 13 files changed, 68 insertions(+), 50 deletions(-) create mode 100644 static/src/app/services/user-interface/spinner/spinner.service.ts diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index ba388f7..3e7b1f9 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -98,7 +98,7 @@ - - - {{error}} - - diff --git a/static/src/app/statistic/campaign/campaign-submit/campaign-submit.component.ts b/static/src/app/statistic/campaign/campaign-submit/campaign-submit.component.ts index d7d38f3..31e3420 100644 --- a/static/src/app/statistic/campaign/campaign-submit/campaign-submit.component.ts +++ b/static/src/app/statistic/campaign/campaign-submit/campaign-submit.component.ts @@ -4,6 +4,8 @@ import {NgForm} from '@angular/forms'; import {Subscription} from 'rxjs/Subscription'; import {Campaign} from '../../../models/model-interfaces'; import {CampaignService} from '../../../services/logs/campaign.service'; +import {Message} from '../../../i18n/de.messages'; +import {SnackBarService} from '../../../services/user-interface/snack-bar/snack-bar.service'; @Component({ @@ -15,24 +17,21 @@ export class CampaignSubmitComponent { campaign: Campaign = {}; - showErrorLabel = false; - - error; - subscription: Subscription; @ViewChild(NgForm) form: NgForm; constructor(private route: ActivatedRoute, private router: Router, - private campaignService: CampaignService) { + private campaignService: CampaignService, + private snackBarService: SnackBarService) { this.subscription = this.route.params - .map(params => params['id']) - .filter(id => id !== undefined) - .flatMap(id => this.campaignService.getCampaign(id)) - .subscribe(campaign => { - this.campaign = campaign; - }); + .map(params => params['id']) + .filter(id => id !== undefined) + .flatMap(id => this.campaignService.getCampaign(id)) + .subscribe(campaign => { + this.campaign = campaign; + }); } saveCampaign() { @@ -42,12 +41,10 @@ export class CampaignSubmitComponent { if (this.campaign._id) { redirectSuccessUrl = '../' + redirectSuccessUrl; } + this.snackBarService.showSuccess(Message.SUCCESS_SAVE); this.router.navigate([redirectSuccessUrl + campaign._id], {relativeTo: this.route}); }, - error => { - this.error = error._body.error.message; - this.showErrorLabel = true; - }); + error => this.snackBarService.showError(error._body.error.message, 30000)); } cancel() { diff --git a/static/src/app/statistic/war/war-edit/war-edit.component.html b/static/src/app/statistic/war/war-edit/war-edit.component.html index ff08c34..eb1f5a0 100644 --- a/static/src/app/statistic/war/war-edit/war-edit.component.html +++ b/static/src/app/statistic/war/war-edit/war-edit.component.html @@ -1,4 +1,4 @@ -
+

Schlacht bearbeiten

@@ -71,15 +71,10 @@ - - - {{error}} - - diff --git a/static/src/app/statistic/war/war-edit/war-edit.component.ts b/static/src/app/statistic/war/war-edit/war-edit.component.ts index e84e42b..634d3fa 100644 --- a/static/src/app/statistic/war/war-edit/war-edit.component.ts +++ b/static/src/app/statistic/war/war-edit/war-edit.component.ts @@ -5,6 +5,8 @@ import {WarService} from '../../../services/logs/war.service'; import {War} from '../../../models/model-interfaces'; import {CampaignService} from '../../../services/logs/campaign.service'; import {Subscription} from 'rxjs/Subscription'; +import {SnackBarService} from '../../../services/user-interface/snack-bar/snack-bar.service'; +import {Message} from '../../../i18n/de.messages'; @Component({ @@ -19,15 +21,12 @@ export class WarEditComponent { subscription: Subscription; - showErrorLabel = false; - - error; - @ViewChild(NgForm) form: NgForm; constructor(private route: ActivatedRoute, private router: Router, private warService: WarService, + private snackBarService: SnackBarService, public campaignService: CampaignService) { this.subscription = this.route.params .map(params => params['id']) @@ -41,12 +40,10 @@ export class WarEditComponent { updateWar() { this.warService.updateWar(this.war) .subscribe(war => { + this.snackBarService.showSuccess(Message.SUCCESS_SAVE); this.router.navigate(['../../war/' + war._id], {relativeTo: this.route}); }, - error => { - this.error = error._body.error.message; - this.showErrorLabel = true; - }); + error => this.snackBarService.showError(error._body.error.message, 30000)); } cancel() { diff --git a/static/src/app/statistic/war/war-submit/war-submit.component.html b/static/src/app/statistic/war/war-submit/war-submit.component.html index 5d6138c..2708d55 100644 --- a/static/src/app/statistic/war/war-submit/war-submit.component.html +++ b/static/src/app/statistic/war/war-submit/war-submit.component.html @@ -1,4 +1,4 @@ -
+

Neue Schlacht hinzufügen

@@ -42,6 +42,7 @@