As a site builder I would like to show individual component of an address field in views.

Comments

KelvinWong created an issue. See original summary.

bucefal91’s picture

Gotcha :) When I a chance I'll code this part.

arosboro’s picture

StatusFileSize
new16.79 KB

I just made a patch which addresses this issue.

arosboro’s picture

Status: Active » Needs review
CatherineOmega’s picture

The patch applies cleanly, but I'm not sure I see how to actually add a subfield of a given composite field. Can anyone else confirm?

simohell’s picture

Thanks for this! The patch works well for the version: Commit 5d2b725 on 8.x-5.x
but it seems it won't install with the latest version: Commit a67d79d on 8.x-5.x

update: Seems to work on a clean site even also current dev-version. So the problem at the development site was something else...

However with the clean install for some reason don't seem to be getting any output from default Address-elements City and Postal code output, although I can see the sub-elements data in the views field with complete element.

bucefal91’s picture

StatusFileSize
new23.42 KB
new9.27 KB

Nice patch in #3 - thank you. It leverages a really nice idea of exposing each composite as a separate table, so the actual views handlers (field/sort/filter) do not have to worry about proper filtering out other components out.

I have reviewed it and taken slightly further the work. Namely:

  1. I've taken the logic of generating composite data out from generic WebformElementViewsAbstract into WebformCompositeViews. Thus in the future, if we need any extra customizations there (for example for some specific type of a composite element, one could extend WebformCompositeViews and place extra logic into overriding methods).
  2. No dedicated sorter is required - we can reuse the already existing WebformSubmissionFieldSort
  3. Simplified WebformSubmissionCompositeFieldFilter by making it extend WebformSubmissionFieldFilter. I've spent some fair couple of hrs trying to make the composite filter work by picking up a specific subset of the $element widget, but I was hitting deeply nested errors/exceptions so I opted to back out. So at the moment the composite filter is hard coded to use textfield as the input widget.
  4. Schema declarations included for all the above code.

On the address field, I've tried the following test cases:

  1. Include a component as a field (Address, in my case, to be precise) into a view
  2. Click sort the result table by that field
  3. Standard sorting (not click sorting) on the "Address" component
  4. Non-exposed filter with all possible operators
  5. Exposed filter with all possible operators
  6. Exposed filter with exposed operator.

No issues were identified. Feedback about the patch is very welcome. As far as I am concerned this patch is commit ready.

  • bucefal91 committed 1e28874 on 8.x-5.x
    Issue #2850600 by arosboro: Initial try on composite element types.
    
  • bucefal91 committed 22ed9b4 on 8.x-5.x
    Issue #2850600 by bucefal91, arosboro: Cannot show individual component...
bucefal91’s picture

Status: Needs review » Fixed

I have committed my patch #7.

Thank you once again for your contribution :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.