mapper ok

This commit is contained in:
salam committed 2026-01-06 13:09:18 +01:00
1 parent 2e57e49f08
commit c617935e2f
18 files changed
+227 -97

No files matched your search

+56 -6
View File
@@ -18,14 +18,19 @@ use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\Size;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Attributes\Lazy;
use Livewire\Attributes\On;
use Livewire\Component;
#[Lazy]
class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
{
use InteractsWithActions;
@@ -34,14 +39,33 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public $elements_swopped = false;
public $search_left = false;
protected $listeners = [
'reload_data' => '$refresh',
'reload_data_left' => '$refresh',
];
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
{
$searchValues = preg_split('/\s+/', $this->search_left, -1, PREG_SPLIT_NO_EMPTY);
if (($key = array_search($field, $searchValues)) !== false) {
unset($searchValues[$key]);
}
if ($searchValues) {
$this->search_left = implode(' ', $searchValues);
} else {
$this->search_left = '';
}
$this->dispatch('reload_data_left');
}
public function table(Table $table): Table
{
return $table
->query(LoadEvents::load())
->query(LoadEvents::load($this->search_left))
->columns([
MapperLeftColumn::make('left')->label(''),
])
@@ -107,6 +131,16 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
);
})->indicateUsing(function (): array {
$indicators = [];
if ($this->search_left) {
$searchValues = preg_split('/\s+/', $this->search_left, -1, PREG_SPLIT_NO_EMPTY);
foreach ($searchValues as $value) {
$indicators[] = Indicator::make($value)->removeField($value);
}
}
return $indicators;
})
->columns(4)->columnSpan(4),
], layout: FiltersLayout::AboveContent)
@@ -116,12 +150,15 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->toolbarActions([
Action::make('reload_data_left')
->hiddenLabel()
->color('gray')
->icon('heroicon-o-arrow-path')
// ->icon('phosphor-x')
->icon('phosphor-x')
->color('danger')
->size(Size::Small)
->action(function (Component $livewire) {
$livewire->resetTableFiltersForm(); // Clears all filters
$this->search_left = '';
$this->tableSearch = ''; // Clears the main search bar
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
$this->dispatch('reload_data_left');
}),
]);
}
@@ -131,6 +168,14 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
$this->elements_swopped = ! $this->elements_swopped;
}
#[On('search_left')]
public function searchLeft($str)
{
$this->search_left = $str;
$this->dispatch('reload_data_left');
}
public function leftAction(): Action
{
return Action::make('left')
@@ -145,6 +190,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
})
->action(function ($arguments) {
StoreMapped::store($arguments, $this->elements_swopped);
$this->search_right = '';
$this->search_left = '';
$this->dispatch('reload_data_left');
$this->dispatch('reload_data_right');
})
->closeModalByEscaping(false)
->modalCloseButton(false)