Code Monkey home page Code Monkey logo

collapsible-resource-manager's Introduction

Collapsible Resource Manager

Latest Version on Packagist Total Downloads License

Laravel Nova Collapsible Resource Manager in action

Provides an easy way to order and group your resources on the sidebar.

Installation

You can install the package via composer:

composer require digital-creative/collapsible-resource-manager

Usage

This package can serve as a seamless replacement for Nova's default sidebar menu. The only modification it makes to the original Nova menu is the addition of the ->icon() method to the MenuItem class, which enables you to easily incorporate icons into each menu item.

For all available options you can check nova documentation here.

class NovaServiceProvider extends NovaApplicationServiceProvider {

    public function boot(): void
    {
        //...
        Nova::mainMenu(function (Request $request): array {    
            return [
                MenuSection::make('Content', [
                    MenuGroup::make('User Base', [
                        MenuItem::resource(User::class)->icon('<svg>...</svg>'),
                        MenuItem::resource(Article::class)->icon('annotation'),
                        MenuItem::resource(Comment::class)->icon('chat-alt'),
                    ]),
                ])->icon('lightning-bolt')->collapsable(),
            ];    
        });
        //...
    }

}

Configuration

You can also enable/disable the main header menu handling. For example, if you don't want the user menu, theme switcher, and notification icon to be moved to the bottom left side, you can manually disable it by adding these lines to your Nova config file:

// config/nova.php

'vendors' => [
    'collapsible_resource_manager' => [
        'move_user_menu' => false,
        'move_theme_switcher' => false,
        'move_notification_center' => false
    ]
]

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

Other Packages You Might Like

License

The MIT License (MIT). Please see License File for more information.

collapsible-resource-manager's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

collapsible-resource-manager's Issues

add option for applying collapsible behaviour to existing groups

It would be nice if the default behaviour, or this could be configurable, was to take the existing resources and groups and made the groups collapsible, without having to explicitly define all the groups and their resources. My resources are all auto-loaded and auto-detected and having to manually specify them is undesirable. Since Nova already has a mechanism for grouping resources, couldn't you just take that and apply your collapsibility to the existing groups? And if a user requires more complex scenarios then they can define it themselves?

Resource icons issue

HI!

I have one Navigation item and resources under it:

