This commit is contained in:
2020-07-29 19:16:58 +00:00
parent 9a3aeab8f8
commit d8e4a45e8a
2 changed files with 16 additions and 25 deletions

View File

@@ -5,7 +5,8 @@
item-value="id"
multiple
chips
:value="selectedRoles"
deletable-chips
:value="selectedValue"
@input="handleInput"
:readonly="readonly"
:disabled="disabled"
@@ -27,16 +28,9 @@ export default {
data() {
return {
internalValue: null,
selectedRoles: [],
availableRoles: []
};
},
watch: {
value(val) {
this.internalValue = val;
this.setSelectedItems();
}
},
props: {
label: String,
rules: Array,
@@ -50,6 +44,20 @@ export default {
},
testId: String
},
computed: {
selectedValue() {
let ret = [];
if (this.value != null && this.value != 0) {
for (let i = 0; i < this.availableRoles.length; i++) {
let role = this.availableRoles[i];
if (!!(this.value & role.id)) {
ret.push(role.id);
}
}
}
return ret;
}
},
methods: {
allErrors() {
let ret = "";
@@ -61,19 +69,6 @@ export default {
}
return ret;
},
setSelectedItems() {
//turn internalValue numeric bitfield role value into array of selected roles
let ret = [];
if (this.internalValue != null && this.internalValue != 0) {
for (let i = 0; i < this.availableRoles.length; i++) {
let role = this.availableRoles[i];
if (!!(this.internalValue & role.id)) {
ret.push(role.id);
}
}
}
this.selectedRoles = [...ret];
},
handleInput(value) {
let newValue = 0;
if (value != null && value != [] && value.length > 0) {