Added trigger function for refresh chart against plant and line
This commit is contained in:
@@ -24,12 +24,11 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) use ($selectedPlant) {
|
||||
// Update only in memory and not in the URL
|
||||
session(['selected_plant' => $state]); // Store in session
|
||||
session()->forget('selected_line'); // Reset line filter
|
||||
session(['selected_plant' => $state]);
|
||||
session()->forget('selected_line');
|
||||
$set('Plant', $state);
|
||||
$set('Line', null);
|
||||
$this->dispatch('filtersUpdated'); // Notify chart to refresh
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
|
||||
// Line Filter
|
||||
@@ -42,9 +41,16 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]); // Store in session
|
||||
$this->dispatch('filtersUpdated'); // Notify chart to refresh
|
||||
$this->triggerChartUpdate(); // Notify chart to refresh
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
// Helper to check if both filters are set
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('selected_plant') && session()->has('selected_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user