Fixed #90 - optionValue and dataKey combination is broken is Select Components
parent
d2b278ce0a
commit
e590e10258
|
@ -97,7 +97,7 @@ export default {
|
|||
|
||||
if (this.value != null && this.options) {
|
||||
for (let option of this.options) {
|
||||
if ((ObjectUtils.equals(this.value, this.getOptionValue(option), this.dataKey))) {
|
||||
if ((ObjectUtils.equals(this.value, this.getOptionValue(option), this.equalityKey))) {
|
||||
selectedOption = option;
|
||||
break;
|
||||
}
|
||||
|
@ -107,14 +107,14 @@ export default {
|
|||
return selectedOption;
|
||||
},
|
||||
isSelected(option) {
|
||||
return ObjectUtils.equals(this.value, this.getOptionValue(option), this.dataKey);
|
||||
return ObjectUtils.equals(this.value, this.getOptionValue(option), this.equalityKey);
|
||||
},
|
||||
getSelectedOptionIndex() {
|
||||
let selectedOptionIndex = -1;
|
||||
|
||||
if (this.value != null && this.visibleOptions) {
|
||||
for (let i = 0; i < this.visibleOptions.length; i++) {
|
||||
if ((ObjectUtils.equals(this.value, this.getOptionValue(this.visibleOptions[i]), this.dataKey))) {
|
||||
if ((ObjectUtils.equals(this.value, this.getOptionValue(this.visibleOptions[i]), this.equalityKey))) {
|
||||
selectedOptionIndex = i;
|
||||
break;
|
||||
}
|
||||
|
@ -420,6 +420,9 @@ export default {
|
|||
return this.getOptionLabel(selectedOption);
|
||||
else
|
||||
return this.value;
|
||||
},
|
||||
equalityKey() {
|
||||
return this.optionValue ? null : this.dataKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ export default {
|
|||
if (this.multiple) {
|
||||
if (this.value) {
|
||||
for (let val of this.value) {
|
||||
if (ObjectUtils.equals(val, optionValue, this.dataKey)) {
|
||||
if (ObjectUtils.equals(val, optionValue, this.equalityKey)) {
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
|
@ -152,13 +152,13 @@ export default {
|
|||
}
|
||||
}
|
||||
else {
|
||||
selected = ObjectUtils.equals(this.value, optionValue, this.dataKey);
|
||||
selected = ObjectUtils.equals(this.value, optionValue, this.equalityKey);
|
||||
}
|
||||
|
||||
return selected;
|
||||
},
|
||||
removeOption(option) {
|
||||
return this.value.filter(val => !ObjectUtils.equals(val, this.getOptionValue(option), this.dataKey));
|
||||
return this.value.filter(val => !ObjectUtils.equals(val, this.getOptionValue(option), this.equalityKey));
|
||||
},
|
||||
updateModel(event, value) {
|
||||
this.$emit('input', value);
|
||||
|
@ -218,6 +218,9 @@ export default {
|
|||
return this.options.filter(option => this.getOptionLabel(option).toLowerCase().indexOf(this.filterValue.toLowerCase()) > -1);
|
||||
else
|
||||
return this.options;
|
||||
},
|
||||
equalityKey() {
|
||||
return this.optionValue ? null : this.dataKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ export default {
|
|||
|
||||
if (this.value) {
|
||||
for (let val of this.value) {
|
||||
if (ObjectUtils.equals(val, optionValue, this.dataKey)) {
|
||||
if (ObjectUtils.equals(val, optionValue, this.equalityKey)) {
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ export default {
|
|||
let value = null;
|
||||
|
||||
if (selected)
|
||||
value = this.value.filter(val => !ObjectUtils.equals(val, this.getOptionValue(option), this.dataKey));
|
||||
value = this.value.filter(val => !ObjectUtils.equals(val, this.getOptionValue(option), this.equalityKey));
|
||||
else
|
||||
value = [...this.value || [], this.getOptionValue(option)];
|
||||
|
||||
|
@ -276,7 +276,7 @@ export default {
|
|||
for (let option of this.options) {
|
||||
let optionValue = this.getOptionValue(option);
|
||||
|
||||
if(ObjectUtils.equals(optionValue, val, this.dataKey)) {
|
||||
if(ObjectUtils.equals(optionValue, val, this.equalityKey)) {
|
||||
label = this.getOptionLabel(option);
|
||||
break;
|
||||
}
|
||||
|
@ -354,6 +354,9 @@ export default {
|
|||
else {
|
||||
return this.value && this.options && (this.value.length > 0 && this.value.length === this.options.length);
|
||||
}
|
||||
},
|
||||
equalityKey() {
|
||||
return this.optionValue ? null : this.dataKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ export default {
|
|||
|
||||
if(this.multiple) {
|
||||
if (selected)
|
||||
newValue = this.value.filter(val => !ObjectUtils.equals(val, optionValue, this.dataKey));
|
||||
newValue = this.value.filter(val => !ObjectUtils.equals(val, optionValue, this.equalityKey));
|
||||
else
|
||||
newValue = this.value ? [...this.value, optionValue]: [optionValue];
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ export default {
|
|||
if (this.multiple) {
|
||||
if (this.value) {
|
||||
for (let val of this.value) {
|
||||
if (ObjectUtils.equals(val, optionValue, this.dataKey)) {
|
||||
if (ObjectUtils.equals(val, optionValue, this.equalityKey)) {
|
||||
selected = true;
|
||||
break;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export default {
|
|||
}
|
||||
}
|
||||
else {
|
||||
selected = ObjectUtils.equals(this.value, optionValue, this.dataKey);
|
||||
selected = ObjectUtils.equals(this.value, optionValue, this.equalityKey);
|
||||
}
|
||||
|
||||
return selected;
|
||||
|
@ -94,7 +94,10 @@ export default {
|
|||
computed: {
|
||||
containerClass() {
|
||||
return 'p-selectbutton p-buttonset p-component p-buttonset-' + String(this.options ? this.options.length : 0);
|
||||
}
|
||||
},
|
||||
equalityKey() {
|
||||
return this.optionValue ? null : this.dataKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue