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

Add a status "badge" to Admin menu #9

Closed
hughbris opened this issue May 18, 2022 · 6 comments
Closed

Add a status "badge" to Admin menu #9

hughbris opened this issue May 18, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@hughbris
Copy link
Owner

Might be called a pill or something else:

image

Showing how many changed/new items.

@hughbris hughbris added the enhancement New feature or request label May 18, 2022
@pamtbaau
Copy link
Collaborator

These badges can be added when adding Pushy to the Admin menu. See for example in Grav Admin itself:

// Pages
$count = new Container(['count' => function () { return $this->admin->pagesCount(); }]);
$twig->plugins_hooked_nav['PLUGIN_ADMIN.PAGES'] = [
      'route' => 'pages',
      'icon' => 'fa-file-text-o',
      'authorize' => ['admin.pages', 'admin.super'],
      'badge' => $count,
      'priority' => 5
];

$twig->plugins_hooked_nav is being called when Pushy add itself to the Admin menu. When Admin is started, the number of "dirty" pages can be added.

However, Pushy uses async calls to commit pages, hence the badge can no longer be update on the server. Some JS should do the trick. That's doable, but unfortunately, the menu-item, nor the badge have proper id of classes.

@hughbris
Copy link
Owner Author

hughbris commented May 18, 2022

Sorry I had seen that option and this wasn't a call for help, just very quickly capturing my idea without wanting to look up the "how" again. Badge is indeed the term I was fishing for, thanks!

Thank you for being helpful and on the ball though.

unfortunately, the menu-item, nor the badge have proper id of classes

(*or classes, I assume)

Try a PR in Admin to add easily selectable id/class attributes if you feel like it. I've had mixed luck with similar PRs though.

@hughbris
Copy link
Owner Author

Perhaps too late because you have solved this ..

unfortunately, the menu-item, nor the badge have proper id of classes.

I noticed this class menu property that I left commented out in my Admin menu code that I copied (from Gitsync I think). I assume it adds a class and that the data property adds data attributes.

@hughbris
Copy link
Owner Author

Very satisfactory implementation provided in 23c4188.

Going to leave this open (sorry) because I would love to have an indicator of new items here as well. Should probably wait for #11 though.

@pamtbaau
Copy link
Collaborator

I noticed this class menu property that I left commented out in my Admin menu code that I copied (from Gitsync I think). I assume it adds a class and that the data property adds data attributes.

Looking at the nav.html.twig template from Admin which generates the Admin menu, properties like class and data are not being referenced/used.

@pamtbaau pamtbaau changed the title Add a status "button" to Admin menu Add a status "badge" to Admin menu May 26, 2022
@hughbris
Copy link
Owner Author

hughbris commented Apr 9, 2023

Integrated circa 23c4188

@hughbris hughbris closed this as completed Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants