mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-04 04:57:51 +00:00 
			
		
		
		
	fix: Allow editing label and placeholder for standard attributes in pre chat form (#6067)
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
		@@ -60,15 +60,11 @@ export const getFormattedPreChatFields = ({ preChatFields }) => {
 | 
				
			|||||||
    return {
 | 
					    return {
 | 
				
			||||||
      ...item,
 | 
					      ...item,
 | 
				
			||||||
      label: getLabel({
 | 
					      label: getLabel({
 | 
				
			||||||
        key: standardFieldKeys[item.name]
 | 
					        key: item.name,
 | 
				
			||||||
          ? standardFieldKeys[item.name].key
 | 
					 | 
				
			||||||
          : item.name,
 | 
					 | 
				
			||||||
        label: item.label ? item.label : item.name,
 | 
					        label: item.label ? item.label : item.name,
 | 
				
			||||||
      }),
 | 
					      }),
 | 
				
			||||||
      placeholder: getPlaceHolder({
 | 
					      placeholder: getPlaceHolder({
 | 
				
			||||||
        key: standardFieldKeys[item.name]
 | 
					        key: item.name,
 | 
				
			||||||
          ? standardFieldKeys[item.name].key
 | 
					 | 
				
			||||||
          : item.name,
 | 
					 | 
				
			||||||
        placeholder: item.placeholder ? item.placeholder : item.name,
 | 
					        placeholder: item.placeholder ? item.placeholder : item.name,
 | 
				
			||||||
      }),
 | 
					      }),
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import draggable from 'vuedraggable';
 | 
					import draggable from 'vuedraggable';
 | 
				
			||||||
import { standardFieldKeys } from 'dashboard/helper/preChat';
 | 
					 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  components: { draggable },
 | 
					  components: { draggable },
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
@@ -64,7 +63,7 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    isFieldEditable(item) {
 | 
					    isFieldEditable(item) {
 | 
				
			||||||
      return !!standardFieldKeys[item.name] || !item.enabled;
 | 
					      return !item.enabled;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    handlePreChatFieldOptions(event, type, item) {
 | 
					    handlePreChatFieldOptions(event, type, item) {
 | 
				
			||||||
      this.$emit('update', event, type, item);
 | 
					      this.$emit('update', event, type, item);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,9 @@
 | 
				
			|||||||
      :label="$t('PRE_CHAT_FORM.FIELDS.MESSAGE.LABEL')"
 | 
					      :label="$t('PRE_CHAT_FORM.FIELDS.MESSAGE.LABEL')"
 | 
				
			||||||
      :placeholder="$t('PRE_CHAT_FORM.FIELDS.MESSAGE.PLACEHOLDER')"
 | 
					      :placeholder="$t('PRE_CHAT_FORM.FIELDS.MESSAGE.PLACEHOLDER')"
 | 
				
			||||||
      validation="required"
 | 
					      validation="required"
 | 
				
			||||||
 | 
					      :validation-messages="{
 | 
				
			||||||
 | 
					        required: $t('PRE_CHAT_FORM.FIELDS.MESSAGE.ERROR'),
 | 
				
			||||||
 | 
					      }"
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <custom-button
 | 
					    <custom-button
 | 
				
			||||||
@@ -208,14 +211,10 @@ export default {
 | 
				
			|||||||
    isContactFieldRequired(field) {
 | 
					    isContactFieldRequired(field) {
 | 
				
			||||||
      return this.preChatFields.find(option => option.name === field).required;
 | 
					      return this.preChatFields.find(option => option.name === field).required;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    getLabel({ name, label }) {
 | 
					    getLabel({ label }) {
 | 
				
			||||||
      if (this.labels[name])
 | 
					 | 
				
			||||||
        return this.$t(`PRE_CHAT_FORM.FIELDS.${this.labels[name]}.LABEL`);
 | 
					 | 
				
			||||||
      return label;
 | 
					      return label;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    getPlaceHolder({ name, placeholder }) {
 | 
					    getPlaceHolder({ placeholder }) {
 | 
				
			||||||
      if (this.labels[name])
 | 
					 | 
				
			||||||
        return this.$t(`PRE_CHAT_FORM.FIELDS.${this.labels[name]}.PLACEHOLDER`);
 | 
					 | 
				
			||||||
      return placeholder;
 | 
					      return placeholder;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    getValue({ name, type }) {
 | 
					    getValue({ name, type }) {
 | 
				
			||||||
@@ -226,11 +225,7 @@ export default {
 | 
				
			|||||||
      return this.formValues[name] || null;
 | 
					      return this.formValues[name] || null;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getRequiredErrorMessage({ name, label }) {
 | 
					    getRequiredErrorMessage({ label }) {
 | 
				
			||||||
      if (this.labels[name])
 | 
					 | 
				
			||||||
        return this.$t(
 | 
					 | 
				
			||||||
          `PRE_CHAT_FORM.FIELDS.${this.labels[name]}.REQUIRED_ERROR`
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
      return `${label} ${this.$t('PRE_CHAT_FORM.IS_REQUIRED')}`;
 | 
					      return `${label} ${this.$t('PRE_CHAT_FORM.IS_REQUIRED')}`;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    getValidation({ type, name }) {
 | 
					    getValidation({ type, name }) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user