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) => {
|
||||
const squadMembers = [];
|
||||
async.eachSeries(users, (user, callback) => {
|
||||
const usr = user.toObject();
|
||||
RankModel.findOne({level: user.rankLvl, fraction: squad.fraction}, (err, rank) => {
|
||||
if (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;
|
||||
}
|
||||
delete usr.rankLvl;
|
||||
squadMembers.push(usr)
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ let createSignature = (userId, res, next) => {
|
|||
return next(err)
|
||||
}
|
||||
|
||||
if (result) {
|
||||
if (user.squadId.fraction === 'BLUFOR') {
|
||||
rankW = 25;
|
||||
rankH = 60;
|
||||
|
@ -93,6 +94,11 @@ let createSignature = (userId, res, next) => {
|
|||
.then(() => {
|
||||
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) => {
|
||||
|
|
|
@ -7,6 +7,12 @@ div.rank-list-entry, a.rank-list-entry {
|
|||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.rank-list-preview {
|
||||
height: 54px;
|
||||
float: left;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.marked {
|
||||
background: lightgrey;
|
||||
}
|
||||
|
@ -25,9 +31,9 @@ small {
|
|||
}
|
||||
|
||||
.trash {
|
||||
float:right;
|
||||
padding-top: 18px;
|
||||
font-size: 17px;
|
||||
margin-left: -10px;
|
||||
}
|
||||
|
||||
.selected {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="fade-in rank-list-entry" [ngClass]="{selected : selected}" (click)="select()">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-11">
|
||||
<div class="col-xs-9">
|
||||
<span>
|
||||
<a>{{rank.name}}</a>
|
||||
</span>
|
||||
|
@ -10,5 +10,12 @@
|
|||
<small *ngIf="rank.fraction == 'BLUFOR'">NATO</small>
|
||||
<small> - Stufe {{rank.level}}</small>
|
||||
</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>
|
||||
|
|
|
@ -27,7 +27,7 @@ export class RankItemComponent {
|
|||
}
|
||||
|
||||
delete() {
|
||||
this.rankSelected.emit(this.rank);
|
||||
this.rankDelete.emit(this.rank);
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
(change)="filterRanksByFraction(query.value, fractRadioOpfor.value)">CSAT
|
||||
</label>
|
||||
</form>
|
||||
<a class="pull-right btn btn-success" (click)="openNewRankForm()">
|
||||
Neuen Rang hinzufügen
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<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);
|
||||
}
|
||||
|
||||
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 = '') {
|
||||
const absoluteUrl = this.location.path().split('?')[0];
|
||||
const queryPart = queryString !== '' ? `query=${queryString}` : '';
|
||||
|
|
|
@ -3,7 +3,7 @@ import {Decoration, Rank} from "../../models/model-interfaces";
|
|||
import {RequestMethod, RequestOptions, URLSearchParams} from "@angular/http";
|
||||
import {Observable} from "rxjs/Observable";
|
||||
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 {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">
|
||||
<thead>
|
||||
<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">Begründung</th>
|
||||
<th class="col-sm-1 text-right" style="width: 65px;">Datum</th>
|
||||
<th class="col-sm-1 text-center" style="width: 45px;"></th>
|
||||
<th class="col-sm-1 text-right">Datum</th>
|
||||
<th class="col-sm-1 text-center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody *ngFor="let award of awards">
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
|
||||
<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)="delete(); $event.stopPropagation()" title="Löschen" class="glyphicon glyphicon-trash trash"></span>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue