View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0020068 | mantisbt | customization | public | 2015-09-01 15:31 | 2015-12-06 02:45 |
Reporter | atrol | Assigned To | dregad | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.3.0-beta.1 | ||||
Target Version | 1.3.0-rc.1 | Fixed in Version | 1.3.0-rc.1 | ||
Summary | 0020068: No color applied to status enums with spaces in status values | ||||
Description | We do not restrict the status values at the moment, e.g. we allow to have spaces in it This configuration worked in 1.2.x You will not get the color in current master as we produce the following HTML output This is not a valid CSS class name, see http://www.w3.org/TR/CSS2/syndata.html#characters Using numeric values should work | ||||
Tags | No tags attached. | ||||
related to | 0020079 | new | Custom status colors not working when displaying issues from another project |
That should be fairly simple to fix, just need to ensure that the status enum's label does not contain any chars not valid for CSS. That being said, there is at least another issue with dynamic CSS for status colors, as I discovered a couple years ago (see https://github.com/mantisbt/mantisbt/commit/fc13f29d2f09b3894e38405f821d95f3851576fe); I'm not really sure how to fix that properly. |
|
What's the reason that you didn't implement my simple proposal (generate class names like status-color-10, status-color-20, ...) You might also consider to append the project id (e.g. status-color-10-1) Furthermore I am not sure if your regexp covers all rules for valid CSS classs names, but that's just a guess, I didn't try. |
|
No particular reason except for me doing this in 10 minutes after lunch break and before rushing into the next meeting, without much in terms of thinking or analysis ;) You're right, performance would be better with use of a number, I'll make an alternative fix. Appending the project is only one aspect of the problem - color codes can also be user-specific... So the key is to dynamically build the right set of CSS classes in status_config.php. In terms of the regexp, I guess it could allow an invalid identifier by allowing the 1st char to be a digit; anyway this point is moot if we go for your number-based approach. |
|
I generally don't see having spaces in status as recommended, I generally prefer having no spaces in $g config option and use spaces in the corresponding $s localization. However, in our documentation for status customization at [1] we replace spaces with underscores to match related custom strings. [1] https://mantisbt.org/docs/master/en-US/Admin_Guide/html-single/#admin.customize.status Now it seems we have two issues being discussed here:
I expect number 2 is unrelated to this specific and is one of what I suspect will be a bug farm when having different statuses per project and colors per users or maybe even statuses per project! We may at one point wan't to block some of our configs from being per project or per user even if they are overridable in the database. |
|
I agree that it's not recommended, but I don't think this is written or explained anywhere. In any case, the fact is that the system allows it, so we need to make sure using enums with spaces does not cause errors. With regards to point 2, you are correct that this is a separate issue, and I should probably have opened a separate bug report to track it (EDIT - now it's done, see 0020079). I mentioned it here as I stumbled upon my earlier comment in the code while investigating. I would definitely advise against (or even disable use of) user-specific color codes, IMO that would really be pointless. On the other hand, project-specific colors / status codes are a useful feature that we should continue to allow. |
|
PR has been updated to follow atrol's proposed approach, plus a minor improvement. |
|
Not that pointless, there are quite a log of people with decreased ability to see color |
|
Including myself actually ;-) What I mean is that currently the only way to customize colors is via adm_config_report.php. Consequently, it is highly unlikely that an admin would go through the trouble to manage colors at user level. |
|
Reviewed and tried updated PR There is a problem to generate .status-<value>-percentage if there is no issue with status <value>. e.g. this is the generated CSS if there is no issue in whole project with "closed" status.
Some more optimization could be to suppress generating .status-<value>-percentage if $g_status_percentage_legend == OFF; BTW, having <div class="error-inline">SYSTEM NOTICE: ... in CSS output is certainly not wanted. |
|
Thanks for testing. Re: the SYSTEM NOTICEs, I inadvertently removed the array_key_exists() check which was present before. I'll put it back in and update the PR.
I thought about that, and a few other scenarios as well. Then I started wondering what impact optimizing the CSS to be minimal would have on caching of the CSS (e.g. what happens if I change systems settings or login as a different user)... I left it there as I didn't have more time for research or testing. You can have a look at the work-in-progress: https://github.com/dregad/mantisbt/tree/css-status-color-2 |
|
|
|
MantisBT: master 94aa0058 2015-09-02 02:47 Details Diff |
Generate valid CSS/class name for custom status with spaces Prior to this, for a custom status 'in progress', Mantis would generate the following invalid code: - HTML (class name): class="small-caption in progress-color" - Dynamic CSS (status_config.php): .in progress-color { ... } We now rely on a new API function html_get_css_identifier() to generate a valid CSS class name by replacing invalid characters with '-'. Fixes 0020068 |
Affected Issues 0020068 |
|
mod - core/html_api.php | Diff File | ||
mod - css/status_config.php | Diff File | ||
MantisBT: master 72ab9338 2015-09-06 13:50 Details Diff |
Use enum value to determine CSS class name As per atrol's suggestion in issue 0020068 This simpler approach allows more efficient code and removes need for an extra API function. |
Affected Issues 0020068 |
|
mod - core/html_api.php | Diff File | ||
mod - css/status_config.php | Diff File |