Skip to content

Commit

Permalink
feature: adds support for defining null values for numeric questions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
takinbo authored Feb 18, 2022
1 parent 1889830 commit 3aaccc9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions apollo/formsframework/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def serialize_field(cls, field):
data['subtype'] = 'integer'
data['min'] = field.get('min', 0)
data['max'] = field.get('max', 9999)
data['null_value'] = field.get('null_value', None)
elif field_type in ('select', 'multiselect'):
sorted_options = sorted(field['options'].items(),
key=itemgetter(1))
Expand Down Expand Up @@ -464,6 +465,7 @@ def deserialize(cls, form, data):

field['min'] = min_limit
field['max'] = max_limit
field['null_value'] = f.get('null_value', None)

# add target/expected value
if f.get('expected'):
Expand Down
7 changes: 6 additions & 1 deletion apollo/static/js/angular-form-builder-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
required: false,
min: 0,
max: 9999,
null_value: "",
subtype: 'integer',
expected: 0,
template:
Expand All @@ -56,10 +57,14 @@
<label class="control-label">{{minimumLabel}}</label>
<input type="text" ng-model="min" class="form-control" value="0" />
</div>
<div class="form-group mb-2">
<div class="form-group mb-2">amples using assignable expressions include:
<label class="control-label">{{maximumLabel}}</label>
<input type="text" ng-model="max" class="form-control" value="9999" />
</div>
<div class="form-group mb-2">
<label class="control-label">{{nullValueLabel}}</label>
<input type="text" ng-model="null_value" class="form-control" value="" />
</div>
<div class="form-group mb-2">
<label class="control-label">{{typeLabel}}</label>
<select ng-model="subtype" ng-options="obj.value as obj.option for obj in subtypeOptions" class="form-control custom-select"></select>
Expand Down
24 changes: 15 additions & 9 deletions apollo/static/js/angular-form-builder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3aaccc9

Please sign in to comment.