Fix request pages

pull/14/head
Florian Hartwich 2017-10-14 17:47:55 +02:00
parent a9ce56a270
commit 43960fa3af
4 changed files with 18 additions and 18 deletions

View File

@ -22,7 +22,7 @@
<div class="form-group"> <div class="form-group">
<label for="user">Aktueller Rang</label> <label for="user">Aktueller Rang</label>
<input class="form-control" <input class="form-control"
[(ngModel)]="user.rank.name" [(ngModel)]="selectedUserRank"
[ngModelOptions]="{standalone: true}" [ngModelOptions]="{standalone: true}"
readonly> readonly>
</div> </div>
@ -53,7 +53,7 @@
*ngIf="showForm" *ngIf="showForm"
(click)="addPromotion()" (click)="addPromotion()"
class="btn btn-default" class="btn btn-default"
[disabled]="newLevel === user.rank.level"> [disabled]="newLevel === user.rankLvl">
Bestätigen Bestätigen
</button> </button>

View File

@ -30,6 +30,8 @@ export class RequestPromotionComponent {
uncheckedPromotions = []; uncheckedPromotions = [];
selectedUserRank;
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private userService: UserService, private userService: UserService,
@ -56,7 +58,8 @@ export class RequestPromotionComponent {
toggleUser() { toggleUser() {
if (this.user._id != '0') { if (this.user._id != '0') {
this.showForm = true; this.showForm = true;
this.newLevel = this.user.rank.level; this.newLevel = this.user.rankLvl;
this.selectedUserRank = this.ranks.filter(rank => rank.level === this.user.rankLvl).map(rank => rank.name);
} else { } else {
this.showForm = false; this.showForm = false;
} }
@ -66,20 +69,20 @@ export class RequestPromotionComponent {
addPromotion() { addPromotion() {
const promotion = { const promotion = {
"userId": this.user._id, "userId": this.user._id,
"oldRankLvl": this.user.rank.level, "oldRankLvl": this.user.rankLvl,
"newRankLvl": this.newLevel "newRankLvl": this.newLevel
}; };
this.promotionService.requestPromotion(promotion).subscribe(() => { this.promotionService.requestPromotion(promotion).subscribe(() => {
this.showSuccessLabel = true;
setTimeout(() => {
this.showSuccessLabel = false;
}, 2000);
this.showForm = false;
this.user = {};
let currentUser = this.loginService.getCurrentUser(); let currentUser = this.loginService.getCurrentUser();
this.promotionService.getSquadPromotions(currentUser.squad._id).subscribe(promotions => { this.promotionService.getSquadPromotions(currentUser.squad._id).subscribe(promotions => {
this.uncheckedPromotions = promotions; this.uncheckedPromotions = promotions;
this.showForm = false;
this.user = {_id: '0'};
this.showSuccessLabel = true;
setTimeout(() => {
this.showSuccessLabel = false;
}, 2000);
}) })
}); });
} }

View File

@ -19,7 +19,7 @@ export class UserService {
this.users$ = userStore.items$; this.users$ = userStore.items$;
} }
findUsers(query = '', fractionFilter?, squadFilter?, limit?, offset?, action?) { findUsers(query = '', fractionFilter?, squadFilter?, limit?, offset?, action = LOAD) {
const searchParams = new URLSearchParams(); const searchParams = new URLSearchParams();
searchParams.append('q', query); searchParams.append('q', query);
if (fractionFilter) { if (fractionFilter) {
@ -33,14 +33,12 @@ export class UserService {
this.http.get(this.config.apiUserPath, searchParams) this.http.get(this.config.apiUserPath, searchParams)
.do((res) => { .do((res) => {
let headerCount = parseInt(res.headers.get('x-total-count')); let headerCount = parseInt(res.headers.get('x-total-count'));
console.log(headerCount)
if (headerCount) { if (headerCount) {
this.totalCount = headerCount; this.totalCount = headerCount;
} }
let users = res.json(); }).map(res => res.json()).do((users) => {
this.userStore.dispatch({type: action, data: users}); this.userStore.dispatch({type: action, data: users});
}).subscribe(_ => { }).subscribe(_ => {});
});
return this.users$; return this.users$;
} }

View File

@ -79,8 +79,7 @@ export class UserListComponent implements OnInit {
} }
filterUsers(action?) { filterUsers(action?) {
if (!action || (action && action === LOAD)) { if (!action || action === LOAD) {
action = LOAD;
this.offset = 0; this.offset = 0;
this.limit = 20; this.limit = 20;
} }