FEATURE: make widget areas not deletable
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests;
|
|
||||||
use App\Http\Requests\EditWidgetAreaRequest;
|
use App\Http\Requests\EditWidgetAreaRequest;
|
||||||
use App\Models\WidgetArea;
|
use App\Models\WidgetArea;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
@@ -61,6 +60,13 @@ class EditWidgetArea extends Controller
|
|||||||
return $this->invalidArea();
|
return $this->invalidArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if widget area is deletable
|
||||||
|
if (!$area->deletable) {
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('error', trans('admin/widgetAreas.notDeletableArea'));
|
||||||
|
}
|
||||||
|
|
||||||
// delete area
|
// delete area
|
||||||
$area->delete();
|
$area->delete();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddTemplateSupportToWidgets extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('widget_types', function (Blueprint $table) {
|
||||||
|
$table->integer('template_id')
|
||||||
|
->comment('Commes this widget with template?')
|
||||||
|
->after('handler')
|
||||||
|
->nullable(true)
|
||||||
|
->default(null);
|
||||||
|
$table->integer('module_id')
|
||||||
|
->comment('Commes this widget with some module?')
|
||||||
|
->after('template_id')
|
||||||
|
->nullable(true)
|
||||||
|
->default(null);
|
||||||
|
|
||||||
|
$table->foreign('template_id')
|
||||||
|
->references('id')
|
||||||
|
->on('modules')
|
||||||
|
->onDelete('cascade')
|
||||||
|
->onUpdate('cascade');
|
||||||
|
|
||||||
|
$table->foreign('module_id')
|
||||||
|
->references('id')
|
||||||
|
->on('modules')
|
||||||
|
->onDelete('cascade')
|
||||||
|
->onUpdate('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('widget_types', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('widget_types_module_id_foreign');
|
||||||
|
$table->dropForeign('widget_types_template_id_foreign');
|
||||||
|
$table->dropColumn(['template_id', 'module_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class MakeWidgetsAndWidgetAreasNotDeletable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('widgets', function (Blueprint $table) {
|
||||||
|
$table->boolean('deletable')
|
||||||
|
->default(true)
|
||||||
|
->comment('Can this widget be deleted?');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('widget_areas', function (Blueprint $table) {
|
||||||
|
$table->boolean('deletable')
|
||||||
|
->default(true)
|
||||||
|
->comment('Can this widget area be deleted?');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('widgets', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('deletable');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('widget_areas', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('deletable');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ return [
|
|||||||
"new" => "Nová plocha pro widgety",
|
"new" => "Nová plocha pro widgety",
|
||||||
"noEntries" => "Zatím nebyla definována žádná plocha pro widgety.",
|
"noEntries" => "Zatím nebyla definována žádná plocha pro widgety.",
|
||||||
"overview" => "Seznam všech ploch pro widgety",
|
"overview" => "Seznam všech ploch pro widgety",
|
||||||
|
"save" => "Uložit",
|
||||||
"successfullyCreated" => "Plocha pro widgety úspěšně vytvořena",
|
"successfullyCreated" => "Plocha pro widgety úspěšně vytvořena",
|
||||||
"successfullyDeleted" => "Úspěšně smazáno",
|
"successfullyDeleted" => "Úspěšně smazáno",
|
||||||
|
"uniqueCode" => "Unikátní kód",
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ return [
|
|||||||
'actions' => 'Actions',
|
'actions' => 'Actions',
|
||||||
'noEntries' => 'No widget areas defined yet. Try to create some first.',
|
'noEntries' => 'No widget areas defined yet. Try to create some first.',
|
||||||
'editButton' => 'Edit',
|
'editButton' => 'Edit',
|
||||||
'save' => 'Save',
|
'save' => 'Save',
|
||||||
'edit' => 'Editing widget area :name',
|
'edit' => 'Editing widget area :name',
|
||||||
|
'editTooltip' => 'Edit widget area',
|
||||||
|
'associateWidgets' => 'Associate widgets with this widget area',
|
||||||
|
'delete' => 'Delete widget area',
|
||||||
|
'notDeletableArea' => 'Cannot delete desired widget area. This area is essential part of installed template and therefore cannot be deleted.',
|
||||||
'editSuccessfull' => 'Successfully edited'
|
'editSuccessfull' => 'Successfully edited'
|
||||||
];
|
];
|
||||||
@@ -27,18 +27,24 @@
|
|||||||
<div class="item-actions-block">
|
<div class="item-actions-block">
|
||||||
<ul class="item-actions-list">
|
<ul class="item-actions-list">
|
||||||
<li>
|
<li>
|
||||||
<a class="edit" href="{{route('widgetareas.edit', ['id' => $area->id])}}"><i
|
<a class="edit" data-toggle="tooltip"
|
||||||
|
title="@lang('admin/widgetAreas.editTooltip')"
|
||||||
|
href="{{route('widgetareas.edit', ['id' => $area->id])}}"><i
|
||||||
class="fa fa-pencil"></i></a>
|
class="fa fa-pencil"></i></a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{route('widgets.associate', ['widgetArea' => $area->id])}}"><i
|
<a href="{{route('widgets.associate', ['widgetArea' => $area->id])}}"
|
||||||
class="fa fa-plus"></i></a>
|
data-toggle="tooltip"
|
||||||
</li>
|
title="@lang('admin/widgetAreas.associateWidgets')">
|
||||||
<li>
|
<i class="fa fa-plus"></i></a>
|
||||||
<a class="confirm remove"
|
|
||||||
href="{{route('widgetareas.delete', ['id' => $area->id])}}"><i
|
|
||||||
class="fa fa-trash"></i></a>
|
|
||||||
</li>
|
</li>
|
||||||
|
@if($area->deletable)
|
||||||
|
<li>
|
||||||
|
<a class="confirm remove" data-toggle="tooltip" title="@lang('admin/widgetAreas.delete')"
|
||||||
|
href="{{route('widgetareas.delete', ['id' => $area->id])}}"><i
|
||||||
|
class="fa fa-trash"></i></a>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user