localgovdrupal / localgov_workflows

Default editorial workflow for LocalGov Drupal content.
GNU General Public License v2.0
0 stars 1 forks source link

Filter content list by 'Service contact' #85

Open willguv opened 3 months ago

willguv commented 3 months ago

Following on from https://github.com/localgovdrupal/localgov_workflows/issues/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 commented 1 week ago

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

Am looking for a few more issues for you if OK

MariosORION commented 1 week ago

@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 commented 1 week ago

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?

NDITGC commented 1 week ago

following with interest

finnlewis commented 3 days ago

@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 commented 3 days ago

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

MariosORION commented 14 hours ago

PR https://github.com/localgovdrupal/localgov_workflows/pull/104 ready for review.

Changes:

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:

Possible cons of this approach:

willguv commented 13 hours ago

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 commented 12 hours ago

@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.