Filter requestable awards to user fraction + alternative fraction
							parent
							
								
									df7edc873c
								
							
						
					
					
						commit
						af2a8882af
					
				| 
						 | 
					@ -37,11 +37,14 @@ decorationRouter.route('/')
 | 
				
			||||||
                .get((req, res, next) => {
 | 
					                .get((req, res, next) => {
 | 
				
			||||||
                  const filter = {};
 | 
					                  const filter = {};
 | 
				
			||||||
                  if (req.query.fractFilter) {
 | 
					                  if (req.query.fractFilter) {
 | 
				
			||||||
                    filter.fraction = req.query.fractFilter.toUpperCase();
 | 
					                    filter.fraction = { "$in" : req.query.fractFilter
 | 
				
			||||||
 | 
					                                                   .toUpperCase()
 | 
				
			||||||
 | 
					                                                   .split(',')};
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
                  if (req.query.q) {
 | 
					                  if (req.query.q) {
 | 
				
			||||||
                    filter.name = {$regex: req.query.q, $options: 'i'};
 | 
					                    filter.name = {$regex: req.query.q, $options: 'i'};
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					                  console.log(filter)
 | 
				
			||||||
                  DecorationModel.find(filter, {}, {
 | 
					                  DecorationModel.find(filter, {}, {
 | 
				
			||||||
                    sort: {
 | 
					                    sort: {
 | 
				
			||||||
                      fraction: 'asc',
 | 
					                      fraction: 'asc',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,12 +35,10 @@
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div class="div-table-row" [style.display]="decoPreviewDisplay" style="margin-top: 5px; margin-bottom:10px">
 | 
					    <div class="div-table-row" [style.display]="decoPreviewDisplay" style="margin-top: 5px; margin-bottom:10px">
 | 
				
			||||||
      <div class="col-sm-1 decoration-preview">
 | 
					      <div class="decoration-preview">
 | 
				
			||||||
        <img class="center-block" #decoPreview>
 | 
					        <img class="center-block" #decoPreview>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div class="col-sm-2"
 | 
					      <div style="border-radius: 0px 15px 15px 0px; font-style: oblique; padding: 0 10px" #decoDescription>
 | 
				
			||||||
           style="border-radius: 0px 15px 15px 0px; font-style: oblique" #decoDescription>
 | 
					 | 
				
			||||||
         
 | 
					 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {DecorationService} from '../../services/army-management/decoration.servi
 | 
				
			||||||
import {UserService} from '../../services/army-management/user.service';
 | 
					import {UserService} from '../../services/army-management/user.service';
 | 
				
			||||||
import {LoginService} from '../../services/app-user-service/login-service';
 | 
					import {LoginService} from '../../services/app-user-service/login-service';
 | 
				
			||||||
import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service';
 | 
					import {SnackBarService} from '../../services/user-interface/snack-bar/snack-bar.service';
 | 
				
			||||||
 | 
					import {Fraction} from '../../utils/fraction.enum';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
| 
						 | 
					@ -47,7 +48,13 @@ export class RequestAwardComponent implements OnInit {
 | 
				
			||||||
    this.userService.findUsers({squadId: currentUser.squad._id}).subscribe(users => {
 | 
					    this.userService.findUsers({squadId: currentUser.squad._id}).subscribe(users => {
 | 
				
			||||||
      this.users = 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;
 | 
					      this.decorations = decorations;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
export enum Fraction {
 | 
					export enum Fraction {
 | 
				
			||||||
  ARF = 'ARF',
 | 
					  ARF = 'ARF',
 | 
				
			||||||
  COLOR_ARF = '#668866',
 | 
					  COLOR_ARF = '#336699',
 | 
				
			||||||
  SWORD = 'SWORD',
 | 
					  SWORD = 'SWORD',
 | 
				
			||||||
  COLOR_SWORD = '#9499a1',
 | 
					  COLOR_SWORD = '#8b8b8b',
 | 
				
			||||||
  BLUFOR = 'NATO',
 | 
					  BLUFOR = 'NATO',
 | 
				
			||||||
  OPFOR = 'CSAT',
 | 
					  OPFOR = 'CSAT',
 | 
				
			||||||
  COLOR_BLUFOR = '#3c5fa1',
 | 
					  COLOR_BLUFOR = '#3c5fa1',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue