From c1e666ebbc5afd8d63bed70d9ba34980e0bfb339 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Wed, 2 Aug 2017 20:20:05 +0200 Subject: [PATCH] Fix request user select --- .../request/award/req-award.component.html | 1 + .../app/request/award/req-award.component.ts | 30 +++++++++++-------- .../promotion/req-promotion.component.html | 1 + .../promotion/req-promotion.component.ts | 10 +++++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/static/src/app/request/award/req-award.component.html b/static/src/app/request/award/req-award.component.html index e9ba9e2..eddd70c 100644 --- a/static/src/app/request/award/req-award.component.html +++ b/static/src/app/request/award/req-award.component.html @@ -10,6 +10,7 @@ [compareWith]="equals" (change)="toggleUser(decoPreview, decoDescription)" required> + diff --git a/static/src/app/request/award/req-award.component.ts b/static/src/app/request/award/req-award.component.ts index 6935187..b41a02a 100644 --- a/static/src/app/request/award/req-award.component.ts +++ b/static/src/app/request/award/req-award.component.ts @@ -19,7 +19,7 @@ export class RequestAwardComponent { showSuccessLabel = false; - user: User = {}; + user: User = {_id: '0'}; decoration: Decoration = null; @@ -49,19 +49,23 @@ export class RequestAwardComponent { } toggleUser(previewImage, decoDescription) { - this.decoration = null; - if (previewImage && decoDescription) { - previewImage.src = decoDescription.innerHTML = ''; + if (this.user._id != '0') { + this.decoration = null; + if (previewImage && decoDescription) { + previewImage.src = decoDescription.innerHTML = ''; + } + this.decorationService.findDecorations('', this.user.squad.fraction).subscribe(decorations => { + this.decorations = decorations; + }); + + this.awardingService.getUserAwardings(this.user._id).subscribe(awards => { + this.awards = awards; + }); + + this.showForm = true; + } else { + this.showForm = false; } - this.decorationService.findDecorations('', this.user.squad.fraction).subscribe(decorations => { - this.decorations = decorations; - }); - - this.awardingService.getUserAwardings(this.user._id).subscribe(awards => { - this.awards = awards; - }); - - this.showForm = true; } diff --git a/static/src/app/request/promotion/req-promotion.component.html b/static/src/app/request/promotion/req-promotion.component.html index fddaa11..e8a082b 100644 --- a/static/src/app/request/promotion/req-promotion.component.html +++ b/static/src/app/request/promotion/req-promotion.component.html @@ -10,6 +10,7 @@ [compareWith]="equals" required (change)="toggleUser()"> + diff --git a/static/src/app/request/promotion/req-promotion.component.ts b/static/src/app/request/promotion/req-promotion.component.ts index e2dec44..7be13fc 100644 --- a/static/src/app/request/promotion/req-promotion.component.ts +++ b/static/src/app/request/promotion/req-promotion.component.ts @@ -19,7 +19,7 @@ export class RequestPromotionComponent { showSuccessLabel = false; - user: User = {}; + user: User = {_id: '0'}; newLevel: number; @@ -52,8 +52,12 @@ export class RequestPromotionComponent { } toggleUser() { - this.showForm = true; - this.newLevel = this.user.rank.level; + if (this.user._id != '0') { + this.showForm = true; + this.newLevel = this.user.rank.level; + } else { + this.showForm = false; + } }