'navigation' => [
        [
            'title' => 'Main Content',
            'resources' => [
                Class1::class,
                Class2::class,
                Class3::class
            ],
        ],
        [

I want to add icons for each resource. So should I add

public static function icon(): string
    {

method to each resource? It does not seem to work.

indent group menu items

Having a lot of grouped menu items with icons now - It is hard to distinguish between the group label and the grouped items.

It would be great to have items with icons indented, so the icons start where the text starts now.

A flexible way to achieve would be to introduce a "class" parameter to each Resource Type so we can add a CSS class and style it.

Trigger reload of the menu when running action

Hi,

I use your great badge function on entries in the menu.

Do you know if there is any way to trigger a reload of the menu?
I use the badges so show unprocessed resources and updates them with an action. It would be neat if the badges got updated when the action has ran.

Kind regards
Tim

Cards not updating

This is probably not a direct issue of this package, but anyways:

When linking directly to resources like this:

NovaResource::make(\App\Nova\User::class)->detail(1)->label('User 1'),
NovaResource::make(\App\Nova\User::class)->detail(2)->label('User 2'),

and navigating between them, the cards are not updated - I use Ericlagarda\NovaTextCard to display some resource specific information.

Any idea why this happens and how to solve it?

Permissions

Is there any way we can implement permission via policies so it doesn't show links not allowed to users with certain roles i am using Spatie permission package?

Can the default Dashboard menu option be removed or edited?

If not, what is the syntax for adding dashboards under resources?
I tried using both NovaResource:: and InternalLink::, but NovaResource:: threw errors pointing to the dashboard class file, and InternalLink wasn't doing a RouterLink, so the whole page was being redrawn.
The docs say WidgetResource:: only supports the Nova Dashboard package, so I didn't try that.

The menu in Nova is one of its weakest points, but this package goes a LONG way to fixing that. Many Thanks!

Please don't show not available resources in collapsible navigation

on CollapsibleResourceManager.php class, into private method resolveResources() please add another check on availableForNavigation(). ex:
if ($resource::authorizedToViewAny(request()) && $resource::availableForNavigation(request())) {
return [
'icon' => method_exists($resource, 'icon') ? $resource::icon() : null,
'label' => is_numeric($key) ? $resource::label() : $this->translateKey($key),
'route' => $resource::uriKey()
];
}

Now if on resource availableForNavigation() method is returned false, the navigation menu is showing.

Thanks

Add link to custom tool

I'm unable to add link to my custom tool
Tried with internal link but did not get it to work
Any idea ?

Lenses

Hi,

Do you think it would be possible to add support for lenses in the menu?

I can use the "Internal Link" example, but the link wont be marked as active and it will do a full page reload.

Kind regards
Tim

Lens missing when using NovaResource::make(...)

I have a App\Nova\Resource that has lenses, they work fine when this tool is not registered in Nova.
The lenses drop down selection does not appear on the resource after I use this tool to modify the sidebar navigation.

Unknown custom element: <RouterLink>

Please fix

vendor.js?id=8a0b277a131df1bccb14:91212 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

--->


Tool links with params

Hi,

Trying to use RawRessource for a tool but when trying to access another id nova doesn't reload the data correctly.

Let's says i have a link to /tool/1 and a link to /tool/2

when trying to reach /tool/2 from /tool/1 the data doesn't reload on _self link i still have the data from /tool/1.

Yeah! but you need to define the router name/params/query manually using the RawResource

RawResource::make([
    'label' => 'Your Tool',
    'name' => 'ROUTER_NAME',
    'params' => [ 'foo' => 'bar' ],
    'query' => [ 'foo' => 'bar' ],
])

Originally posted by @milewski in #15 (comment)

Adding a separator with no link

I want to customize menu with a separator (not grouping, not new TopLevel item)
For example:

*Admin
->Users
->Permissions
/ / / / /
->Site configuration
->Crons jobs

Thanks in advance.

How to enable CollapsibleResourceManager

Hello,

I run below command
"composer require digital-creative/collapsible-resource-manager" and have set menu items in NovaServiceProvider. But i got below error
"Class 'App\Providers\CollapsibleResourceManager' not found".

Please help me out. I have invested full time to solve this issue.

allow to add tools

The option to add tools to the menu would be great (think you should rename the package to menu manager)

Cosmetics: animation of submenu with icons

Submenu has icons.

When opening the submenu, the animation first shows the text-items, and with a short delay shows the icons.

It would be great to have a smooth animation where text and icons appear as one unit.

Top Level Collapsible

Maybe I have overlooked something, but how to make a toplevel collapsible? I mean, I would like to have in my sidebar something like the following:

  • Dashboard
  • Group1 +
    • Resource1
    • Resource2
  • Group2 +
    • Resource3
    • Resource4

And "Group1" and "Group2" should be collapsed by default?

BTW: Thank you for your great package.

Using internal or external link, not working

Defining an internal link as such:

            [
                'title'     => 'Menu Item',
                'expanded'  => false,
                'resources' => [
                   'Item Name' => '/item'
                ]
            ],

This causes the menu category to not show up at all. Same thing happens if I change it to

'Item Name' => 'https://www.foo.com'

Am I not understanding the internal / external functionality?

group toggle icon misleading

great stuff!

I think the group toggle icon (+ | - ) should be the other way round:

  • indicates the group can be expanded
  • indicates the group can be collapsed

icons

can we get support for icons for any entry, not just the top level?

missing style ?

Hi, I get plus sign on the right and no margin on groups
is that not enough to publish styles ?
php artisan nova:publish

Hide TopLevelResource label and icon when all resources in the group hidden

I'm using permissions to show/hide resources to users. Sometimes, it happens that a given user is not allowed to see all the resources in the group(s) under one of the TopLevel menus.

I am able to hide all the resources, however, the label and icon of the TopLevelResource as still visible, as on the attached screenshot.

Is it possible to hide the TopLevelResource menu in those cases?
Screen Shot 2020-03-26 at 2 26 14 pm

make Active for current resource when press F5

hi
when use url for arriving to the resource content
Or when I refresh the page by F5
the the group menu and resource not expanded automatically
so i must click the resource in sidebar and expand it manually
and 'remember_menu_state'=>true, not work

..sorry for bad English

Resource label type confusion

Depending on the resource name, it is possible that the resource label will be unconditionally fetched from a global function matching that name, despite deriving from the resource as a string.

This is because AbstractResource::$label is used as a callable (not a closure) first and then as a string. But the typing on the label function only supports a string.

A string which maps to a global function is a valid callable, but almost never what you want with how the lable is automatically wired up with collapsible resource manager.

how to add items programmatically

Wonder if this would require some development or could already be solved with some code:

How can we add items to the navigation programmatically (eventually through a nova resource)?

Gapping or blanks when user not authorized to see resource.

Howdy.

Having some trouble with blank spaces when all the models in a Group::make are made not visible to the logged in user by a Laravel Policy.

Looking at the HTML source, it appears the li tags are being created but contain no group div tags within them.

After install: Error Class 'App\Providers\CollapsibleResourceManager' not found

Just after installation i have this error, added to nova tool.

I also tried add any of those, cannot find good way
use DigitalCreative\CollapsibleResourceManager;
use DigitalCreative\CollapsibleResourceManager\TopLevelResource;
use DigitalCreative\CollapsibleResourceManager\CollapsibleResourceManager;
use DigitalCreative\CollapsibleResourceManager\CollapsibleResourceManagerServiceProvider;
use DigitalCreative\CollapsibleResourceManager\TopLevelResource;
use App\Providers\CollapsibleResourceManager;

Reserved prop name "style"

I'm getting the following console warning:
"style" is a reserved attribute and cannot be used as component prop.
I believe renaming the prop "style" to "styles" in CollapsibleIndicator.vue should fix this.

Group nested resources under another resource

I am looking to take a few related resources and place them in groups to better show the hierarchy of the resources. With this group, I would like to make the top most resource a link to that resource and then have nested resources in an expandable list under that resource. I have found 2 possible ways to come close to this but both seem to lack something the other has.

Option 1 (Use top level resource):

TopLevelResource::make([
    'label' => 'Resource 1',
    'linkTo' => Resource1::class,
    'expanded' => false,
    'resources' => [
        Resource2::class,
    ]
]),

I will probably use this option for the time being. However, when using this option this has to be in the top level list. This is conceivably fine, except you lose the capability to expand or collapse the list.

Option 2 (Use group):

TopLevelResource::make([
    'label' => 'Resources',
    'resources' => [
        OtherResource::class,
        Group::make([
            'linkTo' => Resource1::class,
            'expanded' => true,
            'resources' => [
                Resource2::class,
            ]
        ]),
    ]
]),

Using this option comes closer but has a bigger drawback. This will create the expand and collapse feature that I am looking for with the next data but the Group heading is no longer a link so I would have to duplicate resource1 in the list just to make it so the user can click on it. Also, you lose the plus/minus symbol to denote the expanded/collapsed status.

Recipe: Font Awesome icons

  1. composer require nothingworks/blade-svg
  2. php artisan vendor:publish --provider="BladeSvg\BladeSvgServiceProvider"
  3. download and configure the path to Fontawesome SVG as described on https://medium.com/@simondepelchin/how-to-use-font-awesome-5-svgs-with-laravel-blade-a5dc93743cd0
  4. make a helper function
function faIcon($faIcon, $group = 'solid')
{
    try {
        return svg_image($group . '/' . $faIcon, '', ['width' => '24px', 'height' => '24px', 'fill' => 'var(--sidebar-icon)'])->toHtml();
    } catch (FileNotFoundException $exception) {
        return svg_image( 'regular/question-circle' , '', ['width' => '24px', 'height' => '24px', 'fill' => 'var(--sidebar-icon)'])->toHtml();
    }
}

and you are ready to add icons like this:

->icon(faIcon('language'))
or
'icon' => faIcon('users-cog'),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.