I needed a progress bar for integer fields. Where the percentage is calculated based on max/min value. (Or by default use 0-100) I created a patch for this module added in comment #1 witch adds this functionality.

Comments

MDJ Webdiensten created an issue. See original summary.

maico de jong’s picture

StatusFileSize
new2.73 KB
maico de jong’s picture

Status: Active » Needs review
tiikeri’s picture

Hi, I tested the patch and it works fine.
I tested both on default min-max (0-100) and custom min-max values.
The only thing I noticed for a better user experience (just saying for documentation purpose): you need to add the "%" sign in the suffix (in the field settings) to give sense to the bar result. Actually it is the only suffix that make sense, since the bar is calculated on a percentage of the min-max values assigned to the field settings.

anyway the use of prefix and suffix is a smart thing if someone would add more information about the bar.
Ex.
prefix= "participation level: "
suffix= " %"
would result in a bar description showing "participation level: 50 %", where 50 is an example of result value.

Nice feature, thanks for your work.

Test environment:
drupal 8.5.1, Apache/2.4.25 (Debian), PHP 7.0.27-0+deb9u1, 5.5.5-10.1.26-MariaDB-0+deb9u1

Please note that I tested on an existing test project, not clean install.

If I may be useful in some other way, please let me know.

dqd’s picture

Status: Needs review » Reviewed & tested by the community

The patch works and has no flaws IMHO. Thanks for all contributions.
A project maintainer to review and commit is required to go on here. Looks minimally maintained. I will ask if they need maintainer support to get things forward.

Only drawback: The integer field has as many states as it has number steps which makes it impossible to change color by state added to the color input like in a list of 10 or 20 items. This means we maybe need to change the way the color change works. Rather based on a splitted percentage regarding the number of given colors. When given 4 colors the module should automatically split the existing values (rounded) in 4 parts(?) to choose the color change wheree the next color will be used, or we maybe need another formatter for integers to calculate in "from-to" states like 1-20,21-25, etc.

Maintainers should also consider to possibly cooperate with the color_field module or the conditional_field module to better implement color change based on value.

maico de jong’s picture

Assigned: maico de jong » Unassigned
maico de jong’s picture

dishabhadra’s picture

Status: Reviewed & tested by the community » Fixed

Thank you Maico de Jong for providing a patch. Patch looks good.
Thank you tiikeri & diqidoq for RTBC and improvement suggestion.

I applied the patch and releasing a new version.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.