(function(angular, $, _) {
var id = 0;
// Example usage: <div af-fieldset="myModel"><af-field name="do_not_email" /></div>
- angular.module('af').directive('afField', function() {
+ angular.module('af').directive('afField', function(crmApi4) {
return {
restrict: 'E',
require: ['^^afForm', '^^afFieldset', '?^^afJoin', '?^^afRepeatItem'],
}, [])
};
};
+
+ // ChainSelect - watch control field & reload options as needed
+ if ($scope.defn.input_type === 'ChainSelect') {
+ $scope.$watch('dataProvider.getFieldData()[defn.input_attrs.controlField]', function(val) {
+ if (val) {
+ var params = {
+ where: [['name', '=', $scope.fieldName]],
+ select: ['options'],
+ loadOptions: true,
+ values: {}
+ };
+ params.values[$scope.defn.input_attrs.controlField] = val;
+ crmApi4($scope.dataProvider.getEntityType(), 'getFields', params, 0)
+ .then(function(data) {
+ $scope.defn.options.length = 0;
+ _.transform(data.options, function(options, label, key) {
+ options.push({key: key, label: label});
+ }, $scope.defn.options);
+ });
+ }
+ });
+ }
}
};
});
this.getName = function() {
return this.modelName;
};
+ this.getEntityType = function() {
+ return this.afFormCtrl.getEntity(this.modelName).type;
+ };
this.getFieldData = function() {
var data = this.getData();
if (!data.length) {
},
controller: function($scope) {
var self = this;
+ this.getEntityType = function() {
+ return this.entity;
+ };
this.getData = function() {
var data, fieldsetData;
if (self.repeatItem) {
},
controller: function($scope) {
this.getItems = $scope.getItems = function() {
- var data = $scope.afJoin ? $scope.afJoin.getData() : $scope.afFieldset.getData();
+ var data = getEntityController().getData();
while ($scope.min && data.length < $scope.min) {
data.push(getRepeatType() === 'join' ? {} : {fields: {}, joins: {}});
}
}
this.getRepeatType = getRepeatType;
+ function getEntityController() {
+ return $scope.afJoin || $scope.afFieldset;
+ }
+ this.getEntityController = getEntityController;
+
$scope.addItem = function() {
$scope.getItems().push(getRepeatType() === 'join' ? {} : {fields: {}});
};
this.getFieldData = function() {
return this.afRepeat.getRepeatType() === 'join' ? this.item : this.item.fields;
};
+
+ this.getEntityType = function() {
+ return this.afRepeat.getEntityController().getEntityType();
+ };
}
};
});
--- /dev/null
+<input crm-ui-select="{data: select2Options, multiple: defn.input_attrs.multiple, placeholder: defn.input_attrs.placeholder}" id="{{ fieldId }}" ng-model="dataProvider.getFieldData()[fieldName]" />
--- /dev/null
+<div class="af-container af-layout-inline">
+ <af-field name="street_address" />
+ <af-field name="location_type_id" />
+</div>
+<div class="af-container af-layout-inline">
+ <af-field name="city" />
+ <af-field name="state_province_id" />
+ <af-field name="country_id" />
+ <af-field name="postal_code" />
+</div>
--- /dev/null
+{
+ "title": "Address Block (default)",
+ "block": "Contact",
+ "join": "Address",
+ "repeat": true
+}
#afGuiEditor .af-gui-field-input-type-select .input-group-btn {
position: initial;
}
+#afGuiEditor .af-gui-field-input-type-chainselect .input-group .dropdown-toggle,
#afGuiEditor .af-gui-field-input-type-select .input-group .dropdown-toggle {
padding: 3px 11px;
}
--- /dev/null
+<div class="form-inline">
+ <div class="input-group">
+ <input autocomplete="off" class="form-control" placeholder="{{ ts('Select') }}" title="{{ ts('Click to add placeholder text') }}" ng-model="getSet('input_attrs.placeholder')" ng-model-options="{getterSetter: true}" type="text" />
+ <div class="input-group-btn">
+ <button type="button" class="btn btn-default disabled dropdown-toggle"><i class="crm-i fa-caret-down"></i></button>
+ </div>
+ </div>
+</div>