Skip to content

Commit

Permalink
Añadida comprobación para evitar que se enlacen modals con botones an…
Browse files Browse the repository at this point in the history
…tes de añadir ese modal a una sección o pestaña.
  • Loading branch information
NeoRazorX committed Nov 3, 2023
1 parent 336b8b8 commit 2613465
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Core/Template/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public function name(): string
return $this->name;
}

public function parentId(): string
{
return $this->parent_id;
}

public function position(): int
{
return $this->position;
Expand Down
6 changes: 6 additions & 0 deletions Core/UI/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace FacturaScripts\Core\UI;

use Exception;
use FacturaScripts\Core\Template\UI\Component;
use FacturaScripts\Core\Tools;

Expand Down Expand Up @@ -51,6 +52,11 @@ public function label(bool $translate = false): string

public function linkModal(Modal $modal): self
{
// si el modal no tiene padre, no lo podemos enlazar
if (empty($modal->parentId())) {
throw new Exception('Add the modal to a section or tab before linking it to a button.');
}

$this->modal_id = $modal->id();

return $this;
Expand Down

0 comments on commit 2613465

Please sign in to comment.