fix: Render checkbox if string value passed (#3453)
This commit is contained in:
parent
da8f9d0337
commit
00143f7ee5
1 changed files with 16 additions and 6 deletions
|
@ -66,7 +66,7 @@
|
||||||
{{ value || '---' }}
|
{{ value || '---' }}
|
||||||
</a>
|
</a>
|
||||||
<p v-else class="value">
|
<p v-else class="value">
|
||||||
{{ formattedValue || '---' }}
|
{{ displayValue || '---' }}
|
||||||
</p>
|
</p>
|
||||||
<div class="action-buttons__wrap">
|
<div class="action-buttons__wrap">
|
||||||
<woot-button
|
<woot-button
|
||||||
|
@ -138,10 +138,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isEditing: false,
|
isEditing: false,
|
||||||
editedValue:
|
editedValue: null,
|
||||||
this.attributeType === 'date'
|
|
||||||
? format(new Date(this.value || new Date()), DATE_FORMAT)
|
|
||||||
: this.value,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
validations() {
|
validations() {
|
||||||
|
@ -156,6 +153,15 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
formattedValue() {
|
||||||
|
if (this.isAttributeTypeDate) {
|
||||||
|
return format(new Date(this.value || new Date()), DATE_FORMAT);
|
||||||
|
}
|
||||||
|
if (this.isAttributeTypeCheckbox) {
|
||||||
|
return this.value === 'false' ? false : this.value;
|
||||||
|
}
|
||||||
|
return this.value;
|
||||||
|
},
|
||||||
listOptions() {
|
listOptions() {
|
||||||
return this.values.map((value, index) => ({
|
return this.values.map((value, index) => ({
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
|
@ -175,6 +181,9 @@ export default {
|
||||||
isAttributeTypeLink() {
|
isAttributeTypeLink() {
|
||||||
return this.attributeType === 'link';
|
return this.attributeType === 'link';
|
||||||
},
|
},
|
||||||
|
isAttributeTypeDate() {
|
||||||
|
return this.attributeType === 'date';
|
||||||
|
},
|
||||||
notAttributeTypeCheckboxAndList() {
|
notAttributeTypeCheckboxAndList() {
|
||||||
return !this.isAttributeTypeCheckbox && !this.isAttributeTypeList;
|
return !this.isAttributeTypeCheckbox && !this.isAttributeTypeList;
|
||||||
},
|
},
|
||||||
|
@ -190,7 +199,7 @@ export default {
|
||||||
}
|
}
|
||||||
return this.$t('CUSTOM_ATTRIBUTES.VALIDATIONS.REQUIRED');
|
return this.$t('CUSTOM_ATTRIBUTES.VALIDATIONS.REQUIRED');
|
||||||
},
|
},
|
||||||
formattedValue() {
|
displayValue() {
|
||||||
if (this.attributeType === 'date') {
|
if (this.attributeType === 'date') {
|
||||||
return format(new Date(this.editedValue), 'dd-MM-yyyy');
|
return format(new Date(this.editedValue), 'dd-MM-yyyy');
|
||||||
}
|
}
|
||||||
|
@ -198,6 +207,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.editedValue = this.formattedValue;
|
||||||
bus.$on(BUS_EVENTS.FOCUS_CUSTOM_ATTRIBUTE, focusAttributeKey => {
|
bus.$on(BUS_EVENTS.FOCUS_CUSTOM_ATTRIBUTE, focusAttributeKey => {
|
||||||
if (this.attributeKey === focusAttributeKey) {
|
if (this.attributeKey === focusAttributeKey) {
|
||||||
this.onEdit();
|
this.onEdit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue