If you create a standard View of entities you can add a special filed "Operations" that creates a drop-down button of all operations available for an entity.
But if the view is backed by Search API this operations field isn't available. It would be great to have it as it will enable us to replace some views in core by more powerful ones based on Search API.

Comments

mkalkbrenner created an issue. See original summary.

drunken monkey’s picture

Sure, we can into that. Thanks for the suggestion!

mkalkbrenner’s picture

Status: Active » Needs review
StatusFileSize
new2.72 KB

Here's a first patch. It a proof-of-concept at the moment.

drunken monkey’s picture

StatusFileSize
new5.72 KB
new4.7 KB

Looks pretty good already, and seems to work great, thanks a lot!
Why do you say it's still just a proof of concept, what would you want to improve? (Of course, we could add a getOperations() method to the datasource class (plus a separate interface) to enable non-entity datasources to also provide operations – but that would probably be a bit too much, especially if no-one has yet requested it.)

In any case, a few nitpicks about code style and structure, but no real changes.

Might be good to get tests for this, though, of course. Question is whether the entity_test_mulrev_changed entity type (which we use in ViewsTest) defines operations. Otherwise, this would probably be too bothersome to test.

mkalkbrenner’s picture

Looks pretty good already, and seems to work great, thanks a lot!

Thanks. We already use it in production ;-)

Why do you say it's still just a proof of concept, what would you want to improve?

I'm not sure, when $this->_object will be set. Especially when you enable "Retrieve data from Solr". But I was in a hurry as we required the patch. So I just didn't spent any time on a deeper investigation.

Might be good to get tests for this, though, of course. Question is whether the entity_test_mulrev_changed entity type (which we use in ViewsTest) defines operations. Otherwise, this would probably be too bothersome to test.

We can use a test module and a hook to add operations to entity_test_mulrev_changed.

drunken monkey’s picture

StatusFileSize
new787 bytes
new4.71 KB

I'm not sure, when $this->_object will be set.

Ah, you're right, didn't think about that. The attached revision should make this more reliable.

We can use a test module and a hook to add operations to entity_test_mulrev_changed.

Good idea! Do you have the time to work on that? You can just use the search_api_test_views module for the hook.

drunken monkey’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
mtodor’s picture

Status: Needs work » Needs review
StatusFileSize
new11.5 KB
new6.75 KB

Here is a proposal for testing.

Following things are added in tests:

  1. New page for existing test view, because we need fields in a view row
  2. List builder is added to test entity type because list builder is required for getting operations and triggering entity operation hooks
  3. Hook to add operations to entities, with exception of one, so that we can test case when an entity doesn't have operations
  4. New test function, to keep the tests separated

drunken monkey’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Awesome, thanks a lot for finally taking care of this!
Looks pretty good, too, just minimally improved code style.

Committed.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

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