Comments

frank.schalkwijk created an issue. See original summary.

frank.schalkwijk’s picture

Assigned: frank.schalkwijk » Unassigned
Status: Active » Needs work
StatusFileSize
new4.22 KB

I tried to make this work, but I can't get the last part to work. When I try to view a view with a domain source filter I get an error saying domain_source field is undefined.
Also the hook_view_data_alter doesn't appear in the core modules so I think they solved their needs with the YAML files, but I don't see how.

agentrickard’s picture

I don't understand. Views provides this support by default.

What are you trying to do with the filter?

agentrickard’s picture

StatusFileSize
new30.99 KB
agentrickard’s picture

This patch actually works fine for me. Did you rebuild the cache drush cr when testing?

What I don't understand is this part:

views.filter_value.domain_source:
  type: views.filter_value.in_operator
  label: 'Domain source'

What does this try to do?

spadxiii’s picture

Just did a re-roll (against latest dev) with a small fix for the '_active_domain' value as it wasn't filtering properly for the active domain.

The default domain_source filter seems to be an input field and not a select. This patch changes that filter to a select.

I don't know why there is a views.filter_value.domain_source entry in the domain_source.views.schema.yml file. Even after removing that (and drush cr), I could still use and configure the filter in the view.

ps. I found out what the problem was with the error as describe by Frank: it was custom code that was changing the options list.

spadxiii’s picture

StatusFileSize
new4.16 KB

And of course I forgot to attach the new patch ... :)

spadxiii’s picture

StatusFileSize
new4.16 KB

Found another typo in the last patch; correct in a new patch.

agentrickard’s picture

Thanks for the notes.

I have this mirrored at https://github.com/agentrickard/domain/pull/383 for testing, but have not updated the patch there.

spadxiii’s picture

StatusFileSize
new4.16 KB

If there is no value for the filter, it is an empty string. That triggers a nice error with an array_search in the filter.
Corrected that in a new patch :)

agentrickard’s picture

I haven't written any automated tests for Views yet. Have you nay ideas about how to test this?

spadxiii’s picture

I did a manual test where I added 2 domains, made a few nodes with each a different domain source, created a view with a domain source filter and when filtered saw the correct nodes in the view :)

This might take a bit of setup-code to test, but should be doable. I haven't done that either just yet, but I could look into that.

A few thoughts: the contents of the filter is not filtered by your permissions? Might be something worth adding.
What still feels 'wrong' is that a hook_views_data_alter is used to set the correct field/filter id.

agentrickard’s picture

You have to use hook_views_data_alter() because these are defined as "field UI fields" and therefore get default Views handlers assigned to them on creation.

agentrickard’s picture

Just revisiting this patch. The domain.loader service has been deprecated. It's all moved to regular entity storage now.

\Drupal::service('entity_type.manager')->getStorage('domain');
agentrickard’s picture

Status: Needs work » Reviewed & tested by the community

I've fixed the above and am looking at the filter now. I think we can commit this and worry about restricting the list later.

Both this filter and the Domain Access filter will need an option to "restrict" the list to assigned domains.

agentrickard’s picture

Status: Reviewed & tested by the community » Fixed

This has been committed!

I opened #2928354: Add filter options to domain_access and domain_source views as a follow-up.

Status: Fixed » Closed (fixed)

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

spadxiii’s picture

StatusFileSize
new539 bytes

Made a new pull-request: https://github.com/agentrickard/domain/pull/400

From the comitted patch, the domain_source.views.schema.yml seems to be missing. Without this file, views doesn't know what to do with a field_domain_source_target_id filter.

(ps. I can't re-open this issue)