diff --git a/caluma/caluma_form/models.py b/caluma/caluma_form/models.py index f1bd59b8e..29bceb202 100644 --- a/caluma/caluma_form/models.py +++ b/caluma/caluma_form/models.py @@ -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") diff --git a/caluma/caluma_form/schema.py b/caluma/caluma_form/schema.py index dde23b1f0..97a9dcd88 100644 --- a/caluma/caluma_form/schema.py +++ b/caluma/caluma_form/schema.py @@ -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") diff --git a/caluma/caluma_form/serializers.py b/caluma/caluma_form/serializers.py index 5a32b8e8a..257eb37a7 100644 --- a/caluma/caluma_form/serializers.py +++ b/caluma/caluma_form/serializers.py @@ -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 = ( @@ -358,6 +359,7 @@ class Meta(SaveQuestionSerializer.Meta): fields = SaveQuestionSerializer.Meta.fields + [ "min_value", "max_value", + "step", "placeholder", "hint_text", ] diff --git a/caluma/caluma_form/tests/__snapshots__/test_question.ambr b/caluma/caluma_form/tests/__snapshots__/test_question.ambr index 38229c7aa..d0edea37c 100644 --- a/caluma/caluma_form/tests/__snapshots__/test_question.ambr +++ b/caluma/caluma_form/tests/__snapshots__/test_question.ambr @@ -245,6 +245,7 @@ '__typename': 'FloatQuestion', 'floatMaxValue': 1.0, 'floatMinValue': 0.0, + 'floatStep': None, 'hintText': '', 'id': 'RmxvYXRRdWVzdGlvbjplbnZpcm9ubWVudGFsLXRlbg==', 'infoText': '', @@ -269,6 +270,7 @@ '__typename': 'FloatQuestion', 'floatMaxValue': None, 'floatMinValue': None, + 'floatStep': None, 'hintText': '', 'id': 'RmxvYXRRdWVzdGlvbjplbnZpcm9ubWVudGFsLXRlbg==', 'infoText': '', diff --git a/caluma/caluma_form/tests/test_question.py b/caluma/caluma_form/tests/test_question.py index 921a56f89..f20c7f3b1 100644 --- a/caluma/caluma_form/tests/test_question.py +++ b/caluma/caluma_form/tests/test_question.py @@ -93,6 +93,7 @@ def test_query_all_questions( ... on FloatQuestion { floatMinValue: minValue floatMaxValue: maxValue + floatStep: step placeholder hintText } diff --git a/caluma/tests/__snapshots__/test_schema.ambr b/caluma/tests/__snapshots__/test_schema.ambr index b101572a5..7ce3179de 100644 --- a/caluma/tests/__snapshots__/test_schema.ambr +++ b/caluma/tests/__snapshots__/test_schema.ambr @@ -1206,6 +1206,7 @@ id: ID! minValue: Float maxValue: Float + step: Float } type Flow implements Node { @@ -2671,6 +2672,7 @@ isArchived: Boolean minValue: Float maxValue: Float + step: Float placeholder: String hintText: String clientMutationId: String