Skip to content

Commit

Permalink
Merge pull request #30500 from eileenmcnaughton/revert_ui
Browse files Browse the repository at this point in the history
Add revert option to the UI for MessageAdmin
  • Loading branch information
eileenmcnaughton authored Jun 19, 2024
2 parents 7dc0a35 + de9473a commit f0e2d0f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ext/message_admin/ang/crmMsgadm/ListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
3 changes: 3 additions & 0 deletions ext/message_admin/ang/crmMsgadm/Workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<tbody>
<tr ng-repeat="record in $ctrl.records | filter:filters.text | orderBy:['msg_title','_is_translation','tx_language_label']">
<td>{{record.msg_title}}</td>
<td class="text-right">
<a ng-show="record.master_id" class="btn btn-xs btn-default" ng-click="$ctrl.revert(record)">{{:: ts('Revert') }}</a>
</td>
<td class="text-right">
<a class="btn btn-xs btn-default" ng-href="{{$ctrl.editUrl(record)}}">{{:: ts('Edit') }}</a>
</td>
Expand Down
2 changes: 1 addition & 1 deletion ext/message_admin/ang/crmMsgadm/Workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
3 changes: 3 additions & 0 deletions ext/message_admin/ang/crmMsgadm/WorkflowTranslated.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<tbody>
<tr ng-repeat="record in $ctrl.records | filter:filters.text | filter:{_is_visible: true} | orderBy:['msg_title','!_is_primary','tx_language_label']">
<td>{{record.msg_title}}</td>
<td class="text-right">
<a ng-show="record.master_id" class="btn btn-xs btn-default" ng-click="$ctrl.revert(record)">{{:: ts('Revert') }}</a>
</td>
<td>{{record.tx_language_label || ts('Standard')}}</td>
<td>
<span ng-if="!record.tx_language || !!record.tx_statuses.active">
Expand Down

0 comments on commit f0e2d0f

Please sign in to comment.