Skip to content

Commit

Permalink
message_admin - If tpl is translated in default-locale, then it repla…
Browse files Browse the repository at this point in the history
…ces "Standard" tpl
  • Loading branch information
totten committed Jul 11, 2023
1 parent e2b8310 commit 4258524
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions ext/message_admin/ang/crmMsgadm/ListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@
});

var $ctrl = this;
$ctrl.records = _.map(
[].concat(prefetch.records, _.map(prefetch.translations || [], simpleKeys)),
function(r) {
r._is_translation = (r.tx_language !== undefined);
return r;
}
);
var allRecords = [].concat(prefetch.records, _.map(prefetch.translations || [], simpleKeys));
$ctrl.records = _.map(allRecords, function(r) {
r._is_translation = (r.tx_language !== undefined);

// If there is a translation in the system-default-locale, then it replaces the "Standard" tpl as the primary/visible item entry.
const defaultLocaleTpl = _.find(allRecords, {workflow_name: r.workflow_name, tx_language: CRM.config.lcMessages});
r._is_primary = defaultLocaleTpl ? (r === defaultLocaleTpl) : (!r._is_translation);
r._is_visible = (r._is_translation || r._is_primary);

return r;
});

function findTranslations(record) {
return _.reduce($ctrl.records, function(existing, rec){
Expand Down
4 changes: 2 additions & 2 deletions ext/message_admin/ang/crmMsgadm/WorkflowTranslated.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="record in $ctrl.records | filter:filters.text | orderBy:['msg_title','_is_translation','tx_language_label']">
<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>{{record.tx_language_label || ts('Standard')}}</td>
<td>
Expand All @@ -39,7 +39,7 @@
</span>
</td>
<td>
<span ng-if="!record.tx_language">
<span ng-if="record._is_primary">
<a href crm-icon="fa-plus" ng-click="$ctrl.addTranslation(record)" title="{{ts('Add translation, &quot;%1&quot;', {1: record.msg_title})}}">{{:: ts('Translate') }}</a>
</span>
</td>
Expand Down

0 comments on commit 4258524

Please sign in to comment.