Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CiviMail - Only display "Headers and Footers" if there are headers and footers #15326

Merged
merged 2 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ang/crmMailing.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
selectedMail: function($route, crmMailingMgr) {
return crmMailingMgr.get($route.current.params.id);
},
mailingFields: function(crmMetadata) {
return crmMetadata.getFields('Mailing');
},
attachments: function($route, CrmAttachments) {
var attachments = new CrmAttachments(function () {
return {entity_table: 'civicrm_mailing', entity_id: $route.current.params.id};
Expand Down
3 changes: 2 additions & 1 deletion ang/crmMailing/EditMailingCtrl.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
(function(angular, $, _) {

angular.module('crmMailing').controller('EditMailingCtrl', function EditMailingCtrl($scope, selectedMail, $location, crmMailingMgr, crmStatus, attachments, crmMailingPreviewMgr, crmBlocker, CrmAutosaveCtrl, $timeout, crmUiHelp) {
angular.module('crmMailing').controller('EditMailingCtrl', function EditMailingCtrl($scope, selectedMail, $location, crmMailingMgr, crmStatus, attachments, crmMailingPreviewMgr, crmBlocker, CrmAutosaveCtrl, $timeout, crmUiHelp, mailingFields) {
var APPROVAL_STATUSES = {'Approved': 1, 'Rejected': 2, 'None': 3};

$scope.mailing = selectedMail;
$scope.attachments = attachments;
$scope.crmMailingConst = CRM.crmMailing;
$scope.checkPerm = CRM.checkPerm;
$scope.mailingFields = mailingFields;

var ts = $scope.ts = CRM.ts(null);
$scope.hs = crmUiHelp({file: 'CRM/Mailing/MailingUI'});
Expand Down
2 changes: 1 addition & 1 deletion ang/crmMailing/EditMailingCtrl/2step.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div crm-ui-tab id="tab-attachment" crm-title="ts('Attachments')">
<div crm-attachments="attachments"></div>
</div>
<div crm-ui-tab id="tab-header" crm-title="ts('Header and Footer')">
<div crm-ui-tab id="tab-header" crm-title="ts('Header and Footer')" ng-if="mailingFields.header_id.options.length > 0 || mailingFields.footer_id.options.length > 0">
<div crm-mailing-block-header-footer crm-mailing="mailing"></div>
</div>
<div crm-ui-tab id="tab-pub" crm-title="ts('Publication')">
Expand Down
2 changes: 1 addition & 1 deletion ang/crmMailing/EditMailingCtrl/workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div crm-mailing-body-text crm-mailing="mailing"></div>
</div>
<span ng-model="placeholder" crm-ui-validate="mailing.body_html || mailing.body_text"></span>
<div crm-ui-accordion="{title: ts('Header and Footer'), collapsed: true}">
<div crm-ui-accordion="{title: ts('Header and Footer'), collapsed: true}" ng-if="mailingFields.header_id.options.length > 0 || mailingFields.footer_id.options.length > 0">
<div crm-mailing-block-header-footer crm-mailing="mailing"></div>
</div>
<div crm-ui-accordion="{title: ts('Attachments'), collapsed: true}">
Expand Down
3 changes: 3 additions & 0 deletions ang/crmMailingAB.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
templateUrl: '~/crmMailingAB/EditCtrl/main.html',
controller: 'CrmMailingABEditCtrl',
resolve: {
mailingFields: function(crmMetadata) {
return crmMetadata.getFields('Mailing');
},
abtest: function($route, CrmMailingAB) {
var abtest = new CrmMailingAB($route.current.params.id == 'new' ? null : $route.current.params.id);
return abtest.load();
Expand Down
3 changes: 2 additions & 1 deletion ang/crmMailingAB/EditCtrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(angular, $, _) {

angular.module('crmMailingAB').controller('CrmMailingABEditCtrl', function($scope, abtest, crmMailingABCriteria, crmMailingMgr, crmMailingPreviewMgr, crmStatus, $q, $location, crmBlocker, $interval, $timeout, CrmAutosaveCtrl, dialogService) {
angular.module('crmMailingAB').controller('CrmMailingABEditCtrl', function($scope, abtest, crmMailingABCriteria, crmMailingMgr, crmMailingPreviewMgr, crmStatus, $q, $location, crmBlocker, $interval, $timeout, CrmAutosaveCtrl, dialogService, mailingFields) {
$scope.abtest = abtest;
var ts = $scope.ts = CRM.ts(null);
var block = $scope.block = crmBlocker();
Expand All @@ -9,6 +9,7 @@
$scope.crmMailingABCriteria = crmMailingABCriteria;
$scope.crmMailingConst = CRM.crmMailing;
$scope.checkPerm = CRM.checkPerm;
$scope.mailingFields = mailingFields;

$scope.isSubmitted = function isSubmitted() {
return _.size(abtest.mailings.a.jobs) > 0 || _.size(abtest.mailings.b.jobs) > 0;
Expand Down
6 changes: 3 additions & 3 deletions ang/crmMailingAB/EditCtrl/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<div crm-attachments="abtest.attachments.a"></div>
</div>
-->
<div crm-ui-tab id="tab-header" crm-title="ts('Header and Footer')">
<div crm-ui-tab id="tab-header" crm-title="ts('Header and Footer')" ng-if="mailingFields.header_id.options.length > 0 || mailingFields.footer_id.options.length > 0">
<div crm-mailing-block-header-footer crm-mailing="abtest.mailings.a"></div>
</div>
<div crm-ui-tab id="tab-pub" crm-title="ts('Publication')">
Expand Down Expand Up @@ -101,7 +101,7 @@
<div crm-ui-tab id="tab-attachmentA" crm-title="ts('Attachments')">
<div crm-attachments="abtest.attachments.a"></div>
</div>
<div crm-ui-tab id="tab-headerA" crm-title="ts('Header and Footer')">
<div crm-ui-tab id="tab-headerA" crm-title="ts('Header and Footer')" ng-if="mailingFields.header_id.options.length > 0 || mailingFields.footer_id.options.length > 0">
<div crm-mailing-block-header-footer crm-mailing="abtest.mailings.a"></div>
</div>
<div crm-ui-tab id="tab-pubA" crm-title="ts('Publication')">
Expand Down Expand Up @@ -136,7 +136,7 @@
<div crm-ui-tab id="tab-attachmentB" crm-title="ts('Attachments')">
<div crm-attachments="abtest.attachments.b"></div>
</div>
<div crm-ui-tab id="tab-headerB" crm-title="ts('Header and Footer')">
<div crm-ui-tab id="tab-headerB" crm-title="ts('Header and Footer')" ng-if="mailingFields.header_id.options.length > 0 || mailingFields.footer_id.options.length > 0">
<div crm-mailing-block-header-footer crm-mailing="abtest.mailings.b"></div>
</div>
<div crm-ui-tab id="tab-pubB" crm-title="ts('Publication')">
Expand Down