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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2960477-support-integer-fields-1.patch | 2.73 KB | maico de jong |
Comments
Comment #2
maico de jongComment #3
maico de jongComment #4
tiikeri commentedHi, 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.
Comment #5
dqdThe 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.
Comment #6
maico de jongComment #7
maico de jongComment #9
dishabhadra commentedThank 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.