Fix request pages
parent
a9ce56a270
commit
43960fa3af
|
@ -22,7 +22,7 @@
|
|||
<div class="form-group">
|
||||
<label for="user">Aktueller Rang</label>
|
||||
<input class="form-control"
|
||||
[(ngModel)]="user.rank.name"
|
||||
[(ngModel)]="selectedUserRank"
|
||||
[ngModelOptions]="{standalone: true}"
|
||||
readonly>
|
||||
</div>
|
||||
|
@ -53,7 +53,7 @@
|
|||
*ngIf="showForm"
|
||||
(click)="addPromotion()"
|
||||
class="btn btn-default"
|
||||
[disabled]="newLevel === user.rank.level">
|
||||
[disabled]="newLevel === user.rankLvl">
|
||||
Bestätigen
|
||||
</button>
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ export class RequestPromotionComponent {
|
|||
|
||||
uncheckedPromotions = [];
|
||||
|
||||
selectedUserRank;
|
||||
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private userService: UserService,
|
||||
|
@ -56,7 +58,8 @@ export class RequestPromotionComponent {
|
|||
toggleUser() {
|
||||
if (this.user._id != '0') {
|
||||
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 {
|
||||
this.showForm = false;
|
||||
}
|
||||
|
@ -66,20 +69,20 @@ export class RequestPromotionComponent {
|
|||
addPromotion() {
|
||||
const promotion = {
|
||||
"userId": this.user._id,
|
||||
"oldRankLvl": this.user.rank.level,
|
||||
"oldRankLvl": this.user.rankLvl,
|
||||
"newRankLvl": this.newLevel
|
||||
};
|
||||
|
||||
this.promotionService.requestPromotion(promotion).subscribe(() => {
|
||||
this.showSuccessLabel = true;
|
||||
setTimeout(() => {
|
||||
this.showSuccessLabel = false;
|
||||
}, 2000);
|
||||
this.showForm = false;
|
||||
this.user = {};
|
||||
let currentUser = this.loginService.getCurrentUser();
|
||||
this.promotionService.getSquadPromotions(currentUser.squad._id).subscribe(promotions => {
|
||||
this.uncheckedPromotions = promotions;
|
||||
this.showForm = false;
|
||||
this.user = {_id: '0'};
|
||||
this.showSuccessLabel = true;
|
||||
setTimeout(() => {
|
||||
this.showSuccessLabel = false;
|
||||
}, 2000);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export class UserService {
|
|||
this.users$ = userStore.items$;
|
||||
}
|
||||
|
||||
findUsers(query = '', fractionFilter?, squadFilter?, limit?, offset?, action?) {
|
||||
findUsers(query = '', fractionFilter?, squadFilter?, limit?, offset?, action = LOAD) {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('q', query);
|
||||
if (fractionFilter) {
|
||||
|
@ -33,14 +33,12 @@ export class UserService {
|
|||
this.http.get(this.config.apiUserPath, searchParams)
|
||||
.do((res) => {
|
||||
let headerCount = parseInt(res.headers.get('x-total-count'));
|
||||
console.log(headerCount)
|
||||
if (headerCount) {
|
||||
this.totalCount = headerCount;
|
||||
}
|
||||
let users = res.json();
|
||||
this.userStore.dispatch({type: action, data: users});
|
||||
}).subscribe(_ => {
|
||||
});
|
||||
}).map(res => res.json()).do((users) => {
|
||||
this.userStore.dispatch({type: action, data: users});
|
||||
}).subscribe(_ => {});
|
||||
|
||||
return this.users$;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,7 @@ export class UserListComponent implements OnInit {
|
|||
}
|
||||
|
||||
filterUsers(action?) {
|
||||
if (!action || (action && action === LOAD)) {
|
||||
action = LOAD;
|
||||
if (!action || action === LOAD) {
|
||||
this.offset = 0;
|
||||
this.limit = 20;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue