Skip to content

Commit

Permalink
Убраны deprecated роуты
Browse files Browse the repository at this point in the history
Добавлена фильтрация по типу виджетов
  • Loading branch information
butschster committed Feb 15, 2016
1 parent a4f0c2f commit 302a23d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
25 changes: 22 additions & 3 deletions src/Http/Controllers/WidgetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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'));
}

/**
Expand All @@ -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'));
}

/**
Expand Down
38 changes: 16 additions & 22 deletions src/Http/routes.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
<?php

Route::group(['prefix' => 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 () {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/widgets/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="form-group">
<label class="control-label col-md-3">@lang('widgets::core.field.type')</label>
<div class="col-md-6">
{!! Form::select('type', $types, 'html', ['class' => 'form-control', 'size' => 10]) !!}
{!! Form::select('type', $types, $type, ['class' => 'form-control', 'size' => 10]) !!}
</div>
</div>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/resources/views/widgets/list.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<div class="panel">
<div class="panel-heading">
@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
</div>

<div class="panel-heading">
@foreach($widgetTypeLinks as $link)
{!! $link !!}
@endforeach
</div>
@if(count($widgets) > 0)
<table class="table table-primary table-striped table-hover">
<colgroup>
Expand Down

0 comments on commit 302a23d

Please sign in to comment.