From a29a39d8e0e05dc87a9940f4c3652d246144524e Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 12:46:58 +0200 Subject: [PATCH] add possibility to delete multiple player awardings at once (CC-23) --- .../award-user/award-user.component.html | 13 +++++++-- .../users/award-user/award-user.component.ts | 29 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/static/src/app/users/award-user/award-user.component.html b/static/src/app/users/award-user/award-user.component.html index 9ff5fdc..12633ab 100644 --- a/static/src/app/users/award-user/award-user.component.html +++ b/static/src/app/users/award-user/award-user.component.html @@ -73,7 +73,9 @@ Begründung Datum Status - + + Löschen + @@ -94,10 +96,15 @@ {{award.date | date: 'dd.MM.yyyy'}} - {{award.confirmed === 0? 'In Bearbeitung' : (award.confirmed === 1? 'Genehmigt' : 'Abgelehnt')}} + {{award.confirmed === 0 ? 'In Bearbeitung' : (award.confirmed === 1 ? 'Genehmigt' : 'Abgelehnt')}} - + diff --git a/static/src/app/users/award-user/award-user.component.ts b/static/src/app/users/award-user/award-user.component.ts index e826195..14f230d 100644 --- a/static/src/app/users/award-user/award-user.component.ts +++ b/static/src/app/users/award-user/award-user.component.ts @@ -93,17 +93,24 @@ export class AwardUserComponent implements OnInit { } } - deleteAwarding(awardingId) { - this.awardingService.deleteAwarding(awardingId).subscribe((res) => { - this.awardingService.getUserAwardings(this.userId) - .subscribe((awards) => { - this.awards = awards; - this.showSuccessLabel = true; - setTimeout(() => { - this.showSuccessLabel = false; - }, 2000); - }); - }); + deleteAwarding() { + const checkedAwardings = this.awards.filter(award => award['checked'] == true); + + if (checkedAwardings.length > 0) { + checkedAwardings.forEach(awarding => { + this.awardingService.deleteAwarding(awarding._id).subscribe((res) => { + this.awardingService.getUserAwardings(this.userId) + .subscribe((awards) => { + this.awards = awards; + }); + }); + }); + + this.showSuccessLabel = true; + setTimeout(() => { + this.showSuccessLabel = false; + }, 4000); + } } cancel() {