Refactor fraction names in army management

pull/60/head
HardiReady 2019-08-04 13:16:11 +02:00
parent 845593b2ec
commit af3c4f8b46
27 changed files with 79 additions and 42 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.9.4", "version": "1.9.5",
"author": "Florian Hartwich <hardi@noarch.de>", "author": "Florian Hartwich <hardi@noarch.de>",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -8,6 +8,16 @@ const CampaignSchema = new Schema({
type: String, type: String,
required: true, required: true,
}, },
fractionMappingBlufor: {
type: String,
enum: ['BLUFOR', 'OPFOR', 'ARF', 'SWORD'],
default: 'BLUFOR',
},
fractionMappingOpfor: {
type: String,
enum: ['BLUFOR', 'OPFOR', 'ARF', 'SWORD'],
default: 'OPFOR',
},
}, { }, {
collection: 'campaign', collection: 'campaign',
timestamps: {createdAt: 'timestamp'}, timestamps: {createdAt: 'timestamp'},

View File

@ -10,7 +10,7 @@ const DecorationSchema = new Schema({
}, },
fraction: { fraction: {
type: String, type: String,
enum: ['BLUFOR', 'OPFOR', 'GLOBAL'], enum: ['BLUFOR', 'OPFOR', 'ARF', 'SWORD', 'GLOBAL'],
required: true, required: true,
}, },
description: { description: {

View File

@ -8,7 +8,7 @@
</div> </div>
<h3 class="text-center" style="font-weight: 600" <h3 class="text-center" style="font-weight: 600"
[style.color]="user.squadId?.fraction === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR"> [style.color]="user.squadId?.fraction === 'BLUFOR' ? fraction.COLOR_ARF : fraction.COLOR_SWORD">
{{'public.army.member.headline' | translate:{name: user.username} }} {{'public.army.member.headline' | translate:{name: user.username} }}
</h3> </h3>

View File

@ -7,7 +7,7 @@
</div> </div>
<div class=" middle-row"> <div class=" middle-row">
<div class="name-cell"> <div class="name-cell">
<div [style.color]="squadFraction === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR" <div [style.color]="squadFraction === 'BLUFOR' ? fraction.COLOR_ARF : fraction.COLOR_SWORD"
*ngFor="let member of squad.members"> *ngFor="let member of squad.members">
<span class="member-link" <span class="member-link"
(click)="select(member._id)"> (click)="select(member._id)">

View File

@ -2,8 +2,8 @@
<h1>{{'public.army.headline' | translate}}</h1> <h1>{{'public.army.headline' | translate}}</h1>
<div class="pull-left army-column" *ngIf="!isSmallLayout || singleViewSelected === fraction.BLUFOR"> <div class="pull-left army-column" *ngIf="!isSmallLayout || singleViewSelected === fraction.BLUFOR">
<h3 class="army-head" [style.color]="fraction.COLOR_BLUFOR"> <h3 class="army-head" [style.color]="fraction.COLOR_ARF">
{{fraction.BLUFOR}} {{fraction.ARF}}
<button mat-icon-button class="switch-btn-blufor" <button mat-icon-button class="switch-btn-blufor"
(click)="singleViewSwitch(fraction.OPFOR)"> (click)="singleViewSwitch(fraction.OPFOR)">
<mat-icon svgIcon="chevron-right"></mat-icon> <mat-icon svgIcon="chevron-right"></mat-icon>
@ -18,12 +18,12 @@
</div> </div>
<div class="pull-right army-column" *ngIf="!isSmallLayout || singleViewSelected === fraction.OPFOR"> <div class="pull-right army-column" *ngIf="!isSmallLayout || singleViewSelected === fraction.OPFOR">
<h3 class="army-head" [style.color]="fraction.COLOR_OPFOR"> <h3 class="army-head" [style.color]="fraction.COLOR_SWORD">
<button mat-icon-button class="switch-btn-opfor" <button mat-icon-button class="switch-btn-opfor"
(click)="singleViewSwitch(fraction.BLUFOR)"> (click)="singleViewSwitch(fraction.BLUFOR)">
<mat-icon svgIcon="chevron-right"></mat-icon> <mat-icon svgIcon="chevron-right"></mat-icon>
</button> </button>
{{fraction.OPFOR}} {{fraction.SWORD}}
</h3> </h3>
<cc-army-squad *ngFor="let squad of army[1].squads" <cc-army-squad *ngFor="let squad of army[1].squads"
[squad]="squad" [squad]="squad"

View File

@ -6,6 +6,8 @@
<a>{{decoration.name}}</a> <a>{{decoration.name}}</a>
</span> </span>
<br> <br>
<small *ngIf="decoration.fraction == 'ARF'">{{fraction.ARF}}</small>
<small *ngIf="decoration.fraction == 'SWORD'">{{fraction.SWORD}}</small>
<small *ngIf="decoration.fraction == 'OPFOR'">{{fraction.OPFOR}}</small> <small *ngIf="decoration.fraction == 'OPFOR'">{{fraction.OPFOR}}</small>
<small *ngIf="decoration.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small> <small *ngIf="decoration.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small>
<small *ngIf="decoration.fraction == 'GLOBAL'">{{'decorations.list.filter.global' | translate}}</small> <small *ngIf="decoration.fraction == 'GLOBAL'">{{'decorations.list.filter.global' | translate}}</small>

View File

@ -1,6 +1,8 @@
<div class="select-list"> <div class="select-list">
<cc-list-filter <cc-list-filter
[filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'}, [filterButtons]="[{label: fraction.ARF, value: 'ARF'},
{label: fraction.SWORD, value: 'SWORD'},
{label: fraction.BLUFOR, value: 'BLUFOR'},
{label: fraction.OPFOR, value: 'OPFOR'}, {label: fraction.OPFOR, value: 'OPFOR'},
{label: 'decorations.list.filter.global', value: 'GLOBAL'}]" {label: 'decorations.list.filter.global', value: 'GLOBAL'}]"
[addButton]="{svgIcon: 'add', tooltip: 'decorations.list.button.add'}" [addButton]="{svgIcon: 'add', tooltip: 'decorations.list.button.add'}"

View File

@ -17,8 +17,10 @@
<select id="fraction" name="fraction" class="form-control btn dropdown-toggle" <select id="fraction" name="fraction" class="form-control btn dropdown-toggle"
required required
[(ngModel)]="decoration.fraction"> [(ngModel)]="decoration.fraction">
<option value="OPFOR">{{fraction.OPFOR}}</option> <option value="{{fraction.ARF}}">{{fraction.ARF}}</option>
<option value="BLUFOR">{{fraction.BLUFOR}}</option> <option value="{{fraction.SWORD}}">{{fraction.SWORD}}</option>
<option value="{{fraction.OPFOR}}">{{fraction.OPFOR}}</option>
<option value="{{fraction.BLUFOR}}">{{fraction.BLUFOR}}</option>
<option value="GLOBAL">{{'decorations.submit.field.fraction.global' | translate}}</option> <option value="GLOBAL">{{'decorations.submit.field.fraction.global' | translate}}</option>
</select> </select>
<show-error displayName="{{'decorations.submit.field.fraction' | translate}}" controlPath="fraction"></show-error> <show-error displayName="{{'decorations.submit.field.fraction' | translate}}" controlPath="fraction"></show-error>

View File

@ -17,8 +17,8 @@
<select id="fraction" name="fraction" class="form-control btn dropdown-toggle" <select id="fraction" name="fraction" class="form-control btn dropdown-toggle"
required required
[(ngModel)]="rank.fraction"> [(ngModel)]="rank.fraction">
<option value="OPFOR">{{fraction.OPFOR}}</option> <option value="OPFOR">{{fraction.SWORD}}</option>
<option value="BLUFOR">{{fraction.BLUFOR}}</option> <option value="BLUFOR">{{fraction.ARF}}</option>
</select> </select>
<show-error displayName="{{'ranks.submit.field.fraction' | translate}}" controlPath="fraction"></show-error> <show-error displayName="{{'ranks.submit.field.fraction' | translate}}" controlPath="fraction"></show-error>
</div> </div>

View File

@ -6,8 +6,8 @@
<a>{{rank.name}}</a> <a>{{rank.name}}</a>
</span> </span>
<br> <br>
<small *ngIf="rank.fraction == 'OPFOR'">{{fraction.OPFOR}}</small> <small *ngIf="rank.fraction == 'OPFOR'">{{fraction.SWORD}}</small>
<small *ngIf="rank.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small> <small *ngIf="rank.fraction == 'BLUFOR'">{{fraction.ARF}}</small>
<small> {{'ranks.list.item.label.level' | translate:{level: rank.level} }}</small> <small> {{'ranks.list.item.label.level' | translate:{level: rank.level} }}</small>
</div> </div>

View File

@ -1,7 +1,7 @@
<div class="select-list"> <div class="select-list">
<cc-list-filter <cc-list-filter
[filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'}, [filterButtons]="[{label: fraction.ARF, value: 'BLUFOR'},
{label: fraction.OPFOR, value: 'OPFOR'}]" {label: fraction.SWORD, value: 'OPFOR'}]"
[addButton]="{svgIcon: 'add', tooltip: 'ranks.list.button.add'}" [addButton]="{svgIcon: 'add', tooltip: 'ranks.list.button.add'}"
(executeSearch)="filterRanks($event)" (executeSearch)="filterRanks($event)"
(openAddFrom)="openNewRankForm()"> (openAddFrom)="openNewRankForm()">

View File

@ -17,8 +17,8 @@
<select id="fraction" name="fraction" class="form-control btn dropdown-toggle" <select id="fraction" name="fraction" class="form-control btn dropdown-toggle"
required required
[(ngModel)]="squad.fraction"> [(ngModel)]="squad.fraction">
<option value="OPFOR">{{fraction.OPFOR}}</option> <option value="OPFOR">{{fraction.SWORD}}</option>
<option value="BLUFOR">{{fraction.BLUFOR}}</option> <option value="BLUFOR">{{fraction.ARF}}</option>
</select> </select>
<show-error displayName="{{'squad.submit.field.fraction' | translate}}" controlPath="fraction"></show-error> <show-error displayName="{{'squad.submit.field.fraction' | translate}}" controlPath="fraction"></show-error>
</div> </div>

View File

@ -6,8 +6,8 @@
<a>{{squad.name}}</a> <a>{{squad.name}}</a>
</span> </span>
<br> <br>
<small *ngIf="squad.fraction == 'OPFOR'">{{fraction.OPFOR}}</small> <small *ngIf="squad.fraction == 'OPFOR'">{{fraction.ARF}}</small>
<small *ngIf="squad.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small> <small *ngIf="squad.fraction == 'BLUFOR'">{{fraction.SWORD}}</small>
</div> </div>
<div class="col-xs-4"> <div class="col-xs-4">

View File

@ -1,7 +1,7 @@
<div class="select-list"> <div class="select-list">
<cc-list-filter <cc-list-filter
[filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'}, [filterButtons]="[{label: fraction.ARF, value: 'BLUFOR'},
{label: fraction.OPFOR, value: 'OPFOR'}]" {label: fraction.SWORD, value: 'OPFOR'}]"
[addButton]="{svgIcon: 'add', tooltip: 'squad.list.tooltip.new'}" [addButton]="{svgIcon: 'add', tooltip: 'squad.list.tooltip.new'}"
(executeSearch)="filterSquads($event)" (executeSearch)="filterSquads($event)"
(openAddFrom)="openNewSquadForm()"> (openAddFrom)="openNewSquadForm()">

View File

@ -13,7 +13,8 @@
style="min-width: 200px;"> style="min-width: 200px;">
<option [value]="0">{{'users.award.field.decoration.placeholder' | translate}}</option> <option [value]="0">{{'users.award.field.decoration.placeholder' | translate}}</option>
<option *ngFor="let deco of decorations" [value]="deco._id"> <option *ngFor="let deco of decorations" [value]="deco._id">
{{deco.fraction == 'BLUFOR'? fraction.BLUFOR : deco.fraction == 'OPFOR'? fraction.OPFOR : 'Global'}}: {{deco.fraction == 'BLUFOR' ? fraction.BLUFOR : deco.fraction == 'OPFOR' ? fraction.OPFOR : deco.fraction ==
'ARF' ? fraction.ARF : deco.fraction == 'SWORD' ? fraction.SWORD : 'Global'}}:
{{deco.name}} {{deco.name}}
</option> </option>
</select> </select>
@ -94,7 +95,7 @@
<td class="text-center"> <td class="text-center">
{{award.confirmed === 0 ? {{award.confirmed === 0 ?
awardStatus['users.award.table.status.in.progress'] : (award.confirmed === 1 ? awardStatus['users.award.table.status.in.progress'] : (award.confirmed === 1 ?
awardStatus['users.award.table.status.approved']: awardStatus['users.award.table.status.rejected'])}} awardStatus['users.award.table.status.approved'] : awardStatus['users.award.table.status.rejected'])}}
</td> </td>
<td class="text-center"> <td class="text-center">
<label> <label>

View File

@ -23,7 +23,7 @@
(change)="toggleRanks()"> (change)="toggleRanks()">
<option [value]="0">{{'user.submit.field.squad.not.assigned' | translate}}</option> <option [value]="0">{{'user.submit.field.squad.not.assigned' | translate}}</option>
<option *ngFor="let squad of squads" [ngValue]="squad"> <option *ngFor="let squad of squads" [ngValue]="squad">
{{squad.fraction == 'BLUFOR'? fraction.BLUFOR : fraction.OPFOR}}: {{squad.name}} {{squad.fraction == 'BLUFOR'? fraction.ARF : fraction.SWORD}}: {{squad.name}}
</option> </option>
</select> </select>
<show-error displayName="{{'user.submit.field.squad' | translate}}" controlPath="squad"></show-error> <show-error displayName="{{'user.submit.field.squad' | translate}}" controlPath="squad"></show-error>

View File

@ -6,8 +6,8 @@
<a>{{user.username}}</a> <a>{{user.username}}</a>
</span> </span>
<br> <br>
<small *ngIf="user.squadId && user.squadId.fraction == 'OPFOR'">{{fraction.OPFOR}} - {{user.squadId.name}}</small> <small *ngIf="user.squadId && user.squadId.fraction == 'OPFOR'">{{fraction.SWORD}} - {{user.squadId.name}}</small>
<small *ngIf="user.squadId && user.squadId.fraction == 'BLUFOR'">{{fraction.BLUFOR}} - {{user.squadId.name}} <small *ngIf="user.squadId && user.squadId.fraction == 'BLUFOR'">{{fraction.ARF}} - {{user.squadId.name}}
</small> </small>
<small *ngIf="!user.squadId">{{'users.list.item.label.no.squad' | translate}}</small> <small *ngIf="!user.squadId">{{'users.list.item.label.no.squad' | translate}}</small>
</div> </div>

View File

@ -1,7 +1,7 @@
<div class="select-list"> <div class="select-list">
<cc-list-filter <cc-list-filter
[filterButtons]="[{label: fraction.BLUFOR, value: 'BLUFOR'}, [filterButtons]="[{label: fraction.ARF, value: 'BLUFOR'},
{label: fraction.OPFOR, value: 'OPFOR'}, {label: fraction.SWORD, value: 'OPFOR'},
{label: 'users.list.filter.no.squad', value: 'UNASSIGNED'}]" {label: 'users.list.filter.no.squad', value: 'UNASSIGNED'}]"
[addButton]="{svgIcon: 'add-user', tooltip: 'users.list.tooltip.new'}" [addButton]="{svgIcon: 'add-user', tooltip: 'users.list.tooltip.new'}"
(executeSearch)="filterUsers(undefined, $event)" (executeSearch)="filterUsers(undefined, $event)"

View File

@ -2,6 +2,8 @@
<h1>{{'public.decorations.headline' | translate}}</h1> <h1>{{'public.decorations.headline' | translate}}</h1>
<div class="fraction-side-bar"> <div class="fraction-side-bar">
<div [ngClass]="{active: active === 'ARF'}" (click)="switchFraction('ARF')">{{fraction.ARF}}</div>
<div [ngClass]="{active: active === 'SWORD'}" (click)="switchFraction('SWORD')">{{fraction.SWORD}}</div>
<div [ngClass]="{active: active === 'BLUFOR'}" (click)="switchFraction('BLUFOR')">{{fraction.BLUFOR}}</div> <div [ngClass]="{active: active === 'BLUFOR'}" (click)="switchFraction('BLUFOR')">{{fraction.BLUFOR}}</div>
<div [ngClass]="{active: active === 'OPFOR'}" (click)="switchFraction('OPFOR')">{{fraction.OPFOR}}</div> <div [ngClass]="{active: active === 'OPFOR'}" (click)="switchFraction('OPFOR')">{{fraction.OPFOR}}</div>
<div [ngClass]="{active: active === 'GLOBAL'}" (click)="switchFraction('GLOBAL')">GLOBAL</div> <div [ngClass]="{active: active === 'GLOBAL'}" (click)="switchFraction('GLOBAL')">GLOBAL</div>

View File

@ -45,10 +45,11 @@ export class DecorationOverviewComponent implements OnInit, OnDestroy {
} }
const fract = queryParams.fraction; const fract = queryParams.fraction;
if (fract && (fract === 'BLUFOR' || fract === 'OPFOR' || fract === 'GLOBAL')) { if (fract && (fract === 'ARF' || fract === 'SWORD' ||
fract === 'BLUFOR' || fract === 'OPFOR' || fract === 'GLOBAL')) {
this.switchFraction(queryParams.fraction); this.switchFraction(queryParams.fraction);
} else { } else {
this.switchFraction('BLUFOR'); this.switchFraction('ARF');
} }
}); });
}; };

View File

@ -5,8 +5,7 @@
[class]="decoration.isMedal ? 'img-medal' : 'img-ribbon'"> [class]="decoration.isMedal ? 'img-medal' : 'img-ribbon'">
</div> </div>
<mat-card-content> <mat-card-content>
<div [style.background]="decoration.fraction === 'BLUFOR' ? <div [style.background]="getColor(decoration.fraction)">
fraction.COLOR_BLUFOR : decoration.fraction === 'OPFOR' ? fraction.COLOR_OPFOR : '#666666'">
{{decoration.name}} {{decoration.name}}
</div> </div>
<div class="decoration-description"> <div class="decoration-description">

View File

@ -17,6 +17,21 @@ export class DecorationPanelComponent {
readonly fraction = Fraction; readonly fraction = Fraction;
private getColor(fractionKey) {
switch (fractionKey) {
case 'ARF':
return this.fraction.COLOR_ARF;
case 'SWORD':
return this.fraction.COLOR_SWORD;
case 'BLUFOR':
return this.fraction.COLOR_BLUFOR;
case 'OPFOR':
return this.fraction.COLOR_OPFOR;
default:
return this.fraction.COLOR_NEUTRAL;
}
}
selectDecoration() { selectDecoration() {
this.select.emit(this.decoration); this.select.emit(this.decoration);
} }

View File

@ -2,7 +2,7 @@
<h1>{{'public.ranks.headline' | translate}}</h1> <h1>{{'public.ranks.headline' | translate}}</h1>
<div class="column-container pull-left"> <div class="column-container pull-left">
<h3 [style.color]="fraction.COLOR_BLUFOR">{{fraction.BLUFOR}}</h3> <h3 [style.color]="fraction.COLOR_ARF">{{fraction.ARF}}</h3>
<table mat-table [dataSource]="ranksBlufor" class="mat-elevation-z8"> <table mat-table [dataSource]="ranksBlufor" class="mat-elevation-z8">
@ -19,7 +19,7 @@
</div> </div>
<div class="column-container pull-right"> <div class="column-container pull-right">
<h3 [style.color]="fraction.COLOR_OPFOR">{{fraction.OPFOR}}</h3> <h3 [style.color]="fraction.COLOR_SWORD">{{fraction.SWORD}}</h3>
<table mat-table [dataSource]="ranksOpfor" class="pull-right mat-elevation-z8"> <table mat-table [dataSource]="ranksOpfor" class="pull-right mat-elevation-z8">

View File

@ -13,8 +13,6 @@ export class RankPanelComponent {
@Output() select = new EventEmitter(); @Output() select = new EventEmitter();
readonly fraction = Fraction;
selectRank() { selectRank() {
this.select.emit(this.rank); this.select.emit(this.rank);
} }

View File

@ -24,8 +24,8 @@
<span mat-line> <span mat-line>
{{user.username}} {{user.username}}
</span> </span>
<span mat-line [style.color]="user.squadId.fraction === 'BLUFOR' ? fraction.COLOR_BLUFOR :fraction.COLOR_OPFOR"> <span mat-line [style.color]="user.squadId.fraction === 'BLUFOR' ? fraction.COLOR_ARF :fraction.COLOR_SWORD">
{{user.squadId.fraction === 'BLUFOR' ? fraction.BLUFOR : fraction.OPFOR}} - {{user.squadId.name}} {{user.squadId.fraction === 'BLUFOR' ? fraction.ARF : fraction.SWORD}} - {{user.squadId.name}}
</span> </span>
</a> </a>
</mat-nav-list> </mat-nav-list>

View File

@ -1,4 +1,8 @@
export enum Fraction { export enum Fraction {
ARF = 'ARF',
COLOR_ARF = '#668866',
SWORD = 'SWORD',
COLOR_SWORD = '#9499a1',
BLUFOR = 'NATO', BLUFOR = 'NATO',
OPFOR = 'CSAT', OPFOR = 'CSAT',
COLOR_BLUFOR = '#3c5fa1', COLOR_BLUFOR = '#3c5fa1',
@ -8,5 +12,6 @@ export enum Fraction {
COLOR_OPFOR = '#a90100', COLOR_OPFOR = '#a90100',
COLOR_OPFOR_DARK = '#890F0F', COLOR_OPFOR_DARK = '#890F0F',
COLOR_OPFOR_LIGHT = '#fb5555', COLOR_OPFOR_LIGHT = '#fb5555',
COLOR_OPFOR_GREY = '#955c5f' COLOR_OPFOR_GREY = '#955c5f',
COLOR_NEUTRAL = "#666666",
} }