Problem/Motivation

In #2843917: Implement Library entity type we add the library item entity type. As file module does with file usages, the view that lists all the items of the library should also display the number of usages of each library item.

Proposed resolution

Show number of usages in the list view.
Discuss if it will also list the places where that item is used, when clicking the number of usages.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

yongt9412 created an issue. See original summary.

miro_dietiker’s picture

Mind that this is specifically about user awareness when editing.
Simply show a message with count if paragraphs (with our library field) exist with the reference.

For regular usage tab, see:
https://www.drupal.org/project/entity_usage
Let's try to avoid cloning its complexity.

thenchev’s picture

Assigned: Unassigned » thenchev
miro_dietiker’s picture

I think this should be an info (or even warning) box at the top of the edit form.

primsi’s picture

Project: Paragraphs » Paragraphs Collection
miro_dietiker’s picture

Treat these things as different issues.
A usage count on the overview is helpful.

The item itself each can have a usage tab showing where they are used. The entity usage module is providing that!
https://www.drupal.org/project/entity_usage

We should recommend it at least in documentation! Plz check if the number in the list can also be provided by that module. I'm fine to depend to that module if it makes life significantly easier!

thenchev’s picture

Status: Active » Needs review
StatusFileSize
new7.44 KB

This patch adds "used in' column in admin/content/paragraphs
it appears that we need to use aggregation in view when we want to show the usage count without duplicates.
The problem is that it does't play nice with the paragraphs column in view, I'm getting some sql error.
I will investigate that but the easiest fix will be to remove it...

this patch is btw without the aggregation enabled.

Status: Needs review » Needs work

The last submitted patch, 7: display_usage_number_of-2847055-7.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new421 bytes

Right the dependency

Status: Needs review » Needs work

The last submitted patch, 9: display_usage_number_of-2847055-9.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new443 bytes

Sorry, moved to the wrong place.

primsi’s picture

Status: Needs review » Needs work

Probably uploaded wrong patch.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new566 bytes
new13.38 KB

So paragraphs library doesn't depend on collection only on paragraphs. Adding the dependency in collection composer.json wont help and we probably don't want it in paragraphs.

Status: Needs review » Needs work

The last submitted patch, 13: display_usage_number_of-2847055-13.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new961 bytes
new13.21 KB

After discussing with @Primsi we wanted to check if this works when adding to collection.

Status: Needs review » Needs work

The last submitted patch, 15: display_usage_number_of-2847055-15.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new13.21 KB

Status: Needs review » Needs work

The last submitted patch, 17: display_usage_number_of-2847055-17.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new10.43 KB

Status: Needs review » Needs work

The last submitted patch, 19: display_usage_number_of-2847055-19.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new10.43 KB

Status: Needs review » Needs work

The last submitted patch, 21: display_usage_number_of-2847055-21.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new393 bytes

Checking if nothing else is causing the problem

Status: Needs review » Needs work

The last submitted patch, 23: display_usage_number_of-2847055-23.patch, failed testing.

  • Primsi committed 9d01ce6 on 8.x-1.x authored by Denchev
    Issue #2847055 by Denchev: Display usage number of library items - part...
thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new10.02 KB

Status: Needs review » Needs work

The last submitted patch, 26: display_usage_number_of-2847055-26.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new10.46 KB

Updated tests. This works locally.

thenchev’s picture

This patch above is for the admin/content/paragraphs listing page.
I removed the column that lists what paragraphs are in library item since it caused error when using aggregate. Is this ok?
Wondering if we need some update hook for indexing library items?

Also do we want to split the displaying usage on edit in another issue?

primsi’s picture

Status: Needs review » Needs work

I removed the column that lists what paragraphs are in library item since it caused error when using aggregate. Is this ok?

I think it's fine for now.

Wondering if we need some update hook for indexing library items?

No need for that, we are still in very early development stage.

Also do we want to split the displaying usage on edit in another issue?

IMHO we can do it here

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new3.33 KB
new12.13 KB

Display usage on edit with test coverage.

miro_dietiker’s picture

Status: Needs review » Needs work
+++ b/modules/paragraphs_library/config/install/views.view.paragraphs_library.yml
@@ -305,22 +355,22 @@ display:
+            path: 'admin/content/entity-usage/paragraphs_library_item/{{ id }}'

So this is not a tab / local task when editing a library item? It's a completely different path.

I'm not so convinced about the grouping.

Since this is a UI change, we want to have screenshots in the issue.

thenchev’s picture

StatusFileSize
new48.89 KB
new24.8 KB
new35.13 KB
new18.32 KB
new25.34 KB

So this is not a tab / local task when editing a library item? It's a completely different path.

Since #4

I think this should be an info (or even warning) box at the top of the edit form.

i added an warning when editing a library item. I can add a link for more usage information here too?

For the listing here are some screenshots and comparison to listing for files.

Library item listing:

Files listing:

And when we click on the link to get more details about usages:
Library item:

Files:

Now by looking at it i see that the breadcrumbs for files usage information page are more useful since you can go back to files listing page. For paragraphs usage information you can only get back to admin/content.

thenchev’s picture

Status: Needs work » Needs review
primsi’s picture

Status: Needs review » Needs work

Tested this manually. Looks quite ok. Just two remarks.

"Operations" are usually in the last column of the table.

+++ b/modules/paragraphs_library/paragraphs_library.module
@@ -5,16 +5,64 @@
+function paragraphs_library_count_usage(array $usage_data) {

I would prefix this with _ given that this a utility function.

miro_dietiker’s picture

Yeah, operations need to be last.

I would just name the column "Used" and make it contain the number. I don't like the repetition of "place" / "places".
IMHO these number columns should be right aligned.

Also i really don't like that the summary is removed. We added it as an example to learn how we need to provide and improve the summary. It's very important to collect the different use cases for the collapsed summary and learn from them. It will be a critical issue to readd it.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new6.2 KB
new12.38 KB
new38.16 KB

This covers #35 and #36

I will next create a followup for the summary...

Status: Needs review » Needs work

The last submitted patch, 37: display_usage_number_of-2847055-37.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new12.6 KB
new2.87 KB

  • Primsi committed 5166923 on 8.x-1.x authored by Denchev
    Issue #2847055 by Denchev, miro_dietiker, Primsi: Display usage number...
primsi’s picture

Issue summary: View changes
Status: Needs review » Fixed

Let's get that in then. Thanks.

Status: Fixed » Closed (fixed)

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