mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-29 10:12:34 +00:00
feat: Add the option for consent form (#6511)
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@@ -1 +1,6 @@
|
|||||||
{}
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"chatwoot",
|
||||||
|
"dompurify"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -476,7 +476,8 @@
|
|||||||
"WHATSAPP_SECTION_TITLE": "API Key",
|
"WHATSAPP_SECTION_TITLE": "API Key",
|
||||||
"WHATSAPP_SECTION_UPDATE_TITLE": "Update API Key",
|
"WHATSAPP_SECTION_UPDATE_TITLE": "Update API Key",
|
||||||
"WHATSAPP_SECTION_UPDATE_PLACEHOLDER": "Enter the new API Key here",
|
"WHATSAPP_SECTION_UPDATE_PLACEHOLDER": "Enter the new API Key here",
|
||||||
"WHATSAPP_SECTION_UPDATE_BUTTON": "Update"
|
"WHATSAPP_SECTION_UPDATE_BUTTON": "Update",
|
||||||
|
"UPDATE_PRE_CHAT_FORM_SETTINGS": "Update Pre Chat Form Settings"
|
||||||
},
|
},
|
||||||
"AUTO_ASSIGNMENT": {
|
"AUTO_ASSIGNMENT": {
|
||||||
"MAX_ASSIGNMENT_LIMIT": "Auto assignment limit",
|
"MAX_ASSIGNMENT_LIMIT": "Auto assignment limit",
|
||||||
|
|||||||
@@ -16,17 +16,19 @@
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<div v-if="preChatFormEnabled">
|
<div v-if="preChatFormEnabled">
|
||||||
<label class="medium-3 columns">
|
<label class="columns medium-8 large-8">
|
||||||
{{ $t('INBOX_MGMT.PRE_CHAT_FORM.PRE_CHAT_MESSAGE.LABEL') }}
|
<label>
|
||||||
<textarea
|
{{ $t('INBOX_MGMT.PRE_CHAT_FORM.PRE_CHAT_MESSAGE.LABEL') }}
|
||||||
v-model.trim="preChatMessage"
|
</label>
|
||||||
type="text"
|
<woot-message-editor
|
||||||
|
v-model="preChatMessage"
|
||||||
|
class="message-editor"
|
||||||
:placeholder="
|
:placeholder="
|
||||||
$t('INBOX_MGMT.PRE_CHAT_FORM.PRE_CHAT_MESSAGE.PLACEHOLDER')
|
$t('INBOX_MGMT.PRE_CHAT_FORM.PRE_CHAT_MESSAGE.PLACEHOLDER')
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<div class="medium-8 columns">
|
<div class="columns medium-8 large-8 pre-chat-fields">
|
||||||
<label>{{ $t('INBOX_MGMT.PRE_CHAT_FORM.SET_FIELDS') }}</label>
|
<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">
|
||||||
@@ -65,7 +67,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<woot-submit-button
|
<woot-submit-button
|
||||||
:button-text="$t('INBOX_MGMT.SETTINGS_POPUP.UPDATE')"
|
class="submit-button"
|
||||||
|
:button-text="
|
||||||
|
$t('INBOX_MGMT.SETTINGS_POPUP.UPDATE_PRE_CHAT_FORM_SETTINGS')
|
||||||
|
"
|
||||||
:loading="uiFlags.isUpdating"
|
:loading="uiFlags.isUpdating"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
@@ -76,10 +81,11 @@ import { mapGetters } from 'vuex';
|
|||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import PreChatFields from './PreChatFields.vue';
|
import PreChatFields from './PreChatFields.vue';
|
||||||
import { getPreChatFields, standardFieldKeys } from 'dashboard/helper/preChat';
|
import { getPreChatFields, standardFieldKeys } from 'dashboard/helper/preChat';
|
||||||
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
PreChatFields,
|
PreChatFields,
|
||||||
|
WootMessageEditor,
|
||||||
},
|
},
|
||||||
mixins: [alertMixin],
|
mixins: [alertMixin],
|
||||||
props: {
|
props: {
|
||||||
@@ -171,4 +177,11 @@ export default {
|
|||||||
.pre-chat--title {
|
.pre-chat--title {
|
||||||
margin: var(--space-medium) 0 var(--space-slab);
|
margin: var(--space-medium) 0 var(--space-slab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.submit-button {
|
||||||
|
margin-top: var(--space-normal);
|
||||||
|
}
|
||||||
|
.pre-chat-fields {
|
||||||
|
margin-top: var(--space-normal);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="shouldShowHeaderMessage"
|
v-if="shouldShowHeaderMessage"
|
||||||
class="mb-4 text-sm leading-5"
|
v-dompurify-html="formatMessage(headerMessage, false)"
|
||||||
|
class="mb-4 text-sm leading-5 pre-chat-header-message"
|
||||||
:class="$dm('text-black-800', 'dark:text-slate-50')"
|
:class="$dm('text-black-800', 'dark:text-slate-50')"
|
||||||
>
|
/>
|
||||||
{{ headerMessage }}
|
|
||||||
</div>
|
|
||||||
<FormulateInput
|
<FormulateInput
|
||||||
v-for="item in enabledPreChatFields"
|
v-for="item in enabledPreChatFields"
|
||||||
:key="item.name"
|
:key="item.name"
|
||||||
@@ -25,7 +24,7 @@
|
|||||||
:validation-messages="{
|
:validation-messages="{
|
||||||
isPhoneE164OrEmpty: $t('PRE_CHAT_FORM.FIELDS.PHONE_NUMBER.VALID_ERROR'),
|
isPhoneE164OrEmpty: $t('PRE_CHAT_FORM.FIELDS.PHONE_NUMBER.VALID_ERROR'),
|
||||||
email: $t('PRE_CHAT_FORM.FIELDS.EMAIL_ADDRESS.VALID_ERROR'),
|
email: $t('PRE_CHAT_FORM.FIELDS.EMAIL_ADDRESS.VALID_ERROR'),
|
||||||
required: getRequiredErrorMessage(item),
|
required: $t('PRE_CHAT_FORM.REQUIRED'),
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<FormulateInput
|
<FormulateInput
|
||||||
@@ -60,7 +59,7 @@ import CustomButton from 'shared/components/Button';
|
|||||||
import Spinner from 'shared/components/Spinner';
|
import Spinner from 'shared/components/Spinner';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import { getContrastingTextColor } from '@chatwoot/utils';
|
import { getContrastingTextColor } from '@chatwoot/utils';
|
||||||
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
||||||
import { isEmptyObject } from 'widget/helpers/utils';
|
import { isEmptyObject } from 'widget/helpers/utils';
|
||||||
import routerMixin from 'widget/mixins/routerMixin';
|
import routerMixin from 'widget/mixins/routerMixin';
|
||||||
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
||||||
@@ -69,7 +68,7 @@ export default {
|
|||||||
CustomButton,
|
CustomButton,
|
||||||
Spinner,
|
Spinner,
|
||||||
},
|
},
|
||||||
mixins: [routerMixin, darkModeMixin],
|
mixins: [routerMixin, darkModeMixin, messageFormatterMixin],
|
||||||
props: {
|
props: {
|
||||||
options: {
|
options: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -224,10 +223,6 @@ export default {
|
|||||||
}
|
}
|
||||||
return this.formValues[name] || null;
|
return this.formValues[name] || null;
|
||||||
},
|
},
|
||||||
|
|
||||||
getRequiredErrorMessage({ label }) {
|
|
||||||
return `${label} ${this.$t('PRE_CHAT_FORM.IS_REQUIRED')}`;
|
|
||||||
},
|
|
||||||
getValidation({ type, name }) {
|
getValidation({ type, name }) {
|
||||||
if (!this.isContactFieldRequired(name)) {
|
if (!this.isContactFieldRequired(name)) {
|
||||||
return '';
|
return '';
|
||||||
@@ -290,6 +285,7 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@import '~widget/assets/scss/variables.scss';
|
||||||
::v-deep {
|
::v-deep {
|
||||||
.wrapper[data-type='checkbox'] {
|
.wrapper[data-type='checkbox'] {
|
||||||
.formulate-input-wrapper {
|
.formulate-input-wrapper {
|
||||||
@@ -318,5 +314,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.pre-chat-header-message {
|
||||||
|
.link {
|
||||||
|
color: $color-woot;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -65,7 +65,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CAMPAIGN_HEADER": "Please provide your name and email before starting the conversation",
|
"CAMPAIGN_HEADER": "Please provide your name and email before starting the conversation",
|
||||||
"IS_REQUIRED": "is required"
|
"IS_REQUIRED": "is required",
|
||||||
|
"REQUIRED": "Required"
|
||||||
},
|
},
|
||||||
"FILE_SIZE_LIMIT": "File exceeds the {MAXIMUM_FILE_UPLOAD_SIZE} attachment limit",
|
"FILE_SIZE_LIMIT": "File exceeds the {MAXIMUM_FILE_UPLOAD_SIZE} attachment limit",
|
||||||
"CHAT_FORM": {
|
"CHAT_FORM": {
|
||||||
|
|||||||
Reference in New Issue
Block a user