Enhance API parameter documentation and introduce reusable component
- Added a new Blade component `<x-logistics.param-table>` for displaying API parameter tables across all Filament pages, ensuring consistent styling and reducing HTML duplication. - Integrated parameter tables for each endpoint in the Articles, Documents, Divers, Journaux, Tiers, and other pages, providing users with clear reference information. - Updated the documentation to reflect the new structure and details of API parameters, including required fields and descriptions. - Improved user experience by ensuring that endpoints without parameters do not display empty tables. - Overall, enhanced the clarity and usability of API interactions within the application.
This commit is contained in:
@@ -28,6 +28,8 @@ class Divers extends Page
|
||||
// codes_list
|
||||
public string $code = '';
|
||||
|
||||
public string $codesSelect = '';
|
||||
|
||||
public array $codesData = [];
|
||||
|
||||
// custom_geninv_updatestock
|
||||
@@ -41,7 +43,9 @@ class Divers extends Page
|
||||
|
||||
public string $stkToCheckDetail = '';
|
||||
|
||||
public string $stkMode = '';
|
||||
public string $stkMode = '1';
|
||||
|
||||
public string $stkThirdId = '';
|
||||
|
||||
public array $updateStockResult = [];
|
||||
|
||||
@@ -54,6 +58,33 @@ class Divers extends Page
|
||||
|
||||
public bool $hasUpdatedStock = false;
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, type: string, required: string, description: string}>
|
||||
*/
|
||||
public function paramTableCodesList(): array
|
||||
{
|
||||
return [
|
||||
['name' => 'code', 'type' => 'string', 'required' => 'Oui', 'description' => 'Nom exact du groupe de codes internes (table incodes). Correspondance exacte, sensible a la casse (MAJUSCULES). Chaine vide pour la liste maitre.'],
|
||||
['name' => 'select', 'type' => 'string', 'required' => 'Non', 'description' => 'Sans effet. Toutes les colonnes sont toujours retournees.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, type: string, required: string, description: string}>
|
||||
*/
|
||||
public function paramTableUpdateStock(): array
|
||||
{
|
||||
return [
|
||||
['name' => 'ARTID', 'type' => 'string', 'required' => 'Oui', 'description' => 'Identifiant de l\'article (champ artid de la table art).'],
|
||||
['name' => 'STKID', 'type' => 'string', 'required' => 'Oui', 'description' => 'Code du depot / entrepot. Valeurs via codes_list STOCK (ex: A, SG).'],
|
||||
['name' => 'QTY', 'type' => 'string', 'required' => 'Oui', 'description' => 'Quantite a ajouter au stock. Peut etre negatif pour retirer du stock.'],
|
||||
['name' => 'MODE', 'type' => 'string', 'required' => 'Oui', 'description' => '"0" = Inventaire (journal KI). "1" = Restock (journal KM, necessite THIRDID).'],
|
||||
['name' => 'THIRDID', 'type' => 'string', 'required' => 'Si MODE=1', 'description' => 'Identifiant du tiers / fournisseur (custid de la table cust). Obligatoire en mode Restock.'],
|
||||
['name' => 'TOCHECK', 'type' => 'string', 'required' => 'Oui', 'description' => 'Prix de controle. Stocke avec le mouvement mais n\'affecte pas la quantite de stock.'],
|
||||
['name' => 'TOCHECKDETAIL', 'type' => 'string', 'required' => 'Oui', 'description' => 'Remarque / detail de controle. Texte libre stocke avec le mouvement.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getSerialNumber(): void
|
||||
{
|
||||
$this->errorMessage = null;
|
||||
@@ -88,7 +119,13 @@ class Divers extends Page
|
||||
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
$response = $service->codesList(['code' => $this->code]);
|
||||
$params = ['code' => $this->code];
|
||||
|
||||
if (filled($this->codesSelect)) {
|
||||
$params['select'] = $this->codesSelect;
|
||||
}
|
||||
|
||||
$response = $service->codesList($params);
|
||||
|
||||
$this->codesData = $response['data'] ?? [];
|
||||
$this->errorMessage = ApiErrorTranslator::translate($response['error'] ?? null);
|
||||
@@ -105,8 +142,14 @@ class Divers extends Page
|
||||
{
|
||||
$this->errorMessage = null;
|
||||
|
||||
if (blank($this->stkArtId) || blank($this->stkId) || blank($this->stkQty)) {
|
||||
$this->errorMessage = 'Les champs ARTID, STKID et QTY sont obligatoires.';
|
||||
if (blank($this->stkArtId) || blank($this->stkId) || blank($this->stkQty) || blank($this->stkMode)) {
|
||||
$this->errorMessage = 'Les champs ARTID, STKID, QTY et MODE sont obligatoires.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->stkMode === '1' && blank($this->stkThirdId)) {
|
||||
$this->errorMessage = 'Le champ THIRDID est obligatoire en mode Restock (MODE=1).';
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -116,14 +159,18 @@ class Divers extends Page
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
|
||||
$params = array_filter([
|
||||
$params = [
|
||||
'ARTID' => $this->stkArtId,
|
||||
'STKID' => $this->stkId,
|
||||
'QTY' => $this->stkQty,
|
||||
'TOCHECK' => $this->stkToCheck,
|
||||
'TOCHECKDETAIL' => $this->stkToCheckDetail,
|
||||
'MODE' => $this->stkMode,
|
||||
]);
|
||||
];
|
||||
|
||||
if (filled($this->stkThirdId)) {
|
||||
$params['THIRDID'] = $this->stkThirdId;
|
||||
}
|
||||
|
||||
$response = $service->customGeninvUpdatestock($params);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user