Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: adds support for defining null values for numeric questions #873

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feature: adds support for defining null values for numeric questions
  • Loading branch information
takinbo committed Feb 17, 2022
commit ecac9046cdc522dba0543eb9ade6250615d4f7fe
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.