1
0
forked from poc/pds

Added trigger function for refresh chart against plant and line

This commit is contained in:
dhanabalan
2025-04-19 12:53:18 +05:30
parent f1f9a2c5da
commit 8980429b52

View File

@@ -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');
}
}
}