Bug fixes and Code Climate issue fix

This commit is contained in:
Fayaz Ahmed 2022-05-13 12:41:55 +05:30
parent 123b5a7e6a
commit fe2bf47fce
2 changed files with 28 additions and 27 deletions

View file

@ -218,6 +218,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.allCustomAttributes = this.$store.getters['attributes/getAttributes'];
this.manifestCustomAttributes(); this.manifestCustomAttributes();
}, },
}; };

View file

@ -123,11 +123,8 @@ export default {
}, },
getConditionDropdownValues(type) { getConditionDropdownValues(type) {
const statusFilters = this.$t('CHAT_LIST.CHAT_STATUS_FILTER_ITEMS'); const statusFilters = this.$t('CHAT_LIST.CHAT_STATUS_FILTER_ITEMS');
const allCustomAttributes = this.$store.getters[
'attributes/getAttributes'
];
const isCustomAttributeCheckbox = allCustomAttributes.find(attr => { const isCustomAttributeCheckbox = this.allCustomAttributes.find(attr => {
return ( return (
attr.attribute_key === type && attr.attribute_key === type &&
attr.attribute_display_type === 'checkbox' attr.attribute_display_type === 'checkbox'
@ -146,14 +143,13 @@ export default {
]; ];
} }
const isCustomAttributeList = allCustomAttributes.find(attr => { const isCustomAttributeList = this.allCustomAttributes.find(attr => {
return ( return (
attr.attribute_key === type && attr.attribute_display_type === 'list' attr.attribute_key === type && attr.attribute_display_type === 'list'
); );
}); });
if (isCustomAttributeList) { if (isCustomAttributeList) {
return allCustomAttributes return this.allCustomAttributes
.find(attr => attr.attribute_key === type) .find(attr => attr.attribute_key === type)
.attribute_values.map(item => { .attribute_values.map(item => {
return { return {
@ -162,7 +158,6 @@ export default {
}; };
}); });
} }
switch (type) { switch (type) {
case 'status': case 'status':
return [ return [
@ -331,7 +326,7 @@ export default {
].conditions.find(item => item.key === condition.attribute_key) ].conditions.find(item => item.key === condition.attribute_key)
.inputType; .inputType;
} }
if (inputType === 'plain_text') { if (inputType === 'plain_text' || inputType === 'date') {
return { return {
...condition, ...condition,
values: condition.values[0], values: condition.values[0],
@ -346,27 +341,32 @@ export default {
}); });
return conditions; return conditions;
}, },
generateActionsArray(action) {
let actionParams = [];
const inputType = this.automationActionTypes.find(
item => item.key === action.action_name
).inputType;
if (inputType === 'multi_select') {
actionParams = [
...this.getActionDropdownValues(action.action_name),
].filter(item => [...action.action_params].includes(item.id));
} else if (inputType === 'team_message') {
actionParams = {
team_ids: [
...this.getActionDropdownValues(action.action_name),
].filter(item =>
[...action.action_params[0].team_ids].includes(item.id)
),
message: action.action_params[0].message,
};
} else actionParams = [...action.action_params];
return actionParams;
},
manifestActions(automation) { manifestActions(automation) {
let actionParams = [];
const actions = automation.actions.map(action => { const actions = automation.actions.map(action => {
let actionParams = [];
if (action.action_params.length) { if (action.action_params.length) {
const inputType = this.automationActionTypes.find( actionParams = this.generateActionsArray(action);
item => item.key === action.action_name
).inputType;
if (inputType === 'multi_select') {
actionParams = [
...this.getActionDropdownValues(action.action_name),
].filter(item => [...action.action_params].includes(item.id));
} else if (inputType === 'team_message') {
actionParams = {
team_ids: [
...this.getActionDropdownValues(action.action_name),
].filter(item =>
[...action.action_params[0].team_ids].includes(item.id)
),
message: action.action_params[0].message,
};
} else actionParams = [...action.action_params];
} }
return { return {
...action, ...action,