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

Minimum value threshold validation #145

Closed
Nex-Otaku opened this issue Oct 31, 2016 · 5 comments
Closed

Minimum value threshold validation #145

Nex-Otaku opened this issue Oct 31, 2016 · 5 comments

Comments

@Nex-Otaku
Copy link

Nex-Otaku commented Oct 31, 2016

With this configuration

'min' => 1,
'max' => 5,
'step' => 1,
'showClear' => false,

plugin is calculating wrong star hovering width.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@kartik-v
Copy link
Owner

You need to read the documentation to understand how the above setting will work.

Check the star highlight logic section of the document to understand.

@Nex-Otaku
Copy link
Author

No, that's not the point.

You just can't make configuration that works with minimum 1 and maximum 5.
For example, to cover 100% of star on each step, I need to set "stars" to 4?
But this makes 4 stars visible. And I need 5 stars.

I need one star always to be filled, this is what "minimum 1" actually means. And it is not possible with current version of plugin. It only can start from "0".

It is common option. So I wish it could be possible without rewriting whole JS plugin.
Here it is implemented: see http://callmenick.com/_development/five-star-rating/ (first block, "Dope Hat")
In some other rating plugins it is default behavior.

@kartik-v
Copy link
Owner

kartik-v commented Nov 3, 2016

As I mentioned the star highlight logic section covers and controls how a star is highlighted. This is very important for determining fractional highlight of stars if you need for example 1/4th of a star to be highlighted (for step = 0.25). It is thus different from other plugins.

The min value represents the value WHEN NO STARS are highlighted.

The max value represents the value WHEN ALL STARS are highlighted.

The step (which is 1 in the default case) in combination with above variables controls how much percent of a star is highlighted when you move each step left or right (its a math which is mentioned in the logic)

If you have understood that, you can still achieve what you need through several ways:

  • with min = 0 (when no stars are highlighted) and max = 5 (when all stars are highlighted) , and step = 1, you can preset the input default value to be 1 so you have one star highlighted always as a minimum value and set showClear to false to prevent clearing the input which will set it to zero (also handle a client code to set it back to 1 in case it does)

Or

  • with min = 0 (when no stars are highlighted) and max = 5 (when all stars are highlighted) , and step = 1, you can handle the logic to return 1 when no stars are selected (i.e. 0 is the value) on your server code..

Or

  • with min = 1 (when no stars are highlighted) and max = 6 (when all stars are highlighted) , and step = 1, you can handle the logic to return input_value - 1 as your star rating value when input_value is > 1

@Nex-Otaku
Copy link
Author

Well it is up to you to decide. I just found it inconvenient having to do so much rewriting or adding code to plugin, to achieve behavior, which is default on other plugins.

I wish it could be possible with some option. As for now, it is not possible to do with just options.

It will be cool if you provide that option in future. Thanks for the plugin, at any rate it saves developers time.

@kartik-v kartik-v reopened this Nov 4, 2016
@kartik-v
Copy link
Owner

kartik-v commented Nov 4, 2016

The options already exist in controlling this like any native HTML input (e.g. value validation of a number input).

I may still try to add an enhancement for setting a minimum value threshold that will not allow users to rate below this value - so that it becomes even more easier.

@kartik-v kartik-v changed the title Not working without "clear" element Minimum value threshold validation Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants