Add possibility to remove ranks, catch error use-cases in signature creation and army-overview
parent
630668e032
commit
4c6f3dab78
|
@ -48,12 +48,16 @@ overview.route('/')
|
||||||
}, {sort: {rankLvl: 'desc', name: 'asc'}}, (err, users) => {
|
}, {sort: {rankLvl: 'desc', name: 'asc'}}, (err, users) => {
|
||||||
const squadMembers = [];
|
const squadMembers = [];
|
||||||
async.eachSeries(users, (user, callback) => {
|
async.eachSeries(users, (user, callback) => {
|
||||||
|
const usr = user.toObject();
|
||||||
RankModel.findOne({level: user.rankLvl, fraction: squad.fraction}, (err, rank) => {
|
RankModel.findOne({level: user.rankLvl, fraction: squad.fraction}, (err, rank) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
const usr = user.toObject();
|
|
||||||
|
// not defined if rank was deleted / rankLvl not available for fraction
|
||||||
|
if (rank) {
|
||||||
usr.rank = rank.name;
|
usr.rank = rank.name;
|
||||||
|
}
|
||||||
delete usr.rankLvl;
|
delete usr.rankLvl;
|
||||||
squadMembers.push(usr)
|
squadMembers.push(usr)
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ let createSignature = (userId, res, next) => {
|
||||||
return next(err)
|
return next(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
if (user.squadId.fraction === 'BLUFOR') {
|
if (user.squadId.fraction === 'BLUFOR') {
|
||||||
rankW = 25;
|
rankW = 25;
|
||||||
rankH = 60;
|
rankH = 60;
|
||||||
|
@ -93,6 +94,11 @@ let createSignature = (userId, res, next) => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
addDecorationsAndSave(userId, loadedImage, res, next);
|
addDecorationsAndSave(userId, loadedImage, res, next);
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
// user has not any assignable rank in his fraction at this point,
|
||||||
|
// e.g. assigned rank has been deleted or switched fraction so rankLvl is not defined
|
||||||
|
addDecorationsAndSave(userId, loadedImage, res, next);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
|
@ -7,6 +7,12 @@ div.rank-list-entry, a.rank-list-entry {
|
||||||
margin-bottom: -1px;
|
margin-bottom: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rank-list-preview {
|
||||||
|
height: 54px;
|
||||||
|
float: left;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.marked {
|
.marked {
|
||||||
background: lightgrey;
|
background: lightgrey;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +31,9 @@ small {
|
||||||
}
|
}
|
||||||
|
|
||||||
.trash {
|
.trash {
|
||||||
|
float:right;
|
||||||
padding-top: 18px;
|
padding-top: 18px;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
margin-left: -10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected {
|
.selected {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="fade-in rank-list-entry" [ngClass]="{selected : selected}" (click)="select()">
|
<div class="fade-in rank-list-entry" [ngClass]="{selected : selected}" (click)="select()">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-11">
|
<div class="col-xs-9">
|
||||||
<span>
|
<span>
|
||||||
<a>{{rank.name}}</a>
|
<a>{{rank.name}}</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -10,5 +10,12 @@
|
||||||
<small *ngIf="rank.fraction == 'BLUFOR'">NATO</small>
|
<small *ngIf="rank.fraction == 'BLUFOR'">NATO</small>
|
||||||
<small> - Stufe {{rank.level}}</small>
|
<small> - Stufe {{rank.level}}</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-xs-3">
|
||||||
|
<img src="resource/rank/{{rank._id}}.png" class="rank-list-preview">
|
||||||
|
<span (click)="delete(); $event.stopPropagation()" title="Löschen" class="glyphicon glyphicon-trash trash"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,7 +27,7 @@ export class RankItemComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete() {
|
delete() {
|
||||||
this.rankSelected.emit(this.rank);
|
this.rankDelete.emit(this.rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked() {
|
ngAfterViewChecked() {
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
(change)="filterRanksByFraction(query.value, fractRadioOpfor.value)">CSAT
|
(change)="filterRanksByFraction(query.value, fractRadioOpfor.value)">CSAT
|
||||||
</label>
|
</label>
|
||||||
</form>
|
</form>
|
||||||
|
<a class="pull-right btn btn-success" (click)="openNewRankForm()">
|
||||||
|
Neuen Rang hinzufügen
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group search-bar" style="padding-top: 0;">
|
<div class="input-group search-bar" style="padding-top: 0;">
|
||||||
|
|
|
@ -60,6 +60,15 @@ export class RankListComponent implements OnInit {
|
||||||
this.ranks$ = this.rankService.findRanks(query, fractionFilter);
|
this.ranks$ = this.rankService.findRanks(query, fractionFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteRank(rank) {
|
||||||
|
const fraction = rank.fraction === 'OPFOR' ? 'CSAT' : 'NATO';
|
||||||
|
if (confirm('Soll der Rang ' + rank.name + ' (' + fraction + ') wirklich gelöscht werden?')) {
|
||||||
|
this.rankService.deleteRank(rank)
|
||||||
|
.subscribe((res) => {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
adjustBrowserUrl(queryString = '') {
|
adjustBrowserUrl(queryString = '') {
|
||||||
const absoluteUrl = this.location.path().split('?')[0];
|
const absoluteUrl = this.location.path().split('?')[0];
|
||||||
const queryPart = queryString !== '' ? `query=${queryString}` : '';
|
const queryPart = queryString !== '' ? `query=${queryString}` : '';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Decoration, Rank} from "../../models/model-interfaces";
|
||||||
import {RequestMethod, RequestOptions, URLSearchParams} from "@angular/http";
|
import {RequestMethod, RequestOptions, URLSearchParams} from "@angular/http";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {LOAD} from "../stores/decoration.store";
|
import {LOAD} from "../stores/decoration.store";
|
||||||
import {EDIT, RankStore} from "../stores/rank.store";
|
import {EDIT, RankStore, REMOVE} from "../stores/rank.store";
|
||||||
import {AppConfig} from "../../app.config";
|
import {AppConfig} from "../../app.config";
|
||||||
import {HttpClient} from "../http-client";
|
import {HttpClient} from "../http-client";
|
||||||
|
|
||||||
|
@ -84,6 +84,13 @@ export class RankService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteRank(rank: Rank) {
|
||||||
|
return this.http.delete(this.config.apiUrl + this.config.apiRankPath + rank._id)
|
||||||
|
.do(res => {
|
||||||
|
this.rankStore.dispatch({type: REMOVE, data: rank});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,11 +66,11 @@
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-sm-1" style="width: 60px;">Bild</th>
|
<th class="col-sm-1">Bild</th>
|
||||||
<th class="col-sm-2">Bezeichnung</th>
|
<th class="col-sm-2">Bezeichnung</th>
|
||||||
<th class="col-sm-2">Begründung</th>
|
<th class="col-sm-2">Begründung</th>
|
||||||
<th class="col-sm-1 text-right" style="width: 65px;">Datum</th>
|
<th class="col-sm-1 text-right">Datum</th>
|
||||||
<th class="col-sm-1 text-center" style="width: 45px;"></th>
|
<th class="col-sm-1 text-center"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody *ngFor="let award of awards">
|
<tbody *ngFor="let award of awards">
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xs-3">
|
<div class="col-xs-3">
|
||||||
<span (click)="select()" title="Bearbeiten" class="glyphicon glyphicon-pencil pull-left edit"></span>
|
<span (click)="select()" title="Name, Squad, Rang" class="glyphicon glyphicon-pencil pull-left edit"></span>
|
||||||
<span (click)="award()" title="Auszeichnungen" class="icon-award pull-left"></span>
|
<span (click)="award()" title="Auszeichnungen" class="icon-award pull-left"></span>
|
||||||
<span (click)="delete(); $event.stopPropagation()" title="Löschen" class="glyphicon glyphicon-trash trash"></span>
|
<span (click)="delete(); $event.stopPropagation()" title="Löschen" class="glyphicon glyphicon-trash trash"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue