Nodequeue has an option to create a tab on Node pages that links to: node/%/nodequeue. Entityqueue could add a similar page. This page would allow you to see all the queues that the entity can be added to. For any queues that the entity is already in, it would show a "Remove from queue" link, otherwise it would show a "Add to queue" link.

The only thing I can see wrong with the Nodequeue's implementation, is if the same node is in the queue multiple times (assuming this bug #593468: adding the same node more than once to a queue causes bad behavior was fixed), then clicking "Remove from queue" only removes the first instance of the node in the queue. We may want to consider a "Remove all from queue" and maybe a "Remove from queue position X" to give the user more control over which one is removed from this page.

Comments

jamesdevware’s picture

Version: » 7.x-1.0-alpha3
StatusFileSize
new3.04 KB

Hi,

I needed to do the same thing,

Attached is a module which I created to do exactly that (for nodes). I have quite a basic entityqueue setup but it works for what I needed.

joachim’s picture

Version: 7.x-1.0-alpha3 » 8.x-1.x-dev
Priority: Normal » Major

Bumping the version & upping to major. Now that this module is replacing nodequeue for D8, this is sort of a regression in the UX...

josebc’s picture

Assigned: Unassigned » josebc
josebc’s picture

Status: Active » Needs review
StatusFileSize
new15.09 KB

Code is a little dirty but good for a start

rajab natshah’s picture

+1 Testing :)

rajab natshah’s picture

Passed
https://travis-ci.org/Vardot/varbase/jobs/175542568

Feature: Module Requirements - Standard Entity Queue Management - Have Entityqueue tab inside the full content page and be able to Add to a queue or Remove from a queue

Feature: Module Requirements - Standard Entity Queue Management - Have Entityqueue tab inside the full content page and be able to Add to a queue or Remove from a queue
As a logged in user with a permission to manage entity queues
I well be able to see an Entityqueue tab inside the full content page of a selected content
So that I can Add to queue or Remove from queue for the content.

@javascript @local @development
Scenario: Check if queuable content have the "Entityqueue" tab at the full content page and can Add to queue or Remove from queue.
  Given I am a logged in user with the "webmaster" user
   When I go to "/node/add/test_content"
    And I wait
   Then I should see "Create Test Content"
   When I fill in "Test tab content number 1" for "Title"
    And I fill in the rich text editor field "Body" with "Test tab content number 1 Body"
    And I press "Save"
    And I wait
   Then I should see "Test Content Test tab content number 1 has been created."
    And I should see "Entityqueue"
   When I click "Entityqueue"
    And I wait
   Then I should see "Add to queue"
   When I click "Add to queue"
    And I wait for AJAX to finish
   Then I should see "Remove from queue"
   When I click "Remove from queue"
    And I wait for AJAX to finish
   Then I should see "Add to queue"
rajab natshah’s picture

Status: Needs review » Reviewed & tested by the community
rajab natshah’s picture

Assigned: josebc » Unassigned
Status: Reviewed & tested by the community » Needs work

I have one issue for this patch.
The Entityqueue Tab will show up for content types which are not selected in any eneity queue

josebc’s picture

Status: Needs work » Needs review
StatusFileSize
new16.87 KB

new patch with condition

rajab natshah’s picture

Testing .......

rajab natshah’s picture

rajab natshah’s picture

Status: Needs review » Reviewed & tested by the community
amateescu’s picture

Status: Reviewed & tested by the community » Needs work

As @josebc mentioned in #4, the code does look kinda dirty to me as well :)

