Feature: Rich Message Types (#610)
Co-authored-by: Pranav Raj S <pranavrajs@gmail.com> Co-authored-by: Nithin David Thomas <webofnithin@gmail.com>
This commit is contained in:
parent
48f603798b
commit
b0950d6880
58 changed files with 997 additions and 146 deletions
|
@ -4,6 +4,8 @@
|
|||
:key="action.uri"
|
||||
class="action-button button"
|
||||
:href="action.uri"
|
||||
target="_blank"
|
||||
rel="noopener nofollow noreferrer"
|
||||
>
|
||||
{{ action.text }}
|
||||
</a>
|
||||
|
@ -44,11 +46,14 @@ export default {
|
|||
@import '~dashboard/assets/scss/mixins.scss';
|
||||
|
||||
.action-button {
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
max-height: 34px;
|
||||
margin-top: $space-smaller;
|
||||
align-items: center;
|
||||
border-radius: $space-micro;
|
||||
display: flex;
|
||||
font-weight: $font-weight-medium;
|
||||
justify-content: center;
|
||||
margin-top: $space-smaller;
|
||||
max-height: 34px;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -52,7 +52,6 @@ export default {
|
|||
@import '~dashboard/assets/scss/mixins.scss';
|
||||
|
||||
.card-message {
|
||||
@include border-normal;
|
||||
background: white;
|
||||
max-width: 220px;
|
||||
padding: $space-small;
|
||||
|
|
114
app/javascript/shared/components/ChatForm.vue
Normal file
114
app/javascript/shared/components/ChatForm.vue
Normal file
|
@ -0,0 +1,114 @@
|
|||
<template>
|
||||
<div class="form chat-bubble agent">
|
||||
<form @submit.prevent="onSubmit">
|
||||
<div v-for="item in items" :key="item.key" class="form-block">
|
||||
<label>{{ item.label }}</label>
|
||||
<input
|
||||
v-if="item.type === 'email' || item.type === 'text'"
|
||||
v-model="formValues[item.name]"
|
||||
:type="item.type"
|
||||
:name="item.name"
|
||||
:placeholder="item.placeholder"
|
||||
:disabled="!!submittedValues.length"
|
||||
/>
|
||||
<textarea
|
||||
v-else-if="item.type === 'text_area'"
|
||||
v-model="formValues[item.name]"
|
||||
:name="item.name"
|
||||
:placeholder="item.placeholder"
|
||||
:disabled="!!submittedValues.length"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
v-if="!submittedValues.length"
|
||||
class="button small block"
|
||||
type="submit"
|
||||
:disabled="!isFormValid"
|
||||
>
|
||||
{{ $t('COMPONENTS.FORM_BUBBLE.SUBMIT') }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
items: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
submittedValues: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formValues: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isFormValid() {
|
||||
return this.items.reduce((acc, { name }) => {
|
||||
return !!this.formValues[name] && acc;
|
||||
}, true);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.updateFormValues();
|
||||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
if (!this.isFormValid) {
|
||||
return;
|
||||
}
|
||||
this.$emit('submit', this.formValues);
|
||||
},
|
||||
updateFormValues() {
|
||||
this.formValues = this.submittedValues.reduce((acc, obj) => {
|
||||
return {
|
||||
...acc,
|
||||
[obj.name]: obj.value,
|
||||
};
|
||||
}, {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '~widget/assets/scss/variables.scss';
|
||||
|
||||
.form {
|
||||
padding: $space-normal;
|
||||
width: 100%;
|
||||
|
||||
.form-block {
|
||||
max-width: 100%;
|
||||
padding-bottom: $space-small;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
font-weight: $font-weight-bold;
|
||||
padding: $space-smaller 0;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
input,
|
||||
textarea {
|
||||
border-radius: $space-smaller;
|
||||
border: 1px solid $color-border;
|
||||
display: block;
|
||||
font-size: $font-size-default;
|
||||
line-height: 1.5;
|
||||
padding: $space-smaller $space-small;
|
||||
width: 90%;
|
||||
|
||||
&:disabled {
|
||||
background: $color-background-light;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -3,7 +3,7 @@
|
|||
<button class="option-button button" @click="onClick">
|
||||
<span v-if="isSelected" class="icon ion-checkmark-circled" />
|
||||
<span v-else class="icon ion-android-radio-button-off" />
|
||||
<span>{{ action.text }}</span>
|
||||
<span>{{ action.title }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</template>
|
||||
|
@ -23,7 +23,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
// Do postback here
|
||||
this.$emit('click', this.action);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -4,12 +4,17 @@
|
|||
<h4 class="title">
|
||||
{{ title }}
|
||||
</h4>
|
||||
<ul class="options" :class="{ 'has-selected': !!selected }">
|
||||
<ul
|
||||
v-if="!hideFields"
|
||||
class="options"
|
||||
:class="{ 'has-selected': !!selected }"
|
||||
>
|
||||
<chat-option
|
||||
v-for="option in options"
|
||||
:key="option.id"
|
||||
:action="option"
|
||||
:is-selected="isSelected(option)"
|
||||
@click="onClick"
|
||||
/>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -36,11 +41,18 @@ export default {
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
hideFields: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isSelected(option) {
|
||||
return this.selected === option.id;
|
||||
},
|
||||
onClick(selectedOption) {
|
||||
this.$emit('click', selectedOption);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -59,7 +71,6 @@ export default {
|
|||
@import '~dashboard/assets/scss/mixins.scss';
|
||||
|
||||
.options-message {
|
||||
@include border-normal;
|
||||
background: white;
|
||||
width: 60%;
|
||||
max-width: 17rem;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue