Skip to content

Commit

Permalink
message_admin - When using "Preview", use the 'locale' from the editi…
Browse files Browse the repository at this point in the history
…ng UI
  • Loading branch information
totten committed Oct 8, 2021
1 parent 17858e1 commit d2c77bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion ext/message_admin/ang/crmMsgadm/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@
}
return acc;
}, []),
title: ts('Preview')
filterData: function(data) {
data.modelProps.locale = $ctrl.lang;
return data;
},
title: $ctrl.lang ? ts('Preview - %1', {1: $ctrl.locales[$ctrl.lang] || $ctrl.lang}) : ts('Preview')
};

crmApi4({
Expand Down
10 changes: 7 additions & 3 deletions ext/message_admin/ang/crmMsgadm/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
}).then(function(response){
dlgModel.title = ts('Example: %1', {1: response[0].title || response[0].name});
dlgModel.data = response[0];
if (model.filterData && dlgModel.data.data) {
dlgModel.data['data(filtered)'] = model.filterData(angular.copy(dlgModel.data.data));
}
});
};

Expand Down Expand Up @@ -76,10 +79,11 @@
// $ctrl.preview = model.revisions[$ctrl.revisionId].rec;
$ctrl.preview = {loading: true};
var rendering = $ctrl.isAdhocExample ? requestAdhocExample() : requestStoredExample();
rendering.then(function(exampleData){
rendering.then(function(exampleData) {
var filteredData = model.filterData ? model.filterData(exampleData) : exampleData;
return crmApi4('WorkflowMessage', 'render', {
workflow: exampleData.workflow,
values: exampleData.modelProps,
workflow: filteredData.workflow,
values: filteredData.modelProps,
messageTemplate: model.revisions[$ctrl.revisionId].rec
});
}).then(function(response) {
Expand Down

0 comments on commit d2c77bf

Please sign in to comment.