Refactor to update boards on user changes
This commit is contained in:
parent
5aa6882e5c
commit
98ce544c9e
@ -58,18 +58,7 @@ export class UserAdmin {
|
|||||||
settings.getUsers()
|
settings.getUsers()
|
||||||
.subscribe((response: ApiResponse) => {
|
.subscribe((response: ApiResponse) => {
|
||||||
this.users = response.data[1];
|
this.users = response.data[1];
|
||||||
|
this.getBoards();
|
||||||
this.settings.getBoards()
|
|
||||||
.subscribe((response: ApiResponse) => {
|
|
||||||
let boards = response.data[1];
|
|
||||||
if (boards) {
|
|
||||||
this.boards = boards;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.settings.updateBoards(this.boards);
|
|
||||||
this.updateUserList();
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +77,7 @@ export class UserAdmin {
|
|||||||
response.alerts.forEach(note => this.notes.add(note));
|
response.alerts.forEach(note => this.notes.add(note));
|
||||||
|
|
||||||
this.replaceUserList(response);
|
this.replaceUserList(response);
|
||||||
|
this.closeModal(response.status);
|
||||||
if (response.status === 'success') {
|
|
||||||
this.modal.close(this.MODAL_ID);
|
|
||||||
this.saving = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -103,11 +88,7 @@ export class UserAdmin {
|
|||||||
response.alerts.forEach(note => this.notes.add(note));
|
response.alerts.forEach(note => this.notes.add(note));
|
||||||
|
|
||||||
this.replaceUser(JSON.parse(response.data[1]));
|
this.replaceUser(JSON.parse(response.data[1]));
|
||||||
|
this.closeModal(response.status);
|
||||||
if (response.status === 'success') {
|
|
||||||
this.modal.close(this.MODAL_ID);
|
|
||||||
this.saving = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +100,34 @@ export class UserAdmin {
|
|||||||
|
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
this.modal.close(this.MODAL_CONFIRM_ID);
|
this.modal.close(this.MODAL_CONFIRM_ID);
|
||||||
|
this.getBoards();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private closeModal(status: string): void {
|
||||||
|
if (status === 'success') {
|
||||||
|
this.modal.close(this.MODAL_ID);
|
||||||
|
this.saving = false;
|
||||||
|
|
||||||
|
this.getBoards();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getBoards(): void {
|
||||||
|
this.settings.getBoards()
|
||||||
|
.subscribe((response: ApiResponse) => {
|
||||||
|
let boards = response.data[1];
|
||||||
|
if (boards) {
|
||||||
|
this.boards = boards;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.settings.updateBoards(this.boards);
|
||||||
|
this.updateUserList();
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private replaceUser(newUser: User) {
|
private replaceUser(newUser: User) {
|
||||||
this.users.forEach((user, index) => {
|
this.users.forEach((user, index) => {
|
||||||
if (user.id === newUser.id) {
|
if (user.id === newUser.id) {
|
||||||
|
Reference in New Issue
Block a user