Problem/Motivation
For fields with multiple property values, in the 7.x version of the module we could select them right in the mapping UI. This was particularly convenient for Address fields, which require a lot of clicking to map anyway. In #2899460, we created a workaround, the "Properties, Extended" field mapping type. That is more powerful still, allowing you to drill down into related objects, but the UX for it is confusing and awkward, especially when editing existing mappings.
Proposed resolution
While working on the Mailchimp module in D8, I noticed a nice field property selector. I realized I could pull that code over to this module to recreate the D7 experience. Doing this produced some need for more sophisticated value code, but I found that the 'Properties, Extended" mapping field type already did all the work I needed.
So, I pulled a great deal of the Properties Extended field plugin into the Properties plugin, and made the Properties, Extended plugin an extension of the Properties plugin (it reads well!).
The result is a better "Properties" plugin.
User interface changes
You now see properties of complex-data fields like address fields in the mapping UI for "Properties" mappings.
API changes
Effectively none.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | field_property_access_mapping_ui-3168053-5.patch | 11.11 KB | gcb |
| #2 | field_property_access_mapping_ui-3168053-2.patch | 20.38 KB | gcb |
Comments
Comment #2
gcbI also put this into a PR here https://git.drupalcode.org/project/salesforce/-/merge_requests/1
Comment #3
aaronbaumanI'm getting an error when saving a new mapping after adding fields:
Comment #4
gcbComment #5
gcbWell that's ugly. I see what happened there: my attempt to be cute and turn PropertiesExtended into an extension of Properties, for purposes of DRYness, was probably ill-advised.
Here's a simpler patch that just adds the functionality to Properties field plugin.
I might advocate for deprecating PropertiesExtended if this works: I'm not sure what data structure you'd want to use PropertiesExtended for if you can get to things from here.
Comment #6
aaronbaumanCool, seems to be working now.
Properties Extended allows to traverse arbitrarily deep into entity relationships, so I don't think it can be replaced yet.
I just can't picture a way to make that interface work in a static select-option widget without having an overwhelmingly long list.
Really both the Properties plugins could be replaced by Token...
but I think it's fine that there's some overlap though, so long as the maintenance doesn't get too onerous.
To that end, eventually (after this patch is committed) I'd like to figure some refactoring here because the constructors are getting super ugly.
Not necessary for this patch, but would be good to eventually get some test coverage for actually submitting the mapping form to save the mapping. I think the coverage we have now basically just loads the form and clicks the "add field" button.
Comment #7
gcbAgreed: It seems like the "Properties Extended" was built to solve the problem of selecting sub-properties, but accidentally provided a ton more functionality (if I'm reading the ticket history accurately). Certainly a drop-down is impractical -- too easy to get a circular reference!
The tokens are a little developer-y for some of the site admins we work with, who actually do make mapping changes when they add new fields. Scary but surprisingly viable.
It does seem like a lot of overlapping code could be united in the two of them, though. Tests would definitely be good.
Thanks for looking at this!
Comment #9
aaronbauman