{{:: ts('Search by range') }}
</a>
</li>
+<li ng-if="$ctrl.isSearch()">
+ <div href ng-click="$event.stopPropagation()" class="af-gui-field-select-in-dropdown">
+ <label>{{:: ts('Operator:') }}</label>
+ <select class="form-control" ng-model="getSet('search_operator')" ng-model-options="{getterSetter: true}" title="{{:: ts('Field type') }}">
+ <option ng-repeat="(name, label) in $ctrl.searchOperators" value="{{ name }}">{{ label }}</option>
+ </select>
+ </div>
+</li>
<li role="separator" class="divider" ng-if="hasOptions()"></li>
<li ng-if="hasOptions()" ng-click="$event.stopPropagation()">
<a href ng-click="resetOptions()" title="{{:: ts('Reset the option list for this field') }}">
$scope.editingOptions = val;
};
+ this.searchOperators = {
+ '': ts('Auto'),
+ '=': '=',
+ '!=': '≠',
+ '>': '>',
+ '<': '<',
+ '>=': '≥',
+ '<=': '≤',
+ 'CONTAINS': ts('Contains'),
+ 'IN': ts('Is One Of'),
+ 'NOT IN': ts('Not One Of'),
+ 'LIKE': ts('Is Like'),
+ 'NOT LIKE': ts('Not Like'),
+ 'REGEXP': ts('Matches Pattern'),
+ 'NOT REGEXP': ts("Doesn't Match Pattern"),
+ };
+
// Returns a reference to a path n-levels deep within an object
function drillDown(parent, path) {
var container = parent;
) {
value = value.split(',');
}
- $scope.dataProvider.getFieldData()[ctrl.fieldName] = value;
+ $scope.getSetValue(value);
}
// Get the repeat index of the entity fieldset (not the join)
};
};
+ // Getter/Setter function for most fields (except select & entityRef)
+ $scope.getSetValue = function(val) {
+ var currentVal = $scope.dataProvider.getFieldData()[ctrl.fieldName];
+ // Setter
+ if (arguments.length) {
+ if (ctrl.defn.search_operator) {
+ if (typeof currentVal !== 'object') {
+ $scope.dataProvider.getFieldData()[ctrl.fieldName] = {};
+ }
+ return ($scope.dataProvider.getFieldData()[ctrl.fieldName][ctrl.defn.search_operator] = val);
+ }
+ return ($scope.dataProvider.getFieldData()[ctrl.fieldName] = val);
+ }
+ // Getter
+ if (ctrl.defn.search_operator) {
+ return (currentVal || {})[ctrl.defn.search_operator];
+ }
+ return currentVal;
+ };
+
// Getter/Setter function for fields of type select or entityRef.
$scope.getSetSelect = function(val) {
var currentVal = $scope.dataProvider.getFieldData()[ctrl.fieldName];
else if (ctrl.defn.search_range) {
return ($scope.dataProvider.getFieldData()[ctrl.fieldName]['>='] = val);
}
+ else if (ctrl.defn.search_operator) {
+ if (typeof currentVal !== 'object') {
+ $scope.dataProvider.getFieldData()[ctrl.fieldName] = {};
+ }
+ return ($scope.dataProvider.getFieldData()[ctrl.fieldName][ctrl.defn.search_operator] = val);
+ }
return ($scope.dataProvider.getFieldData()[ctrl.fieldName] = val);
}
// Getter
else if (ctrl.defn.search_range) {
return currentVal['>='];
}
+ else if (ctrl.defn.search_operator) {
+ return (currentVal || {})[ctrl.defn.search_operator];
+ }
return currentVal;
};
-<input class="form-control" ng-required="$ctrl.defn.required" crm-ui-select="{data: select2Options, multiple: $ctrl.defn.input_attrs.multiple, placeholder: $ctrl.defn.input_attrs.placeholder}" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" />
+<input class="form-control" ng-required="$ctrl.defn.required" crm-ui-select="{data: select2Options, multiple: $ctrl.defn.input_attrs.multiple, placeholder: $ctrl.defn.input_attrs.placeholder}" id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" />
<label for="{{ fieldId + opt.id }}">{{:: opt.label }}</label>
</li>
</ul>
-<input type="checkbox" ng-required="$ctrl.defn.required" ng-if="!$ctrl.defn.options" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" />
+<input type="checkbox" ng-required="$ctrl.defn.required" ng-if="!$ctrl.defn.options" id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" />
-<input ng-if=":: !$ctrl.defn.search_range" class="form-control" crm-ui-datepicker=":: $ctrl.defn.input_attrs" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" />
+<input ng-if=":: !$ctrl.defn.search_range" class="form-control" crm-ui-datepicker=":: $ctrl.defn.input_attrs" id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" />
<div ng-if=":: $ctrl.defn.search_range" class="form-inline">
<input class="form-control" ng-required="$ctrl.defn.required" crm-ui-datepicker=":: $ctrl.inputAttrs[1]" id="{{:: fieldId }}1" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]['>=']" />
<span class="af-field-range-sep">-</span>
-<input ng-if=":: !$ctrl.defn.search_range" class="form-control" ng-required="$ctrl.defn.required" type="number" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" placeholder="{{:: $ctrl.defn.input_attrs.placeholder }}" >
+<input ng-if=":: !$ctrl.defn.search_range" class="form-control" ng-required="$ctrl.defn.required" type="number" id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" placeholder="{{:: $ctrl.defn.input_attrs.placeholder }}" >
<div ng-if=":: $ctrl.defn.search_range" class="form-inline">
<input class="form-control" type="number" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]['>=']" placeholder="{{:: $ctrl.defn.input_attrs.placeholder }}" >
<span class="af-field-range-sep">-</span>
<label ng-repeat="opt in getOptions() track by opt.id" >
- <input class="crm-form-radio" type="radio" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" ng-value="opt.id" />
+ <input class="crm-form-radio" type="radio" ng-model="getSetValue" ng-model-options="{getterSetter: true}" ng-value="opt.id" />
{{:: opt.label }}
</label>
<a ng-if="!$ctrl.defn.required" class="crm-hover-button" title="{{:: ts('Clear') }}" ng-show="!!dataProvider.getFieldData()[$ctrl.fieldName] || dataProvider.getFieldData()[$ctrl.fieldName] === false || dataProvider.getFieldData()[$ctrl.fieldName] === 0" ng-click="dataProvider.getFieldData()[$ctrl.fieldName] = null">
-<textarea crm-ui-richtext id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" ></textarea>
+<textarea crm-ui-richtext id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" ></textarea>
-<input ng-if=":: !$ctrl.defn.search_range" class="form-control" type="text" ng-required="$ctrl.defn.required" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" placeholder="{{:: $ctrl.defn.input_attrs.placeholder }}" >
+<input ng-if=":: !$ctrl.defn.search_range" class="form-control" type="text" ng-required="$ctrl.defn.required" id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" placeholder="{{:: $ctrl.defn.input_attrs.placeholder }}" >
<div ng-if=":: $ctrl.defn.search_range" class="form-inline">
<input class="form-control" type="text" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]['>=']" placeholder="{{:: $ctrl.defn.input_attrs.placeholder }}" >
<span class="af-field-range-sep">-</span>
-<textarea class="crm-form-textarea" id="{{:: fieldId }}" ng-required="$ctrl.defn.required" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" ></textarea>
+<textarea class="crm-form-textarea" id="{{:: fieldId }}" ng-required="$ctrl.defn.required" ng-model="getSetValue" ng-model-options="{getterSetter: true}" ></textarea>