I'm working on a site where I plan to use a bunch of relations. Several of these relations will have the same label, but the configuration will be different. Such as source, target and field.
The current UI is very simple and since it is using the source label as name, it then means that it will not be possible to distinguish them from each other in the list. Only way is to hover over the names to see the machine names.
A simple way to greatly improve usability for sitebuilder would be by adding:
- A separate Name field
- A Description field
This would not only allow me to use more describing names, but also write a short description. Both these would also improve usability for teams where several sitebuilders are working on the same, or different, parts of the site.
Comments
Comment #1
tsvenson commentedBeen doing some more testing with this and realised the need for a separate relation name is bigger than what I first thought. For example, the Entity Collector block is using the label in the drop down menu. Then, if I have several relations that share the same source label name it will be impossible to pick the right one without guessing.
For me this is a major usability issue so bumping priority.
Comment #2
steveoliver commentedThomas,
I resist adding default fields to relations when they are fieldable -- but I understand you need fields for display in the relation admin UI.
I wonder if a combination of relation_type and/or options for when to use label and/or relation_type can help accomplish your needs.
Attached patch simply adds the relation_type in parenthesis to the relation label in the Relation Entity Collector block form.
Please let me know if this helps and if there are other places we might be able to use the existing relation_type in the UI to help distinguish relation types.
Comment #3
tsvenson commentedWell, it does make it easier to identify the right one in the list. However, it doesn't solve the UX/usability inconsistency this introduces compare to how things are done elsewhere in Drupal.
Main problem is that the label doubles as the name as well as being used for the automatic machine name. So every time I create a new relation where the source label is the same as an existing one, I will be forced to also manually edit the machine name. In other parts of Drupal this rarely happens as it is very seldom you reuse an existing name for a new configuration of the same type. Thus, the machine name will also be unique, but also reflect the name, making it easy to identify the configuration based on it.
There is really no other way than adding a new field for Name here to be able to reach UX consistency with other parts of Drupal.
Regarding that relations are fieldable. I'm not a skilled Drupal developer so I don't really know how that works. But isn't the machine name used as the entity identifier and then also for adding fields to?
If so, adding a Name field wont change that. Just the source for where the machine name is created from.
Comment #4
Uncle_Code_Monkey commentedI also ran into this issue which required a fix to display the "user friendly" node type name since normal users were being given access to the Entity Collector and not just admins. I created this patch which will display the proper "user friendly" node type along with the node title so there is no guessing involved.
I am basically calling the core function node_type_get_type($bundle) and then accessing it's ->name property.
Comment #6
Uncle_Code_Monkey commentedI forgot to include my changes to the validate() function with this feature. I have a few fixes/features that I'm trying to break out as several patches instead of one big one. Patch has been updated with everything it should need now.
Comment #8
joachim commentedI am maybe missing patch context here, but what if the entity is not a node?
Comment #9
Uncle_Code_Monkey commentedMy patch won't ever pass the tests defined in the relation_entity_collector.test file because I had to change the key being used.
The above needs to be changed so that the .":$entity_bundle" is appended after nid, but I don't know what the test 'node' entity bundle name would be to correct it. Anyone know what it should be?
@joachim if the node_type is not found, the original $entity_bundle name is used. I wanted to do more for other types, but I cannot seem to get non-node entities to show up on the dropdown on my site anymore (even after reverting to the original source). The gist of what I am doing is that by changing the key to be $options["$entity_type:$entity_id:$entity_bundle"] frees up the label text to be anything we wish. I am able to change node entity type names to be what they should, but since I cannot test other types, someone else will need to help properly patch it.
Comment #10
joachim commented> if the node_type is not found, the original $entity_bundle name is used. I wanted to do more for other types
You should be working generically, and not doing anything node-specific.
You can get bundle labels by doing:
Comment #11
Uncle_Code_Monkey commentedThanks! I am by no measure a Drupal expert, so knowing the generic way to do things without the means to easily test it is no simple task. I will incorporate the changes you suggest and issue another patch once I figure out the answer to comment #9 about the test case modification.
Comment #12
Uncle_Code_Monkey commentedIncorporating @joachim's code to generalize it for any entity type and adjusting the defined test case to reflect both the key change and the label change.
Comment #13
steveoliver commentedUncle Code Monkey,
Thank you so much. This is helpful, and I think should probably be committed to Relation, but @tsvenson's original request was for clarifying/customizing the relation type (first drop-down) in the Entity Collector block, not the endpoint label (second drop-down).
So, with your change (and a few edits as seen in the attached patch + interdiff), maybe you can continue to develop a solution that adds Name and Description fields for use in the first drop-down (among possible other places)?
-Steve
Comment #14
steveoliver commentedI guess we should put a testbot on my patch.
Comment #15
steveoliver commentedSome notes on my changes to your patch (the interdiff):
Moved this helper function to relation module, as we may want to use it elsewhere in Relation (I am surprised D7 core doesn't have such a function).
Keying by type:bundle:id seems to make more sense to me.
Break was a silly var name. ;) Changed order of entity properties to satisfy my eyes.
Keys make more sense as type:bundle:id here, too.
Comment #17
joachim commentedI really don't think we need a helper for this; it's just two lines of code. Lots of places where you're working with the entity type you've got hold of the entity info too, in which case it's only 1 line of code.
Comment #18
steveoliver commented@joachim: Agreed.
Comment #19
steveoliver commentedFrom the interdiff:
Apparently this is where the test is failing, but I can't tell why.
Comment #20
Uncle_Code_Monkey commentedI wasn't the only one to make the mistake about what the original issue was for (Relation Type dropdown vs. Entity to Pick dropdown) as other issues which meant Entity Pick dropdown point back to this one. Anyway, I don't have the resources to devote to the Relation Type issue, nor do I see why one's business case would have several types with the same exact label, yet different machine names and allowed entities. Perhaps the issue creator could comment with a use-case so that the community can come up with a good solution to his dilemma.
@steveoliver - I don't think your patch changes worked because your test case changes to the $node1_label broke the last line
$this->assertRaw(l($node1_label, $node1_uri['path'], $node1_uri['options']), 'Node1 link found');which expected $node1_label to be just the previously declaredentity_label('node', $this->node1);Same thing applies to the $node3_label variable. Keeping all your current changes and making those last two lines:should probably do the trick.
I tried to change as little as possible with my patch, which is why I wrote it as I did, which also meant that other code that expected the entity option keys to be type:id still worked with type:id:bundle because that code would just ignore the extra :bundle. /shrug Possibly just over-thinking it.
I wrote my bundle label function because I would rather waste time creating an easy to use function than work with one or two lines of esoteric code that is difficult to remember or construct. Being the Drupal-newb that I am, I had to be told about those two lines of code rather than discovering a bundle label function on my own. I will be glad for Drupal 8 when many of these functions and esoteric lines of code can be replaced by class objects and their properties/methods. /old-fashioned soapbox
Comment #21
steveoliver commented@Uncle,
All fair points.
To address @tsvenson's original request on it's own:
The use case seems a bit confusing to me too, but the argument for specificity at the relation type as opposed to the relation instance level seems valid and worth considering.
The attached patch adds Name and Description fields, with a db update to update existing relation types with new name and description field values derived from label.
Name and Description aren't implemented anywhere and don't show up in the fields after you've saved a new relation, but I updated the language and UI as best I could to address @tsvenson's feature request.
Gotta sign off, but just wanted to post this -- I think it'd probably be more help than hurt and could help any other UI work, which is hope for anyone attempting to efficiently use the Entity Collector Block. ;)
Relation++ :)
Comment #22
steveoliver commentedsplitting tags, seems logical.
Comment #23
steveoliver commentedwait, sorry. that didn't make sense.
Comment #25
steveoliver commentedRe: the two things we're doing here (wondering if we should spin off another issue, but not doing it for now):
1. Add name and description fields.
2. Clarify entity drop-down
I'd actually like to see both happen.
@tsvenson,
Have a look at #21 and lemme know if you think this might help. Next steps would be to get it passing tests and implement Name and Description in helpful locations.
@Uncle,
Attached patch with your input from #20 should pass now. I wonder if key 'type:bundle:id' (as opposed to yours 'type:id:bundle') will fly... I think we're pretty close.
Comment #26
steveoliver commentedRe: the patch and #25 and discussion about the entity drop-down, please see separate issue #1710234: entity collector selector only shows bundle, not entity type and is thus ambiguous.
Comment #27
tsvenson commented@steveoliver: Saw your ping in IRC. Thanks for alerting me about the progress you've done here.
From your description it sounds like like a good UX improvement in line with how other features works in Drupal. Will need to test it to know for sure though. I'm swamped today, but should be able to squeeze in an hour or two in the weekend to set up a testing environment for this.
Hope that's OK with you.
Comment #28
steveoliver commented@tsvenson,
No problem -- just hadn't heard from you on this thread since the beginning.
When you do get time, apply the patch and make any notes on the UI for the Add Relation Type screen, then maybe point out where you'd like to see Name and Description used throughout the Relation UI?
Will be out this weekend, but back online next week.
Cheers,
-Steve
Comment #29
tsvenson commented@steveoliver: Just want to drop a quick line and let you know that I haven't been able to look into this yet. I have a ton of other stuff I must finish first. At this point I don't think I will have time to install, patch and test this until earliest end of the coming week.
However, if you can post a couple of screenshots of how this now looks, it would probably give me enough to be able to give feedback on for now.
Comment #30
steveoliver commented@tsvenson,
This is the UI change generated by the patch in #21:
Comment #31
tsvenson commentedThanks, that is definitely an improvement. However, when comparing with the below screenshot of a content type we can see two distinctive differences:
It would be great if we could have the same here as a uniformed UI/UX for these thing are beneficial for everyone using Drupal.
Other than that, great work so far. We are almost there.
Comment #32
mikran commentedComment #33
naught101 commentedProposal:
Another option might be to just remove the reverse label, and fix #1479346: Create a display formatter to display relation_endpoints with tokens, and allow relation predicates to be defined using fields and tokens. Not sure where that would happen though...
Comment #34
naught101 commentedStupid updates.
Comment #35
naught101 commented#1624456: Expose Label(s) to views. is postponed, waiting on an outcome for this issue.
Comment #36
tsvenson commented@naught101
From a sitebuilder point of view I would prefer if the label/reverse labels can still be there to define. However, they are then used as default labels that then can be overridden by #1479346: Create a display formatter to display relation_endpoints with tokens. In most cases the default labels will be fine, but in those rare use cases they need to be something else, the display formatter will allow for that.
Comment #37
naught101 commented@tsvenson: what about the proposal without the "another option" part? Would that suit?