feat(admin): humanise les libelles restants (Reference/Variation/Auteur) (#54)
All checks were successful
CI / secret-scan (push) Successful in 12s
CI / php-lint (push) Successful in 21s
CI / js-tests (push) Successful in 24s
CI / auto-merge (push) Has been skipped
CI / static-tests (push) Successful in 52s

This commit is contained in:
Corentin JOGUET 2026-06-18 13:45:46 +02:00
parent 60535bbe00
commit 1697b94b62
6 changed files with 11 additions and 11 deletions

View file

@ -197,9 +197,9 @@ class CategoryController extends AdminController
}
if ($slug === '' || mb_strlen($slug) > 60 || preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $slug) !== 1) {
$errors['slug'] = 'Slug requis : minuscules, chiffres et tirets (60 max).';
$errors['slug'] = 'Reference requise : minuscules, chiffres et tirets (60 max).';
} elseif ($repo->slugExists($slug, $exceptId)) {
$errors['slug'] = 'Ce slug existe deja.';
$errors['slug'] = 'Cette reference existe deja.';
}
if ($image !== '' && mb_strlen($image) > 255) {
@ -258,7 +258,7 @@ class CategoryController extends AdminController
// getCode() rend la chaine SQLSTATE pour une vraie PDOException ; le cast
// couvre aussi un code entier (23000 = violation de contrainte d'integrite).
if ((string) $exception->getCode() === '23000') {
return $this->renderForm($guard, $id, $form, ['slug' => 'Ce libelle ou ce slug existe deja.'], 409);
return $this->renderForm($guard, $id, $form, ['slug' => 'Ce libelle ou cette reference existe deja.'], 409);
}
throw $exception;

View file

@ -40,7 +40,7 @@ $err = static fn (string $k): string => isset($errs[$k]) && is_string($errs[$k])
</div>
<div class="form-group">
<label class="form-label" for="slug">Slug</label>
<label class="form-label" for="slug">Reference</label>
<input class="form-input" type="text" id="slug" name="slug" maxlength="60" value="<?= $val('slug') ?>" required>
<?php if ($err('slug') !== ''): ?><p class="form-error"><?= htmlspecialchars($err('slug'), ENT_QUOTES, 'UTF-8') ?></p><?php endif; ?>
</div>

View file

@ -32,7 +32,7 @@ $esc = static fn (mixed $v): string => htmlspecialchars((string) $v, ENT_QUOTES,
<thead>
<tr>
<th>Libelle</th>
<th>Slug</th>
<th>Reference</th>
<th>Ordre</th>
<th>Statut</th>
<th style="width:160px;"></th>

View file

@ -49,9 +49,9 @@ $colspan = $withActor ? 5 : 4;
<tr>
<th>Date</th>
<th>Type</th>
<th>Delta</th>
<th>Variation</th>
<th>Note</th>
<?php if ($withActor): ?><th>Acteur</th><?php endif; ?>
<?php if ($withActor): ?><th>Auteur</th><?php endif; ?>
</tr>
</thead>
<tbody>

View file

@ -202,7 +202,7 @@ final class CategoryControllerTest extends TestCase
self::assertSame(422, $response->status());
self::assertStringContainsString('Le libelle est requis', $response->body());
self::assertStringContainsString('Slug requis', $response->body());
self::assertStringContainsString('Reference requise', $response->body());
self::assertFalse($this->wroteContaining($db, 'INSERT INTO category'));
}
@ -266,7 +266,7 @@ final class CategoryControllerTest extends TestCase
$response = $this->controller($request, $db)->store();
self::assertSame(422, $response->status());
self::assertStringContainsString('Ce slug existe deja', $response->body());
self::assertStringContainsString('Cette reference existe deja', $response->body());
self::assertFalse($this->wroteContaining($db, 'INSERT INTO category'));
}

View file

@ -425,7 +425,7 @@ final class IngredientControllerTest extends TestCase
$response = $this->controller($this->get('/admin/ingredients/5/movements'), $db)->movements(['id' => '5']);
self::assertSame(200, $response->status());
self::assertStringContainsString('Acteur', $response->body());
self::assertStringContainsString('Auteur', $response->body());
self::assertStringContainsString('Sam K', $response->body()); // nom resolu
}
@ -438,6 +438,6 @@ final class IngredientControllerTest extends TestCase
$response = $this->controller($this->get('/admin/ingredients/5/movements'), $db)->movements(['id' => '5']);
self::assertSame(200, $response->status());
self::assertStringNotContainsString('Acteur', $response->body()); // colonne masquee (RG-4)
self::assertStringNotContainsString('Auteur', $response->body()); // colonne masquee (RG-4)
}
}