Use fraction enum in decoration module
parent
055ac797de
commit
761ac758ff
|
@ -6,8 +6,8 @@
|
||||||
<a>{{decoration.name}}</a>
|
<a>{{decoration.name}}</a>
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
<small *ngIf="decoration.fraction == 'OPFOR'">CSAT</small>
|
<small *ngIf="decoration.fraction == 'OPFOR'">{{fraction.OPFOR}}</small>
|
||||||
<small *ngIf="decoration.fraction == 'BLUFOR'">NATO</small>
|
<small *ngIf="decoration.fraction == 'BLUFOR'">{{fraction.BLUFOR}}</small>
|
||||||
<small *ngIf="decoration.fraction == 'GLOBAL'">Global</small>
|
<small *ngIf="decoration.fraction == 'GLOBAL'">Global</small>
|
||||||
<small> - Sortierung: {{decoration.sortingNumber}}</small>
|
<small> - Sortierung: {{decoration.sortingNumber}}</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core";
|
import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core";
|
||||||
import {Router} from "@angular/router";
|
|
||||||
import {Decoration} from "../../models/model-interfaces";
|
import {Decoration} from "../../models/model-interfaces";
|
||||||
|
import {Fraction} from "../../utils/fraction.enum";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pjm-decoration-item',
|
selector: 'decoration-item',
|
||||||
templateUrl: './decoration-item.component.html',
|
templateUrl: './decoration-item.component.html',
|
||||||
styleUrls: ['./decoration-item.component.css', '../../style/list-entry.css'],
|
styleUrls: ['./decoration-item.component.css', '../../style/list-entry.css'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
@ -20,7 +20,9 @@ export class DecorationItemComponent {
|
||||||
decorationSelected = new EventEmitter();
|
decorationSelected = new EventEmitter();
|
||||||
decorationDelete = new EventEmitter();
|
decorationDelete = new EventEmitter();
|
||||||
|
|
||||||
constructor(private router: Router) {
|
readonly fraction = Fraction;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<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)="filterDecorations()">
|
<div class="btn-group" (click)="filterDecorations()">
|
||||||
<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>
|
||||||
<label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="global" uncheckable>Global</label>
|
<label class="btn btn-success" [(ngModel)]="radioModel" btnRadio="GLOBAL" uncheckable>Global</label>
|
||||||
</div>
|
</div>
|
||||||
<a class="pull-right btn btn-success" (click)="openNewDecorationForm()">+</a>
|
<a class="pull-right btn btn-success" (click)="openNewDecorationForm()">+</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,12 +22,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<pjm-decoration-item *ngFor="let decoration of decorations$ | async"
|
<decoration-item *ngFor="let decoration of decorations$ | async"
|
||||||
[decoration]="decoration"
|
[decoration]="decoration"
|
||||||
(decorationDelete)="deleteDecoration(decoration)"
|
(decorationDelete)="deleteDecoration(decoration)"
|
||||||
(decorationSelected)="selectDecoration($event)"
|
(decorationSelected)="selectDecoration($event)"
|
||||||
[selected]="decoration._id == selectedDecorationId">
|
[selected]="decoration._id == selectedDecorationId">
|
||||||
</pjm-decoration-item>
|
</decoration-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {Decoration} from "../../models/model-interfaces";
|
import {Decoration} from "../../models/model-interfaces";
|
||||||
import {DecorationService} from "../../services/army-management/decoration.service";
|
import {DecorationService} from "../../services/army-management/decoration.service";
|
||||||
|
import {Fraction} from "../../utils/fraction.enum";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'decoration-list',
|
selector: 'decoration-list',
|
||||||
|
@ -22,6 +23,8 @@ export class DecorationListComponent implements OnInit {
|
||||||
|
|
||||||
public radioModel: string;
|
public radioModel: string;
|
||||||
|
|
||||||
|
readonly fraction = Fraction;
|
||||||
|
|
||||||
constructor(private decorationService: DecorationService,
|
constructor(private decorationService: DecorationService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
@ -29,7 +32,6 @@ export class DecorationListComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.decorations$ = this.decorationService.decorations$;
|
this.decorations$ = this.decorationService.decorations$;
|
||||||
|
|
||||||
const paramsStream = this.route.queryParams
|
const paramsStream = this.route.queryParams
|
||||||
|
@ -44,7 +46,6 @@ export class DecorationListComponent implements OnInit {
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.switchMap(query => this.decorationService.findDecorations(query, this.radioModel))
|
.switchMap(query => this.decorationService.findDecorations(query, this.radioModel))
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openNewDecorationForm() {
|
openNewDecorationForm() {
|
||||||
|
@ -59,8 +60,8 @@ export class DecorationListComponent implements OnInit {
|
||||||
|
|
||||||
deleteDecoration(decoration) {
|
deleteDecoration(decoration) {
|
||||||
let fraction = 'Global';
|
let fraction = 'Global';
|
||||||
if (decoration.fraction === 'BLUFOR') fraction = 'NATO';
|
if (decoration.fraction === 'BLUFOR') fraction = Fraction.BLUFOR;
|
||||||
else if (decoration.fraction === 'OPFOR') fraction = 'CSAT';
|
else if (decoration.fraction === 'OPFOR') fraction = Fraction.OPFOR;
|
||||||
|
|
||||||
if (confirm('Soll die Auszeichnung "' + decoration.name + '" (' + fraction + ') wirklich gelöscht werden?')) {
|
if (confirm('Soll die Auszeichnung "' + decoration.name + '" (' + fraction + ') wirklich gelöscht werden?')) {
|
||||||
this.decorationService.deleteDecoration(decoration)
|
this.decorationService.deleteDecoration(decoration)
|
||||||
|
|
|
@ -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)]="decoration.fraction">
|
[(ngModel)]="decoration.fraction">
|
||||||
<option value="OPFOR">CSAT</option>
|
<option value="OPFOR">{{fraction.OPFOR}}</option>
|
||||||
<option value="BLUFOR">NATO</option>
|
<option value="BLUFOR">{{fraction.BLUFOR}}</option>
|
||||||
<option value="GLOBAL">Global</option>
|
<option value="GLOBAL">Global</option>
|
||||||
</select>
|
</select>
|
||||||
<show-error text="Fraktion" path="fraction"></show-error>
|
<show-error text="Fraktion" path="fraction"></show-error>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {NgForm} from "@angular/forms";
|
||||||
import {Decoration} from "../../models/model-interfaces";
|
import {Decoration} from "../../models/model-interfaces";
|
||||||
import {DecorationService} from "../../services/army-management/decoration.service";
|
import {DecorationService} from "../../services/army-management/decoration.service";
|
||||||
import {Subscription} from "rxjs/Subscription";
|
import {Subscription} from "rxjs/Subscription";
|
||||||
|
import {Fraction} from "../../utils/fraction.enum";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './edit-decoration.component.html',
|
templateUrl: './edit-decoration.component.html',
|
||||||
|
@ -25,6 +26,8 @@ export class EditDecorationComponent {
|
||||||
|
|
||||||
@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 decorationService: DecorationService) {
|
private decorationService: DecorationService) {
|
||||||
|
|
Loading…
Reference in New Issue