Skip to content

Commit

Permalink
fix: UpdateOnPreviewPopover
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Dec 17, 2024
1 parent 06ee927 commit e72da27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/UI/src/Sets/UpdateOnPreviewPopover.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use MoonShine\UI\Components\Link;
use MoonShine\UI\Components\Popover;
use MoonShine\UI\Fields\Hidden;
use MoonShine\UI\Fields\Text;

final readonly class UpdateOnPreviewPopover
{
Expand Down Expand Up @@ -46,13 +45,17 @@ public function __invoke(): Popover
Flex::make([
Hidden::make('_method')->setValue('PUT'),
Hidden::make('field')->setValue($this->field->getColumn()),
Text::make('Title', 'value')
$this->field

Check failure on line 48 in src/UI/src/Sets/UpdateOnPreviewPopover.php

View workflow job for this annotation

GitHub Actions / moonshine-analyse

Call to an undefined method MoonShine\Contracts\UI\FieldContract::disableUpdateOnPreview().
->style('margin: 0!important')
->setValue($this->field->toFormattedValue())
->withoutWrapper(),
->setColumn('value')
->customAttributes([
'name' => 'value'
])
->withoutWrapper()
->disableUpdateOnPreview(),
]),
])
->submit('OK', ['class' => 'btn-primary'])
->submit(__('moonshine::ui.save'), ['class' => 'btn-primary'])
);
}
}
12 changes: 12 additions & 0 deletions src/UI/src/Traits/Fields/UpdateOnPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public function readonly(Closure|bool|null $condition = null): static
return parent::readonly($condition);
}

public function disableUpdateOnPreview(): static
{
$this->updateOnPreview = false;
$this->onChangeUrl = null;
$this->updateOnPreviewPopover = false;
$this->updateOnPreviewUrl = null;

$this->removeAttribute('@change');

return $this;
}

public function withUpdateRow(string $component): static
{

Expand Down

0 comments on commit e72da27

Please sign in to comment.