Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource icons in resource groups tree #16099

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

theboxer
Copy link
Member

@theboxer theboxer commented Mar 23, 2022

What does it do?

Abstract logic for getting icon classes from Resource\GetNodes processor to the modResource::getIconClasses.
Use the new method in Resource\GetNodes and ResourceGroup\GetNodes.

Lock icon is not part of this - as it's specific for resource tree and has no real benefit in resource group tree, same with classes around permissions.

Why is it needed?

Fixes the BUG that resource group's tree doesn't show resource icons. (100% viable for 3.0)

How to test

Create resource group, add resource, check if it has an icon :)

Related issue(s)/PR(s)

Different approach in #16011

@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Mar 23, 2022
@opengeek opengeek added this to the v3.1.0 milestone Apr 27, 2022
@Ruslan-Aleev
Copy link
Collaborator

Unfortunately, the resource status is not displayed in the group tree (publishing, deleting and displaying in the menu).

deleted_res

Copy link
Collaborator

@smg6511 smg6511 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this and it fixes the missing icons issue. As @Ruslan-Aleev pointed out, the resource status is not shown. That's easy to add in here, but it occurred to me that a case can be made for not showing it; it potentially adds a bunch of visual clutter not necessarily needed for the function of this area (organizing the resources into groups).

Note that @theboxer's solution here is better than #16011, as the abstraction into a new function is more lean and Ruslan's PR adds a whole bunch of unneeded css classes used in the main resource tree for permissions. (The only operations available in the groups tree is to add or remove a resource from a group.)

I can go either way here. We could introduce a system setting and leave it up to users whether statuses are shown in resource groups.

@@ -85,13 +85,13 @@ public function process()
$resources = $resourceGroup->getResources();
/** @var modResource $resource */
foreach ($resources as $resource) {
$icons = $resource->getIconClasses();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If electing to add statuses:

Suggested change
$icons = $resource->getIconClasses();
$icons = $resource->getIconClasses();
$cls = [];
if (!$resource->get('published')) {
$cls[] = 'unpublished';
}
if ($resource->get('deleted')) {
$cls[] = 'deleted';
}
if ($resource->get('hidemenu')) {
$cls[] = 'hidemenu';
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to put this logic in the getIconClasses() method, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now that I think about it longer than 5 seconds, no, because cls is applied somewhere else than iconCls. So support for this suggestion.

$list[] = [
'text' => $resource->get('pagetitle') . ' (' . $resource->get('id') . ')',
'id' => 'n_' . $resource->get('id') . '_' . $resourceGroup->get('id'),
'leaf' => true,
'type' => modResource::class,
'cls' => 'icon-' . $resource->get('class_key'),
'iconCls' => 'icon-file',
'iconCls' => implode(' ', $icons),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If adding statuses:

Suggested change
'iconCls' => implode(' ', $icons),
'iconCls' => implode(' ', $icons),
'cls' => implode(' ', $cls)


$contentType = $this->getOne('ContentType');
if ($contentType && $contentType->get('icon')) {
$iconCls = [$contentType->get('icon')];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this (and the same logic on line 1572) be $iconCls[] = $contentType->get('icon') or is the point that we can only have a single icon between the content type and template?

This does seem to be the same in the original code so happy to let it slide if it's just the way things used to be.

@smg6511
Copy link
Collaborator

smg6511 commented Jun 8, 2023

@theboxer - bump - wondering if you're still interested in this or want someone else to pick it up?

@Mark-H Mark-H added blocked Active participation around the pull request or issue required. Consensus is not reached. and removed cla-signed CLA confirmed for contributors to this PR. labels Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Active participation around the pull request or issue required. Consensus is not reached.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants