Skip to content

Commit

Permalink
crmMosaicoBlockMailing - Fix "Unsubscribe Group"
Browse files Browse the repository at this point in the history
Upstream made some changes in how the list of groups is supplied (CRM-21411, circa
v4.7.28).  This patch ports the change from civicrm/civicrm-core#11258.

Note the use of `CRM.crmMailing.testGroupNames || CRM.crmMailing.groupNames` is intended to
provide compatibility with older and newer protocols.
  • Loading branch information
totten committed Nov 27, 2017
1 parent 1c961ae commit d7c30ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ang/crmMosaico/BlockMailing.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@
<select
class="form-control"
id="inputUnsubscribeGroup"
crm-ui-select="{dropdownAutoWidth : true}"
name="baseGroup"
ng-model="mailing.recipients.groups.base[0]"
ng-required="true"
>
<option ng-repeat="grp in crmMailingConst.groupNames | filter:{is_hidden:0} | orderBy:'title'"
<option value=""></option>
<option ng-repeat="grp in groupNames | filter:{is_hidden:0} | orderBy:'title'"
value="{{grp.id}}">{{grp.title}}</option>
</select>
</div>
Expand Down
26 changes: 24 additions & 2 deletions ang/crmMosaico/BlockMailing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
(function(angular, $, _) {
angular.module('crmMosaico').directive('crmMosaicoBlockMailing', function(crmMailingSimpleDirective) {
return crmMailingSimpleDirective('crmMosaicoBlockMailing', '~/crmMosaico/BlockMailing.html');
angular.module('crmMosaico').directive('crmMosaicoBlockMailing', function($q, crmMetadata, crmUiHelp) {
var directiveName = 'crmMosaicoBlockMailing', templateUrl = '~/crmMosaico/BlockMailing.html';
return {
scope: {
crmMailing: '@'
},
templateUrl: templateUrl,
link: function (scope, elm, attr) {
// Common elements - like crmMailingSimpleDirective
scope.$parent.$watch(attr.crmMailing, function(newValue){
scope.mailing = newValue;
});
scope.crmMailingConst = CRM.crmMailing;
scope.ts = CRM.ts(null);
scope.hs = crmUiHelp({file: 'CRM/Mailing/MailingUI'});
scope[directiveName] = attr[directiveName] ? scope.$parent.$eval(attr[directiveName]) : {};
$q.when(crmMetadata.getFields('Mailing'), function(fields) {
scope.mailingFields = fields;
});

// Unique elements
scope.groupNames = CRM.crmMailing.testGroupNames || CRM.crmMailing.groupNames;
}
};
});
})(angular, CRM.$, CRM._);

0 comments on commit d7c30ea

Please sign in to comment.