From af2a8882af4244dc3e547ad0cc61833c993d22b2 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Tue, 1 Oct 2019 11:38:48 +0200 Subject: [PATCH] Filter requestable awards to user fraction + alternative fraction --- server/routes/decorations.js | 5 ++++- static/src/app/request/award/req-award.component.html | 6 ++---- static/src/app/request/award/req-award.component.ts | 9 ++++++++- static/src/app/utils/fraction.enum.ts | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/server/routes/decorations.js b/server/routes/decorations.js index 89cfabc..bb310d0 100644 --- a/server/routes/decorations.js +++ b/server/routes/decorations.js @@ -37,11 +37,14 @@ decorationRouter.route('/') .get((req, res, next) => { const filter = {}; if (req.query.fractFilter) { - filter.fraction = req.query.fractFilter.toUpperCase(); + filter.fraction = { "$in" : req.query.fractFilter + .toUpperCase() + .split(',')}; } if (req.query.q) { filter.name = {$regex: req.query.q, $options: 'i'}; } + console.log(filter) DecorationModel.find(filter, {}, { sort: { fraction: 'asc', diff --git a/static/src/app/request/award/req-award.component.html b/static/src/app/request/award/req-award.component.html index 5e50a72..705b908 100644 --- a/static/src/app/request/award/req-award.component.html +++ b/static/src/app/request/award/req-award.component.html @@ -35,12 +35,10 @@
-
+
-
-   +
diff --git a/static/src/app/request/award/req-award.component.ts b/static/src/app/request/award/req-award.component.ts index 21407be..bc28422 100644 --- a/static/src/app/request/award/req-award.component.ts +++ b/static/src/app/request/award/req-award.component.ts @@ -7,6 +7,7 @@ import {DecorationService} from '../../services/army-management/decoration.servi import {UserService} from '../../services/army-management/user.service'; import {LoginService} from '../../services/app-user-service/login-service'; import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service'; +import {Fraction} from '../../utils/fraction.enum'; @Component({ @@ -47,7 +48,13 @@ export class RequestAwardComponent implements OnInit { this.userService.findUsers({squadId: currentUser.squad._id}).subscribe(users => { this.users = users; }); - this.decorationService.findDecorations('', currentUser.squad.fraction).subscribe(decorations => { + + const selectableFractions = [ + (currentUser.squad.fraction === Fraction.BLUFOR) ? Fraction.ARF : Fraction.SWORD, + currentUser.squad.fraction + ]; + + this.decorationService.findDecorations('', selectableFractions).subscribe(decorations => { this.decorations = decorations; }); } diff --git a/static/src/app/utils/fraction.enum.ts b/static/src/app/utils/fraction.enum.ts index 1433cae..edfc2cb 100644 --- a/static/src/app/utils/fraction.enum.ts +++ b/static/src/app/utils/fraction.enum.ts @@ -1,8 +1,8 @@ export enum Fraction { ARF = 'ARF', - COLOR_ARF = '#668866', + COLOR_ARF = '#336699', SWORD = 'SWORD', - COLOR_SWORD = '#9499a1', + COLOR_SWORD = '#8b8b8b', BLUFOR = 'NATO', OPFOR = 'CSAT', COLOR_BLUFOR = '#3c5fa1',