CRM-15361, CRM-15857 - crmMailing - Expose email_selection_method in UI
authorTim Otten <totten@civicrm.org>
Sat, 14 Feb 2015 01:09:06 +0000 (17:09 -0800)
committerTim Otten <totten@civicrm.org>
Sat, 14 Feb 2015 01:10:21 +0000 (17:10 -0800)
js/angular-crmMailing.js
partials/crmMailing/dialog/recipientOptions.html

index 5623e42fa9a0d474192ed99d4ccb232fb26ebc14..3ce5edbb5397bc78a9e8d04abdb96bdcbbf25317 100644 (file)
   // Scope members:
   //  - [input] mailing: object
   //  - [output] recipients: array of recipient records
-  angular.module('crmMailing').controller('EditRecipCtrl', function EditRecipCtrl($scope, dialogService, crmApi, crmMailingMgr) {
+  angular.module('crmMailing').controller('EditRecipCtrl', function EditRecipCtrl($scope, dialogService, crmApi, crmMailingMgr, $q, crmMetadata) {
     var ts = $scope.ts = CRM.ts(null);
     $scope.recipients = null;
     $scope.getRecipientsEstimate = function () {
         modal: true,
         title: ts('Edit Options')
       };
-      dialogService.open('previewComponentDialog', '~/crmMailing/dialog/recipientOptions.html', mailing, options);
+      $q.when(crmMetadata.getFields('Mailing')).then(function(fields) {
+        var model = {
+          fields: fields,
+          mailing: mailing
+        };
+        dialogService.open('previewComponentDialog', '~/crmMailing/dialog/recipientOptions.html', model, options);
+      });
     };
   });
 
index ad898f3c2ee5ea57a8639e008a6e05dbd7464af1..4454dd2f98398611f133ae82a9cf5f363bdb626a 100644 (file)
@@ -1,11 +1,12 @@
-<div ng-controller="EditRecipOptionsDialogCtrl">
-  <div class="crm-block" ng-form="responseForm" crm-ui-id-scope>
+<div ng-controller="EditRecipOptionsDialogCtrl" class="crmMailing">
+  <div class="crm-block" ng-form="editRecipOptionsForm" crm-ui-id-scope>
     <div class="crm-group">
+
       <!-- FIXME: ts is not working here. -->
       <div crm-ui-field crm-title="'Dedupe by email'" crm-layout="checkbox">
         <input
           type='checkbox'
-          ng-model='model.dedupe_email'
+          ng-model='model.mailing.dedupe_email'
           ng-true-value="'1'"
           ng-false-value="'0'"
           />
         <p>{{ts('To send only one message to the shared address, enable this option. Mail-merge tokens will be filled for only one person.')}}</p>
         <p>{{ts('To send separate messages for each person, disable this option. Mail-merge tokens will be filled separately for each person.')}}</p>
       </div>
+
+      <div crm-ui-field="editRecipOptionsForm.location_type_id" crm-title="ts('Location Type')">
+        <select
+          crm-ui-id="editRecipOptionsForm.location_type_id"
+          crm-ui-select="{dropdownAutoWidth : true}"
+          name="location_type_id"
+          ng-model="model.mailing.location_type_id"
+          required
+          >
+
+          <option value="">{{ts('Automatic')}}</option>
+          <option ng-repeat="(locTypeId,locType) in model.fields.location_type_id.options | orderBy:'locType'"
+                  ng-value="locTypeId">{{locType}}</option>
+        </select>
+      </div>
+
+      <div crm-ui-field="editRecipOptionsForm.email_selection_method" crm-title="ts('Selection Method')">
+        <select
+          crm-ui-id="editRecipOptionsForm.email_selection_method"
+          crm-ui-select=""
+          name="email_selection_method"
+          ng-model="model.mailing.email_selection_method"
+          required
+          >
+          <option ng-repeat="(selMetId,selMet) in model.fields.email_selection_method.options | orderBy:'selMet'"
+                  ng-value="selMetId">{{selMet}}</option>
+        </select>
+      </div>
+
     </div>
   </div>
 </div>