changes
This commit is contained in:
@@ -20,6 +20,6 @@ class SubSection extends Model
|
||||
|
||||
public function pages() : HasMany
|
||||
{
|
||||
return $this->hasMany(Page::class);
|
||||
return $this->hasMany(Page::class)->orderBy('sort', 'asc');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ class PageNavigateResource extends JsonResource
|
||||
'title' => $this->title,
|
||||
'slug' => $this->slug,
|
||||
'path' => $this->path,
|
||||
'is_url' => $this->is_url,
|
||||
'icon' => $this->icon
|
||||
'is_url' => $this->is_url
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ class PageResource extends JsonResource
|
||||
'path' => $this->path,
|
||||
'is_url' => $this->is_url,
|
||||
'settings' => $this->settings,
|
||||
'icon' => $this->icon,
|
||||
'section' => $this->section ? $this->section->title : null,
|
||||
'created_at' => $this->created_at->diffforhumans()
|
||||
];
|
||||
|
||||
@@ -19,6 +19,9 @@ class CreatePageAction
|
||||
*/
|
||||
public function run(array $data): Page
|
||||
{
|
||||
// Ensure icon is never saved even if sent from old forms
|
||||
unset($data['icon']);
|
||||
|
||||
// Генерируем search_data из контента
|
||||
if (!empty($data['content'])) {
|
||||
$data['search_data'] = $this->generateSearchDataTask->run($data['content']);
|
||||
|
||||
@@ -20,6 +20,9 @@ class UpdatePageAction
|
||||
*/
|
||||
public function run(Page $page, array $data): Page
|
||||
{
|
||||
// Ensure icon is never saved even if sent from old forms
|
||||
unset($data['icon']);
|
||||
|
||||
// Если контент изменился, перегенерируем search_data
|
||||
if (isset($data['content']) && json_encode($data['content']) !== json_encode($page->content)) {
|
||||
$data['search_data'] = $this->generateSearchDataTask->run($data['content']);
|
||||
|
||||
@@ -37,9 +37,9 @@ class DeploySiteAction
|
||||
unlink($this->logFile);
|
||||
}
|
||||
|
||||
// Запускаем deploy.sh в фоне через sudo (полный путь + NOPASSWD для www-data)
|
||||
// Запускаем deploy.sh в фоне (docker socket проброшен в контейнер)
|
||||
$command = sprintf(
|
||||
'/usr/bin/sudo bash %s > %s 2>&1 &',
|
||||
'bash %s > %s 2>&1 &',
|
||||
escapeshellarg($this->deployScript),
|
||||
escapeshellarg($this->logFile)
|
||||
);
|
||||
|
||||
@@ -49,7 +49,6 @@ class CreatePostFromAiDataTask
|
||||
[
|
||||
'type' => 'paragraph',
|
||||
'data' => [
|
||||
'seo_active' => true,
|
||||
'content' => $newsData['body'] ?? '',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -28,7 +28,6 @@ class VkPostGenerationTest extends TestCase
|
||||
[
|
||||
'type' => 'paragraph',
|
||||
'data' => [
|
||||
'seo_active' => true,
|
||||
'content' => '<p>Это основной текст новости. Он содержит важную информацию о событии.</p>',
|
||||
],
|
||||
],
|
||||
@@ -115,7 +114,6 @@ class VkPostGenerationTest extends TestCase
|
||||
[
|
||||
'type' => 'paragraph',
|
||||
'data' => [
|
||||
'seo_active' => true,
|
||||
'content' => '<p>Текст новости без файлов.</p>',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Containers\AppStructure\Models\Page;
|
||||
use App\Containers\AppStructure\Models\SubSection;
|
||||
use App\Containers\Dashboard\Actions\Pages\AttachPageToSubSectionAction;
|
||||
use App\Containers\Dashboard\Actions\Pages\DetachPageFromSubSectionAction;
|
||||
use App\Containers\Dashboard\Actions\Pages\ReorderPagesAction;
|
||||
use App\Containers\Dashboard\Actions\SubSections\AttachSubSectionToMainSectionAction;
|
||||
use App\Containers\Dashboard\Actions\SubSections\CreateSubSectionAction;
|
||||
use App\Containers\Dashboard\Actions\SubSections\DeleteSubSectionAction;
|
||||
@@ -31,6 +32,7 @@ class SubSectionController extends Controller
|
||||
private readonly DetachSubSectionFromMainSectionAction $detachSubSectionAction,
|
||||
private readonly AttachPageToSubSectionAction $attachPageAction,
|
||||
private readonly DetachPageFromSubSectionAction $detachPageAction,
|
||||
private readonly ReorderPagesAction $reorderPagesAction,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -82,7 +84,9 @@ class SubSectionController extends Controller
|
||||
*/
|
||||
public function edit(SubSection $subSection): \Inertia\Response
|
||||
{
|
||||
$subSection->load(['mainSection', 'pages']);
|
||||
$subSection->load(['mainSection', 'pages' => function ($query) {
|
||||
$query->orderBy('sort', 'asc');
|
||||
}]);
|
||||
|
||||
$mainSections = MainSection::pluck('title', 'id');
|
||||
$availablePages = Page::whereNull('sub_section_id')
|
||||
@@ -200,4 +204,23 @@ class SubSectionController extends Controller
|
||||
return back()->with('error', 'Ошибка при откреплении страницы: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Изменяет порядок страниц в подразделе
|
||||
*/
|
||||
public function reorderPages(Request $request, SubSection $subSection): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'page_ids' => ['required', 'array'],
|
||||
'page_ids.*' => ['integer', 'exists:pages,id'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->reorderPagesAction->run($subSection->id, $request->page_ids);
|
||||
|
||||
return back()->with('success', 'Порядок страниц обновлен!');
|
||||
} catch (\Exception $e) {
|
||||
return back()->with('error', 'Ошибка при изменении порядка страниц: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ class StorePageRequest extends FormRequest
|
||||
'sub_section_id' => ['nullable', 'exists:sub_sections,id'],
|
||||
'code' => ['required', Rule::in(['200', '404', '500'])],
|
||||
'searchable' => ['boolean'],
|
||||
'icon' => ['nullable', 'string'],
|
||||
'content' => ['nullable', 'array'],
|
||||
'settings' => ['nullable', 'array'],
|
||||
'settings.hide_page_sub_section_links' => ['nullable', 'boolean'],
|
||||
|
||||
@@ -20,7 +20,6 @@ class UpdatePageRequest extends FormRequest
|
||||
'sub_section_id' => ['nullable', 'exists:sub_sections,id'],
|
||||
'code' => ['required', Rule::in(['200', '404', '500'])],
|
||||
'searchable' => ['boolean'],
|
||||
'icon' => ['nullable', 'string'],
|
||||
'content' => ['nullable', 'array'],
|
||||
'settings' => ['nullable', 'array'],
|
||||
'settings.hide_page_sub_section_links' => ['nullable', 'boolean'],
|
||||
|
||||
@@ -356,6 +356,7 @@ Route::middleware(['access-check', 'dashboard.auth'])->group(function () {
|
||||
// Управление страницами (Relation Manager)
|
||||
Route::post('/{subSection}/pages/attach', [SubSectionController::class, 'attachPage'])->name('pages.attach');
|
||||
Route::delete('/{subSection}/pages/{page}/detach', [SubSectionController::class, 'detachPage'])->name('pages.detach');
|
||||
Route::post('/{subSection}/pages/reorder', [SubSectionController::class, 'reorderPages'])->name('pages.reorder');
|
||||
});
|
||||
|
||||
// CRUD страниц
|
||||
|
||||
Reference in New Issue
Block a user