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

[Progress] Fix wrong error on validating sum total on multiple progress #758

Merged
merged 9 commits into from
Jun 10, 2019

Conversation

exoego
Copy link
Contributor

@exoego exoego commented May 21, 2019

Description

  1. Validation on sum of percents now is performed before rounding, as proposed by @ryamaguchi0220 in [Progress] Fix to validate the sum of the percents before rounding #759.

  2. Add module.helper.derivePrecision that calculates small-enough precision for multiple progress.
    This is handy for users since they do not need to take care about precision for most cases.
    If precision option is explicitly specified, it is used.

Testcase

https://jsfiddle.net/x1ptzvs7/

Screenshot (when possible)

Multiple progress bars are shown for the data in #757
image

Closes

#757

@exoego exoego added type/bug Any issue which is a bug or PR which fixes a bug state/awaiting-reviews Pull requests which are waiting for reviews lang/javascript Anything involving JavaScript labels May 21, 2019
Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

Why don't we just use 10 as a default value for precision?

@lubber-de
Copy link
Member

Alright, my suggestion of using 10 as always default precision could lead into never reaching 100% at all.. So your approach is of course better 🙂

lubber-de
lubber-de previously approved these changes May 21, 2019
Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

Sorry, but there is something wrong when the precision is set to 1. Calculation seems right, but bar color/width is messed up
https://jsfiddle.net/kmbc7fog/3/

image

In addition, the docs say the precision default setting is 1, although it's 0 in the code (which is correct)
This is not related to your changes, i just recognized it and we should setup an additional docs-PR to fix this and also add more information there like "0 means calculated precision, 1 means 1 decimal point , 10 means 2 decimal points, 100 means 3 decimal points, and so on)

Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

Using precision:10 breaks it again as before (calculates a value > 100%)
https://jsfiddle.net/kmbc7fog/4/
image

-> What about comparing against the sum of values instead of the sum of percentages ?

You may join forces with @ryamaguchi0220 .
The following jsfiddle contains a combo of your PR and the changes from #759, because it works then
https://jsfiddle.net/kmbc7fog/6/

@lubber-de lubber-de added this to the 2.7.6 milestone May 21, 2019
@exoego
Copy link
Contributor Author

exoego commented May 21, 2019

Calculation seems right, but bar color/width is messed up

All green ars are due to autoSuccess: true (default).
If autoSuccess: false, bars show each own color even when 100% reached.
Width seems fine for me if autoSuccess: false.

I took changes from #759 into this PR.

@exoego exoego changed the title [Progress] Derive auto precision for multiple progress for convenience [Progress] Fix multiple progress wrong error on validating sum total May 21, 2019
@exoego exoego changed the title [Progress] Fix multiple progress wrong error on validating sum total [Progress] Fix wrong error on validating sum total on multiple progress May 21, 2019
…recision

# Conflicts:
#	src/definitions/modules/progress.js
Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

All green ars are due to autoSuccess: true (default).
If autoSuccess: false, bars show each own color even when 100% reached.

As autoSuccess has true by default and IMHO that feature does not make sense when working with multiple progressbars i suggest to ignore that setting:

if(settings.autoSuccess && !(module.is.warning() || module.is.error() || module.is.success())) {

should be changed to

    if(settings.autoSuccess && $bars.length === 1 && !(module.is.warning() || module.is.error() || module.is.success())) { 

Works as expected then: https://jsfiddle.net/kmbc7fog/7/

@lubber-de lubber-de added the state/awaiting-docs Pull requests which need doc changes/additions label May 21, 2019
@lubber-de
Copy link
Member

@exoego In case you missed my comment for "autoSuccess" , here is a kind reminder... Would like to get this PR approved for the next release 😉

@exoego
Copy link
Contributor Author

exoego commented May 25, 2019

Oops.
Fixed in 1497b64

lubber-de
lubber-de previously approved these changes May 25, 2019
Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

LGTM

y0hami
y0hami previously approved these changes May 25, 2019
Copy link
Member

@y0hami y0hami left a comment

Choose a reason for hiding this comment

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

LGTM

@y0hami y0hami removed the state/awaiting-reviews Pull requests which are waiting for reviews label May 25, 2019
@ryamaguchi0220
Copy link
Contributor

ryamaguchi0220 commented May 30, 2019

@exoego @lubber-de

Oops.
In some case, the progress bar is still broken.
I'm not sure but, I think we should validate sum of the raw value instead of sum of the percents.

The case

https://jsfiddle.net/La8twh3u/

Screen shots

スクリーンショット 2019-05-30 11 30 55

スクリーンショット 2019-05-30 11 43 37

@exoego exoego dismissed stale reviews from y0hami and lubber-de via 7f64554 May 30, 2019 04:21
@exoego
Copy link
Contributor Author

exoego commented May 30, 2019

I'm not sure but, I think we should validate sum of the raw value instead of sum of the percents.

True.
Done in 28a2967

Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

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

LGTM

@lubber-de lubber-de requested a review from y0hami May 30, 2019 08:30
Copy link
Member

@y0hami y0hami left a comment

Choose a reason for hiding this comment

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

LGTM

@y0hami y0hami merged commit 52bfd66 into fomantic:develop Jun 10, 2019
@lubber-de
Copy link
Member

Docs corrected by fomantic/Fomantic-UI-Docs#134

@lubber-de lubber-de added state/has-docs A issue/PR which requires documentation changes and has the corresponding PR open in the docs repo and removed state/awaiting-docs Pull requests which need doc changes/additions labels Jun 10, 2019
@exoego exoego deleted the auto-precision-for-multiple-progress branch July 12, 2019 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang/javascript Anything involving JavaScript state/has-docs A issue/PR which requires documentation changes and has the corresponding PR open in the docs repo type/bug Any issue which is a bug or PR which fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants