FEATURE: make widget areas not deletable
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests;
|
||||
use App\Http\Requests\EditWidgetAreaRequest;
|
||||
use App\Models\WidgetArea;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
@@ -61,6 +60,13 @@ class EditWidgetArea extends Controller
|
||||
return $this->invalidArea();
|
||||
}
|
||||
|
||||
// check if widget area is deletable
|
||||
if (!$area->deletable) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', trans('admin/widgetAreas.notDeletableArea'));
|
||||
}
|
||||
|
||||
// delete area
|
||||
$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",
|
||||
"noEntries" => "Zatím nebyla definována žádná plocha pro widgety.",
|
||||
"overview" => "Seznam všech ploch pro widgety",
|
||||
"save" => "Uložit",
|
||||
"successfullyCreated" => "Plocha pro widgety úspěšně vytvořena",
|
||||
"successfullyDeleted" => "Úspěšně smazáno",
|
||||
"uniqueCode" => "Unikátní kód",
|
||||
];
|
||||
|
||||
@@ -15,5 +15,9 @@ return [
|
||||
'editButton' => 'Edit',
|
||||
'save' => 'Save',
|
||||
'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'
|
||||
];
|
||||
@@ -27,18 +27,24 @@
|
||||
<div class="item-actions-block">
|
||||
<ul class="item-actions-list">
|
||||
<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>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{route('widgets.associate', ['widgetArea' => $area->id])}}"><i
|
||||
class="fa fa-plus"></i></a>
|
||||
<a href="{{route('widgets.associate', ['widgetArea' => $area->id])}}"
|
||||
data-toggle="tooltip"
|
||||
title="@lang('admin/widgetAreas.associateWidgets')">
|
||||
<i class="fa fa-plus"></i></a>
|
||||
</li>
|
||||
@if($area->deletable)
|
||||
<li>
|
||||
<a class="confirm remove"
|
||||
<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>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user