feat(06-admin-base): Admin\ base infrastructure — Form Edit System + Support layer (Phase 6)
Phase 6 zamknięta po 2 planach. Pełny fundament dla Phase 7-13 (migracja 17 admin controllers do Admin\ namespace). 06-01 (Forms infrastructure): - Admin\ViewModels\Forms\* — 5 ViewModeli (687 L) - Admin\Validation\FormValidator (196 L) - composer.json: php >=7.4, PSR-4 paths cross-platform safe (Admin\ → autoload/admin/, Frontend\ → autoload/front/) 06-02 (Support layer): - Admin\Support\TableListRequestFactory (99 L) — parser list z $_GET - Admin\Support\Forms\FormRequestHandler (159 L) — POST + CSRF + walidacja + persist - Admin\Support\Forms\FormFieldRenderer (494 L) — renderer HTML pól Decyzje: - Brak BaseController — Phase 7+ kontrolery jako POJOs z DI (jak shopPRO) - PSR-4 filename fix: TableListRequestFactory.php (bez shopPRO 'class.' prefix) - PascalCase namespace (Admin\Support) na lowercase folder admin/ ze względu na Windows fs case-insensitivity vs legacy admin/controls/ Pliki: 8 nowych klas, 1635 L kodu PHP 7.4-kompatybilnego, zero regresji. Smoke test: walidacja e-maila zwraca PL komunikat, factory parsuje ?page=&per_page=&sort=&filter=, Domain/Shared nadal ładują się. PHPUnit: 37/37 OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
89
autoload/admin/ViewModels/Forms/FormAction.php
Normal file
89
autoload/admin/ViewModels/Forms/FormAction.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace Admin\ViewModels\Forms;
|
||||
|
||||
/**
|
||||
* Definicja akcji formularza (przycisku)
|
||||
*/
|
||||
class FormAction
|
||||
{
|
||||
public string $name;
|
||||
public string $label;
|
||||
public string $type;
|
||||
public string $url;
|
||||
public ?string $backUrl;
|
||||
public string $cssClass;
|
||||
public array $attributes;
|
||||
|
||||
/**
|
||||
* @param string $name Nazwa akcji (save, cancel, delete)
|
||||
* @param string $label Etykieta przycisku
|
||||
* @param string $url URL akcji (dla save)
|
||||
* @param string|null $backUrl URL powrotu po zapisie
|
||||
* @param string $cssClass Klasy CSS przycisku
|
||||
* @param string $type Typ przycisku (submit, button, link)
|
||||
* @param array $attributes Dodatkowe atrybuty HTML
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
string $label,
|
||||
string $url = '',
|
||||
?string $backUrl = null,
|
||||
string $cssClass = 'btn btn-primary',
|
||||
string $type = 'submit',
|
||||
array $attributes = []
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->label = $label;
|
||||
$this->url = $url;
|
||||
$this->backUrl = $backUrl;
|
||||
$this->cssClass = $cssClass;
|
||||
$this->type = $type;
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predefiniowana akcja Zapisz
|
||||
*/
|
||||
public static function save(string $url, string $backUrl = '', string $label = 'Zapisz'): self
|
||||
{
|
||||
return new self(
|
||||
'save',
|
||||
$label,
|
||||
$url,
|
||||
$backUrl,
|
||||
'btn btn-primary',
|
||||
'submit'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Predefiniowana akcja Podgląd (otwiera w nowej karcie)
|
||||
*/
|
||||
public static function preview(string $url, string $label = 'Podgląd'): self
|
||||
{
|
||||
return new self(
|
||||
'preview',
|
||||
$label,
|
||||
$url,
|
||||
null,
|
||||
'btn btn-info',
|
||||
'link',
|
||||
['target' => '_blank']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Predefiniowana akcja Anuluj
|
||||
*/
|
||||
public static function cancel(string $backUrl, string $label = 'Anuluj'): self
|
||||
{
|
||||
return new self(
|
||||
'cancel',
|
||||
$label,
|
||||
$backUrl,
|
||||
null,
|
||||
'btn btn-default',
|
||||
'link'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user