Fix: product attributes with the same sort order value were overwriting each other in getProductAttributes(), causing only one attribute to display on the frontend. Now uses usort() with sequential keys. New: Preview button in product edit form opens product page in new tab. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
90 lines
2.2 KiB
PHP
90 lines
2.2 KiB
PHP
<?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'
|
|
);
|
|
}
|
|
}
|