mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
fix: Partially rendering
This commit is contained in:
@@ -97,6 +97,8 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
protected Width | string | Closure | null $blockPickerWidth = null;
|
||||
|
||||
protected bool | Closure $shouldPartiallyRenderAfterActionsCalled = true;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -270,7 +272,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->livewireClickHandlerEnabled(false)
|
||||
->button()
|
||||
@@ -332,7 +334,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -373,7 +375,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -413,7 +415,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -453,7 +455,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -503,7 +505,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->livewireClickHandlerEnabled(false)
|
||||
->iconButton()
|
||||
@@ -680,7 +682,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->icon(Heroicon::Cog6Tooth)
|
||||
@@ -1156,4 +1158,16 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
|
||||
|
||||
$rules["{$this->getStatePath()}.*.type"] = ['required'];
|
||||
}
|
||||
|
||||
public function partiallyRenderAfterActionsCalled(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->shouldPartiallyRenderAfterActionsCalled = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function shouldPartiallyRenderAfterActionsCalled(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->shouldPartiallyRenderAfterActionsCalled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
protected bool $shouldMergeHydratedDefaultStateWithItemsStateAfterStateHydrated = true;
|
||||
|
||||
protected bool | Closure $shouldPartiallyRenderAfterActionsCalled = true;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -202,7 +204,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->button()
|
||||
->size(Size::Small)
|
||||
@@ -279,7 +281,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->button()
|
||||
->size(Size::Small)
|
||||
@@ -341,7 +343,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -382,7 +384,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -422,7 +424,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -462,7 +464,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->iconButton()
|
||||
->size(Size::Small)
|
||||
@@ -505,7 +507,7 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
$component->callAfterStateUpdated();
|
||||
|
||||
$component->partiallyRender();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
})
|
||||
->livewireClickHandlerEnabled(false)
|
||||
->iconButton()
|
||||
@@ -1375,4 +1377,16 @@ class Repeater extends Field implements CanConcealComponents, HasExtraItemAction
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function partiallyRenderAfterActionsCalled(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->shouldPartiallyRenderAfterActionsCalled = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function shouldPartiallyRenderAfterActionsCalled(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->shouldPartiallyRenderAfterActionsCalled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ class QueryBuilder extends BaseFilter
|
||||
->label($filter->getLabel())
|
||||
->constraints($filter->getConstraints())
|
||||
->blockPickerColumns($filter->getConstraintPickerColumns())
|
||||
->blockPickerWidth($filter->getConstraintPickerWidth())
|
||||
->live(onBlur: true),
|
||||
->blockPickerWidth($filter->getConstraintPickerWidth()),
|
||||
]);
|
||||
|
||||
$this->query(function (Builder $query, array $data): void {
|
||||
|
||||
@@ -107,7 +107,8 @@ class RuleBuilder extends Builder
|
||||
->cloneable()
|
||||
->reorderable(false)
|
||||
->hiddenLabel()
|
||||
->generateUuidUsing(fn (): string => Str::random(4)),
|
||||
->generateUuidUsing(fn (): string => Str::random(4))
|
||||
->partiallyRenderAfterActionsCalled($component->shouldPartiallyRenderAfterActionsCalled()),
|
||||
]),
|
||||
];
|
||||
})
|
||||
@@ -125,6 +126,8 @@ class RuleBuilder extends Builder
|
||||
->expandAllAction(fn (Action $action) => $action->hidden())
|
||||
->collapseAllAction(fn (Action $action) => $action->hidden())
|
||||
->truncateBlockLabel(false)
|
||||
->generateUuidUsing(fn (): string => Str::random(4));
|
||||
->generateUuidUsing(fn (): string => Str::random(4))
|
||||
->live(onBlur: true)
|
||||
->partiallyRenderAfterActionsCalled(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user