Commit fa78cc51 authored by Simon Knox's avatar Simon Knox

fix initial selected item for user dropdown

moves state management to board form component
parent 52e37496
......@@ -49,7 +49,7 @@ export default {
},
data() {
return {
board: Store.boardConfig,
board: { ...Store.state.currentBoard },
expanded: false,
issue: {},
currentBoard: Store.state.currentBoard,
......@@ -151,15 +151,23 @@ export default {
resetFormState() {
if (this.isNewForm) {
// Clear the form when we open the "New board" modal
Store.updateBoardConfig();
this.board = {
id: false,
name: '',
labels: [],
milestone: {},
milestone_id: undefined,
assignee: {},
assignee_id: undefined,
weight: null,
};
} else if (this.currentBoard && Object.keys(this.currentBoard).length) {
Store.updateBoardConfig(this.currentBoard);
this.board = { ...this.currentBoard };
}
},
},
mounted() {
this.resetFormState();
if (this.$refs.name) {
this.$refs.name.focus();
}
......
......@@ -44,8 +44,7 @@ export default {
},
selected: {
type: Object,
required: false,
default: () => ({}),
required: true,
},
wrapperClass: {
type: String,
......@@ -59,8 +58,11 @@ export default {
},
computed: {
hasValue() {
return this.selected.id;
return this.selected.id > 0;
},
selectedId() {
return this.selected ? this.selected.id : null;
}
},
watch: {
selected() {
......@@ -74,12 +76,15 @@ export default {
});
},
selectUser(user, isMarking) {
if (isMarking) {
gl.issueBoards.BoardsStore.boardConfig.assignee = user;
} else {
let assignee = user;
if (!isMarking) {
// correctly select "unassigned" in Assignee dropdown
gl.issueBoards.BoardsStore.boardConfig.assignee = { id: undefined };
assignee = {
id: undefined,
};
}
this.board.assignee_id = user.id;
this.board.assignee = user;
},
},
mounted() {
......@@ -144,7 +149,7 @@ export default {
:data-any-user="anyUserText"
:data-group-id="groupId"
:data-project-id="projectId"
:data-selected="selected.id"
:data-selected="selectedId"
data-toggle="dropdown"
aria-expanded="false"
type="button"
......
......@@ -11,28 +11,6 @@ class BoardsStoreEE {
this.store.removePromotionState = () => {
this.removePromotion();
};
this.store.boardConfig = {
id: false,
name: '',
labels: [],
milestone: {},
milestone_id: undefined,
assignee: {},
assignee_id: undefined,
weight: null,
};
this.store.updateBoardConfig = this.updateBoardConfig;
}
updateBoardConfig(board = {}) {
this.boardConfig.id = board.id;
this.boardConfig.name = board.name;
this.boardConfig.milestone_id = board.milestone_id;
this.boardConfig.milestone = board.milestone;
this.boardConfig.labels = board.labels || [];
this.boardConfig.assignee = board.assignee || {};
this.boardConfig.assignee_id = board.assignee_id;
this.boardConfig.weight = board.weight;
}
shouldAddPromotionState() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment