fix: Set the default value to false for the checkbox custom attribute (#7561)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Karthick Venkatesan
2023-08-16 05:02:06 +05:30
committed by GitHub
parent e3b8c1fbb5
commit 7b68a7639f

View File

@@ -58,13 +58,19 @@ export default {
methods: {
async addAttribute(attribute) {
try {
const { attribute_key } = attribute;
const {
attribute_key: attributeKey,
attribute_display_type: attributeDisplayType,
default_value: attributeDefaultValue,
} = attribute;
const isCheckbox = attributeDisplayType === 'checkbox';
const defaultValue = isCheckbox ? false : attributeDefaultValue || null;
if (this.attributeType === 'conversation_attribute') {
await this.$store.dispatch('updateCustomAttributes', {
conversationId: this.conversationId,
customAttributes: {
...this.customAttributes,
[attribute_key]: null,
[attributeKey]: defaultValue,
},
});
} else {
@@ -72,11 +78,11 @@ export default {
id: this.contactId,
custom_attributes: {
...this.customAttributes,
[attribute_key]: null,
[attributeKey]: defaultValue,
},
});
}
bus.$emit(BUS_EVENTS.FOCUS_CUSTOM_ATTRIBUTE, attribute_key);
bus.$emit(BUS_EVENTS.FOCUS_CUSTOM_ATTRIBUTE, attributeKey);
this.showAlert(this.$t('CUSTOM_ATTRIBUTES.FORM.ADD.SUCCESS'));
} catch (error) {
const errorMessage =