Skip to content

Commit

Permalink
Merge pull request #13 from DissNik/2.x
Browse files Browse the repository at this point in the history
Fixed for release MoonShine
  • Loading branch information
lee-to authored Nov 3, 2024
2 parents b9c928a + a09cdf4 commit 5539cc0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions public/js/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ document.addEventListener('alpine:init', () => {
name: name,
counts: layoutsCount
}, {}, {
beforeCallback: function(data) {
afterResponse: function(data) {
const tempContainer = document.createElement('div');
tempContainer.innerHTML = data.html ?? '';

while (tempContainer.firstChild) {
t.blocksContainer.appendChild(tempContainer.firstChild);
}

t._reindex()
}
})
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{!! $heading !!}
</x-slot>

<x-slot name="button"></x-slot>
<x-slot name="button">{!! $button !!}</x-slot>

{!! $fields !!}
</x-moonshine::collapse>
2 changes: 0 additions & 2 deletions resources/views/layouts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@
<div>
{!! $dropdown !!}
</div>

<br />
</div>
3 changes: 1 addition & 2 deletions src/Fields/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ public function headingFields(): Fields
FlexibleRender::make($this->title()),

...$this->getHeadingAdditionalFields(),

$this->getRemoveButton(),
]))
->customAttributes(['class' => 'w-full'])
->itemsAlign('center')
Expand Down Expand Up @@ -188,6 +186,7 @@ public function render(): View
return view('moonshine-layouts-field::layout', [
'key' => $this->key(),
'heading' => FieldsGroup::make($this->headingFields()),
'button' => $this->getRemoveButton(),
'fields' => FieldsGroup::make($this->fields()),
]);
}
Expand Down
10 changes: 9 additions & 1 deletion src/Fields/Layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use MoonShine\AssetManager\Js;
use MoonShine\Contracts\Core\HasComponentsContract;
use MoonShine\Contracts\Core\PageContract;
use MoonShine\Contracts\Core\ResourceContract;
use MoonShine\Contracts\UI\ActionButtonContract;
use MoonShine\Contracts\UI\Collection\ComponentsContract;
use MoonShine\Contracts\UI\HasFieldsContract;
use MoonShine\Layouts\Casts\LayoutItem;
use MoonShine\Layouts\Casts\LayoutsCast;
Expand Down Expand Up @@ -169,9 +171,15 @@ public function getFilledLayouts(): LayoutCollection
return LayoutCollection::make($filled);
}

private function fillClonedRecursively(Collection $collection, mixed $data): Collection
private function fillClonedRecursively(ComponentsContract|Collection $collection, mixed $data): Collection
{
return $collection->map(function (mixed $item) use ($data) {
if ($item instanceof HasComponentsContract) {
$item = (clone $item)->setComponents(
$this->fillClonedRecursively($item->getComponents(), $data)->toArray()
);
}

if ($item instanceof HasFieldsContract) {
$item = (clone $item)->fields(
$this->fillClonedRecursively($item->getFields(), $data)->toArray()
Expand Down

0 comments on commit 5539cc0

Please sign in to comment.