Fix: Bug fix for repeated board-add for options

This commit is contained in:
winkidney
2019-12-06 20:30:29 +08:00
committed by Isaac Bythewood
parent ee0c7b97a0
commit acdf22210b
2 changed files with 17 additions and 13 deletions

View File

@@ -57,6 +57,19 @@ function getBoardFromResp(boardObject) {
return { name: boardObject.name, value: boardObject.id }; return { name: boardObject.name, value: boardObject.id };
} }
function getAvailableOptions(vm, filter) {
let availableOptions;
if (filter === '' || filter === null) {
availableOptions = vm.allOptions;
} else {
availableOptions = getFilteredOptions(
vm.allOptions, vm.form.name.value,
);
}
return availableOptions;
}
export default { export default {
name: 'FilterSelect', name: 'FilterSelect',
props: { props: {
@@ -89,6 +102,8 @@ export default {
self.$emit('boardCreated', data); self.$emit('boardCreated', data);
const board = getBoardFromResp(data); const board = getBoardFromResp(data);
self.createdOptions.unshift(board); self.createdOptions.unshift(board);
const options = getAvailableOptions(this);
this.availableOptions = this.createdOptions.concat(options);
self.select(board); self.select(board);
self.form.name.value = null; self.form.name.value = null;
}, },
@@ -101,18 +116,8 @@ export default {
watch: { watch: {
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
'form.name.value': function (newVal) { 'form.name.value': function (newVal) {
let availableOptions; const options = getAvailableOptions(this, newVal);
if (newVal === '' || newVal === null) { this.availableOptions = this.createdOptions.concat(options);
availableOptions = this.allOptions;
} else {
availableOptions = getFilteredOptions(
this.allOptions, this.form.name.value,
);
}
this.availableOptions = this.createdOptions.concat(availableOptions);
},
createdOptions() {
this.availableOptions = this.createdOptions.concat(this.availableOptions);
}, },
allOptions() { allOptions() {
this.availableOptions = this.allOptions; this.availableOptions = this.allOptions;

View File

@@ -133,7 +133,6 @@ export default {
); );
}, },
onSelectBoard(boardIds) { onSelectBoard(boardIds) {
console.log('boardId', boardIds);
this.boardIds = boardIds; this.boardIds = boardIds;
}, },
onUploadProcessing() { onUploadProcessing() {