From 302a23d978e6d4edaf5ebaad010faae1724945ac Mon Sep 17 00:00:00 2001 From: Butschster Date: Mon, 15 Feb 2016 21:23:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20deprecat?= =?UTF-8?q?ed=20=D1=80=D0=BE=D1=83=D1=82=D1=8B=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D1=82=D0=B8?= =?UTF-8?q?=D0=BF=D1=83=20=D0=B2=D0=B8=D0=B4=D0=B6=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/Controllers/WidgetController.php | 25 +++++++++++-- src/Http/routes.php | 38 +++++++++----------- src/resources/views/widgets/create.blade.php | 2 +- src/resources/views/widgets/list.blade.php | 7 +++- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/Http/Controllers/WidgetController.php b/src/Http/Controllers/WidgetController.php index e0f1bf0..615bc02 100644 --- a/src/Http/Controllers/WidgetController.php +++ b/src/Http/Controllers/WidgetController.php @@ -25,10 +25,26 @@ public function getIndex(WidgetRepository $repository, $type = null) $query = $repository->getModel()->newQuery(); + $widgetTypeLinks = [ + link_to_route( + 'backend.widget.list', + \UI::label('All', is_null($type) ? 'primary' : 'default'), + [] + ) + ]; + foreach (WidgetManagerDatabase::getAvailableTypes() as $group => $types) { if (isset($types[$type])) { $this->breadcrumbs->add($types[$type]); } + + foreach($types as $key => $title) { + $widgetTypeLinks[] = link_to_route( + 'backend.widget.list.by_type', + \UI::label($title, $key == $type ? 'primary' : 'default'), + [$key] + ); + } } if (! is_null($type)) { @@ -37,7 +53,7 @@ public function getIndex(WidgetRepository $repository, $type = null) $widgets = $query->paginate(); - $this->setContent('widgets.list', compact('widgets')); + $this->setContent('widgets.list', compact('widgets', 'type', 'widgetTypeLinks')); } /** @@ -53,13 +69,16 @@ public function getPopupList(WidgetRepository $repository, $pageId) return $this->setContent('widgets.page.ajax_list', compact('widgets')); } - public function getCreate() + /** + * @param string $type + */ + public function getCreate($type = 'html') { $this->setTitle(trans($this->wrapNamespace('core.title.create'))); $types = WidgetManagerDatabase::getAvailableTypes(); - $this->setContent('widgets.create', compact('types')); + $this->setContent('widgets.create', compact('types', 'type')); } /** diff --git a/src/Http/routes.php b/src/Http/routes.php index 7a144fa..c6da75c 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -1,30 +1,24 @@ backend_url_segment(), 'as' => 'backend.', 'middleware' => ['web']], function () { - Route::controller('snippets', 'SnippetController', [ - 'getIndex' => 'snippet.list', - 'getCreate' => 'snippet.create', - 'postCreate' => 'snippet.create.post', - 'getEdit' => 'snippet.edit', - 'postEdit' => 'snippet.edit.post', - 'postDelete' => 'snippet.delete', - ]); + Route::get('snippets', ['as' => 'snippet.list', 'uses' => 'SnippetController@getIndex']); + Route::get('snippet/create', ['as' => 'snippet.create', 'uses' => 'SnippetController@getCreate']); + Route::post('snippet/create', ['as' => 'snippet.create.post', 'uses' => 'SnippetController@postCreate']); + Route::get('snippet/{id}', ['as' => 'snippet.edit', 'uses' => 'SnippetController@getEdit']); + Route::post('snippet/{id}', ['as' => 'snippet.edit.post', 'uses' => 'SnippetController@postEdit']); + Route::post('snippet/{id}/delete', ['as' => 'snippet.delete', 'uses' => 'SnippetController@postDelete']); + Route::get('widget', ['as' => 'widget.list', 'uses' => 'WidgetController@getIndex']); + Route::get('widget/{id}/location', ['as' => 'widget.location', 'uses' => 'WidgetController@getLocation']); + Route::post('widget/{id}/location', ['as' => 'widget.location.post', 'uses' => 'WidgetController@postLocation']); + Route::get('widget/{id}/edit', ['as' => 'widget.edit', 'uses' => 'WidgetController@getEdit']); + Route::post('widget/{id}/edit', ['as' => 'widget.edit.post', 'uses' => 'WidgetController@postEdit']); + Route::get('widget/create/{type?}', ['as' => 'widget.create', 'uses' => 'WidgetController@getCreate']); + Route::post('widget/create', ['as' => 'widget.create.post', 'uses' => 'WidgetController@postCreate']); + Route::get('widget/{id/}template', ['as' => 'widget.template', 'uses' => 'WidgetController@getCreate']); + Route::post('widget/{id}/delete', ['as' => 'widget.delete', 'uses' => 'WidgetController@postDelete']); + Route::get('widget/popup', ['as' => 'widget.popup_list', 'uses' => 'WidgetController@getPopupList']); Route::get('widget/{type}', ['as' => 'widget.list.by_type', 'uses' => 'WidgetController@getIndex']); - - Route::controller('widget', 'WidgetController', [ - 'getIndex' => 'widget.list', - 'getLocation' => 'widget.location', - 'postLocation' => 'widget.location.post', - 'getTemplate' => 'widget.template', - 'getCreate' => 'widget.create', - 'postCreate' => 'widget.create.post', - 'getEdit' => 'widget.edit', - 'postEdit' => 'widget.edit.post', - 'postDelete' => 'widget.delete', - 'getPopupList' => 'widget.popup_list', - ]); - }); Route::group(['as' => 'api.', 'middleware' => ['web', 'api']], function () { diff --git a/src/resources/views/widgets/create.blade.php b/src/resources/views/widgets/create.blade.php index 83f2062..a2c37aa 100644 --- a/src/resources/views/widgets/create.blade.php +++ b/src/resources/views/widgets/create.blade.php @@ -22,7 +22,7 @@
- {!! Form::select('type', $types, 'html', ['class' => 'form-control', 'size' => 10]) !!} + {!! Form::select('type', $types, $type, ['class' => 'form-control', 'size' => 10]) !!}
diff --git a/src/resources/views/widgets/list.blade.php b/src/resources/views/widgets/list.blade.php index da4c715..34d8f43 100644 --- a/src/resources/views/widgets/list.blade.php +++ b/src/resources/views/widgets/list.blade.php @@ -1,12 +1,17 @@
@if (acl_check('widgets.add')) - {!! link_to_route('backend.widget.create', trans('widgets::core.button.create'), [], [ + {!! link_to_route('backend.widget.create', trans('widgets::core.button.create'), [$type], [ 'class' => 'btn btn-primary btn-labeled', 'data-icon' => 'plus', 'data-hotkeys' => 'ctrl+a' ]) !!} @endif
+
+ @foreach($widgetTypeLinks as $link) + {!! $link !!} + @endforeach +
@if(count($widgets) > 0)