* feat: Adds model for scheduling messages * feat: Implement scheduled message handling and processing jobs * feat: Add ScheduledMessagesController and associated specs for managing scheduled messages * refactor: Simplify scheduled message job specs and improve metadata handling * feat: Add ScheduledMessagePolicy for managing access to scheduled messages * feat: Add routes for managing scheduled messages * feat: Add scheduled message event handling and broadcasting * feat: Add JSON views for scheduled messages creation, destruction, updating, and indexing * feat: Update scheduled message status and dispatch update event after message creation * feat: Ensure scheduled message updates trigger dispatch event * feat: Add mutation types for managing scheduled messages * feat: Add additionalAttributes prop to Message component and provider * feat: Implement scheduled message handling in ActionCable and Vuex store * feat: Add unit tests for scheduled messages actions and mutations * feat: implement scheduled messages functionality - Added support for scheduling messages in the conversation dashboard. - Introduced new components: ScheduledMessageModal and ScheduledMessages for managing scheduled messages. - Enhanced ReplyBottomPanel to include scheduling options. - Updated Base.vue to handle scheduled message styling. - Integrated Vuex store module for managing scheduled messages state. - Added necessary translations for scheduled messages in English and Portuguese. * feat: add pagination to scheduled messages index and update tests accordingly * chore: update scheduled messages specs for future time validation and response status * chore: enhance scheduled messages API with pagination and add skeleton loader component * feat: add create_scheduled_message action to automation rule attributes * feat: implement create_scheduled_message action and enhance attachment handling * feat: add scheduled message functionality with UI components and localization * test: enhance scheduledMessages mutations tests with meta handling and structure * chore: update label to display file name upon successful upload in AutomationFileInput component * feat: add initialAttachment prop to ScheduledMessageModal and update ReplyBox to pass attachment * chore: prepend_mod_with to ScheduledMessagesController for better module handling * fix: attachment visibility in ScheduledMessageItem component * chore: enhance ScheduledMessage model with validations and reduce controller load * refactor: simplify ScheduledMessagesAPI methods by removing unnecessary instance variable * chore: update event emission for scheduled message creation in ReplyBox and ScheduledMessageModal * refactor: update status configuration to use label keys * chore: update date formatting in ScheduledMessageItem component * refactor: collapse logic to checkOverflow and update related functionality * chore: add author indication for current user in scheduled messages * chore: enhance scheduled message metadata with author information and localization * fix: send message shortcut * chore: handle errors in scheduled message submission * chore: update scheduled message modal to use combined date and time input * chore: refactor scheduled messages handling to remove pagination and update related tests * fix: ensure scheduled messages update status and dispatch on failure * fix: update scheduled message due date logic and simplify sending checks * refactor: rename build_message method for send_message * fix: update scheduled message creation time and improve test reliability * chore: ignore unnecessary check * chore: add scheduled message metadata handling in message builder, add scheduled message factorie and update specs * refactor: use scheduled message factorie creation in specs * chore: streamline error handling in scheduled message job and remove dispatch logic * fix: change scheduled_messages association to destroy dependent records * refactor: remove unused attributes from scheduled message payload builder * chore: update scheduled message retrieval to use conversation association * chore: correct cron format for scheduled messages job * chore: remove migration for author_type in scheduled_messages * feat: enhance scheduled messages management with delete confirmation and error handling * chore: set cron poll interval to 10 seconds for improved scheduling precision * feat: include additional_attributes in message JSON response * feat: enhance scheduled message validation and localization support * chore: update scheduled message display * Merge branch 'main' into Cayo-Oliveira/CU-86aenh268/Mensagens-agendadas * feat: add scheduled message indicators and validation for message length * fix: remove unnecessary condition from line-clamp class binding * feat: update scheduled messages localization and enhance content validation * feat: update scheduled messages order, enhance scheduledAt computation, and add message association * fix: reorder condition for Facebook channel message length computation * fix: change detection for attachments in scheduled messages * fix: remove unnecessary colon from close-on-backdrop-click prop in ScheduledMessageModal * chore: add error handling for scheduled message deletion and update localization for delete failure * fix: enforce minimum delay of 1 minute for scheduled messages and update validation * fix: remove unused private property and improve locale formatting for scheduled messages * fix: adjust positioning of DropdownBody in ReplyBottomPanel and clean up schema foreign keys * docs: add scheduled messages management APIs and payload definitions --------- Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
305 lines
7.6 KiB
Vue
305 lines
7.6 KiB
Vue
<script>
|
|
import AutomationActionTeamMessageInput from './AutomationActionTeamMessageInput.vue';
|
|
import AutomationActionFileInput from './AutomationFileInput.vue';
|
|
import AutomationActionScheduledMessageInput from './AutomationActionScheduledMessageInput.vue';
|
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
|
|
|
export default {
|
|
components: {
|
|
AutomationActionTeamMessageInput,
|
|
AutomationActionFileInput,
|
|
AutomationActionScheduledMessageInput,
|
|
WootMessageEditor,
|
|
NextButton,
|
|
},
|
|
props: {
|
|
modelValue: {
|
|
type: Object,
|
|
default: () => null,
|
|
},
|
|
actionTypes: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
dropdownValues: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
errorMessage: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
showActionInput: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
initialFileName: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
isMacro: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
},
|
|
emits: ['update:modelValue', 'input', 'removeAction', 'resetAction'],
|
|
computed: {
|
|
action_name: {
|
|
get() {
|
|
if (!this.modelValue) return null;
|
|
return this.modelValue.action_name;
|
|
},
|
|
set(value) {
|
|
const payload = this.modelValue || {};
|
|
this.$emit('update:modelValue', { ...payload, action_name: value });
|
|
this.$emit('input', { ...payload, action_name: value });
|
|
},
|
|
},
|
|
action_params: {
|
|
get() {
|
|
if (!this.modelValue) return null;
|
|
return this.modelValue.action_params;
|
|
},
|
|
set(value) {
|
|
const payload = this.modelValue || {};
|
|
this.$emit('update:modelValue', { ...payload, action_params: value });
|
|
this.$emit('input', { ...payload, action_params: value });
|
|
},
|
|
},
|
|
inputType() {
|
|
return this.actionTypes.find(action => action.key === this.action_name)
|
|
.inputType;
|
|
},
|
|
actionInputStyles() {
|
|
return {
|
|
'has-error': this.errorMessage,
|
|
'is-a-macro': this.isMacro,
|
|
};
|
|
},
|
|
castMessageVmodel: {
|
|
get() {
|
|
if (Array.isArray(this.action_params)) {
|
|
const value = this.action_params[0];
|
|
return typeof value === 'string' ? value : '';
|
|
}
|
|
return typeof this.action_params === 'string' ? this.action_params : '';
|
|
},
|
|
set(value) {
|
|
this.action_params = value;
|
|
},
|
|
},
|
|
},
|
|
methods: {
|
|
removeAction() {
|
|
this.$emit('removeAction');
|
|
},
|
|
resetAction() {
|
|
this.$emit('resetAction');
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="filter" :class="actionInputStyles">
|
|
<div class="filter-inputs">
|
|
<select
|
|
v-model="action_name"
|
|
class="action__question"
|
|
:class="{ 'full-width': !showActionInput }"
|
|
@change="resetAction()"
|
|
>
|
|
<option
|
|
v-for="attribute in actionTypes"
|
|
:key="attribute.key"
|
|
:value="attribute.key"
|
|
>
|
|
{{ attribute.label }}
|
|
</option>
|
|
</select>
|
|
<div v-if="showActionInput" class="filter__answer--wrap">
|
|
<div v-if="inputType" class="w-full">
|
|
<div
|
|
v-if="inputType === 'search_select'"
|
|
class="multiselect-wrap--small"
|
|
>
|
|
<multiselect
|
|
v-model="action_params"
|
|
track-by="id"
|
|
label="name"
|
|
:placeholder="$t('FORMS.MULTISELECT.SELECT')"
|
|
selected-label
|
|
:select-label="$t('FORMS.MULTISELECT.ENTER_TO_SELECT')"
|
|
deselect-label=""
|
|
:max-height="160"
|
|
:options="dropdownValues"
|
|
:allow-empty="false"
|
|
:option-height="104"
|
|
>
|
|
<template #noOptions>
|
|
{{ $t('FORMS.MULTISELECT.NO_OPTIONS') }}
|
|
</template>
|
|
</multiselect>
|
|
</div>
|
|
<div
|
|
v-else-if="inputType === 'multi_select'"
|
|
class="multiselect-wrap--small"
|
|
>
|
|
<multiselect
|
|
v-model="action_params"
|
|
track-by="id"
|
|
label="name"
|
|
:placeholder="$t('FORMS.MULTISELECT.SELECT')"
|
|
multiple
|
|
selected-label
|
|
:select-label="$t('FORMS.MULTISELECT.ENTER_TO_SELECT')"
|
|
deselect-label=""
|
|
:max-height="160"
|
|
:options="dropdownValues"
|
|
:allow-empty="false"
|
|
:option-height="104"
|
|
>
|
|
<template #noOptions>
|
|
{{ $t('FORMS.MULTISELECT.NO_OPTIONS') }}
|
|
</template>
|
|
</multiselect>
|
|
</div>
|
|
<input
|
|
v-else-if="inputType === 'email'"
|
|
v-model="action_params"
|
|
type="email"
|
|
class="answer--text-input"
|
|
:placeholder="$t('AUTOMATION.ACTION.EMAIL_INPUT_PLACEHOLDER')"
|
|
/>
|
|
<input
|
|
v-else-if="inputType === 'url'"
|
|
v-model="action_params"
|
|
type="url"
|
|
class="answer--text-input"
|
|
:placeholder="$t('AUTOMATION.ACTION.URL_INPUT_PLACEHOLDER')"
|
|
/>
|
|
<AutomationActionFileInput
|
|
v-if="inputType === 'attachment'"
|
|
v-model="action_params"
|
|
:initial-file-name="initialFileName"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<NextButton
|
|
v-if="!isMacro"
|
|
icon="i-lucide-x"
|
|
slate
|
|
ghost
|
|
class="flex-shrink-0"
|
|
@click="removeAction"
|
|
/>
|
|
</div>
|
|
<AutomationActionTeamMessageInput
|
|
v-if="inputType === 'team_message'"
|
|
v-model="action_params"
|
|
:teams="dropdownValues"
|
|
/>
|
|
<WootMessageEditor
|
|
v-if="inputType === 'textarea'"
|
|
v-model="castMessageVmodel"
|
|
rows="4"
|
|
enable-variables
|
|
:placeholder="$t('AUTOMATION.ACTION.TEAM_MESSAGE_INPUT_PLACEHOLDER')"
|
|
class="action-message"
|
|
/>
|
|
<AutomationActionScheduledMessageInput
|
|
v-if="inputType === 'scheduled_message'"
|
|
v-model="action_params"
|
|
:initial-file-name="initialFileName"
|
|
/>
|
|
<p v-if="errorMessage" class="filter-error">
|
|
{{ errorMessage }}
|
|
</p>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.filter {
|
|
@apply bg-n-background p-2 border border-solid border-n-strong dark:border-n-strong rounded-lg mb-2;
|
|
|
|
&.is-a-macro {
|
|
@apply mb-0 bg-n-background dark:bg-n-solid-1 p-0 border-0 rounded-none;
|
|
}
|
|
}
|
|
|
|
.no-margin-bottom {
|
|
@apply mb-0;
|
|
}
|
|
|
|
.filter.has-error {
|
|
@apply bg-n-ruby-8/20 border-n-ruby-5 dark:border-n-ruby-5;
|
|
|
|
&.is-a-macro {
|
|
@apply bg-transparent;
|
|
}
|
|
}
|
|
|
|
.filter-inputs {
|
|
@apply flex gap-1;
|
|
}
|
|
|
|
.filter-error {
|
|
@apply text-n-ruby-9 dark:text-n-ruby-9 block my-1 mx-0;
|
|
}
|
|
|
|
.action__question,
|
|
.filter__operator {
|
|
@apply mb-0 mr-1;
|
|
}
|
|
|
|
.action__question {
|
|
@apply max-w-[50%];
|
|
}
|
|
|
|
.action__question.full-width {
|
|
@apply max-w-full;
|
|
}
|
|
|
|
.filter__answer--wrap {
|
|
@apply max-w-[50%] flex-grow mr-1 flex w-full items-center justify-start;
|
|
|
|
input {
|
|
@apply mb-0;
|
|
}
|
|
}
|
|
.filter__answer {
|
|
&.answer--text-input {
|
|
@apply mb-0;
|
|
}
|
|
}
|
|
|
|
.filter__join-operator-wrap {
|
|
@apply relative z-20 m-0;
|
|
}
|
|
|
|
.filter__join-operator {
|
|
@apply flex items-center justify-center relative my-2.5 mx-0;
|
|
|
|
.operator__line {
|
|
@apply absolute w-full border-b border-solid border-n-weak;
|
|
}
|
|
|
|
.operator__select {
|
|
margin-bottom: 0 !important;
|
|
@apply relative w-auto;
|
|
}
|
|
}
|
|
|
|
.multiselect {
|
|
@apply mb-0;
|
|
}
|
|
.action-message {
|
|
@apply mt-2 mx-0 mb-0;
|
|
}
|
|
// Prosemirror does not have a native way of hiding the menu bar, hence
|
|
::v-deep .ProseMirror-menubar {
|
|
@apply hidden;
|
|
}
|
|
</style>
|