pepperoni dogfart
pepperoni dogfart
FFilament
Created by pepperoni dogfart on 9/2/2024 in #❓┊help
Clickable row add to bulk select
Alright this is super hacky but I haven't found a better way yet (feel free to point and laugh 😆). Looking for some advise cause eventually I'd like to reference the selected rows to update a widget values. (I opened a separate help post about that one) My goal was to change the default behavior on a table row so that when clicked, it simply selects it to be used for a bulk action instead of opening view/edit, etc.
$table
->recordClasses('clickable-row')
->recordAction(null)
$table
->recordClasses('clickable-row')
->recordAction(null)
Here's where it runs a bit astray. I'm sure there's some method to do this with alpine/livewire, what have you - direct in the Resource, but I wasn't able to figure it out. I instead created a new JS asset, imported in a provider as follows:
FilamentAsset::register([
\Filament\Support\Assets\Js::make('custom-script', __DIR__.'/../../resources/js/custom.js'),
]);
FilamentAsset::register([
\Filament\Support\Assets\Js::make('custom-script', __DIR__.'/../../resources/js/custom.js'),
]);
custom.js
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.clickable-row').forEach(function (row) {
row.addEventListener('click', function (event) {
if (event.target.closest('button') || event.target.closest('a') || event.target.closest('.action-buttons')) {
return;
}

let checkbox = row.querySelector('input[type="checkbox"]');
if (checkbox) {
checkbox.checked = !checkbox.checked;
checkbox.dispatchEvent(new Event('change', { bubbles: true }));
}
});
});
});
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.clickable-row').forEach(function (row) {
row.addEventListener('click', function (event) {
if (event.target.closest('button') || event.target.closest('a') || event.target.closest('.action-buttons')) {
return;
}

let checkbox = row.querySelector('input[type="checkbox"]');
if (checkbox) {
checkbox.checked = !checkbox.checked;
checkbox.dispatchEvent(new Event('change', { bubbles: true }));
}
});
});
});
It does work, mostly. Sometimes I'm not able to click them anymore when using table search for example, suspecting the DOM is updated and not reattaching this. Either way, this doesn't feel ideal - any suggestions or insight on a better way to obtain this same behavior?
3 replies
FFilament
Created by pepperoni dogfart on 8/31/2024 in #❓┊help
Selected records to widget
I currently have a Stat widget dispalyed on a resource. Is there a way to pass in what records are selected via the checkmark on Bulk Actions to the widget? The goal is to dynamically update the widget data based on the rows that are selected. I've been playing around with this for a bit and haven't been able to figure it out. From my github searching, I found "livewire->getSelectedTableRecords()" might be useful here, but I'm not positive how to pass that to the Stat widget.
7 replies
FFilament
Created by pepperoni dogfart on 8/22/2024 in #❓┊help
Tabs Blade component, active state in foreach
I'm not super versed in alpine but I am struggling to figure out why the :active property wouldn't be working here. The tabs show up fine with correct labels and switch properly - but it appears all the tabs are all showing in the active state. I've tried a quite a few variations and haven't been able to get any of them to work properly.
<!-- Blade Page -->

<x-filament-panels::page>
@php
$entries = \App\Models\Model::all();
@endphp

<div x-data="{ tab: 'tab1' }">
<x-filament::tabs>
@foreach ($entries as $index => $entry)
@php
$tabId = 'tab' . ($index + 1);
@endphp
<x-filament::tabs.item @click="tab = '{{ $tabId }}'" :active="'tab === {{ $tabId }}'" >
{{ $tabId }} Report
</x-filament::tabs.item>
@endforeach
</x-filament::tabs>

{{-- Tab Data Here --}}

</div>
</x-filament-panels::page>
<!-- Blade Page -->

<x-filament-panels::page>
@php
$entries = \App\Models\Model::all();
@endphp

<div x-data="{ tab: 'tab1' }">
<x-filament::tabs>
@foreach ($entries as $index => $entry)
@php
$tabId = 'tab' . ($index + 1);
@endphp
<x-filament::tabs.item @click="tab = '{{ $tabId }}'" :active="'tab === {{ $tabId }}'" >
{{ $tabId }} Report
</x-filament::tabs.item>
@endforeach
</x-filament::tabs>

{{-- Tab Data Here --}}

