Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter content list by 'Service contact' #85

Closed
willguv opened this issue Mar 28, 2024 · 19 comments
Closed

Filter content list by 'Service contact' #85

willguv opened this issue Mar 28, 2024 · 19 comments
Assignees

Comments

@willguv
Copy link
Member

willguv commented Mar 28, 2024

Following on from #12

Content designers would like a view showing the pages assigned to a specific service owner

Could we add a 'service contact' drop down to filter the main content view at /admin/content?

The order would be

Title / Content type / Published status / Service owner / Language

This is based on amount of use each gets - my hunch is editors would use it less than published status but more than language

Image

@willguv willguv converted this from a draft issue Mar 28, 2024
@willguv willguv changed the title Filter content list by 'Service contact' Discussion: Filter content list by 'Service contact' Mar 28, 2024
@willguv willguv moved this from Ready to Refine in 2025 backlog May 8, 2024
@willguv willguv moved this from Refine to Ready in 2025 backlog May 8, 2024
@willguv willguv changed the title Discussion: Filter content list by 'Service contact' Filter content list by 'Service contact' Jun 11, 2024
@willguv
Copy link
Member Author

willguv commented Jun 18, 2024

Hi @MariosORION did you get chance to look at this? Thanks

Am looking for a few more issues for you if OK

@MariosORION
Copy link
Contributor

MariosORION commented Jun 18, 2024

@willguv yes I've tried a few things but it's proving more tricky than I thought - I'll post my findings shortly.

Am looking for a few more issues for you if OK

Yes, please do

@MariosORION
Copy link
Contributor

To POC this, I've enabled localgov_workflows_notifications and created a service contact entity (associated to a Drupal user). Then, on the content View, I've added a new exposed filter "Service contacts" but only insufficient operators are available by default ("Is equal to" requires the user to enter the entity ID which is not very practical):

localgov-workflows-issue-85-new-exposed-filter-operators

The operator we need here is "is one of" similarly to the content type select list but this is not available by default for entity reference fields in content (such as service contact field on LGD nodes).

I've tried Views Entity Reference Filter
; it does provide the required exposed filter operator but it comes with fatal errors when "Filter" is pressed on the enhanced content View.

localgov-workflows-issue-85-enhanced-content-page

There are a couple of patches available for similar issues but neither of them seems to work.

Better exposed filters doesn't provide the results required either.

I'm thinking of writing a custom filter and adding it to the content View programmatically but that's considerably more work so it makes sense to ask for alternative suggestions, if any?

@GC-92
Copy link

GC-92 commented Jun 18, 2024

following with interest

@finnlewis
Copy link
Member

@stephen-cox is suggesting looking at a hook_form_alter on the exposed field to generate a nicer user experience.

@MariosORION if you can share the fatal error, perhaps we can fix the Views Entity Reference Filter issue ?

@rupertj has used Views Entity Reference Filter with success.

@finnlewis
Copy link
Member

On the deployment question, we want to keep this as an optional feature for existing sites.

One option could be a different view like /admin/content-by-owner

@willguv willguv moved this from Ready to In Progress - Everyone else in 2025 backlog Jun 26, 2024
@MariosORION
Copy link
Contributor

MariosORION commented Jun 28, 2024

PR #104 ready for review.

Changes:

  • Adding new View page /admin/content/localgov-content-by-owner that lists content by owner (relationship to service contact required):
localgov_workflows_notifications-issue-85-content-by-user-view-back-office
  • Adding dynamic menu link that only gets placed if the View above is present:
localgov_workflows_notifications-issue-85-dynamic-menu-link
  • Adding dynamic local task that only gets generated if the View above is present (see below for screenshot).
    I've tested this with a new user, service contact tied to that user and a service page with that service contact assigned; here's how the new View looks like (some columns are sortable just like the vanilla content View):
localgov_workflows_notifications-issue-85-content-by-user-view-and-dynamic-local-task

To add the View when localgov_workflow_notifications is already enabled, Councils can manually import the View's YML configuration (views.view.localgov_content_by_owner.yml) into their site:
views.view.localgov_content_by_owner.yml.zip

