From de9473a9f23c14e39d44ee720c8e0723cdc4e8ce Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 19 Jun 2024 14:14:15 -0400 Subject: [PATCH] Add revert option to the UI for MessageAdmin --- ext/message_admin/ang/crmMsgadm/ListCtrl.js | 15 +++++++++++++++ ext/message_admin/ang/crmMsgadm/Workflow.html | 3 +++ ext/message_admin/ang/crmMsgadm/Workflow.js | 2 +- .../ang/crmMsgadm/WorkflowTranslated.html | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ext/message_admin/ang/crmMsgadm/ListCtrl.js b/ext/message_admin/ang/crmMsgadm/ListCtrl.js index 688474cc6741..4f150103517a 100644 --- a/ext/message_admin/ang/crmMsgadm/ListCtrl.js +++ b/ext/message_admin/ang/crmMsgadm/ListCtrl.js @@ -82,6 +82,21 @@ return url; }; + /** + * + * @param record + * @returns {string} + */ + $ctrl.revert = function(record) { + CRM.api4('MessageTemplate', 'revert', { + where: [["id", "=", record.id]] + }).then(function(results) { + $route.reload(); + }, function(failure) { + // handle failure + }); + }; + $ctrl.addTranslation = function(record) { var existing = findTranslations(record), activeLangs = findActiveLangs(); var langs = []; diff --git a/ext/message_admin/ang/crmMsgadm/Workflow.html b/ext/message_admin/ang/crmMsgadm/Workflow.html index 9260e14f43d9..73e24cc07b9a 100644 --- a/ext/message_admin/ang/crmMsgadm/Workflow.html +++ b/ext/message_admin/ang/crmMsgadm/Workflow.html @@ -18,6 +18,9 @@ {{record.msg_title}} + + {{:: ts('Revert') }} + {{:: ts('Edit') }} diff --git a/ext/message_admin/ang/crmMsgadm/Workflow.js b/ext/message_admin/ang/crmMsgadm/Workflow.js index 926f5f5e3a3c..0c2dd5f724a8 100644 --- a/ext/message_admin/ang/crmMsgadm/Workflow.js +++ b/ext/message_admin/ang/crmMsgadm/Workflow.js @@ -14,7 +14,7 @@ prefetch: function(crmApi4, crmStatus) { var q = crmApi4({ records: ['MessageTemplate', 'get', { - select: ["id", "msg_title", "is_default", "is_active", "workflow_name"], + select: ["id", "msg_title", "is_default", "is_active", "workflow_name", 'master_id'], where: [["workflow_name", "IS NOT EMPTY"], ["is_reserved", "=", "0"]] }], translations: ['MessageTemplate', 'get', { diff --git a/ext/message_admin/ang/crmMsgadm/WorkflowTranslated.html b/ext/message_admin/ang/crmMsgadm/WorkflowTranslated.html index 2bcea9b050c0..9747c58a9aa2 100644 --- a/ext/message_admin/ang/crmMsgadm/WorkflowTranslated.html +++ b/ext/message_admin/ang/crmMsgadm/WorkflowTranslated.html @@ -21,6 +21,9 @@ {{record.msg_title}} + + {{:: ts('Revert') }} + {{record.tx_language_label || ts('Standard')}}