Problem/Motivation

Similar to contextual-links integration we want to be able to render certain links
as a dropbutton.

You want to be able to select certain fields which are rendered as links, and then they should be grouped together as dropbutton.
One day this could be used to have a nice edit experience using admin_views.

Proposed resolution

Provide an integration.

Remaining tasks

-

User interface changes

-

API changes

-

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Issue summary: View changes

test

dawehner’s picture

Status: Active » Needs review
FileSize
4.64 KB
2.08 KB

It still looks a bit different compared to the views edit interface, but this seems to be just styled different.

damiankloip’s picture

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Links.phpundefined
@@ -0,0 +1,91 @@
+ * A abstract handler which provides a collection of links.

An abstract, but should we be calling this abstract when it's not abstract, or make this abstract? I guess the second one :)

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Links.phpundefined
@@ -0,0 +1,91 @@
+    // Only show fields that follow this one.

I think this is meant to be 'Only show fields that precede this one'.

It would also be good good to filter by only fields that can actually render links. This is potentially a good follow up issue, as there currently isn't a nice way to achieve this.

dawehner’s picture

FileSize
4.65 KB
I think this is meant to be 'Only show fields that precede this one'.

Yeah, i got confused by that.

dawehner’s picture

FileSize
12.23 KB

Let's also add tests.

tim.plunkett’s picture

I was just manually testing this patch for #1851086: Replace admin/people with a View and it works great!

+++ b/core/modules/system/system.views.incundefined
@@ -0,0 +1,21 @@
+function system_views_data_alter(&$data) {

Why is this an alter and not just a regular info hook?

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Links.phpundefined
@@ -0,0 +1,91 @@
+    $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));

Don't we do this for tokens as well? We could probably have a helper (follow-up, of course)

+++ b/core/modules/views/lib/Drupal/views/Tests/System/FieldDropButtonTest.phpundefined
@@ -0,0 +1,46 @@
+      $this->assertEqual(count($result), 1);
...
+      $this->assertEqual(count($result), 1);

We should probably add assertion messages

+++ b/core/modules/views/lib/Drupal/views/Tests/System/FieldDropButtonTest.phpundefined
@@ -0,0 +1,46 @@
+      $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => 'Custom Text'));

I think the "Custom Text" should technically be wrapped in t().

dawehner’s picture

FileSize
4.53 KB
14.07 KB

Thanks for the review!!

Well, we use the alter hook, because we add to an (maybe not existing at that point).
But i don't care let's use hook_views_data

I think the "Custom Text" should technically be wrapped in t().

Currently there is no translation system for views, so ... but yeah fixed it :)

Status: Needs review » Needs work

The last submitted patch, drupal-1826604-6.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
14.08 KB

I think we might want to move this back to hook_views_data_alter() as we are adding this to the views "table"?

dawehner’s picture

Noone knows whether it's right to use hook_views_data_alter or hook_views_data when you add to an existing table and in reality it simply doesn't matter.

Status: Needs review » Needs work

The last submitted patch, 1826604-8.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
812 bytes
14.08 KB

The tokens array was being polluted, so we were getting the values returned from getPreviousFieldLabels() twice. Like :

array (
  'age' => 'Age',
  'id' => 'ID',
  'name' => 'Name',
  'Fields' => 
  array (
    '[age]' => 'Age',
    '[id]' => 'ID',
    '[name]' => 'Name',
  ),
)

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, 1826604-11.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#11: 1826604-11.patch queued for re-testing.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

I think this is good to go.
I've manually tested it, and the code changes look great, especially that new helper method.

dawehner’s picture

#11: 1826604-11.patch queued for re-testing.

tim.plunkett’s picture

Title: Create a dropbutton field in views. » Add a dropbutton field handler to Views

This is blocking any efforts to port admin listings to Views.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Status: Reviewed & tested by the community » Needs work

Though, this needs to be updated for the $testViews approach and #1855228: Move Views core module tests to their respective modules

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs work » Postponed
FileSize
1.16 KB
14.22 KB
tim.plunkett’s picture

Status: Postponed » Needs work
tim.plunkett’s picture

Priority: Normal » Major
Status: Needs work » Needs review
FileSize
2.71 KB
15.35 KB

This is major because it blocks every single admin view conversion.

Updated for the recent commits, should be back to RTBC if green.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This interdiff looks fine.

damiankloip’s picture

Yep, looks good to me too.

catch’s picture

Status: Reviewed & tested by the community » Needs work

OK so the code in general looks fine, but system module shouldn't know anything about views. Ideally system module shouldn't know about anything at all because it's been shot in the brain.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
9.76 KB
14 KB

Yep, understood. We can move this back to views.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Oh well that's easier.

dawehner’s picture

So everything which is part of either core/includes or core/lib should get it's views integration in views.views.inc?

Just in general it's a bit odd, because views also implements it's own api, so if you would ask me personally i would like to put the views integration into system.views.inc but i don't care.

catch’s picture

Status: Reviewed & tested by the community » Fixed

If there's something in /includes or core/lib that needs views integration, then that integration should probably go into a new or existing module that's neither system nor views. Same as we just re-added entity module to avoid stuffing things into system.

Eventually /includes shouldn't exist at all - we'll one-day migrate all of that to core/lib or core/modules (although it might take another release or so).

This looks like a generic handler and not related to any particular core subystem so I'm not sure it's a problem here though? Committed/pushed to 8.x but happy to discuss this a bit more.

dawehner’s picture

If there's something in /includes or core/lib that needs views integration, then that integration should probably go into a new or existing module that's neither system nor views. Same as we just re-added entity module to avoid stuffing things into system.

So for the dropbutton field we could create a system_views, but then we basically end up with a system.views.inc kind of functionality.
It's loaded only when views requests that hooks, so it doesn't add additional costs. So yeah i don't have a real solution/good name idea for that problem.

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

Anonymous’s picture

Issue summary: View changes

update

Anybody’s picture

Issue summary: View changes

Will this be backported to Drupal 7 or is there a module to provice dropbutton links in views? This would be very very useful!

Anybody’s picture