FEATURE: ugly commit - rewritten widgets, menu made more compact, added profile menu, few bugfixes etc. Sorry..
This commit is contained in:
@@ -27,28 +27,25 @@ abstract class BaseHandler implements BaseModuleHandler
|
||||
|
||||
// create instance of main menu
|
||||
\Menu::create('mainMenu', function ($menu) {
|
||||
// $menu->route('admin.dashboard', trans('admin/mainMenu.dashboard'), [], 10, ['icon' => 'fa fa-dashboard']);
|
||||
$menu->dropdown(trans('admin/mainMenu.userManagement'), function ($sub) {
|
||||
$sub->route('users.new', trans('admin/mainMenu.newUser'), [], 10, ['icon' => 'fa fa-user-plus']);
|
||||
$sub->route('users.detail', trans('admin/mainMenu.userDetail'), [], 20, ['icon' => 'fa fa-user']);
|
||||
$sub->route('users.overview', trans('admin/mainMenu.usersOverview'), [], 30, ['icon' => 'fa fa-users']);
|
||||
}, 20, ['icon' => 'fa fa-users']);
|
||||
// $menu->route('admin.dashboard', trans('admin/mainMenu.dashboard'), [], 10, ['icon' => 'fa fa-fw fa-dashboard']);
|
||||
|
||||
/**
|
||||
* Content pages
|
||||
*
|
||||
* Submenus can be registered later
|
||||
*/
|
||||
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
|
||||
$modules = \App\Models\Module::where('manages_content', true)
|
||||
->get();
|
||||
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 9999, ['icon' => 'fa fa-fw fa-list']);
|
||||
}, 20, ['icon' => 'fa fa-fw fa-database']);
|
||||
|
||||
if (!empty($modules)) {
|
||||
$sub->dropdown(trans('admin/mainMenu.newContentPage'), function ($sub) use ($modules) {
|
||||
$i = 1;
|
||||
foreach ($modules as $module) {
|
||||
$sub->route('content.new', trans($module->name), ['moduleId' => $module->id], $i++);
|
||||
}
|
||||
}, 10, ['icon' => 'fa fa-plus']);
|
||||
}
|
||||
/**
|
||||
* File manager
|
||||
*/
|
||||
$menu->route('upload.overview', trans('admin/mainMenu.fileManager'), [], 40, ['icon' => 'fa fa-fw fa-folder']);
|
||||
|
||||
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 20, ['icon' => 'fa fa-list']);
|
||||
}, 15, ['icon' => 'fa fa-database']);
|
||||
$menu->route('upload.overview', trans('admin/mainMenu.fileManager'), [], 30, ['icon' => 'fa fa-folder']);
|
||||
/**
|
||||
* Widgets and widget areas
|
||||
*/
|
||||
$menu->dropdown(trans('admin/mainMenu.widgets'), function ($sub) {
|
||||
// create list of all widget types
|
||||
$widgets = WidgetTypes::getWithTranslations();
|
||||
@@ -59,42 +56,61 @@ abstract class BaseHandler implements BaseModuleHandler
|
||||
foreach ($widgets as $type => $name) {
|
||||
$sub->route('widgets.new', $name, ['type' => $type], $i++);
|
||||
}
|
||||
}, 10, ['icon' => 'fa fa-plus']);
|
||||
}, 10, ['icon' => 'fa fa-fw fa-plus']);
|
||||
}
|
||||
|
||||
$sub->route('widgets.overview', trans('admin/mainMenu.widgetsOverview'), [], 20, ['icon' => 'fa fa-list']);
|
||||
$sub->route('widgets.overview', trans('admin/mainMenu.widgetsOverview'), [], 20, ['icon' => 'fa fa-fw fa-list']);
|
||||
|
||||
// menu for widget areas
|
||||
$sub->dropdown(trans('admin/mainMenu.widgetAreas'), function ($sub) {
|
||||
$sub->route('widgetareas.new', trans('admin/mainMenu.newWidgetArea'), [], 1, ['icon' => 'fa fa-plus']);
|
||||
$sub->route('widgetareas.overview', trans('admin/mainMenu.widgetAreaOverview'), [], 2, ['icon' => 'fa fa-list']);
|
||||
}, 50, ['icon' => 'fa fa-object-group']);
|
||||
}, 28, ['icon' => 'fa fa-gears']);
|
||||
$sub->route('widgetareas.new', trans('admin/mainMenu.newWidgetArea'), [], 1, ['icon' => 'fa fa-fw fa-plus']);
|
||||
$sub->route('widgetareas.overview', trans('admin/mainMenu.widgetAreaOverview'), [], 2, ['icon' => 'fa fa-fw fa-list']);
|
||||
}, 50, ['icon' => 'fa fa-fw fa-object-group']);
|
||||
}, 50, ['icon' => 'fa fa-fw fa-puzzle-piece']);
|
||||
|
||||
/**
|
||||
* Templates
|
||||
*/
|
||||
$templatePaths = TemplatePathsHumanReadableRootOnly::getWithTranslations();
|
||||
|
||||
if (!empty($templatePaths)) {
|
||||
$menu->dropdown(trans('admin/mainMenu.templates'), function ($sub) use ($templatePaths) {
|
||||
$i = 1;
|
||||
foreach ($templatePaths as $id => $name) {
|
||||
$sub->route('templates.overview', $name, ['id' => $id], $i++);
|
||||
}
|
||||
}, 29, ['icon' => 'fa fa-folder-open']);
|
||||
}, 60, ['icon' => 'fa fa-fw fa-file-code-o']);
|
||||
}
|
||||
// $menu->dropdown(trans('admin/mainMenu.customFields'), function ($sub) {
|
||||
// $sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-code']);
|
||||
// $sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-code-fork']);
|
||||
// }, 30, ['icon' => 'fa fa-code']);
|
||||
$menu->route('log.overview', trans('admin/mainMenu.actionLog'), [], 40, ['icon' => 'fa fa-history']);
|
||||
$menu->route('settings.overview', trans('admin/mainMenu.settings'), [], 50, ['icon' => 'fa fa-gear']);
|
||||
|
||||
/**
|
||||
* Divide system entries and other links in menu
|
||||
*/
|
||||
$menu->addDivider(9999);
|
||||
|
||||
$menu->dropdown(trans('admin/mainMenu.system'), function ($sub) {
|
||||
$sub->dropdown(trans('admin/mainMenu.userManagement'), function ($sub) {
|
||||
$sub->route('users.new', trans('admin/mainMenu.newUser'), [], 10, ['icon' => 'fa fa-fw fa-user-plus']);
|
||||
$sub->route('users.overview', trans('admin/mainMenu.usersOverview'), [], 30, ['icon' => 'fa fa-fw fa-users']);
|
||||
}, 20, ['icon' => 'fa fa-fw fa-users']);
|
||||
|
||||
// $menu->dropdown(trans('admin/mainMenu.customFields'), function ($sub) {
|
||||
// $sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-fw fa-code']);
|
||||
// $sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-fw fa-code-fork']);
|
||||
// }, 30, ['icon' => 'fa fa-fw fa-code']);
|
||||
|
||||
$sub->route('log.overview', trans('admin/mainMenu.actionLog'), [], 70, ['icon' => 'fa fa-fw fa-history']);
|
||||
$sub->route('settings.overview', trans('admin/mainMenu.settings'), [], 80, ['icon' => 'fa fa-fw fa-gear']);
|
||||
}, 10000, ['icon' => 'fa fa-fw fa-gear']);
|
||||
|
||||
|
||||
});
|
||||
|
||||
// order
|
||||
|
||||
// create menu with user profile
|
||||
\Menu::create('profileMenu', function ($menu) {
|
||||
$menu->route('users.detail', trans('admin/userManagement.profile'));
|
||||
$menu->route('logout', trans('admin/common.logout'));
|
||||
$menu->route('users.detail', trans('admin/userManagement.profile'), [], 10, ['icon' => 'fa fa-fw fa-user icon']);
|
||||
$menu->addDivider(999);
|
||||
$menu->route('logout', trans('admin/common.logout'), [], 1000, ['icon' => 'fa fa-fw fa-power-off icon']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,10 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests;
|
||||
use App\Http\Requests\NewWidgetRequest;
|
||||
use App\Models\Widget;
|
||||
use App\Models\WidgetType;
|
||||
use App\Widgets\Exceptions\MissingParameterException;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class CreateNewWidget extends Controller
|
||||
{
|
||||
@@ -64,7 +61,7 @@ class CreateNewWidget extends Controller
|
||||
|
||||
// redirect with success notification
|
||||
return redirect()
|
||||
->route('widgets.new', ['type' => $type])
|
||||
->route('widgets.overview')
|
||||
->with('success', trans('admin/widgets.successfullyCreated'));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EditWidget extends Controller
|
||||
{
|
||||
/**
|
||||
* Render edit form
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEdit($id)
|
||||
{
|
||||
$widget = Widget::findOrFail($id);
|
||||
@@ -17,6 +24,14 @@ class EditWidget extends Controller
|
||||
return call_user_func([$presenter, 'renderEditForm'], $widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save changes into database
|
||||
*
|
||||
* @param EditWidgetRequest $request
|
||||
* @param $widget
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postEdit(EditWidgetRequest $request, $widget)
|
||||
{
|
||||
// create new widget
|
||||
@@ -53,6 +68,25 @@ class EditWidget extends Controller
|
||||
->with('success', trans('admin/widgets.successfullyEdited'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes widget
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteWidget($id) {
|
||||
// create new widget
|
||||
$widget = Widget::findOrFail($id);
|
||||
|
||||
$widget->delete();
|
||||
|
||||
// redirect with success notification
|
||||
return redirect()
|
||||
->route('widgets.overview')
|
||||
->with('success', trans('admin/widgets.successfullyDeleted'));
|
||||
}
|
||||
|
||||
private function invalidWidget($error)
|
||||
{
|
||||
return redirect()
|
||||
|
||||
@@ -176,6 +176,10 @@ Route::group([
|
||||
Route::get('widgets/edit/{id}', 'EditWidget@getEdit')
|
||||
->name('widgets.edit');
|
||||
|
||||
// delete widget settings
|
||||
Route::get('widgets/delete/{id}', 'EditWidget@deleteWidget')
|
||||
->name('widgets.delete');
|
||||
|
||||
Route::post('widgets/edit/{id}', 'EditWidget@postEdit')
|
||||
->name('widgets.postEdit');
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace App\MenuPresenters;
|
||||
|
||||
use Pingpong\Menus\MenuItem;
|
||||
use Pingpong\Menus\Presenters\Presenter;
|
||||
|
||||
class ProfileMenuPresenter extends Presenter
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function getOpenTagWrapper()
|
||||
{
|
||||
return PHP_EOL . '<div class="dropdown-menu profile-dropdown-menu">' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function getCloseTagWrapper()
|
||||
{
|
||||
return PHP_EOL . '</div>' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function getMenuWithoutDropdownWrapper($item)
|
||||
{
|
||||
return '<a href="' . $item->getUrl() . '" class="dropdown-item">' . $item->getIcon() . ' ' . $item->title . '</a>' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function getActiveState(MenuItem $item)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function getDividerWrapper()
|
||||
{
|
||||
return '<div class="dropdown-divider"></div>' . PHP_EOL;
|
||||
}
|
||||
|
||||
public function getMultiLevelDropdownWrapper($item)
|
||||
{
|
||||
return null;//$this->getMenuWithDropDownWrapper($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function getMenuWithDropDownWrapper($item)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,11 @@ class HtmlCode implements WidgetRenderer
|
||||
*/
|
||||
public static function renderAddForm(WidgetType $type)
|
||||
{
|
||||
return view('admin.widgets.htmlCode.new', ['type' => $type]);
|
||||
return view('admin.widgets.htmlCode.new', [
|
||||
'type' => $type,
|
||||
'widget' => new Widget(),
|
||||
'settings' => new \stdClass()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user