Use fraction enum in squads module

pull/18/head
HardiReady 2017-11-08 19:35:34 +01:00
parent 67e57ac2b0
commit 5f6be06516
6 changed files with 17 additions and 9 deletions

View File

@ -18,8 +18,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">CSAT</option> <option value="OPFOR">{{fraction.OPFOR}}</option>
<option value="BLUFOR">NATO</option> <option value="BLUFOR">{{fraction.BLUFOR}}</option>
</select> </select>
<show-error text="Fraktion" path="fraction"></show-error> <show-error text="Fraktion" path="fraction"></show-error>
</div> </div>

View File

@ -4,6 +4,7 @@ import {NgForm} from "@angular/forms";
import {Squad} from "../../models/model-interfaces"; import {Squad} from "../../models/model-interfaces";
import {SquadService} from "../../services/army-management/squad.service"; import {SquadService} from "../../services/army-management/squad.service";
import {Subscription} from "rxjs/Subscription"; import {Subscription} from "rxjs/Subscription";
import {Fraction} from "../../utils/fraction.enum";
@Component({ @Component({
@ -28,6 +29,8 @@ export class EditSquadComponent {
@ViewChild(NgForm) form: NgForm; @ViewChild(NgForm) form: NgForm;
readonly fraction = Fraction;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private squadService: SquadService) { private squadService: SquadService) {

View File

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

View File

@ -1,6 +1,6 @@
import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core"; import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core";
import {Router} from "@angular/router";
import {Squad} from "../../models/model-interfaces"; import {Squad} from "../../models/model-interfaces";
import {Fraction} from "../../utils/fraction.enum";
@Component({ @Component({
selector: 'pjm-squad-item', selector: 'pjm-squad-item',
@ -20,7 +20,9 @@ export class SquadItemComponent {
imageSrc; imageSrc;
constructor(private router: Router) { readonly fraction = Fraction;
constructor() {
} }
ngOnInit() { ngOnInit() {

View File

@ -1,8 +1,8 @@
<div class="select-list"> <div class="select-list">
<div class="input-group list-header pull-left"> <div class="input-group list-header pull-left">
<div class="btn-group" (click)="filterSquads()"> <div class="btn-group" (click)="filterSquads()">
<label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="blufor" uncheckable>NATO</label> <label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="blufor" uncheckable>{{fraction.BLUFOR}}</label>
<label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="opfor" uncheckable>CSAT</label> <label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="opfor" uncheckable>{{fraction.OPFOR}}</label>
</div> </div>
<a class="pull-right btn btn-success" (click)="openNewSquadForm()">+</a> <a class="pull-right btn btn-success" (click)="openNewSquadForm()">+</a>
</div> </div>

View File

@ -6,6 +6,7 @@ import {ActivatedRoute, Router} from "@angular/router";
import {Observable} from "rxjs/Observable"; import {Observable} from "rxjs/Observable";
import {Squad} from "../../models/model-interfaces"; import {Squad} from "../../models/model-interfaces";
import {SquadService} from "../../services/army-management/squad.service"; import {SquadService} from "../../services/army-management/squad.service";
import {Fraction} from "../../utils/fraction.enum";
@Component({ @Component({
selector: 'squad-list', selector: 'squad-list',
@ -22,6 +23,8 @@ export class SquadListComponent implements OnInit {
public radioModel: string; public radioModel: string;
readonly fraction = Fraction;
constructor(private squadService: SquadService, constructor(private squadService: SquadService,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
@ -58,7 +61,7 @@ export class SquadListComponent implements OnInit {
} }
deleteSquad(squad) { deleteSquad(squad) {
const fraction = squad.fraction === 'OPFOR' ? 'CSAT' : 'NATO'; const fraction = squad.fraction === 'OPFOR' ? Fraction.OPFOR : Fraction.BLUFOR;
if (confirm('Soll das Squad "' + squad.name + '" (' + fraction + ') wirklich gelöscht werden?')) { if (confirm('Soll das Squad "' + squad.name + '" (' + fraction + ') wirklich gelöscht werden?')) {
this.squadService.deleteSquad(squad) this.squadService.deleteSquad(squad)
.subscribe((res) => { .subscribe((res) => {