Skip to content

Commit 5539cc0

Browse files
authored
Merge pull request #13 from DissNik/2.x
Fixed for release MoonShine
2 parents b9c928a + a09cdf4 commit 5539cc0

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

public/js/layouts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ document.addEventListener('alpine:init', () => {
3737
name: name,
3838
counts: layoutsCount
3939
}, {}, {
40-
beforeCallback: function(data) {
40+
afterResponse: function(data) {
4141
const tempContainer = document.createElement('div');
4242
tempContainer.innerHTML = data.html ?? '';
4343

4444
while (tempContainer.firstChild) {
4545
t.blocksContainer.appendChild(tempContainer.firstChild);
4646
}
47-
47+
4848
t._reindex()
4949
}
5050
})

resources/views/layout.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{!! $heading !!}
44
</x-slot>
55

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

88
{!! $fields !!}
99
</x-moonshine::collapse>

resources/views/layouts.blade.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
<div>
1515
{!! $dropdown !!}
1616
</div>
17-
18-
<br />
1917
</div>

src/Fields/Layout.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ public function headingFields(): Fields
129129
FlexibleRender::make($this->title()),
130130

131131
...$this->getHeadingAdditionalFields(),
132-
133-
$this->getRemoveButton(),
134132
]))
135133
->customAttributes(['class' => 'w-full'])
136134
->itemsAlign('center')
@@ -188,6 +186,7 @@ public function render(): View
188186
return view('moonshine-layouts-field::layout', [
189187
'key' => $this->key(),
190188
'heading' => FieldsGroup::make($this->headingFields()),
189+
'button' => $this->getRemoveButton(),
191190
'fields' => FieldsGroup::make($this->fields()),
192191
]);
193192
}

src/Fields/Layouts.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
use Illuminate\Contracts\View\View;
99
use Illuminate\Support\Collection;
1010
use MoonShine\AssetManager\Js;
11+
use MoonShine\Contracts\Core\HasComponentsContract;
1112
use MoonShine\Contracts\Core\PageContract;
1213
use MoonShine\Contracts\Core\ResourceContract;
1314
use MoonShine\Contracts\UI\ActionButtonContract;
15+
use MoonShine\Contracts\UI\Collection\ComponentsContract;
1416
use MoonShine\Contracts\UI\HasFieldsContract;
1517
use MoonShine\Layouts\Casts\LayoutItem;
1618
use MoonShine\Layouts\Casts\LayoutsCast;
@@ -169,9 +171,15 @@ public function getFilledLayouts(): LayoutCollection
169171
return LayoutCollection::make($filled);
170172
}
171173

172-
private function fillClonedRecursively(Collection $collection, mixed $data): Collection
174+
private function fillClonedRecursively(ComponentsContract|Collection $collection, mixed $data): Collection
173175
{
174176
return $collection->map(function (mixed $item) use ($data) {
177+
if ($item instanceof HasComponentsContract) {
178+
$item = (clone $item)->setComponents(
179+
$this->fillClonedRecursively($item->getComponents(), $data)->toArray()
180+
);
181+
}
182+
175183
if ($item instanceof HasFieldsContract) {
176184
$item = (clone $item)->fields(
177185
$this->fillClonedRecursively($item->getFields(), $data)->toArray()

0 commit comments

Comments
 (0)