feat: Remove labels in macro (#5875)

This commit is contained in:
Tejaswini Chile
2022-11-17 12:30:47 +05:30
committed by GitHub
parent 66044a0dc3
commit e85f998a08
6 changed files with 34 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ export default {
case 'assign_agent':
return this.agents;
case 'add_label':
case 'remove_label':
return this.labels.map(i => {
return {
id: i.title,

View File

@@ -49,6 +49,7 @@ export default {
const actionsMap = {
assign_team: resolveTeamIds(this.teams, params),
add_label: resolveLabels(this.labels, params),
remove_label: resolveLabels(this.labels, params),
assign_agent: resolveAgents(this.agents, params),
mute_conversation: null,
snooze_conversation: null,

View File

@@ -14,6 +14,11 @@ export const MACRO_ACTION_TYPES = [
label: 'Add a label',
inputType: 'multi_select',
},
{
key: 'remove_label',
label: 'Remove a label',
inputType: 'multi_select',
},
{
key: 'send_email_transcript',
label: 'Send an email transcript',

View File

@@ -30,7 +30,7 @@ class Macro < ApplicationRecord
validate :json_actions_format
ACTIONS_ATTRS = %w[send_message add_label assign_team assign_agent mute_conversation change_status
ACTIONS_ATTRS = %w[send_message add_label assign_team assign_agent mute_conversation change_status remove_label
resolve_conversation snooze_conversation send_email_transcript send_attachment add_private_note].freeze
def set_visibility(user, params)

View File

@@ -33,6 +33,13 @@ class ActionService
@conversation.update!(assignee_id: @agent.id) if @agent.present?
end
def remove_label(labels)
return if labels.empty?
labels = @conversation.label_list - labels
@conversation.update(label_list: labels)
end
def assign_team(team_ids = [])
return unless team_belongs_to_account?(team_ids)