diff --git a/api/routes/overview.js b/api/routes/overview.js index 38a302f..08b815e 100644 --- a/api/routes/overview.js +++ b/api/routes/overview.js @@ -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(); - usr.rank = rank.name; + + // not defined if rank was deleted / rankLvl not available for fraction + if (rank) { + usr.rank = rank.name; + } delete usr.rankLvl; squadMembers.push(usr) diff --git a/api/signature-tool/signature-tool.js b/api/signature-tool/signature-tool.js index 0c0c1b0..3d0c63f 100644 --- a/api/signature-tool/signature-tool.js +++ b/api/signature-tool/signature-tool.js @@ -71,28 +71,34 @@ let createSignature = (userId, res, next) => { return next(err) } - if (user.squadId.fraction === 'BLUFOR') { - rankW = 25; - rankH = 60; - rankX = 36; - rankY = 34; - } else { - rankW = 37; - rankH = 58; - rankX = 30; - rankY = 34; - } + if (result) { + if (user.squadId.fraction === 'BLUFOR') { + rankW = 25; + rankH = 60; + rankX = 36; + rankY = 34; + } else { + rankW = 37; + rankH = 58; + rankX = 30; + rankY = 34; + } - jimp.read(resourceDir + 'rank/' + result._id + fileExt) - .then((rankImage) => { - rankImage.resize(rankW, rankH); - loadedImage - .print(font, 128, 55, result.name) - .composite(rankImage, rankX, rankY) - }) - .then(() => { - addDecorationsAndSave(userId, loadedImage, res, next); - }) + jimp.read(resourceDir + 'rank/' + result._id + fileExt) + .then((rankImage) => { + rankImage.resize(rankW, rankH); + loadedImage + .print(font, 128, 55, result.name) + .composite(rankImage, rankX, rankY) + }) + .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) => { diff --git a/static/src/app/ranks/rank-list/rank-item.component.css b/static/src/app/ranks/rank-list/rank-item.component.css index fcbdddd..03fd95c 100644 --- a/static/src/app/ranks/rank-list/rank-item.component.css +++ b/static/src/app/ranks/rank-list/rank-item.component.css @@ -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 { diff --git a/static/src/app/ranks/rank-list/rank-item.component.html b/static/src/app/ranks/rank-list/rank-item.component.html index 419e470..e960ace 100644 --- a/static/src/app/ranks/rank-list/rank-item.component.html +++ b/static/src/app/ranks/rank-list/rank-item.component.html @@ -1,7 +1,7 @@
-
+
{{rank.name}} @@ -10,5 +10,12 @@ NATO - Stufe {{rank.level}}
+ +
+ + +
+ +
diff --git a/static/src/app/ranks/rank-list/rank-item.component.ts b/static/src/app/ranks/rank-list/rank-item.component.ts index e984650..e602091 100644 --- a/static/src/app/ranks/rank-list/rank-item.component.ts +++ b/static/src/app/ranks/rank-list/rank-item.component.ts @@ -27,7 +27,7 @@ export class RankItemComponent { } delete() { - this.rankSelected.emit(this.rank); + this.rankDelete.emit(this.rank); } ngAfterViewChecked() { diff --git a/static/src/app/ranks/rank-list/rank-list.component.html b/static/src/app/ranks/rank-list/rank-list.component.html index 0de99ff..eb9bd6e 100644 --- a/static/src/app/ranks/rank-list/rank-list.component.html +++ b/static/src/app/ranks/rank-list/rank-list.component.html @@ -21,6 +21,9 @@ (change)="filterRanksByFraction(query.value, fractRadioOpfor.value)">CSAT + + Neuen Rang hinzufügen +