Merge branch 'module_categories' into dev
This commit is contained in:
@@ -4,16 +4,14 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Enumerations\ActiveContentStatuses;
|
||||
use App\Events\CreateNewContent as CreateNewContentEvent;
|
||||
use App\Http\Requests\CreateNewContentRequest;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Content;
|
||||
use App\Models\ContentHasFile;
|
||||
use App\Models\Directory;
|
||||
use App\Models\File;
|
||||
use App\Models\Module;
|
||||
use App\Models\Template;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Str;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
use Modules\Categories\Entities\Category;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class CreateNewContent extends Controller
|
||||
@@ -43,7 +41,6 @@ class CreateNewContent extends Controller
|
||||
*/
|
||||
public function getNew($moduleId)
|
||||
{
|
||||
|
||||
$module = Module::findOrFail($moduleId);
|
||||
$statuses = ActiveContentStatuses::getWithTranslations();
|
||||
|
||||
@@ -51,6 +48,13 @@ class CreateNewContent extends Controller
|
||||
->select(['template_name', 'name', 'description'])
|
||||
->get();
|
||||
|
||||
// add categories, if supported
|
||||
$categories = [];
|
||||
if ($module->support_categories) {
|
||||
$categories = Category::where('module_id', $moduleId)
|
||||
->get();
|
||||
}
|
||||
|
||||
// create default content object
|
||||
$this->content->status = Content::STATUS_DRAFT;
|
||||
|
||||
@@ -59,6 +63,8 @@ class CreateNewContent extends Controller
|
||||
'contentStatuses' => $statuses,
|
||||
'templates' => $templates,
|
||||
'moduleId' => $moduleId,
|
||||
'module' => $module,
|
||||
'categories' => $categories,
|
||||
'page' => $this->content,
|
||||
'rootPages' => $this->content->getOverview()
|
||||
->get(),
|
||||
@@ -102,6 +108,7 @@ class CreateNewContent extends Controller
|
||||
$page->status = $request->status;
|
||||
$page->template = $request->template;
|
||||
$page->module_handler = $module->handler;
|
||||
$page->category_id = $request->category;
|
||||
|
||||
if ($request->parentPage) {
|
||||
$page->parent_id = $request->parentPage;
|
||||
|
||||
@@ -14,10 +14,12 @@ use App\Http\Requests\Request;
|
||||
use App\Models\Content;
|
||||
use App\Models\ContentHistory;
|
||||
use App\Models\File;
|
||||
use App\Models\Module;
|
||||
use App\Models\Template;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Str;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
use Modules\Categories\Entities\Category;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class EditContent extends Controller
|
||||
@@ -55,16 +57,27 @@ class EditContent extends Controller
|
||||
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = $allModules[$page->module_handler];
|
||||
$module = Module::findOrFail($moduleId);
|
||||
|
||||
$templates = Template::where('module_id', $moduleId)
|
||||
->select(['template_name', 'name', 'description'])
|
||||
->get();
|
||||
|
||||
// add categories, if supported
|
||||
$categories = [];
|
||||
if ($module->support_categories) {
|
||||
$categories = Category::where('module_id', $moduleId)
|
||||
->get();
|
||||
}
|
||||
|
||||
$history = $this->history->getStructuredHistoryOf($page);
|
||||
|
||||
// render view
|
||||
return view('admin.content.edit', [
|
||||
'contentStatuses' => $statuses,
|
||||
'page' => $page,
|
||||
'module' => $module,
|
||||
'categories' => $categories,
|
||||
'rootPages' => $page->getOverview()
|
||||
->where('contents.id', '!=', $page->id)
|
||||
->get(),
|
||||
@@ -121,7 +134,8 @@ class EditContent extends Controller
|
||||
'content' => 'pageContent',
|
||||
'parent_id' => 'parentPage',
|
||||
'status' => 'status',
|
||||
'title_photo' => 'titlePhotoFilename'
|
||||
'title_photo' => 'titlePhotoFilename',
|
||||
'category_id' => 'category'
|
||||
];
|
||||
|
||||
// save new values with history
|
||||
|
||||
@@ -18,6 +18,7 @@ class Content extends Model
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'parent_id',
|
||||
'category_id',
|
||||
'language',
|
||||
'module_handler',
|
||||
'published_from',
|
||||
@@ -260,7 +261,7 @@ class Content extends Model
|
||||
|
||||
if (trim($fieldValue) != $request[$fieldRequest]) {
|
||||
|
||||
$this->saveHistory();
|
||||
$this->saveHistory($revisionId, $fieldRequest, $fieldValue, $request);
|
||||
|
||||
// save change into database
|
||||
if ($commonField) {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCategorySupport extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$platform = Schema::getConnection()
|
||||
->getDoctrineSchemaManager()
|
||||
->getDatabasePlatform();
|
||||
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
$table->integer('category_id', false, true)
|
||||
->comment('FK to table categories')
|
||||
->after('module_handler')
|
||||
->nullable(true)
|
||||
->default(null);
|
||||
});
|
||||
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
$table->foreign('category_id')
|
||||
->references('id')
|
||||
->on('categories')
|
||||
->onDelete('set null')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$platform = Schema::getConnection()
|
||||
->getDoctrineSchemaManager()
|
||||
->getDatabasePlatform();
|
||||
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
$table->dropForeign('contents_category_id_foreign');
|
||||
$table->dropColumn('category_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ return [
|
||||
"alreadyHomepage" => "Domovská stránka",
|
||||
"appearance" => "Vzhled",
|
||||
"basicInfo" => "Základní informace",
|
||||
"category" => "Kategorie",
|
||||
"content" => "Obsah stránky",
|
||||
"deletePage" => "Smazat",
|
||||
"edit" => "Editace :name",
|
||||
|
||||
@@ -5,6 +5,7 @@ return [
|
||||
'status_protected' => 'Protected',
|
||||
'status_public' => 'Public',
|
||||
'new' => 'Create new :name',
|
||||
'category' => 'Category',
|
||||
'edit' => 'Edit :name',
|
||||
'editPlain' => 'Edit',
|
||||
'content' => 'Page content',
|
||||
|
||||
@@ -12,6 +12,7 @@ return [
|
||||
'columnIs_homepage' => 'Homepage',
|
||||
'columnParentPage' => 'Parent page',
|
||||
'columnTitlePhotoFilename' => 'Title photo',
|
||||
'columnCategory' => 'Kategorie',
|
||||
'emptyValue' => '<em>none</em>',
|
||||
'changedFromTo' => 'Changed from <del>:from</del> to <ins>:to</ins>',
|
||||
'numOfChanges' => 'One change|:count changes',
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
<label>
|
||||
@lang('admin/contents.lockUrl')<br />
|
||||
|
||||
<input type="checkbox" value="1" id="lockUrl" @if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked @endif name="lockUrl" />
|
||||
<input type="checkbox" value="1" id="lockUrl"
|
||||
@if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked
|
||||
@endif name="lockUrl" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -68,6 +70,25 @@
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if($module->support_categories && count($categories))
|
||||
<div class="column large-12">
|
||||
<label>
|
||||
@lang('admin/contents.category')
|
||||
|
||||
<select name="category">
|
||||
<option value=""> ---</option>
|
||||
@foreach($categories as $category)
|
||||
<option value="{{$category->id}}"
|
||||
@if($category->id == old('category', $page->category_id)) selected @endif>
|
||||
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user