</div>
</x-filament-panels::page>
4 replies
FFilament
Created by pepperoni dogfart on 7/10/2024 in #❓┊help
Registration - Password Requirement
Durign a new user signup, is there a place to modify the requirements for the password field? I'm using the Breezy plugin which allows setting such things on the profile update once logged in, but not for the initial signup.
13 replies
FFilament
Created by pepperoni dogfart on 6/20/2024 in #❓┊help
Defer loading on a widget
Following livewire's docs I don't seem to be able to get this working, has anyone had success deferring loading on a widget?
class MyWidget extends BaseWidget
{
public bool $readyToLoad = false;

public function loadData()
{
$this->readyToLoad = true;
}

protected function getStats(): array
{
if (! $this->readyToLoad) {
return [
Stat::make('Loading', 'Loading...')
];
}

sleep (5);

return [
Stat::make('Loaded Widget', 'Done!'),
];
}
}
class MyWidget extends BaseWidget
{
public bool $readyToLoad = false;

public function loadData()
{
$this->readyToLoad = true;
}

protected function getStats(): array
{
if (! $this->readyToLoad) {
return [
Stat::make('Loading', 'Loading...')
];
}

sleep (5);

return [
Stat::make('Loaded Widget', 'Done!'),
];
}
}
10 replies
FFilament
Created by pepperoni dogfart on 6/16/2024 in #❓┊help
Repeat table column
I have a hasMany relationship that I'd like to dynamically add to a filament table based on each relationship found, is this possible? For example in my model, I have
return $this->hasMany(Paid::class)->where('paid');
return $this->hasMany(Paid::class)->where('paid');
I basically want to do a foreach in the filament table, somehow, to make a TextColumn on each one.
3 replies
FFilament
Created by pepperoni dogfart on 5/29/2024 in #❓┊help
Select field using search populate another field.
I have a select field that populates the options via an external API request:
Forms\Components\Select::make('ticket_number')
->searchable()
->getSearchResultsUsing(fn (string $search): array => \App\Models\Ticket::apiTickets($search))
->selectablePlaceholder(false)
->searchingMessage('Searching Tickets...')
->native(false)
->live(),

Forms\Components\TextInput::make('ticket_title')->readOnly(),
Forms\Components\Select::make('ticket_number')
->searchable()
->getSearchResultsUsing(fn (string $search): array => \App\Models\Ticket::apiTickets($search))
->selectablePlaceholder(false)
->searchingMessage('Searching Tickets...')
->native(false)
->live(),

Forms\Components\TextInput::make('ticket_title')->readOnly(),
How can I pass the selected result over to the TextInput field? I couldn't figure this out using afterStateUpdated with the getSearchResultsUsing method on the original field.
4 replies
FFilament
Created by pepperoni dogfart on 5/17/2024 in #❓┊help
Filters - setting opposite when unchecked
Hello, I have a column in the database for "complete" in a basic task list. By default when I view the table, I'd like it to display by default all tasks where complete = false. I was able to add a filter toggle in to show completed tasks, but having an issue figuring out when it's not toggled, those records would be hidden.
2 replies
FFilament
Created by pepperoni dogfart on 12/6/2023 in #❓┊help
Access model data on delete action
I have an odd use case where my model is a remote API resource via calebporzio/sushi. Everything is working great from editing, creating, viewing -- but not deleting. For editing I'm utilizing EditAction::make()->using which references a method on my model that performs the update via API. For delete however, I can't find a way to pass any data of the actual model being deleted so that I can facilitate this on my own on the backend. DeleteAction::make()->after() does not appear to be passed the same $data array as the EditAction. Can anyone think of a different way to go about accomplishing this? Working:
Tables\Actions\EditAction::make()->using(function (Model $record, array $data): Model {
\App\Models\Rule::updateRecordAPI($data);
return $record;
}),
Tables\Actions\EditAction::make()->using(function (Model $record, array $data): Model {
\App\Models\Rule::updateRecordAPI($data);
return $record;
}),
Nothing passed:
Tables\Actions\DeleteAction::make()->after(function (array $data){
dd($data);
})
Tables\Actions\DeleteAction::make()->after(function (array $data){
dd($data);
})
22 replies
FFilament
Created by pepperoni dogfart on 11/30/2023 in #❓┊help
Allow resource label to have other capital letters
No description
3 replies
FFilament
Created by pepperoni dogfart on 5/19/2023 in #❓┊help
Switching from Nova to FIlament, questions on relation manager
When using relation manager, it looks like you have to re-create new/edit forms that may already be present on the relationship resource itself? Is there anyway when you click on a BelongsTo in the related table to simply use the form already created for that original resource instead of having to keep two separate copies of it? Or better yet, the edit button will bring up the original edit page for that resource (same with new)? This is how it works on Nova anyway, just trying to wrap my head around it here.
16 replies