From b8c0422318884a50f5b9c1fde4ec59bf86d477ef Mon Sep 17 00:00:00 2001 From: andre Date: Fri, 25 Sep 2026 21:44:59 +0100 Subject: [PATCH] refactor(modalidades): partilhar _form.php entre create e edit (audit 6.8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extrai os campos comuns (nome, cor, ícone/upload, ordem, descrição, e a biblioteca de ícones disponíveis) para _form.php, seguindo o padrão de events/ e memberships/. A diferença genuína entre criar e editar — o bloco de ícone mostra pré-visualização e checkbox "remover imagem atual" só quando já existe um registo — fica como um if ($item === null) explícito dentro do parcial, tal como o hero_image em events/. Co-Authored-By: Claude Sonnet 5 --- views/admin/modalidades/_form.php | 53 ++++++++++++++++++++++++++++++ views/admin/modalidades/create.php | 29 +--------------- views/admin/modalidades/edit.php | 35 +------------------- 3 files changed, 55 insertions(+), 62 deletions(-) create mode 100644 views/admin/modalidades/_form.php diff --git a/views/admin/modalidades/_form.php b/views/admin/modalidades/_form.php new file mode 100644 index 0000000..14bf36e --- /dev/null +++ b/views/admin/modalidades/_form.php @@ -0,0 +1,53 @@ + of both create.php and +// edit.php. Expects: +// $data : associative array with every modalidades column (nome, cor, icon, +// descricao, item_order) +// $item : the existing row on edit (for the current icon preview/remove +// checkbox), or null +// $icons : rows from db_flaticon_list($pdo) — the shared icon library +$item = $item ?? null; +?> +
+
+
+
+
+ +
+ +
Escolha um da biblioteca abaixo, ou carregue um novo.
+
+ +
Substitui o nome acima. Máx. 2 MB.
+ +
+ +
atual
+
+ +
Substitui o ícone atual. Máx. 2 MB.
+ +
+ + +
+
+ +
+
+
+
+
+ +
+
+ +
+ +
+
+ +
+
+ diff --git a/views/admin/modalidades/create.php b/views/admin/modalidades/create.php index 439683d..10f0b87 100644 --- a/views/admin/modalidades/create.php +++ b/views/admin/modalidades/create.php @@ -43,34 +43,7 @@ include __DIR__ . '/../../../includes/header.php';
-
-
-
-
-
-
- -
Escolha um da biblioteca abaixo, ou carregue um novo.
-
- -
Substitui o nome acima. Máx. 2 MB.
-
-
-
-
-
- -
-
- -
- -
-
- -
-
- +
Cancelar diff --git a/views/admin/modalidades/edit.php b/views/admin/modalidades/edit.php index 65f239c..edb6d16 100644 --- a/views/admin/modalidades/edit.php +++ b/views/admin/modalidades/edit.php @@ -70,40 +70,7 @@ include __DIR__ . '/../../../includes/header.php';
-
-
-
-
-
-
- -
atual
-
- -
Substitui o ícone atual. Máx. 2 MB.
- -
- - -
-
-
-
-
-
-
- -
-
- -
- -
-
- -
-
- +
Cancelar