Update project dependencies and enhance documentation
- Added `barryvdh/laravel-dompdf` to `composer.json` for PDF generation capabilities. - Updated `boost.json` to include `tailwindcss-development` in skills. - Modified `package.json` and `package-lock.json` to upgrade Tailwind CSS and related packages. - Improved README.md for clarity and corrected French language errors. - Created design system documentation for Filament components. - Added new Filament pages for Dashboard and Documentation with dynamic content loading. - Enhanced TablesExplorer functionality with improved table and column management.
This commit is contained in:
@@ -23,24 +23,75 @@ class TablesExplorer extends Page
|
||||
#[Url]
|
||||
public string $selectedTable = '';
|
||||
|
||||
public string $tableFilter = '';
|
||||
|
||||
public array $tables = [];
|
||||
|
||||
public array $columns = [];
|
||||
|
||||
public ?array $tablesMetadata = null;
|
||||
|
||||
public ?array $columnsMetadata = null;
|
||||
|
||||
public ?string $errorMessage = null;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private static array $dataTypeLabels = [
|
||||
'C' => 'Caractère',
|
||||
'N' => 'Numérique',
|
||||
'T' => 'Date/Heure',
|
||||
'D' => 'Date',
|
||||
'L' => 'Logique',
|
||||
'M' => 'Mémo',
|
||||
];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->loadTables();
|
||||
|
||||
if (filled($this->selectedTable)) {
|
||||
$this->loadColumns();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadTables(): void
|
||||
public function selectTable(string $tableName): void
|
||||
{
|
||||
$this->selectedTable = $tableName;
|
||||
$this->loadColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getFilteredTablesProperty(): array
|
||||
{
|
||||
if (blank($this->tableFilter)) {
|
||||
return $this->tables;
|
||||
}
|
||||
|
||||
$filter = mb_strtolower($this->tableFilter);
|
||||
|
||||
return array_values(array_filter(
|
||||
$this->tables,
|
||||
fn (array $table): bool => str_contains(mb_strtolower($table['name'] ?? ''), $filter),
|
||||
));
|
||||
}
|
||||
|
||||
public static function getDataTypeLabel(string $type): string
|
||||
{
|
||||
return self::$dataTypeLabels[strtoupper($type)] ?? $type;
|
||||
}
|
||||
|
||||
private function loadTables(): void
|
||||
{
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
$response = $service->tablesList();
|
||||
|
||||
$this->tables = $response['data'] ?? [];
|
||||
$this->tablesMetadata = $response['metadata'] ?? null;
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
@@ -49,10 +100,11 @@ class TablesExplorer extends Page
|
||||
}
|
||||
}
|
||||
|
||||
public function loadColumns(): void
|
||||
private function loadColumns(): void
|
||||
{
|
||||
if (blank($this->selectedTable)) {
|
||||
$this->columns = [];
|
||||
$this->columnsMetadata = null;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -61,12 +113,36 @@ class TablesExplorer extends Page
|
||||
$service = app(LogisticsService::class);
|
||||
$response = $service->columnList($this->selectedTable);
|
||||
|
||||
$this->columns = $response['data'] ?? [];
|
||||
$rawColumns = $response['data'] ?? [];
|
||||
$this->columns = $this->deduplicateColumns($rawColumns);
|
||||
$this->columnsMetadata = $response['metadata'] ?? null;
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
$this->columns = [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = "Erreur inattendue : {$e->getMessage()}";
|
||||
$this->columns = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $columns
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
private function deduplicateColumns(array $columns): array
|
||||
{
|
||||
$seen = [];
|
||||
$unique = [];
|
||||
|
||||
foreach ($columns as $column) {
|
||||
$key = ($column['name'] ?? '').'|'.($column['dataType'] ?? '');
|
||||
if (! isset($seen[$key])) {
|
||||
$seen[$key] = true;
|
||||
$unique[] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
return $unique;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user