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

widget not formatted on 4th widget #3185

Closed
amc123-glitch opened this issue May 16, 2018 · 5 comments
Closed

widget not formatted on 4th widget #3185

amc123-glitch opened this issue May 16, 2018 · 5 comments

Comments

@amc123-glitch
Copy link

"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"tcg/voyager": "^1.1"

Description:

I want to add 4 widgets to the dashboard. I can successfully get the third widget to show in format, but when I add another widget after that it is placed far right, under the third widget instead of being pushed to the left. In addition, If I add more widgets or even just copy and paste the same two new widgets, they show up formatted from left to right as expected.

The first 2 widgets are the ones generated by the --with-dummy data tag. In addition the widgets I made are stored in my App directory in a folder labeled widgets and then referenced as App\Widgets\somefilename.

Steps To Reproduce:

  • create a folder labeled widgets
  • create php file for widget
  • copy and paste widget code from the dummy generated in the vendor/tcg/src/widgets section and modify for whatever the widget is showing
  • php artisan config:cache and refresh
@hemantachhami19
Copy link

I am also having the same problem!!
New Widgets doent get formed ,nor removed while modifying voyager.php

@amc123-glitch
Copy link
Author

amc123-glitch commented Sep 25, 2018

@hemantachhami19 I opted to build my own backend admin panels, partially for this reason and since the team decided to let this issue just sit answered

@Spraynard
Copy link
Contributor

Spraynard commented Nov 13, 2019

I have had the same problem with my layout, and I know the reason for this behavior.

The blade template dimmers.blade.php is used to output all of the Dimmers i.e. Widgets, in voyager context, to HTML. If you look at the template, you can see that it is quite specifically made to only support up to three different widgets (if the count sees two widgets, we will output different classnames to our widgets than if there are three)

This is done by calling the Voyager::dimmers() function, shown below

    /**
     * Get a collection of the dashboard widgets.
     *
     * @return \Arrilot\Widgets\WidgetGroup
     */
    public function dimmers()
    {
        $widgetClasses = config('voyager.dashboard.widgets');
        $dimmers = Widget::group('voyager::dimmers');

        foreach ($widgetClasses as $widgetClass) {
            $widget = app($widgetClass);

            if ($widget->shouldBeDisplayed()) {
                $dimmers->addWidget($widgetClass);
            }
        }

        return $dimmers;
    }

As you can see, we return an instance of \Arrilot\Widgets\WidgetGroup, which is a package used to simplify widget creation. Unfortunately, a WidgetGroup does not give developers an iterative process of going through these widgets.

We are presented with a problem based on how this dimmers() function was created as well. There is almost no way to override this behavior without including a vast amount of voyager source within developer's projects and playing with app configs.

Possible solution

  1. Update the Voyager::dimmers() function to return an array of WidgetGroups, each of which contains up to a max of three widgets. As an example, if we have 2 Widgets, we will return an array containing only 1 WidgetGroup. If we have 5 Widgets we will return an array containing 2 WidgetGroups, and follow this pattern ad infinitum.

  2. Update dimmers.blade.php to handle the changes that are to come from the changes to the Voyager::dimmers() function.

I'm working on this and should be presenting a pull request soon. It would be great if someone from the Voyager team could assign me this.

@emptynick
Copy link
Collaborator

Fixed in #4559

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants