fix: Automation Bugs and minor enhancements (#3936)

This commit is contained in:
Fayaz Ahmed
2022-02-15 23:36:29 +05:30
committed by GitHub
parent e345a4486d
commit 5ad6db07b4
17 changed files with 203 additions and 129 deletions

View File

@@ -351,7 +351,7 @@ export default {
getActionDropdownValues(type) {
switch (type) {
case 'assign_team':
case 'send_message':
case 'send_email_to_team':
return this.$store.getters['teams/getTeams'];
case 'add_label':
return this.$store.getters['labels/getLabels'].map(i => {
@@ -365,12 +365,24 @@ export default {
}
},
appendNewCondition() {
this.automation.conditions.push({
attribute_key: 'status',
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
});
switch (this.automation.event_name) {
case 'message_created':
this.automation.conditions.push({
attribute_key: 'message_type',
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
});
break;
default:
this.automation.conditions.push({
attribute_key: 'status',
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
});
break;
}
},
appendNewAction() {
this.automation.actions.push({

View File

@@ -121,10 +121,10 @@
variant="clear"
@click.prevent="onClose"
>
{{ $t('AUTOMATION.ADD.CANCEL_BUTTON_TEXT') }}
{{ $t('AUTOMATION.EDIT.CANCEL_BUTTON_TEXT') }}
</woot-button>
<woot-button @click="submitAutomation">
{{ $t('AUTOMATION.ADD.SUBMIT') }}
{{ $t('AUTOMATION.EDIT.SUBMIT') }}
</woot-button>
</div>
</div>
@@ -351,9 +351,9 @@ export default {
getActionDropdownValues(type) {
switch (type) {
case 'assign_team':
case 'send_message':
return this.$store.getters['teams/getTeams'];
case 'add_label':
case 'send_email_to_team':
return this.$store.getters['teams/getTeams'];
case 'add_label':
return this.$store.getters['labels/getLabels'].map(i => {
return {
id: i.title,
@@ -365,12 +365,32 @@ export default {
}
},
appendNewCondition() {
this.automation.conditions.push({
attribute_key: 'status',
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
});
if (
!this.automation.conditions[this.automation.conditions.length - 1]
.query_operator
) {
this.automation.conditions[
this.automation.conditions.length - 1
].query_operator = 'and';
}
switch (this.automation.event_name) {
case 'message_created':
this.automation.conditions.push({
attribute_key: 'message_type',
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
});
break;
default:
this.automation.conditions.push({
attribute_key: 'status',
filter_operator: 'equal_to',
values: '',
query_operator: 'and',
});
break;
}
},
appendNewAction() {
this.automation.actions.push({
@@ -380,14 +400,14 @@ export default {
},
removeFilter(index) {
if (this.automation.conditions.length <= 1) {
this.showAlert(this.$t('FILTER.FILTER_DELETE_ERROR'));
this.showAlert(this.$t('AUTOMATION.CONDITION.DELETE_MESSAGE'));
} else {
this.automation.conditions.splice(index, 1);
}
},
removeAction(index) {
if (this.automation.actions.length <= 1) {
this.showAlert(this.$t('FILTER.FILTER_DELETE_ERROR'));
this.showAlert(this.$t('AUTOMATION.ACTION.DELETE_MESSAGE'));
} else {
this.automation.actions.splice(index, 1);
}
@@ -421,8 +441,9 @@ export default {
const formattedConditions = automation.conditions.map(condition => {
const inputType = this.automationTypes[
automation.event_name
].conditions.find(item => item.key === condition.attribute_key)
.inputType;
].conditions.find(
item => item.key === condition.attribute_key
).inputType;
if (inputType === 'plain_text') {
return {
...condition,

View File

@@ -219,7 +219,7 @@ export default {
const action =
mode === 'EDIT' ? 'automations/update' : 'automations/create';
const successMessage =
mode === 'edit'
mode === 'EDIT'
? this.$t('AUTOMATION.EDIT.API.SUCCESS_MESSAGE')
: this.$t('AUTOMATION.ADD.API.SUCCESS_MESSAGE');
@@ -229,7 +229,7 @@ export default {
this.hideEditPopup();
} catch (error) {
const errorMessage =
mode === 'edit'
mode === 'EDIT'
? this.$t('AUTOMATION.EDIT.API.ERROR_MESSAGE')
: this.$t('AUTOMATION.ADD.API.ERROR_MESSAGE');
this.showAlert(errorMessage);

View File

@@ -58,8 +58,8 @@ export const AUTOMATIONS = {
filterOperators: OPERATOR_TYPES_1,
},
{
key: 'message_contains',
name: 'Message Contains',
key: 'content',
name: 'Message Content',
attributeI18nKey: 'MESSAGE_CONTAINS',
inputType: 'plain_text',
filterOperators: OPERATOR_TYPES_2,
@@ -76,11 +76,11 @@ export const AUTOMATIONS = {
name: 'Add a label',
attributeI18nKey: 'ADD_LABEL',
},
{
key: 'send_message',
name: 'Send an email to team',
attributeI18nKey: 'SEND_MESSAGE',
},
// {
// key: 'send_email_to_team',
// name: 'Send an email to team',
// attributeI18nKey: 'SEND_MESSAGE',
// },
],
},
conversation_created: {
@@ -120,11 +120,11 @@ export const AUTOMATIONS = {
name: 'Assign a team',
attributeI18nKey: 'ASSIGN_TEAM',
},
{
key: 'send_message',
name: 'Send an email to team',
attributeI18nKey: 'SEND_MESSAGE',
},
// {
// key: 'send_email_to_team',
// name: 'Send an email to team',
// attributeI18nKey: 'SEND_MESSAGE',
// },
{
key: 'assign_agent',
name: 'Assign an agent',
@@ -183,11 +183,11 @@ export const AUTOMATIONS = {
name: 'Assign a team',
attributeI18nKey: 'ASSIGN_TEAM',
},
{
key: 'send_message',
name: 'Send an email to team',
attributeI18nKey: 'SEND_MESSAGE',
},
// {
// key: 'send_email_to_team',
// name: 'Send an email to team',
// attributeI18nKey: 'SEND_MESSAGE',
// },
{
key: 'assign_agent',
name: 'Assign an agent',
@@ -222,8 +222,8 @@ export const AUTOMATION_ACTION_TYPES = [
key: 'add_label',
label: 'Add a label',
},
{
key: 'send_message',
label: 'Send an email to team',
},
// {
// key: 'send_email_to_team',
// label: 'Send an email to team',
// },
];