Benefits of this approach:

  • No additional module required (verf). There is also a patch required for this module to avoid a fatal error when a VERF select exposed filter is added to the View (issue https://www.drupal.org/project/verf/issues/3113519)
  • The "Content by owner" View can be optionally enabled and only comes to play when the localgov_workflow_notifications sub-module is enabled

Possible cons of this approach:

  • The new "Content by owner" View is on its own distinct path and not integrated with the default Content View (which might be appealing for some Councils as it also keeps the main Content View clean)

@willguv
Copy link
Member Author

willguv commented Jun 28, 2024

Thanks for doing this @MariosORION - could you add a screenshot to this page?

Is there a composer command I can use to install this branch?

@MariosORION
Copy link
Contributor

MariosORION commented Jun 28, 2024

@willguv it should be something like:

composer require "localgovdrupal/localgov_workflows":"dev-feature/85-content-filter-by-service-contact" --with-all-dependencies

but I haven't tested it yet.

I've added description and screenshots from the PR in my previous comment here.

@Polynya
Copy link

Polynya commented Aug 23, 2024

Thanks for your work on this issue @MariosORION . I've got an autocomplete filter working using your branch, a core patch and a contrib module:
image

If this would be a good addition to this issue, do you want to try it or I can create a commit? I see you've already considered VERF, so I'm happy to keep this as a follow-up issue.

See:

@MariosORION
Copy link
Contributor

Hey @Polynya, there's actually a PR for this issue already - please see #85 (comment).

Benefits of this approach:

  • No additional module required (verf).
  • The "Content by owner" View can be optionally enabled and only comes to play when the localgov_workflow_notifications sub-module is enabled

Possible cons of this approach:

  • The new "Content by owner" View is on its own distinct path and not integrated with the default Content View, which might be appealing for some Councils as it also keeps the main Content View clean

Your suggestion (and thank you for that!) could also work -it's just a different approach, do you have a preference over the approach in the open PR? (There are some tests failing on the PR but I'll have another go today - any help is more than welcome!).

@Polynya
Copy link

Polynya commented Aug 30, 2024

Hi @MariosORION , I was using your PR but it doesn't allow you to see the content for just one owner. I think that the exposed filter is needed if there are a lot of pages and owners.

@MariosORION
Copy link
Contributor

@Polynya true, only sorting would be available with the additional custom View but no additional module is necessary. I'm more than happy to follow the alternative approach but I feel this should be a wider decision so best to discuss on a merge call (I'll try to make it today) :)

@Polynya
Copy link

Polynya commented Sep 3, 2024

Before finding this issue, I was working on a different approach, which is to display the pages relating to a Service Contact on their canonical page - /admin/content/localgov-service-contact/%
This would remove the need for an external filter and new module. Could we do this along with your View but with links to the Service Contact page?

@MariosORION
Copy link
Contributor

I like this idea (feel free to push to this branch). I'm also thinking about permissions; would this allow all involved Drupal users (roles) to access the list of content for any given Service Contact?

@willguv
Copy link
Member Author

willguv commented Sep 3, 2024

@Polynya could you provide screenshots of the work you've done? Trying to get my head round this - many thanks!

(Sorry for not being present in this chat, was on holiday)

@Polynya
Copy link

Polynya commented Sep 3, 2024

Here's the Service Contact page, showing a block that I added to @MariosORION' s view (with a contextual filter to show content for one Service Contact)
image

This is the "Content by owner" page using the view with the exposed filter added:
image

Although I used a contrib module for the entity reference filter, I don't think it's essential. It does need a core patch though, and it may be best to wait until it's merged:
https://www.drupal.org/project/drupal/issues/3347343

@stephen-cox
Copy link
Member

@Polynya Nice to see core is finally getting the ability to add entity reference filters to views. I've ended up doing hook_form_alters to get this sort of thing working in the past.

The issue seems to be quite active, so probably best to waiting to see if it gets committed soon.

In the meantime I suggest we get Marios' work on this committed and the service contact filter added later.

@MariosORION
Copy link
Contributor

PR #104 tests are now clean and suggestions committed @stephen-cox @Polynya @willguv . Thanks all!

@willguv willguv closed this as completed Nov 27, 2024
@github-project-automation github-project-automation bot moved this from Review to Done in 2025 backlog Nov 27, 2024
@willguv willguv moved this from Done to Documentation in 2025 backlog Feb 4, 2025
@willguv willguv moved this from Documentation to Done in 2025 backlog Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

6 participants