From 0f377da1091d54fd42d95cd71d59950b086143d6 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Tue, 15 Jun 2021 14:14:59 +0530 Subject: [PATCH] feat: Add an option to delete campaigns (#2402) Co-authored-by: Pranav Raj S --- .../api/v1/accounts/campaigns_controller.rb | 5 + .../dashboard/i18n/locale/en/campaign.json | 13 ++ .../settings/inbox/components/AddCampaign.vue | 207 ++++++++--------- .../settings/inbox/components/Campaign.vue | 46 +++- .../inbox/components/CampaignsTable.vue | 14 +- .../inbox/components/EditCampaign.vue | 212 ++++++++---------- .../dashboard/store/modules/campaigns.js | 12 + .../modules/specs/campaigns/actions.spec.js | 22 ++ .../modules/specs/campaigns/mutations.spec.js | 8 + .../dashboard/store/mutation-types.js | 1 + config/routes.rb | 2 +- .../v1/accounts/campaigns_controller_spec.rb | 36 +++ 12 files changed, 334 insertions(+), 244 deletions(-) diff --git a/app/controllers/api/v1/accounts/campaigns_controller.rb b/app/controllers/api/v1/accounts/campaigns_controller.rb index c4555017d..5c58d3f51 100644 --- a/app/controllers/api/v1/accounts/campaigns_controller.rb +++ b/app/controllers/api/v1/accounts/campaigns_controller.rb @@ -10,6 +10,11 @@ class Api::V1::Accounts::CampaignsController < Api::V1::Accounts::BaseController @campaign = Current.account.campaigns.create!(campaign_params) end + def destroy + @campaign.destroy + head :ok + end + def show; end def update diff --git a/app/javascript/dashboard/i18n/locale/en/campaign.json b/app/javascript/dashboard/i18n/locale/en/campaign.json index 2eed61b19..f1c249669 100644 --- a/app/javascript/dashboard/i18n/locale/en/campaign.json +++ b/app/javascript/dashboard/i18n/locale/en/campaign.json @@ -42,6 +42,19 @@ "ERROR_MESSAGE": "There was an error. Please try again." } }, + "DELETE": { + "BUTTON_TEXT": "Delete", + "CONFIRM": { + "TITLE": "Confirm Deletion", + "MESSAGE": "Are you sure to delete?", + "YES": "Yes, Delete ", + "NO": "No, Keep " + }, + "API": { + "SUCCESS_MESSAGE": "Campaign deleted successfully", + "ERROR_MESSAGE": "Could not delete the campaign. Please try again later." + } + }, "EDIT": { "TITLE": "Edit campaign", "UPDATE_BUTTON_TEXT": "Update", diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue index 70be87feb..ea067fa3e 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AddCampaign.vue @@ -1,132 +1,112 @@