Commit 277b65fc authored by Nicolas Widart's avatar Nicolas Widart

Preparing an menu item list

parent 9a2295da
......@@ -7,6 +7,7 @@ use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Menu\Entities\Menu;
use Modules\Menu\Http\Requests\CreateMenuRequest;
use Modules\Menu\Http\Requests\UpdateMenuRequest;
use Modules\Menu\Repositories\MenuItemRepository;
use Modules\Menu\Repositories\MenuRepository;
class MenuController extends AdminBaseController
......@@ -19,12 +20,17 @@ class MenuController extends AdminBaseController
* @var Redirector
*/
private $redirector;
/**
* @var MenuItemRepository
*/
private $menuItem;
public function __construct(MenuRepository $menu, Redirector $redirector)
public function __construct(MenuRepository $menu, MenuItemRepository $menuItem, Redirector $redirector)
{
parent::__construct();
$this->menu = $menu;
$this->redirector = $redirector;
$this->menuItem = $menuItem;
}
public function index()
......@@ -49,7 +55,8 @@ class MenuController extends AdminBaseController
public function edit(Menu $menu)
{
return View::make('menu::admin.menus.edit', compact('menu'));
$menuItems = $this->menuItem->all();
return View::make('menu::admin.menus.edit', compact('menu', 'menuItems'));
}
public function update(Menu $menu, UpdateMenuRequest $request)
......
......@@ -13,6 +13,7 @@
@section('styles')
<link href="{!! Module::asset('core', 'css/vendor/iCheck/flat/blue.css') !!}" rel="stylesheet" type="text/css" />
<link href="{!! Module::asset('menu', 'css/nestable.css') !!}" rel="stylesheet" type="text/css" />
@stop
@section('content')
......@@ -20,12 +21,26 @@
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="btn-group pull-right">
<div class="btn-group pull-right" style="margin: 0 15px 15px 0;">
<a href="{{ URL::route('dashboard.menuitem.create', [$menu->id]) }}" class="btn btn-primary btn-flat">
<i class="fa fa-pencil"></i> {{ trans('menu::menu.button.create menu item') }}
</a>
</div>
</div>
<div class="box box-info" style="overflow: hidden;">
<div class="box-body">
<div class="dd">
<ol class="dd-list">
<?php foreach($menuItems as $menuItem): ?>
<li class="dd-item" data-id="{{ $menuItem->id }}">
<a href="" class="btn btn-sm btn-info" style="float: left; margin-right: 15px">Edit</a>
<div class="dd-handle" style="margin-left: 50px;">{{ $menuItem->title }}</div>
</li>
<?php endforeach; ?>
</ol>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-info">
......@@ -91,4 +106,14 @@ $( document ).ready(function() {
});
});
</script>
<script src="{!! Module::asset('menu', 'js/jquery.nestable.js') !!}"></script>
<script>
$( document ).ready(function() {
$('.dd').nestable();
$('.dd').on('change', function() {
var data = $('.dd').nestable('serialize');
console.log(data);
});
});
</script>
@stop
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment