diff --git a/api/models/awarding.js b/api/models/awarding.js index bd2b60d..4a632a7 100644 --- a/api/models/awarding.js +++ b/api/models/awarding.js @@ -29,6 +29,9 @@ const AwardingSchema = new Schema({ max: 2, default: 0 }, + rejectReason: { + type: String + }, date: { type: Date, default: Date.now() diff --git a/api/routes/awardings.js b/api/routes/awardings.js index e29fc83..61b15e0 100644 --- a/api/routes/awardings.js +++ b/api/routes/awardings.js @@ -114,7 +114,6 @@ awarding.route('/:id') return; // prevent node to process this function further after next() has finished. } - // optional task 3: increment version manually as we do not use .save(.) req.body.updatedAt = new Date(); req.body.$inc = {__v: 1}; diff --git a/static/src/app/request/confirm-award/confirm-award.component.html b/static/src/app/request/confirm-award/confirm-award.component.html index 6361bfb..06799b6 100644 --- a/static/src/app/request/confirm-award/confirm-award.component.html +++ b/static/src/app/request/confirm-award/confirm-award.component.html @@ -16,7 +16,7 @@ Begründung Antragsteller Datum - Aktion + Aktion @@ -34,7 +34,10 @@ {{award.decorationId.name}} - {{award.reason}} + {{award.proposer?.username}} @@ -43,8 +46,15 @@ {{award.date | date: 'dd.MM.yyyy'}} - Bestätigen
- Ablehnen + Bestätigen
+ Ablehnen +
+ +
diff --git a/static/src/app/request/confirm-award/confirm-award.component.ts b/static/src/app/request/confirm-award/confirm-award.component.ts index 835efbf..59238cc 100644 --- a/static/src/app/request/confirm-award/confirm-award.component.ts +++ b/static/src/app/request/confirm-award/confirm-award.component.ts @@ -25,12 +25,20 @@ export class ConfirmAwardComponent implements OnInit { }); } - confirm(award: Award, decision: boolean) { + confirm(award: Award, decision: boolean, reason: string, rejectReason: string) { const updateObject = { _id: award._id, confirmed: decision ? 1 : 2 }; + if (rejectReason) { + updateObject['rejectReason'] = rejectReason; + } + + if (reason && reason !== award.reason) { + updateObject['reason'] = reason; + } + this.awardingService.updateAward(updateObject).subscribe(res => { const currentUser = this.loginService.getCurrentUser(); this.awardingService.getUnconfirmedAwards(currentUser.squad.fraction).subscribe(awards => {