Deep copy when editing board to prevent in-memory changes
This commit is contained in:
parent
3cb62e56c0
commit
9a5aa36912
@ -184,6 +184,20 @@ export class BoardAdmin {
|
|||||||
return category.defaultColor;
|
return category.defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private deepCopy(source: any) {
|
||||||
|
var output: any, value: any, key: any;
|
||||||
|
|
||||||
|
output = Array.isArray(source) ? [] : {};
|
||||||
|
|
||||||
|
for (key in source) {
|
||||||
|
value = source[key];
|
||||||
|
output[key] = (typeof value === "object") ?
|
||||||
|
this.deepCopy(value) : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
private showModal(title: string, board?: Board): void {
|
private showModal(title: string, board?: Board): void {
|
||||||
let isAdd = (title === 'Add');
|
let isAdd = (title === 'Add');
|
||||||
|
|
||||||
@ -196,16 +210,14 @@ export class BoardAdmin {
|
|||||||
} else {
|
} else {
|
||||||
this.modalProps.id = board.id;
|
this.modalProps.id = board.id;
|
||||||
this.modalProps.boardName = board.name;
|
this.modalProps.boardName = board.name;
|
||||||
this.modalProps.columns = board.columns.slice();
|
this.modalProps.columns = this.deepCopy(board.columns);
|
||||||
this.modalProps.categories = board.categories.slice();
|
this.modalProps.categories = this.deepCopy(board.categories);
|
||||||
this.modalProps.issueTrackers = board.issue_trackers.slice();
|
this.modalProps.issueTrackers = this.deepCopy(board.issue_trackers);
|
||||||
|
|
||||||
this.users.forEach((user: SelectableUser) => {
|
this.users.forEach((user: SelectableUser) => {
|
||||||
let filtered = board.users.filter(u => u.id === user.id);
|
let filtered = board.users.filter(u => u.id === user.id);
|
||||||
|
|
||||||
if (filtered.length) {
|
user.selected = filtered.length > 0;
|
||||||
user.selected = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user