Skip to content

Commit

Permalink
feat(float): add step configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
velrest committed Jan 20, 2025
1 parent 361df5f commit dd2d193
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions caluma/caluma_form/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ def color(self):
def color(self, value):
self.configuration["color"] = value

@property
def step(self):
return self.configuration.get("step")

@step.setter
def step(self, value):
self.configuration["step"] = value

@property
def validate_on_enter(self):
return self.configuration.get("validate_on_enter")
Expand Down
1 change: 1 addition & 0 deletions caluma/caluma_form/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ class Meta:
class FloatQuestion(QuestionQuerysetMixin, FormDjangoObjectType):
min_value = graphene.Float()
max_value = graphene.Float()
step = graphene.Float()
placeholder = graphene.String()
hint_text = graphene.String()
default_answer = graphene.Field("caluma.caluma_form.schema.FloatAnswer")
Expand Down
2 changes: 2 additions & 0 deletions caluma/caluma_form/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class Meta(SaveQuestionSerializer.Meta):
class SaveFloatQuestionSerializer(SaveQuestionSerializer):
min_value = FloatField(required=False, allow_null=True)
max_value = FloatField(required=False, allow_null=True)
step = FloatField(required=False, allow_null=True)

def validate(self, data):
min_value = (
Expand All @@ -358,6 +359,7 @@ class Meta(SaveQuestionSerializer.Meta):
fields = SaveQuestionSerializer.Meta.fields + [
"min_value",
"max_value",
"step",
"placeholder",
"hint_text",
]
Expand Down
2 changes: 2 additions & 0 deletions caluma/caluma_form/tests/__snapshots__/test_question.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
'__typename': 'FloatQuestion',
'floatMaxValue': 1.0,
'floatMinValue': 0.0,
'floatStep': None,
'hintText': '',
'id': 'RmxvYXRRdWVzdGlvbjplbnZpcm9ubWVudGFsLXRlbg==',
'infoText': '',
Expand All @@ -269,6 +270,7 @@
'__typename': 'FloatQuestion',
'floatMaxValue': None,
'floatMinValue': None,
'floatStep': None,
'hintText': '',
'id': 'RmxvYXRRdWVzdGlvbjplbnZpcm9ubWVudGFsLXRlbg==',
'infoText': '',
Expand Down
1 change: 1 addition & 0 deletions caluma/caluma_form/tests/test_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_query_all_questions(
... on FloatQuestion {
floatMinValue: minValue
floatMaxValue: maxValue
floatStep: step
placeholder
hintText
}
Expand Down
2 changes: 2 additions & 0 deletions caluma/tests/__snapshots__/test_schema.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@
id: ID!
minValue: Float
maxValue: Float
step: Float
}

type Flow implements Node {
Expand Down Expand Up @@ -2671,6 +2672,7 @@
isArchived: Boolean
minValue: Float
maxValue: Float
step: Float
placeholder: String
hintText: String
clientMutationId: String
Expand Down

0 comments on commit dd2d193

Please sign in to comment.