-
Notifications
You must be signed in to change notification settings - Fork 4.2k
set default value for empty integer and float fields #1931
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
set default value for empty integer and float fields #1931
Conversation
cms/static/js/views/metadata.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
cms/static/js/views/metadata.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you Anton. From the diff, I didn't realize the code was inside Metadata.Number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're welcome, Christina. I'm Anton :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry! Thank you, 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.