fix: Pre chat custom fields drag and drop (#4530)
This commit is contained in:
parent
66d366f0ff
commit
4f9d41962a
3 changed files with 28 additions and 15 deletions
|
@ -17,12 +17,8 @@ export default {
|
||||||
value: { type: Boolean, default: false },
|
value: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onClick(event) {
|
onClick() {
|
||||||
if (event.pointerId === -1) {
|
|
||||||
event.preventDefault();
|
|
||||||
} else {
|
|
||||||
this.$emit('input', !this.value);
|
this.$emit('input', !this.value);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<draggable v-model="preChatFields" tag="tbody">
|
<draggable v-model="preChatFieldOptions" tag="tbody" @end="onDragEnd">
|
||||||
<tr v-for="(item, index) in preChatFields" :key="index">
|
<tr v-for="(item, index) in preChatFieldOptions" :key="index">
|
||||||
<td class="pre-chat-field"><fluent-icon icon="drag" /></td>
|
<td class="pre-chat-field"><fluent-icon icon="drag" /></td>
|
||||||
<td class="pre-chat-field">
|
<td class="pre-chat-field">
|
||||||
<woot-switch
|
<woot-switch
|
||||||
|
@ -51,15 +51,27 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
handlePreChatFieldOptions: {
|
},
|
||||||
type: Function,
|
data() {
|
||||||
default: () => {},
|
return {
|
||||||
|
preChatFieldOptions: this.preChatFields,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
preChatFields() {
|
||||||
|
this.preChatFieldOptions = this.preChatFields;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isFieldEditable(item) {
|
isFieldEditable(item) {
|
||||||
return !!standardFieldKeys[item.name] || !item.enabled;
|
return !!standardFieldKeys[item.name] || !item.enabled;
|
||||||
},
|
},
|
||||||
|
handlePreChatFieldOptions(event, type, item) {
|
||||||
|
this.$emit('update', event, type, item);
|
||||||
|
},
|
||||||
|
onDragEnd() {
|
||||||
|
this.$emit('drag-end', this.preChatFieldOptions);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label class="medium-8 columns">
|
<div class="medium-8 columns">
|
||||||
{{ $t('INBOX_MGMT.PRE_CHAT_FORM.SET_FIELDS') }}
|
<label>{{ $t('INBOX_MGMT.PRE_CHAT_FORM.SET_FIELDS') }}</label>
|
||||||
<table class="table table-striped w-full">
|
<table class="table table-striped w-full">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -58,10 +58,11 @@
|
||||||
</thead>
|
</thead>
|
||||||
<pre-chat-fields
|
<pre-chat-fields
|
||||||
:pre-chat-fields="preChatFields"
|
:pre-chat-fields="preChatFields"
|
||||||
:handle-pre-chat-field-options="handlePreChatFieldOptions"
|
@update="handlePreChatFieldOptions"
|
||||||
|
@drag-end="changePreChatFieldFieldsOrder"
|
||||||
/>
|
/>
|
||||||
</table>
|
</table>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<woot-submit-button
|
<woot-submit-button
|
||||||
|
@ -138,6 +139,10 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changePreChatFieldFieldsOrder(updatedPreChatFieldOptions) {
|
||||||
|
this.preChatFields = updatedPreChatFieldOptions;
|
||||||
|
},
|
||||||
|
|
||||||
async updateInbox() {
|
async updateInbox() {
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|
Loading…
Reference in a new issue