Commit 156759e7 authored by jaapjansma's avatar jaapjansma
Browse files

Revert "Changed the handling of select2 drop downs."

This reverts commit d873ce5f.
parent d873ce5f
Version 1.21 (not yet released)
============
* Changed the handling of select2 drop downs.
Version 1.20
============
......
......@@ -12,11 +12,11 @@
<select class="huge40"
name="{{input.name}}"
crm-ui-id="defaultData.{{input.name}}"
crm-form-processor-select2="{dropdownAutoWidth : true, allowClear: true, placeholder: ts('- Select field to add to the output -')}"
crm-ui-select="{dropdownAutoWidth : true, allowClear: true}"
ng-model="formProcessor.default_data_output_configuration[input.name]"
ng-required="false"
>
<option value=""></option>
<option value="">{{ts('- Select field to add to the output -')}}</option>
<option ng-repeat="field in default_data_fields track by field.name" value="{{field.name}}">{{field.label}}</option>
</select>
</td>
......
......@@ -6,7 +6,7 @@
<div ng-attr-class="{{!noLabel ? 'content' : ''}}" ng-if="specification.options">
<select
class="huge"
crm-form-processor-select2="{allowClear: true, minimumInputLength: 0}"
crm-ui-select="{allowClear: true, minimumInputLength: 0}"
crm-ui-id="{{specification.name}}"
name="{{specification.name}}"
ng-model="configuration[specification.name]"
......@@ -45,7 +45,7 @@
<div ng-attr-class="{{!noLabel ? 'content' : ''}}">
<select
name="{{specification.name}}"
crm-form-processor-select2="{allowClear: true, minimumInputLength: 0}"
crm-ui-select="{allowClear: true, minimumInputLength: 0}"
ng-model="configuration[specification.name]"
ng-required="specification.required"
ng-options="field.name as field.label for field in fields track by field.name">
......
(function (angular, $, _) {
angular.module('form_processor').directive('crmFormProcessorSelect2', function($parse, $timeout) {
return {
require: '?ngModel',
priority: 999,
scope: {
crmFormProcessorSelect2: '='
},
link: function (scope, element, attrs, ngModel) {
ngModel.$render = function () {
var newVal = ngModel.$modelValue;
// Fix possible data-type mismatch
if (typeof newVal === 'string' && element.select2('container').hasClass('select2-container-multi')) {
newVal = newVal.length ? newVal.split(',') : [];
}
element.select2('val', newVal);
};
function refreshModel() {
var oldValue = ngModel.$viewValue, newValue = element.select2('val');
if (oldValue != newValue) {
scope.$parent.$apply(function () {
ngModel.$setViewValue(newValue);
});
}
}
function init() {
var settings = scope.crmFormProcessorSelect2 || {};
element.crmSelect2(settings);
if (ngModel) {
element.on('change', refreshModel);
}
}
init();
}
};
});
})(angular, CRM.$, CRM._);
......@@ -2,7 +2,7 @@
<div crm-ui-field="spec.crmUiField"
ng-if="spec.options">
<select crm-ui-id="{{spec.name}}"
crm-form-processor-select2="{allowClear: true, minimumInputLength: 0}"
crm-ui-select="{allowClear: true, minimumInputLength: 0}"
name="{{spec.name}}"
ng-if="!spec.multiple"
ng-model="configuration[spec.name]"
......@@ -13,7 +13,7 @@
</select>
<select class="huge"
crm-ui-id="{{spec.name}}"
crm-form-processor-select2="{allowClear: true, minimumInputLength: 0}"
crm-ui-select="{allowClear: true, minimumInputLength: 0}"
name="{{spec.name}}"
ng-if="spec.multiple"
ng-model="configuration[spec.name]"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment