),
);
+ $config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
'options' => array(
'limit' => 500,
'sort' => 'is_archived asc, scheduled_date desc',
- )
+ ),
));
// Generic params
$params = array(
'options' => array('limit' => 0),
'sequential' => 1,
);
-
- $campNames = civicrm_api3('Campaign', 'get', $params + array(
- 'is_active' => 1,
- 'return' => 'title',
- ));
+
$groupNames = civicrm_api3('Group', 'get', $params + array(
'is_active' => 1,
'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
$mailGrp = civicrm_api3('MailingGroup', 'get', $params);
$mailTokens = civicrm_api3('Mailing', 'gettokens', array(
'entity' => array('contact', 'mailing'),
- 'sequential' => 1
+ 'sequential' => 1,
));
$fromAddress = civicrm_api3('OptionValue', 'get', $params + array(
'option_group_id' => "from_email_address",
->addSetting(array(
'crmMailing' => array(
'civiMails' => $civiMails['values'],
- 'campNames' => $campNames['values'],
+ 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents),
'groupNames' => $groupNames['values'],
'headerfooterList' => $headerfooterList['values'],
'mesTemplate' => $mesTemplate['values'],
};
})
+ // Render a crmEntityRef widget
+ // usage: <input crm-entityref="{entity: 'Contact', select: {allowClear:true}}" ng-model="myobj.field" />
+ .directive('crmEntityref', function ($parse, $timeout) {
+ return {
+ require: '?ngModel',
+ scope: {
+ crmEntityref: '='
+ },
+ link: function (scope, element, attrs, ngModel) {
+ // In cases where UI initiates update, there may be an extra
+ // call to refreshUI, but it doesn't create a cycle.
+
+ ngModel.$render = function () {
+ $timeout(function () {
+ // ex: msg_template_id adds new item then selects it; use $timeout to ensure that
+ // new item is added before selection is made
+ element.select2('val', ngModel.$viewValue);
+ });
+ };
+ function refreshModel() {
+ var oldValue = ngModel.$viewValue, newValue = element.select2('val');
+ if (oldValue != newValue) {
+ scope.$parent.$apply(function () {
+ ngModel.$setViewValue(newValue);
+ });
+ }
+ }
+
+ function init() {
+ // TODO watch options
+ // TODO can we infer "entity" from model?
+ element.crmEntityRef(scope.crmEntityref || {});
+ element.on('change', refreshModel);
+ $timeout(ngModel.$render);
+ }
+
+ init();
+ }
+ };
+ })
+
// example <div crm-ui-tab crm-title="ts('My Title')">...content...</div>
// WISHLIST: use a full Angular component instead of an incomplete jQuery wrapper
.directive('crmUiTab', function($parse) {
name="mailingName" />
</div>
</div>
- <div crm-ui-field="{name: 'subform.campaign', title: ts('Campaign'), help: hs({id: 'id-campaign_id', file: 'CRM/Campaign/Form/addCampaignToComponent'})}" ng-show="crmMailingConst.campNames.length > 0">
- <select
+ <div crm-ui-field="{name: 'subform.campaign', title: ts('Campaign'), help: hs({id: 'id-campaign_id', file: 'CRM/Campaign/Form/addCampaignToComponent'})}" ng-show="crmMailingConst.campaignEnabled">
+ <input
+ crm-entityref="{entity: 'Campaign', select: {allowClear: true, placeholder: ts('Select Campaign')}}"
crm-ui-id="subform.campaign"
name="campaign"
- ui-jq="select2"
- ui-options="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Select Campaign')}"
ng-model="mailing.campaign_id"
- ng-options="campaign.id as campaign.title for campaign in crmMailingConst.campNames|orderBy:'title'"
- >
- <option value=""></option>
- </select>
+ />
</div>
</div>
</div>
placeholder="A/B Test Name"
required/>
</div>
- <div crm-ui-field="{name: 'setupForm.campaign', title: ts('Campaign'), help: hs({id: 'id-campaign_id', file: 'CRM/Campaign/Form/addCampaignToComponent'})}" ng-show="crmMailingConst.campNames.length > 0"
+ <div crm-ui-field="{name: 'setupForm.campaign', title: ts('Campaign'), help: hs({id: 'id-campaign_id', file: 'CRM/Campaign/Form/addCampaignToComponent'})}" ng-show="crmMailingConst.campaignEnabled"
ng-if="fields.campaign">
- <select
+ <input
+ crm-entityref="{entity: 'Campaign', select: {allowClear: true, placeholder: ts('Select Campaign')}}"
crm-ui-id="setupForm.campaign"
name="campaign"
- ui-jq="select2"
- ui-options="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('Select Campaign')}"
ng-model="mailing.campaign_id"
- ng-options="campaign.id as campaign.title for campaign in crmMailingConst.campNames|orderBy:'title'"
- >
- <option value=""></option>
- </select>
+ />
</div>
<div crm-ui-field="{title: ts('Test Type')}" ng-if="fields.testing_criteria">
<div ng-repeat="criteria in crmMailingABCriteria.getAll()">