};
this.canBeRange = function() {
+ // Range search only makes sense for search display forms
return this.isSearch() &&
- !ctrl.getDefn().input_attrs.multiple &&
- _.includes(['Date', 'Timestamp', 'Integer', 'Float'], ctrl.getDefn().data_type) &&
- _.includes(['Date', 'Number', 'Select'], $scope.getProp('input_type'));
+ // Hack for postal code which is not stored as a number but can act like one
+ (ctrl.node.name.substr(-11) === 'postal_code' || (
+ // Multiselects cannot use range search
+ !ctrl.getDefn().input_attrs.multiple &&
+ // DataType & inputType must make sense for a range
+ _.includes(['Date', 'Timestamp', 'Integer', 'Float'], ctrl.getDefn().data_type) &&
+ _.includes(['Date', 'Number', 'Select'], $scope.getProp('input_type'))
+ ));
};
this.canBeMultiple = function() {
-<input autocomplete="off" class="form-control" ng-model="getSet('input_attrs.placeholder')" ng-model-options="{getterSetter: true}" type="text" title="{{:: ts('Click to add placeholder text') }}" />
+<div class="form-inline">
+ <div class="form-group" ng-repeat="i in $ctrl.getRangeElements('Text')">
+ <span class="af-field-range-sep" ng-if="i">-</span>
+ <input autocomplete="off" class="form-control" ng-model="getSet('input_attrs.placeholder' + i)" ng-model-options="{getterSetter: true}" type="text" title="{{:: ts('Click to add placeholder text') }}"/>
+ </div>
+</div>
-<input class="form-control" type="text" 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" id="{{:: fieldId }}" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]" 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>
+ <input class="form-control" type="text" id="{{:: fieldId }}2" ng-model="dataProvider.getFieldData()[$ctrl.fieldName]['<=']" placeholder="{{:: $ctrl.defn.input_attrs.placeholder2 }}" >
+</div>