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

fix: Decimals and Steps options only allow positive values (DHIS2-9002, DHIS2-9194) #1161

Merged
merged 11 commits into from
Aug 14, 2020

Conversation

martinkrulltott
Copy link
Contributor

@martinkrulltott martinkrulltott commented Jul 28, 2020

Fixes DHIS2-9002, DHIS2-9194

Based on playground PoC

Decimals and Steps could previously be entered as negative numbers and decimal values, which was incorrect. This change prevents this behaviour and only allows positive whole numbers, e.g. 0, 1, 2. Negative values will undefined, which in turn displays the placeholder. Note that for Decimals, 0 and undefined outputs the same result (no decimals shown), while for Steps, 0 means no steps while undefined displays the default amount of steps set by Highcharts.

  • New base type PositiveNumberBaseType added that only allows positive whole numbers
  • Math.round prevents decimal numbers and returns Number instead of String, which fixes DHIS2-9194
  • parseInt(value, 10) to allow for clearing the value with backspace
  • Applies to both typing manually and by using the browser's built-in "stepper arrows".
  • New help text for Steps, as per Slack discussion, Number of axis tick steps, including the min and max. A value of 2 or lower will be ignored.

Example input and expected output:

  • Typing whole numbers 0, 1, 2 -> kept as is
  • Typing negative numbers -1 -> 0
  • Decimal numbers 1.6, 1.1 -> rounded (to 2 and 1 respectively)
  • Stepping below 0 -> 0
  • Clearing the input with backspace -> undefined

ezgif com-video-to-gif

Copy link
Collaborator

@janhenrikoverland janhenrikoverland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@martinkrulltott martinkrulltott merged commit f29e13c into master Aug 14, 2020
@martinkrulltott martinkrulltott deleted the fix/DHIS2-9002-positive-numbers branch August 14, 2020 12:06
dhis2-bot added a commit that referenced this pull request Aug 14, 2020
## [35.7.1](v35.7.0...v35.7.1) (2020-08-14)

### Bug Fixes

* Decimals and Steps options only allow positive values (DHIS2-9002, DHIS2-9194) ([#1161](#1161)) ([f29e13c](f29e13c))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 35.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

martinkrulltott added a commit that referenced this pull request Aug 25, 2020
dhis2-bot added a commit that referenced this pull request Aug 25, 2020
## [34.6.14](v34.6.13...v34.6.14) (2020-08-25)

### Bug Fixes

* change help text for aggregation type ([#1151](#1151)) ([#1209](#1209)) ([b9c3519](b9c3519))
* Decimals and Steps options only allow positive values (DHIS2-9002, DHIS2-9194) ([#1161](#1161)) v34 ([#1210](#1210)) ([b099607](b099607))
* reorder options for consistency (DHIS2-9004) (519b0ba) v34 ([#1211](#1211)) ([8c59852](8c59852))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants