FEATURE #1455: add template path overview

This commit is contained in:
Michal Kváček
2016-02-18 18:19:52 +01:00
parent f3dde68481
commit d082cee7b5
10 changed files with 150 additions and 2 deletions
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Models\TemplatePath;
use Illuminate\Http\Request;
class TemplateOverview extends Controller
{
public function getPath($path)
{
$path = TemplatePath::findOrFail($path);
return view('admin.templates.list', [
'directory' => $path,
'isWritable' => is_writable(base_path($path->path)),
'templates' => $path->templates()
->get(),
'subdirectories' => $path->subdirectories()
->get()
]);
}
}
+15
View File
@@ -51,6 +51,21 @@ Route::group([
Route::get('customfields/delete/{id}', 'EditCustomField@deleteCustomField')
->name('customfields.delete');
Route::get('templates/overview/path/{id}', 'TemplateOverview@getPath')
->name('templates.overview');
Route::get('templates/copy/{id}', 'TemplateOverview@getPath')
->name('templates.copy');
Route::get('templates/new/{pathId}', 'TemplateOverview@getPath')
->name('templates.new');
Route::get('templates/edit/{id}', 'TemplateOverview@getPath')
->name('templates.edit');
Route::post('templates/edit/{id}', 'TemplateOverview@getPath')
->name('templates.postEdit');
});
// these routes are available for all logged (authenticated) users
+12 -1
View File
@@ -18,7 +18,18 @@ class TemplatePath extends Model
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function templates() {
public function templates()
{
return $this->hasMany('App\Models\Template', 'path');
}
/**
* List of all subdirectories of given path
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function subdirectories()
{
return $this->hasMany('App\Models\TemplatePath', 'parent_id');
}
}
+9
View File
@@ -2,6 +2,8 @@
namespace App\Providers;
use App\Enumerations\TemplatePathsHumanReadable;
use App\Enumerations\TemplatePathsHumanReadableRootOnly;
use App\Enumerations\WidgetTypes;
use Illuminate\Support\ServiceProvider;
@@ -54,6 +56,13 @@ class AdminMenusProvider extends ServiceProvider
$sub->route('widgetareas.overview', trans('admin/mainMenu.widgetAreaOverview'), [], 2, ['icon' => 'fa fa-list']);
}, 50, ['icon' => 'fa fa-object-group']);
}, 28, ['icon' => 'fa fa-gears']);
$menu->dropdown(trans('admin/mainMenu.templates'), function ($sub) {
$i = 1;
$templatePaths = TemplatePathsHumanReadableRootOnly::getWithTranslations();
foreach ($templatePaths as $id => $name) {
$sub->route('templates.overview', $name, ['id' => $id], $i++);
}
}, 29, ['icon' => 'fa fa-folder-open']);
$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']);