acroninja
acroninja
FFilament
Created by Bryan on 1/9/2024 in #❓┊help
Page refresh when header action is clicked
8 replies
FFilament
Created by apreski on 9/18/2023 in #❓┊help
Any example with "onbeforeunload" for dirty form check ?
See this trait:-
Concerns/HasUnsavedDataChangesAlert
Concerns/HasUnsavedDataChangesAlert
You have to add
->unsavedChangesAlerts()
->unsavedChangesAlerts()
to your config.
2 replies
FFilament
Created by Phil on 6/20/2024 in #❓┊help
Get form dirty state in requiresConfirmation method of an action
Make a trait that extends the updatedInteractsWithForms method,
namespace App\Traits;

use Filament\Actions\Action;
use Illuminate\Support\HtmlString;

trait HasDirtyState
{
protected bool $formDirty = false;

public function updatedInteractsWithForms(string $statePath): void
{
parent::updatedInteractsWithForms($statePath);

if (data_get($this->oldFormState, $statePath) !== data_get($this, $statePath)) {
$this->formDirty = true;
$this->resetCachedHeaderActions()
->dispatch('$refresh');
}
}

protected function getCancelFormAction(): Action
{
return parent::getCancelFormAction()
->visible(fn ($livewire) => $livewire->formDirty);
}

protected function getSaveFormAction(): Action
{
return Action::make('save')
->visible(fn ($livewire) => $livewire->formDirty)
->action(function () {
$this->formDirty = false;
$this->save();
$this->resetCachedHeaderActions()
->dispatch('$refresh');
})
->visible(fn ($livewire) => $livewire->formDirty);
}


public function resetCachedHeaderActions(): static
{
// Clear the page header cached actions
$this->cachedHeaderActions = [];
// Immediately rebuild them so they're available
$this->cacheHeaderActions();

return $this;
}
namespace App\Traits;

use Filament\Actions\Action;
use Illuminate\Support\HtmlString;

trait HasDirtyState
{
protected bool $formDirty = false;

public function updatedInteractsWithForms(string $statePath): void
{
parent::updatedInteractsWithForms($statePath);

if (data_get($this->oldFormState, $statePath) !== data_get($this, $statePath)) {
$this->formDirty = true;
$this->resetCachedHeaderActions()
->dispatch('$refresh');
}
}

protected function getCancelFormAction(): Action
{
return parent::getCancelFormAction()
->visible(fn ($livewire) => $livewire->formDirty);
}

protected function getSaveFormAction(): Action
{
return Action::make('save')
->visible(fn ($livewire) => $livewire->formDirty)
->action(function () {
$this->formDirty = false;
$this->save();
$this->resetCachedHeaderActions()
->dispatch('$refresh');
})
->visible(fn ($livewire) => $livewire->formDirty);
}


public function resetCachedHeaderActions(): static
{
// Clear the page header cached actions
$this->cachedHeaderActions = [];
// Immediately rebuild them so they're available
$this->cacheHeaderActions();

return $this;
}
Add it to your edit page
class EditOrder extends EditRecord
{
use HasDirtyState;
class EditOrder extends EditRecord
{
use HasDirtyState;
In my case I wanted to only show the actions when the form is dirty, so use this closure
->visible(fn ($livewire) => $livewire->formDirty)
->visible(fn ($livewire) => $livewire->formDirty)
Note you'll need to add ->live() to the form components
3 replies
FFilament
Created by Dan Harrin on 2/27/2025 in #❓┊help
Help Us Improve Filament’s Docs & Education in v4
I think the documentation indexing needs some tweaking. Search for databaseNotificationsPolling and nothing found. Goto this page https://filamentphp.com/docs/3.x/panels/notifications#setting-up-websockets-in-a-panel and you'll see databaseNotificationsPolling('30s') Pretty sure this is a common issue with not finding code that is there. That would be a useful fix.
81 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
If anyone interested there are bunch of articles comparing Cypress and Playwright. Gonna try playwright as it also has mobile emulation and ability to work on multiple domains which didn't work on Cypress https://www.browserstack.com/guide/playwright-vs-cypress https://www.lambdatest.com/blog/cypress-vs-playwright/ https://medium.com/@mohsenny/deciding-between-cypress-and-playwright-a-comprehensive-guide-4d883d1be147
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
So I would also like to be able to say to the client, the sales order process has been tested in Chome, Safari, FF, Edge or whatever MS is calling their browser now 🧐
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
Ahha Great, I was leaning that way. range of different browsers tested. we had a really angry email from a firefox user who couldn't login and was very upset that we clearly didn't support alternative browsers as he could login with chrome. Wasnt any bug, just user error from what we could tell!!
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
SOK, good to question everything i suppose but we really do need a browser test. Even if it's just for my amusement and joy to watch it run - which it isn't.
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
But i've been coding since 1983 and there's not much I haven't seen in code
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
Mate, experience is useful, I'm 51 already so well on the way to being a fossil
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
Thanks, you're giving me flashbacks to a traumatic period when this old dinosaur developer that used to work for me argued about everything. I used to hate going into the office at that time, it was a really shit period. Thankfully he doesn't work for me anymore and life is good.
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
It's not just the email, thats one part of a long process to create and process an order
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
dude, stop arguing with me, i know what i need and i don't need to be wasting time trying to convince you that my requirement is valid
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
i need to know that the select box is prepopulated with the organisation name
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
url param example:- on the organisation page there is a button to create quote. Organisation id or contact id is passed as a url param to the quote create page
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
yes
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
and thats only part of the process
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
the unit test won't confirm that the user received an email with a clickable link. the link then opens a signed url, user does some input and saves form. Another email is sent. Another user then receives an email with a link to the admin panel to edit the order. They then need to login, view that order, and enter more stuff, Another email is sent. Some time passes and the training session should have elapsed. Now we expect to see another email sent to the coach to confirm if the session was completed or cancelled
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
If you don't know the answer it's ok, please believe me we need browser tests
43 replies
FFilament
Created by acroninja on 2/28/2025 in #❓┊help
Dusk, Cypress or Playwright for filament browser tests?
The click in an email is totally relevant. Thats the process that needs to be followed.
43 replies