taz
taz
FFilament
Created by taz on 12/23/2024 in #❓┊help
ToggleButtons default not working
This is definitely an issue. When using ToggleButtons within a filtersForm, setting defaults does not work.
8 replies
FFilament
Created by taz on 12/23/2024 in #❓┊help
ToggleButtons default not working
Okay works perfectly in a tradictional Form. Im in a filtersForm.
php public function filtersForm(Form $form): Form
php public function filtersForm(Form $form): Form
Might be an issue. I will investigate more.
8 replies
FFilament
Created by taz on 12/23/2024 in #❓┊help
ToggleButtons default not working
afterStateHydrated is called on the component during its first lifecycle and $state is null so it sets $component->state([]) at the end of the function to an empty array overrding defaut state defined in the components builder
php ToggleButtons::make('technologies')
->default('tailwind')
php ToggleButtons::make('technologies')
->default('tailwind')
8 replies
FFilament
Created by taz on 12/23/2024 in #❓┊help
ToggleButtons default not working
It works but I noticed that this piece of code messed up with setting the default state:
class ToggleButtons extends Field implements Contracts\CanDisableOptions
{
use Concerns\CanDisableOptions;
use Concerns\CanDisableOptionsWhenSelectedInSiblingRepeaterItems;
use Concerns\CanFixIndistinctState;
use Concerns\HasColors;
use Concerns\HasExtraInputAttributes;
use Concerns\HasGridDirection;
use Concerns\HasIcons;
use Concerns\HasOptions;

public const GROUPED_VIEW = 'filament-forms::components.toggle-buttons.grouped';

protected bool | Closure $isMultiple = false;

/**
* @var view-string
*/
protected string $view = 'filament-forms::components.toggle-buttons.index';

protected bool | Closure $isInline = false;

protected function setUp(): void
{
parent::setUp();

$this->default(fn (ToggleButtons $component): mixed => $component->isMultiple() ? [] : null);

$this->afterStateHydrated(static function (ToggleButtons $component, $state): void {
if (! $component->isMultiple()) {
return;
}

if (is_array($state)) {
return;
}

$component->state([]);
});
}
class ToggleButtons extends Field implements Contracts\CanDisableOptions
{
use Concerns\CanDisableOptions;
use Concerns\CanDisableOptionsWhenSelectedInSiblingRepeaterItems;
use Concerns\CanFixIndistinctState;
use Concerns\HasColors;
use Concerns\HasExtraInputAttributes;
use Concerns\HasGridDirection;
use Concerns\HasIcons;
use Concerns\HasOptions;

public const GROUPED_VIEW = 'filament-forms::components.toggle-buttons.grouped';

protected bool | Closure $isMultiple = false;

/**
* @var view-string
*/
protected string $view = 'filament-forms::components.toggle-buttons.index';

protected bool | Closure $isInline = false;

protected function setUp(): void
{
parent::setUp();

$this->default(fn (ToggleButtons $component): mixed => $component->isMultiple() ? [] : null);

$this->afterStateHydrated(static function (ToggleButtons $component, $state): void {
if (! $component->isMultiple()) {
return;
}

if (is_array($state)) {
return;
}

$component->state([]);
});
}
8 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
I will try to investigate more to find the precise reason but yes it's very odd ! For the moment I will just try to never launch the two Laravel app at the same time as a workaround. (docker start order) .
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
Thanks you for your time you pointed me toward the good direction !
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
i will try to add --isolated to some of the commands if they are isolatable. I restarted the two laravel app (one by one) and not at same time and it works fine now. The issue araised when they are start at same time.
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
When a command is marked as Isolatable, Laravel will automatically add an --isolated option to the command. When the command is invoked with that option, Laravel will ensure that no other instances of that command are already running. Laravel accomplishes this by attempting to acquire an atomic lock using your application's default cache driver. If other instances of the command are running, the command will not execute; however, the command will still exit with a successful exit status code:
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
From Laravel doc :
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
Are there potential issues if the two laravel app run this simultaneously ?
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
OK I might investigate this. THanks you for your time. I just noticed right now that all my containers restarted in the same time a few hours ago and the bug happended right after. Same last time. Your guess seems right. On update containers starts one after each other (Docker Swarm rolling update). But on VPS reboot they all start together. This is my startup script
#!/usr/bin/env bash
set -e
initialStuff() {
php artisan migrate --force; \
php artisan storage:link; \
php artisan optimize:clear; \
php artisan event:cache; \
php artisan config:cache; \
php artisan route:cache; \
php artisan filament:cache-components; \
php artisan icons:cache; \
php artisan app:generate-sitemap https://chatters.tech;
}
echo "Octane Server: $octane_server"
initialStuff
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.frankenphp.conf
#!/usr/bin/env bash
set -e
initialStuff() {
php artisan migrate --force; \
php artisan storage:link; \
php artisan optimize:clear; \
php artisan event:cache; \
php artisan config:cache; \
php artisan route:cache; \
php artisan filament:cache-components; \
php artisan icons:cache; \
php artisan app:generate-sitemap https://chatters.tech;
}
echo "Octane Server: $octane_server"
initialStuff
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.frankenphp.conf
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
Also another hint when I restart the servers its fine for a few days, then the error appears
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
These bug only appear in prod where I have two Laravel container for zero downtime updates. Livewiere is stateless right ?
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
after first click and the error come from alpineJS Uncaught TypeError: Cannot read properties of undefined (reading 'dispatchEvent')
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
I have also this error here on the frontend where a button click dont do nothing
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
It's a simple resource
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
Section::make(__('Credentials'))
->description(__('Set a username and a password. The chatter will need these credentials to access its dashboard and start chatting.'))
->columns([
'default' => 1,
'lg' => 2,
])
->schema([
TextInput::make("username")
->label(__('Username'))
->required()
->minLength(4)
->maxLength(30)
->unique(table: Chatter::class, ignoreRecord: true),
TextInput::make('clear_password')
->label(__('Password'))
->afterStateHydrated(function ($state, callable $set, Chatter $chatter) {
if (empty($state)) {
$set('clear_password', $chatter->clear_password);
}
})
->password()
->revealable()
->required()
->rules([Rules\Password::default(), fn(Chatter $chatter): Closure => function( string $attribute, $value, Closure $fail) use ($chatter) {
$user = auth('web')->user();
if (!$chatter->exists && $user->numberOfChattersLimitHit()) {
$fail(trans('validation.custom.chatters.max_chatters'));
return;
}
},
])
->minLength(8)
->maxLength(30),
])
];
Section::make(__('Credentials'))
->description(__('Set a username and a password. The chatter will need these credentials to access its dashboard and start chatting.'))
->columns([
'default' => 1,
'lg' => 2,
])
->schema([
TextInput::make("username")
->label(__('Username'))
->required()
->minLength(4)
->maxLength(30)
->unique(table: Chatter::class, ignoreRecord: true),
TextInput::make('clear_password')
->label(__('Password'))
->afterStateHydrated(function ($state, callable $set, Chatter $chatter) {
if (empty($state)) {
$set('clear_password', $chatter->clear_password);
}
})
->password()
->revealable()
->required()
->rules([Rules\Password::default(), fn(Chatter $chatter): Closure => function( string $attribute, $value, Closure $fail) use ($chatter) {
$user = auth('web')->user();
if (!$chatter->exists && $user->numberOfChattersLimitHit()) {
$fail(trans('validation.custom.chatters.max_chatters'));
return;
}
},
])
->minLength(8)
->maxLength(30),
])
];
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
public static function getForm(): array
{
return [
Section::make(__('Personal information'))
->columns([
'default' => 1,
'lg' => 2,
])
->schema([
TextInput::make('name')
->label(__('Name'))
->required()
->unique(table: Chatter::class, ignoreRecord: true, modifyRuleUsing: function (Unique $rule) {
return $rule->where('user_id', Auth::user()->id);
})
->minLength(4)
->maxLength(30)
->autofocus(),
TextInput::make('email')
->label('Email')
->required()
->prefixIcon('heroicon-s-envelope')
->minLength(4)
->helperText(__('The address will be used to send an onboarding email to the chatter.'))
->maxLength(320)
->email(),
]),
public static function getForm(): array
{
return [
Section::make(__('Personal information'))
->columns([
'default' => 1,
'lg' => 2,
])
->schema([
TextInput::make('name')
->label(__('Name'))
->required()
->unique(table: Chatter::class, ignoreRecord: true, modifyRuleUsing: function (Unique $rule) {
return $rule->where('user_id', Auth::user()->id);
})
->minLength(4)
->maxLength(30)
->autofocus(),
TextInput::make('email')
->label('Email')
->required()
->prefixIcon('heroicon-s-envelope')
->minLength(4)
->helperText(__('The address will be used to send an onboarding email to the chatter.'))
->maxLength(320)
->email(),
]),
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
"To" node in Morph dom is assigned to this text '\n\n' ? Is this an escaping issue ?
32 replies
FFilament
Created by taz on 10/15/2024 in #❓┊help
Button Edit Action disappear after first click
<?php

namespace App\Filament\Resources\ChatterResource\Pages;

use App\Filament\Resources\ChatterResource;
use App\Models\Chatter;
use Filament\Actions;
use Filament\Actions\StaticAction;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Contracts\Support\Htmlable;


class ViewChatter extends ViewRecord
{
protected static string $resource = ChatterResource::class;

public function getTitle(): string | Htmlable
{
/** @var Post */
$record = $this->getRecord();

return $record->name;
}

protected function getHeaderActions(): array
{
return [
Actions\EditAction::make()
->icon('heroicon-o-pencil-square')
->slideOver(),
Actions\DeleteAction::make()
->icon('heroicon-o-trash')
->color('danger')

];
}
}
<?php

namespace App\Filament\Resources\ChatterResource\Pages;

use App\Filament\Resources\ChatterResource;
use App\Models\Chatter;
use Filament\Actions;
use Filament\Actions\StaticAction;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Contracts\Support\Htmlable;


class ViewChatter extends ViewRecord
{
protected static string $resource = ChatterResource::class;

public function getTitle(): string | Htmlable
{
/** @var Post */
$record = $this->getRecord();

return $record->name;
}

protected function getHeaderActions(): array
{
return [
Actions\EditAction::make()
->icon('heroicon-o-pencil-square')
->slideOver(),
Actions\DeleteAction::make()
->icon('heroicon-o-trash')
->color('danger')

];
}
}
32 replies