set default value for empty integer and float fields - #1931
Conversation
There was a problem hiding this comment.
- Why do we need
(this.isIntegerField() || this.isFloatField())here? - What if
this.minisundefined? In this case, integer/float fields will be empty. - You can use
value.lengthinsteadthis.getValueFromEditor().length( See line 197 ). - Probably, will be better to use
_.isNumber(this.min)insteadthis.min != undefined.
|
I'm wondering what the behavior should be when the entry is deleted. I think it should actually revert to the default value for the field (as if you pressed the revert button next to the field), instead of the minimum value. @marcotuts what do you think? |
There was a problem hiding this comment.
Instead of copying this code, pull the helper function verifyValueAfterChanged out and use it in both test methods.
|
👍 After refactoring test code, removing the redundant conditions in Metadata.Number, and getting the thumbs-up from @marcotuts |
There was a problem hiding this comment.
This view is used just for fields with type Integer and Float. Use else instead else if (this.isIntegerField() || this.isFloatField()). Also, isFloatField is redundant and can be removed.
There was a problem hiding this comment.
Yes, thank you Anton. From the diff, I didn't realize the code was inside Metadata.Number.
There was a problem hiding this comment.
You're welcome, Christina. I'm Anton :).
|
@zubair-arbi my suggestion here would be to treat a keyboard key deleting of text as a reset to the default value instead of using the min value (as cahrens described) This will keep keyboard deletes in sync with the revert button, which I think is preferred and would cause less confusion than using min and presuming that as a user override. |
|
lgtm 👍 |
|
👍 |
…loatfield set default value for empty integer and float fields
STUD-894
@cahrens @polesye
When deleting float/integer field values in Studio, set Model value to default value of that field.