This commit is contained in:
salam committed 2026-02-15 09:19:26 +01:00
1 parent 965c7fca90
commit d077b6a429
26 files changed
+134 -123

No files matched your search

+16 -24
View File
@@ -4,6 +4,7 @@ namespace App\Livewire;
use App\Filament\Tables\Columns\MapperRightColumn;
use App\Livewire\Mapper\LoadProvider;
use App\Livewire\Mapper\SearchString;
use App\Livewire\Mapper\StoreMapped;
use App\Models\Country;
use App\Models\Event;
@@ -42,7 +43,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public $elements_swopped = false;
public $search_right = false;
public $search_values = [];
protected $listeners = [
'refreshMapperRight' => '$refresh',
@@ -50,16 +51,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
{
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
if (($key = array_search($field, $searchValues)) !== false) {
unset($searchValues[$key]);
}
if ($searchValues) {
$this->search_right = implode(' ', $searchValues);
} else {
$this->search_right = '';
if (($key = array_search($field, $this->search_values)) !== false) {
unset($this->search_values[$key]);
}
$this->dispatch('refreshMapperRight');
@@ -68,7 +61,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
return $table
->query(LoadProvider::load($this->search_right, auth()->user()))
->query(LoadProvider::load($this->search_values, auth()->user()))
->striped()
->columns([
MapperRightColumn::make('right')->label(''),
TextColumn::make('starttime')
@@ -93,7 +87,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->schema([
FusedGroup::make([
Select::make('country_id')
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]) && auth()->user()->sport_id != 5)
->placeholder('Country')
->hiddenLabel()
->label('')
@@ -257,9 +251,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
});
})->indicateUsing(function (): array {
$indicators = [];
if ($this->search_right) {
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
foreach ($searchValues as $value) {
if ($this->search_values) {
foreach ($this->search_values as $value) {
$indicators[] = Indicator::make($value)->removeField($value)->color('info');
}
}
@@ -283,7 +276,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->icon('phosphor-x')
->size(Size::Small)
->action(function (Component $livewire) {
$this->search_right = '';
$this->search_values = [];
$this->tableSearch = ''; // Clears the main search bar
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
@@ -301,11 +294,11 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
#[On('search_right')]
public function searchRight($str)
{
foreach ($this->tableFilters['events'] as $key => $value) {
$this->tableFilters['events'][$key] = null;
}
$this->search_values = SearchString::explode($str);
$this->search_right = $str;
// foreach ($this->tableFilters['events'] as $key => $value) {
// $this->tableFilters['events'][$key] = null;
// }
$this->dispatch('refreshMapperRight');
}
@@ -324,8 +317,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
})->action(function ($arguments) {
StoreMapped::store($arguments, $this->elements_swopped);
$this->search_right = '';
$this->search_left = '';
$this->search_values = [];
$this->dispatch('refreshMapperLeft');
$this->dispatch('refreshMapperRight');
})
@@ -345,6 +337,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function render()
{
return view('livewire.mapper-left');
return view('livewire.mapper-right');
}
}