CRM-15856 - crmMailing - "Reply-To" and "Track Replies" are mutually exclusive
authorTim Otten <totten@civicrm.org>
Thu, 12 Feb 2015 21:47:12 +0000 (13:47 -0800)
committerTim Otten <totten@civicrm.org>
Thu, 12 Feb 2015 21:47:12 +0000 (13:47 -0800)
js/angular-crmMailing.js
partials/crmMailing/mailing.html
partials/crmMailing/responses.html

index 3077d4d11be0ab08a3ab7b8767a1d87d6042a0f4..86ff87168ef73ead32c85192ffb633b7df23a6bc 100644 (file)
     setTimeout(scopeApply(init), 0);
   });
 
-  angular.module('crmMailing').controller('EmailAddrCtrl', function EmailAddrCtrl($scope, crmFromAddresses) {
+  angular.module('crmMailing').controller('EmailAddrCtrl', function EmailAddrCtrl($scope, crmFromAddresses, crmUiAlert) {
+    var ts = CRM.ts(null);
+    function changeAlert(winnerField, loserField) {
+      crmUiAlert({
+        title: ts('Conflict'),
+        text: ts('The "%1" option conflicts with the "%2" option. The "%2" option has been disabled.', {
+          1: winnerField,
+          2: loserField
+        })
+      });
+    }
+
     $scope.crmFromAddresses = crmFromAddresses;
+    $scope.checkReplyToChange = function checkReplyToChange(mailing) {
+      if (!_.isEmpty(mailing.replyto_email) && mailing.override_verp == '0') {
+        mailing.override_verp = '1';
+        changeAlert(ts('Reply-To'), ts('Track Replies'))
+      }
+    };
+    $scope.checkVerpChange = function checkVerpChange(mailing) {
+      if (!_.isEmpty(mailing.replyto_email) && mailing.override_verp == '0') {
+        mailing.replyto_email = '';
+        changeAlert(ts('Track Replies'), ts('Reply-To'));
+      }
+    };
   });
 
   var lastEmailTokenAlert = null;
index de2068fdda0dcb74463dafa58f959f8acd62e6c6..84b855b69f6be061ada1d959fd01ae6774d93fc1 100644 (file)
@@ -25,13 +25,12 @@ It could perhaps be thinned by 30-60% by making more directives.
       <div ng-controller="EmailAddrCtrl" crm-mailing-from-address="fromPlaceholder" crm-mailing="mailing">
         <select
           crm-ui-id="subform.fromAddress"
+          crm-ui-select="{dropdownAutoWidth : true, allowClear: false, placeholder: ts('Email address')}"
           name="fromAddress"
-          ui-jq="select2"
-          ui-options="{dropdownAutoWidth : true, allowClear: false, placeholder: ts('Email address')}"
           ng-model="fromPlaceholder.label"
-          ng-options="frm.label as frm.label for frm in crmFromAddresses.getAll() | filter:{is_active:1} | orderBy:'weight'"
           required>
           <option value=""></option>
+          <option ng-repeat="frm in crmFromAddresses.getAll() | filter:{is_active:1} | orderBy:'weight'" value="{{frm.label}}">{{frm.label}}</option>
         </select>
       </div>
     </div>
@@ -39,13 +38,13 @@ It could perhaps be thinned by 30-60% by making more directives.
       <div ng-controller="EmailAddrCtrl">
         <select
           crm-ui-id="subform.replyTo"
+          crm-ui-select="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Email address')}"
           name="replyTo"
-          ui-jq="select2"
-          ui-options="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Email address')}"
+          ng-change="checkReplyToChange(mailing)"
           ng-model="mailing.replyto_email"
-          ng-options="frm.label as frm.label for frm in crmFromAddresses.getAll() | filter:{is_active:1} | orderBy:'weight'"
           >
           <option value=""></option>
+          <option ng-repeat="frm in crmFromAddresses.getAll() | filter:{is_active:1} | orderBy:'weight'" value="{{frm.label}}">{{frm.label}}</option>
         </select>
       </div>
     </div>
index 5bebd5072415999de85535223b4c65d3e7d6a9d0..43d8f7ddf6c7f6dd3a3b44142a4985f0fe018d30 100644 (file)
@@ -6,7 +6,16 @@ Required vars: mailing, crmMailingConst
   <div class="crm-group">
     <div crm-ui-field crm-title="ts('Track Replies')" crm-layout="checkbox">
       <!-- Comparing data-model and UI of "override_verp", note that true/false are inverted (enabled==0,disabled==1) -->
-      <input name="override_verp" type="checkbox" ng-model="mailing.override_verp" ng-true-value="'0'" ng-false-value="'1'" />
+      <span ng-controller="EmailAddrCtrl">
+        <input
+          name="override_verp"
+          type="checkbox"
+          ng-change="checkVerpChange(mailing)"
+          ng-model="mailing.override_verp"
+          ng-true-value="'0'"
+          ng-false-value="'1'"
+          />
+      </span>
     </div>
     <div class="crm-section" id="help">
       {{ts('Recipients\' replies are sent to a CiviMail specific address instead of the sender\'s address so they can be stored within CiviCRM.')}}