Here's a small review for now:

  1. +++ b/entityqueue.routing.yml
    @@ -63,3 +63,21 @@ entity.entity_subqueue.add_form:
    +entity.entity_subqueue.add:
    +  path: '/admin/structure/entityqueue/{entity_queue}/{entity_subqueue}/{entity}/add'
    ...
    +entity.entity_subqueue.remove:
    +  path: '/admin/structure/entityqueue/{entity_queue}/{entity_subqueue}/{entity}/remove'
    
    +++ b/src/Entity/EntitySubqueue.php
    @@ -49,7 +49,9 @@ use Drupal\user\UserInterface;
    + *     "add" = "/admin/structure/entityqueue/{entity_queue}/{entity_subqueue}/{entity}/add",
    + *     "remove" = "/admin/structure/entityqueue/{entity_queue}/{entity_subqueue}/{entity}/remove"
    
    @@ -277,6 +279,28 @@ class EntitySubqueue extends ContentEntityBase implements EntitySubqueueInterfac
    +  public function add($entity_id) {
    ...
    +  public function remove($entity_id) {
    

    The names of these operations are a bit vague, since they are not adding or removing subqueues, but subqueue *items*, so how about renaming the links to "add-item" and "remove-item", and everywhere they're used as well.

  2. +++ b/src/Controller/EntityQueueEntityController.php
    @@ -0,0 +1,142 @@
    +class EntityQueueEntityController extends ControllerBase {
    

    All methods from this controller could actually move to the existing \Drupal\entityqueue\Controller\EntityQueueUIController class.

  3. +++ b/src/Controller/EntityQueueEntityController.php
    @@ -0,0 +1,142 @@
    +              'url' => $subqueue->urlInfo('remove'),
    ...
    +              'url' => $subqueue->urlInfo('add'),
    
    +++ b/src/Entity/EntitySubqueue.php
    @@ -309,7 +333,12 @@ class EntitySubqueue extends ContentEntityBase implements EntitySubqueueInterfac
    +    if (in_array($rel, ['add', 'remove'])) {
    +      $route_match = \Drupal::routeMatch();
    +      $entity_type = $route_match->getParameter('entity_type_id');
    +      $entity = $route_match->getParameter($entity_type);
    +      $url->setRouteParameter('entity', $entity->id());
    +    }
    

    Instead of the hackish code in \Drupal\entityqueue\Entity\EntitySubqueue::toUrl(), why don't we add the parameter directly where we need it?

  4. +++ b/src/Controller/EntityQueueEntityController.php
    @@ -0,0 +1,142 @@
    +    //TODO: change to replace command instead of reload.
    

    Needs to be done, I think?

  5. +++ b/src/Controller/EntityQueueEntityController.php
    @@ -0,0 +1,142 @@
    +    $lol = $entity;
    

    :)

  6. +++ b/src/Controller/EntityQueueEntityController.php
    @@ -0,0 +1,142 @@
    +        return AccessResult::allowedIf(TRUE);
    ...
    +    return AccessResult::allowedIf(FALSE);
    

    This can just be ::allowed() and ::forbidden().

  7. +++ b/src/Plugin/Derivative/EntityqueueLocalTask.php
    @@ -0,0 +1,76 @@
    +          'weight' => 999,
    

    Do we really need this weight so high? If yes, I'm very curious why :)

josebc’s picture

amateescu thanx for the review, ill be working on your notes however i still think this needs some more work (ie. AJAX replace instead of refresh on success).
Will upload a new patch soon
ps: Im still a D8 noob

rajab natshah’s picture

Grate work!!!

My only wish will be if we could have a custom label for the tab.

amateescu’s picture

@josebc, D8 noob or not, you're doing a very good job :)

josebc’s picture

Status: Needs work » Needs review
StatusFileSize
new17.03 KB

new patch with review feedback and some cleanup

amateescu’s picture

Can you please provide an interdiff so it's easier for a reviewer to see exactly what changed from the previous patch?

josebc’s picture

StatusFileSize
new17.64 KB

interdiff

rajab natshah’s picture

Testing .....

rajab natshah’s picture

Status: Needs review » Needs work

- Not up to date with the latest DEV.
- ( Suggestion )

No custom label caption. "Entityqueue" is not User friendly, this should be added for each content type, something like "Featured", "Add to featured", "Top Order", "Add to Order", "Add to the stack", "Queue", "Queues", or "Stack".
josebc’s picture

Status: Needs work » Needs review
StatusFileSize
new16.91 KB

Reroll for latest dev

rajab natshah’s picture

Testing ....

rajab natshah’s picture

rajab natshah’s picture

Status: Needs review » Needs work
rajab natshah’s picture

The patch is not working with the latest Entityqueue release.

abu-zakham’s picture

Patch #22 works fine on latest dev version, Thanks @josebc.

rajab natshah’s picture

Testing ... with e17c172fe1bfdab2194b06b848cad92bc6824e49 and the patch.

We had an issue with:
#2479377: content_translation_page_attachments() should check for a canonical link before generating a URL to it

rajab natshah’s picture

Status: Needs work » Needs review
rajab natshah’s picture

rajab natshah’s picture

rajab natshah’s picture

StatusFileSize
new17.09 KB
dennis cohn’s picture

I've deleted an entityqueue. And now I get a fatal error when I go the the entityqueue tab:

Error: Call to a member function getEntitySettings() on null in Drupal\entityqueue\Controller\EntityQueueUIController->entityGetAllowedSubqueList()

Can't add/edit anything from the node form anymore.

millionleaves’s picture

I just tried patch #32 on the dev release from October 20, 2017 in a site running Drupal 8.4.2.

I get this error when clearing the cache:

[error] Class Drupal\entityqueue\Routing\RouteSubscriber does not exist

millionleaves’s picture

I just tried #32 again on two separate 8.4.4 codebases. The patch applied OK, and added an Entityqueue tab to those node types that can be added to an entityqueue.

In relation to #33, I also tried creating, then deleting, a test entityqueue that related to just one of my node types. When I deleted it, I got a website error:

Uncaught PHP Exception Drupal\\Core\\Entity\\EntityStorageException: "Some mandatory parameters are missing ("entity") to generate a URL for route "entity.entity_subqueue.add_item"." at /var/www/html/path-to/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 753, referer: https://www.mysite.com/admin/structure/entityqueue/test_queue/delete

When I went to the edit page for a node, I could make changes but clicking on the Entityqueue tab gave me this error:

PHP Fatal error: Call to a member function getEntitySettings() on null in /var/www/html/path-to/drupal/modules/contrib/entityqueue/src/Controller/EntityQueueUIController.php on line 87, referer: https://www.mysite.com/node/57/edit?destination=/admin/content

This was the case for the single node type I'd linked to the test entityqueue, plus other node types that were linked to other entityqueues.

I resolved it by manually removing my test entityqueue from the entity_subqueue table, and the single node link I'd created to that entityqueue from the entity_subqueue__items table. Once I did that, I was able to click the Entityqueue tab on a node and see the available queues, as expected.

I haven't tested an unpatched version of the Entityqueue module to see if this problem with deleting a queue was already happening, but I'm not sure how this patch would have caused this error to start happening.

amateescu’s picture

StatusFileSize
new17 KB
new19.52 KB

The patch needed quite some work to get in a proper state, but I'm pretty happy with how it turned out. Thanks @josebc and @RajabNatshah!

The problem outlined in #35 was easy to fix, we can simply take out the new link relationships from the entity subqueue definition, as they are pretty useless there anyway :)

Edit: and I couldn't reproduce #33, maybe that was also fixed with some of the refactoring that I made.

amateescu’s picture

Title: Option to create Entityqueue tab on Entity pages » Add an Entityqueue tab on entity pages

  • amateescu committed b52c984 on 8.x-1.x authored by josebc
    Issue #2145441 by josebc, RajabNatshah, amateescu, Xenza, millionleaves...
amateescu’s picture

Status: Needs review » Fixed

Committed to 8.x-1.x. Thanks everyone!

dww’s picture

Sweet, thanks for all the work here, everyone!

One question: it seems very common that if you're on the 'Entityqueue' tab on a given entity, in addition to the 'add to queue' or 'remove from queue' operation, a content editor/admin would want/need to be able to 'Edit queue items' to change the order, etc. Should I open a follow-up issue about this or is there interest in another patch in here for it?

Thanks again!
-Derek

millionleaves’s picture

@dww I think we definitely need the option for Edit queue items, but I think you should start another issue, given that this one is already fixed and committed.

dww’s picture

Fair enough. Opened #2947820: Add 'Edit queue items' operation to new entityqueue tab on entities as a child issue.

Let's continue the discussion there.

Thanks,
-Derek

Status: Fixed » Closed (fixed)

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