I'm not 100% sure this is a bug, but I am sure it is a function I miss from Rules 1:
In Rules 2 it is not possible to manually set the lables for conditions and actions. For actions like "set a data value" the label becomes too generic to be really useful, and it would really be nice to be able to change it manually.
I know there are details about the actions/conditions in the fine print below the labels – which is really useful – but it would be even better with a clear label.
(This being said, having the condition/action name written clearly is also a good thing – in Rules 1 I have a few times been wondering what the heck a condition/action actually was. If manual labels are added, is it possible to have the condition/action name in the fine print descriptions?)
Now: Going back to read the API docs. I wanna learn how to create Rules data types, to be able to handle Views metadata better. Cheers!
| Comment | File | Size | Author |
|---|---|---|---|
| #55 | rapture-rules-rbbdev.png | 96.46 KB | delacosta456 |
| #42 | rules-description-field-1244738-42.patch | 4.52 KB | hgoto |
| #30 | interdiff-1244738-25-30.txt | 390 bytes | hgoto |
| #30 | rules-description-field-1244738-30.patch | 4.52 KB | hgoto |
| #26 | 1244738 -rules-overview-table-with-descriptions.png | 201.86 KB | megachriz |
Comments
Comment #1
fagoYep, I've done away with generating human-readable labels in rules 2, so with the possibility with custom labels. But I agree with you that all the *general* data_set labels aren't helpful.
I thought about automatically generating better labels for them originally, but had no time for implementing it yet :/ E.g. instead of "Set a data value" the label could turn into "Set node:author" once it is configured - the same way for the data_is conditions and entity conditions/actions.
However, I'd not like to go with that pattern for all actions/conditions, but use it only for the generic ones. I really want to avoid ending with auto-generated sentences in rules 1.x - it's a mess and won't work in all languages anyway.
Also, I think we should add a rule description field somewhere, which allows for a human-readable description of the whole role (what the heck is it doing?).
Do you think both improvements would do it, or still custom labels would be better? I'm not in favour of custom labels as it is much work to input them for every action/condition and it's probably a bit inconsistent to have some custom ones + machine-generated ones?
Comment #2
itangalo commentedDescription fields would definately do it.
I'm a bit surprised that I didn't think of this myself – what I really want is to (1) know which condition/action is used, and (2) what it does. Machine-created label + description is a very good fit.
Great work, as always.
Comment #3
fagoThen let's do that!
Comment #4
videographics commentedThat sounds great! Just to be clear... you're talking about a description field for each rule in addition to one for each element?
Comment #5
fagoWe definitely want a description field per rule/config. I'm not sure whether we need one per element too.
Comment #6
videographics commentedI'd be curious to see broader input on that. If not description fields for individual elements, how about an option to see all of the settings for all of the elements from the rule listing on the main rule page? I know the hover option is available for this but it only allows you to see the details of one at a time. With a long list of elements, I think it would be really helpful to see the details of each in the context of the whole.
Comment #7
itangalo commentedI'd definitely like to have descriptions on each action/condition, allowing to clarify "set data value" with something like "Turn off commenting".
(That's my five cents...)
Comment #8
mitchell commented@Itangalo: I vaguely remember some of the info on this subject from the BoF. Do you have notes on this?
Bumping priority because many people liked this idea.
Comment #9
mitchell commentedMarked #1217582: improve component variable UI as a duplicate of this.
Comment #10
mitchell commentedWe spoke about generating descriptions per element at the BoF, and, afair, it was a very well liked idea. I forgot how we said it would look, so I haven't included it in the mockups at #1495552: [Meta] Improve overview page, but that should go in there next.
Cross referencing #1331556: Debug log: add component name for related "generating human-readable labels."
Marked #1149108: Add a documentation field as a duplicate of this issue.
Aside: Changing to feature request, because it involves new code. Tasks, to me, seem more like fix documentation, but just trying to be consistent.
Comment #11
mitchell commentedMarked #1190034: Provide rulesets labels with translation option as a duplicate.
Comment #12
Anonymous (not verified) commentedI'm glad the need for useful documentation of rules is already placed in the issue queue. Currently I'm working on a bunch of rules. They're calculating status values for users and nodes, and I'm still not sure how to document this properly. The problem is to keep documentation and rules in sync. This is, because rule sets tend to change interative and restrictions often come up during this process. So at least for me (and I think I'm not the only one) it is not possible to plan and document all that during development.
Fago, your approach at #1 would help a lot. I'd be glad with automatic descriptions as a default. But as you mentioned, this wouldn't work well for all kinds of actions and conditions, and i18n would be the next problem. And further more, automatisms would never reflext the reasons behind an action. For example, adding 1 to a value is an obvious operation, but the reason for such an operation should be documented, too.
Therefore it would be very convenient to have an optional description field for everything, to override the automatic description.
In addition to that, a "rule documentation" tab for each rule (or all together) would be helpful. I think of a printable version of all descriptions in the order of their occurrence, with all parameters and with indented loops and references to components. Something one could attach to the project documentation and update at a click (based on the rules in effect).
Comment #13
yang_yi_cn commentedIt will be very helpful as I have many rules with "Execute custom PHP code" and I use to be able to change it to a custom label in Rules 1 to make it readable.
Comment #14
megachrizClosed as duplicates:
Relevant information from these issues:
Comment #15
megachrizIn the attached patch I've added a description field to the rules config entity.
I tried to find all the places in the Rules module where the description should be used. I altered the following:
returnExport(): make sure description can be exported.import(): make sure description can be imported.settingsForm(): added textarea field called 'description'.buildContent(): displays description.This means the following is implemented:
The following is NOT implemented:
Comment #16
megachrizFrom https://drupal.org/node/1181250
Feature requests are never critical.
Comment #19
megachrizReroll of the patch in #15.
Comment #21
anybody+1 for this issue. The current situation is really problematic because complicated rules are missing important documentation.
Comment #22
megachrizThe failing test looks unrelated to the patch. The tests are failing because for some reason the testbot doesn't checkout the variable module, which is a dependency for the Internationalization module, used by the test "RulesI18nTestCase", so setting this back to "Needs review".
Comment #23
shortspoken commentedPatch #19 works well. It would be good to have the description displayed in the rules overview table though.
thx and cheers.
Comment #24
anybodyConfirming that Patch #19 works well and agree with #23. Is there a way to set the dependency for the Testbot? I have not read something like that yet.
Comment #25
megachriz#2650886: Reduce the likeliness of cache rebuilding locks also added
rules_update_7215(), so here is a new reroll against dev. The update function is now calledrules_update_7216(). (The patch from #19 can still be used for Rules 7.x-2.9.)There is also a new testbot now, so hopefully this patch doesn't fail on the same error again.
Comment #26
megachriz@shortspoken, Anybody

I think the descriptions are displayed on the rules overview table? See screenshot. Or have I missed something on an other place in the UI?
Comment #27
shortspoken commented@MegaChriz: You're totally right. The descriptions ARE showing in the overview table. Maybe a cache issue... weird. But great. Please get this commited soon!
Comment #28
anybodyYes I can confirm that, the description appears. Seems to have been a cache issue. #25 RTBC!
Comment #29
kinmen commentedCan the Description field be translated in other languages? I can't see any way to do so because the text (ex: You've deleted a content, therefore... etc) doesn't appear in the translation interface of i18 module...
Rules 7.x-2.9, D7
tnx
Comment #30
hgoto commentedI tested the patch #26. It works for me, too.
I'd like to move this to RTBC but want to suggest to keep the line breaks in descriptions using the following one-line change to the patch.
Since the input field for the description is textarea, people will expect line breaks are kept, I think.
Comment #31
hgoto commented@kinmen, it's too late and maybe your interest is off-topic but I'd like to answer your question. There's no way to translate description as well as the titles, I think.
Comment #32
kinmen commentedthat's too bad... in a multilingual website how can users understand those messages?
Comment #33
megachriz@kinmen
Why do you want the description of a rule to be translatable? They are meant to document what a rule does (because a rule configuration can get quite complex). The description of a rule is not shown to end users, only to users who may administer rules.
Comment #34
anybodyI agree with @MegaChriz, other things may be edge cases which would exists for many many Drupal administration pages etc... I think a translation would be too complex and better a separate module if someone needs it.
Comment #35
kinmen commentedMaybe I didn't explain it well: I don't mean the description of a rule in the administrative interface but the description of the reason which caused the action, which is visible to the users. For example, if using the userpoint module, you get something like: "You've deleted a content, therefore 2 points have been taken away from you!"
Comment #36
anybody@kinmen: I can't see a relation to this issue. This issue only handles the first thing you mentioned: An administrative description for rules to explain to site admins what the rule does and how.
Comment #37
kinmen commentedOk I didn't exlain well what I meant, I'll open a new issue
Comment #38
megachriz@kinmen
This issue is only about the description of a rule in the administrative interface, not about showing messages to users. I think you are talking about the Rules action "Show a message on the site". If the message set in that action appears to be not translatable, an option would be to write your own Rules action in a custom module. There you would have the freedom to make strings translatable with the
t()function.Comment #39
kinmen commentedWhat I need is to translate, under the Action page, the value of the Description "Can contain the reason why the points have been granted." I think it just needs a "t" function in the form
Comment #40
hgoto commented@kinmen, thank you for the image.
As MegaChriz and Anybody told, "description" in this issue is the administrative description only for admin users who manage rules. And your "description" is actually a message which is shown to users as MegaChriz told. And this issue does target not all the "description" but only the former description. So it's better for you to ask your question in another issue (as you already noticed).
FYI, Userpoints - Rules integration is implemented in Userpoints module (see https://www.drupal.org/project/userpoints) and I recommend you to create an issue in Userpoints module issue queue, not Rules. I hope this helps.
@Anybody thank you for your review!
Comment #41
fagoThis seems good to me, but the patch does not apply any more. It needs a reroll.
Comment #42
hgoto commented@fago thank you for your comment! This is a reroll of the last patch.
Comment #43
tr commentedIf this feature is committed it should go into D8 as well.
Comment #44
delacosta456 commentedhi i like this feature.
yes after applying the patch it does exactly what i expect..
Comment #45
delacosta456 commentedhi
after more deep test i can confirm that description looks to be working .. however is it possible to have more/deep integration ? which means that inside rules any new row of areas: "any new Event..", "Any new condition", any new action etc (and so on)has their own description field to have a well documented rules steps..?
Thanks
Comment #46
megachriz@delacosta456
That would be a nice idea for a follow-up, but let's keep the scope of this issue to just the description field for the whole rule. The module Rules Dev Comments might also fulfull this feature request.
Comment #47
delacosta456 commented@MegaChriz
Ok Many thanks for guidance .. i didn't know that sandbox project before .. That look to be solving my problem :
Many thanks
Comment #48
bassplaya commentedAfter patching the patch in #42 it worked but after flushing the caches
drush cc allI get this:PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.description' in 'field list': SELECT base.id AS id, base.name AS name, base.label AS label, base.description AS description, base.plugin AS plugin, base.active AS active, base.weight AS weight, base.status AS status, base.dirty AS dirty, base.module AS module, base.owner AS owner, base.access_exposed AS access_exposed, base.data AS data FROM {rules_config} base WHERE (base.status IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) ; Array ( [:db_condition_placeholder_0] => 3 [:db_condition_placeholder_1] => 2 [:db_condition_placeholder_2] => 6 ) in EntityAPIController->query() (line 187 of /Users/GraphicDesign/Sites/www.sandbox-D7.67.dev/sites/all/modules/entity/includes/entity.controller.inc).And I am unable to revert. Whatever I do on the site leads to this.
What can I do?
Comment #49
tr commented@BassPlaya: Did you run update.php ?
I realize that when I commented on this in #43 over a year ago, I didn't understand what this issue was about. I thought the issue summary described the feature request here, but it doesn't. In fact, this issue seems to be entirely about adding a description field to reaction rules that will show up in the reaction rule overview at /admin/config/workflow/rules. I don't know why no-one ever re-wrote the issue summary to reflect this.
Drupal 8 Rules already has this description field, and has had it for many years. So this issue is now really about a backport of that feature. Thus, I removed the "Needs port to D8" tag that I put on this issue.
In D8 this feature is really useful so I'm not opposed to putting it into D7, but I AM worried about breaking some of the existing >200,000 D7 sites that are using Rules by making a schema change this late in the D7 development cycle. It would have been pretty simple to get this committed 6 or 7 years ago, but at this point I'm reluctant to do that because I will be the one who has to deal with the fallout if the patch breaks things and I don't have time to work on this myself because I am focused on the Drupal 8 (&9!) versions of Rules.
Moving to "Needs work" because we need a clear issue summary describing exactly what this patch is meant to do. I would also really like some test cases for this to help prevent disruption to established sites.
Regardless, the patch is here and available for anyone who wants to use it, but I don't think there are enough benefits at this point to risk the schema change.
Comment #50
megachrizI've added the "Needs issue summary update" tag.
Comment #51
bassplaya commented@TR: I wasn't able to do anything, not even a update.php However, I fiddled around and added a table named "description" in the table named "rules_config" because clearly that one was missing. And that got me my site back. Phew!
So, to me, that patch in #42 worked but after clearing the caches broke my site.
I'll try to redo it again and see if it was a one-off or if it's always like that. But now that's not my priority.
I understand why you would not want to look into this at this moment and I appreciate that.
It's a minor thing to me at this moment. Thank you for the reply.
Comment #52
bassplaya commented@MegaChriz yes, I've installed Rules Dev Comments and that seems to work partly.. I'll discuss that over there. Thanks
Comment #53
tr commentedI think update.php should be run first, before drush cc all, because after the cache clear the next page request will run code without having fixed the DB schema ... But even with that order this may be causing a problem if you have active Rules that are trying to fire on Drupal init or something like that - executing a Rule before the schema update will also cause problems. So the patch MAY need to disable Rules execution until the update.php is performed, or something along those lines.
The big problem I see is that no one ever goes through the update process twice - they just do it once; if it works, great, if it fails, they struggle to fix it and then move on. No one is going to help develop a new patch to fix the update process, then revert their site and test to see if the new update patch fixes the update process. That means if I commit the above patch and is DOES cause problems for some fraction of sites, there won't be a good way to develop a new patch which fixes those update problems. And history shows that if there is an update problem, there will be repeated bug reports here in the issue queue for literally years after it has been solved ... this is true even for seemingly benign changes, and it will only be worse for a schema change. If there were support from the community then perhaps I would think differently, but nobody is helping out in the issue queue so it would be all up to me. I can't support any more of that for the D7 version.
Comment #54
delacosta456 commentedhi
i have been using this nice patch for a moment . Now i just want to suggest a little css tweak
** Make the description field have it's own class ... this can help coloring the background and text from css.
Actually trying colors background by copying the selector structure may be coloring the next field (tags) if description is not present.
For the moment below is my css workround
The above CSS helps having the screenshot in attached file
Thanks
Comment #55
delacosta456 commentedAttched files: result of the above #54 comment