diff --git a/app/Actions/Web/Website/PublishWebsiteMarginal.php b/app/Actions/Web/Website/PublishWebsiteMarginal.php index 92b6f011d..def4b53cf 100644 --- a/app/Actions/Web/Website/PublishWebsiteMarginal.php +++ b/app/Actions/Web/Website/PublishWebsiteMarginal.php @@ -25,6 +25,13 @@ class PublishWebsiteMarginal public function handle(Website $website, string $marginal, array $modelData): Website { + $compiledLayout = ''; + if ($marginal == 'header') { + $compiledLayout = Arr::get($website->unpublishedHeaderSnapshot->layout, 'html'); + } elseif ($marginal == 'footer') { + $compiledLayout = Arr::get($website->unpublishedFooterSnapshot->layout, 'html'); + } + foreach ($website->snapshots()->where('scope', $marginal)->where('state', SnapshotStateEnum::LIVE)->get() as $liveSnapshot) { UpdateSnapshot::run($liveSnapshot, [ 'state' => SnapshotStateEnum::HISTORIC, @@ -39,8 +46,9 @@ public function handle(Website $website, string $marginal, array $modelData): We [ 'state' => SnapshotStateEnum::LIVE, 'published_at' => now(), - 'layout' => Arr::get($modelData, 'layout'), - 'scope' => $marginal + 'layout' => $compiledLayout, + 'scope' => $marginal, + 'comment' => Arr::get($modelData, 'comment') ], ); @@ -69,7 +77,6 @@ public function authorize(ActionRequest $request): bool public function rules(): array { return [ - 'layout' => ['required', 'array:delay,common,components'], 'comment' => ['sometimes', 'required', 'string', 'max:1024'] ]; } diff --git a/app/Actions/Web/Website/UI/ShowWebsiteWorkshop.php b/app/Actions/Web/Website/UI/ShowWebsiteWorkshop.php index b1f1235ad..ee6ff12fd 100644 --- a/app/Actions/Web/Website/UI/ShowWebsiteWorkshop.php +++ b/app/Actions/Web/Website/UI/ShowWebsiteWorkshop.php @@ -83,11 +83,11 @@ public function htmlResponse(Website $website, ActionRequest $request): Response 'websiteState'=>$website->state, 'publishRoutes' => [ 'workshop_header'=> [ - 'name' => 'org.models.website.header.content.update', + 'name' => 'org.models.website.header.content.publish', 'parameters' => $website->id ], 'workshop_footer'=> [ - 'name' => 'org.models.website.footer.content.update', + 'name' => 'org.models.website.footer.content.publish', 'parameters' => $website->id ], 'workshop_layout'=> [ diff --git a/app/Http/Middleware/HandlePublicInertiaRequests.php b/app/Http/Middleware/HandlePublicInertiaRequests.php index 9b1665135..dc2617894 100644 --- a/app/Http/Middleware/HandlePublicInertiaRequests.php +++ b/app/Http/Middleware/HandlePublicInertiaRequests.php @@ -24,6 +24,7 @@ public function share(Request $request): array ]); }; + $firstLoadOnlyProps['structure']=$request->get('website')->compiled_structure; return array_merge( $firstLoadOnlyProps, diff --git a/routes/org/web/models.php b/routes/org/web/models.php index 84518782e..b74f02299 100644 --- a/routes/org/web/models.php +++ b/routes/org/web/models.php @@ -43,6 +43,7 @@ use App\Actions\Web\Webpage\StoreArticle; use App\Actions\Web\Webpage\StoreWebpage; use App\Actions\Web\Webpage\UpdateWebpageContent; +use App\Actions\Web\Website\PublishWebsiteMarginal; use App\Actions\Web\Website\ShowWebsiteFooterContent; use App\Actions\Web\Website\ShowWebsiteHeaderContent; use App\Actions\Web\Website\StoreWebsite; @@ -105,9 +106,13 @@ Route::patch('{website:id}/layout', UpdateWebsiteLayout::class)->name('layout.update'); Route::post('{website:id}/header/content', UpdateWebsiteHeaderContent::class)->name('header.content.update'); + Route::post('{website:id}/header/publish', [PublishWebsiteMarginal::class,'header'])->name('header.content.publish'); + Route::get('{website:id}/header/content', ShowWebsiteHeaderContent::class)->name('header.content.show'); Route::post('{website:id}/footer/content', UpdateWebsiteFooterContent::class)->name('footer.content.update'); + Route::post('{website:id}/footer/publish', [PublishWebsiteMarginal::class,'footer'])->name('footer.content.publish'); + Route::get('{website:id}/footer/content', ShowWebsiteFooterContent::class)->name('footer.content.show');