Commit d3a98db6 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

feat(plugins): add defaultValue for all field types

parent 00bd4c02
Loading
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ use RuntimeException;
 * @property string $language_code
 * @property int $category_id
 * @property Category|null $category
 * @property int[] $other_categories_ids
 * @property string $other_categories_ids
 * @property Category[] $other_categories
 * @property string|null $parental_advisory
 * @property string|null $publisher
@@ -111,10 +111,7 @@ class Podcast extends Entity
     */
    protected ?array $other_categories = null;

    /**
     * @var string[]|null
     */
    protected ?array $other_categories_ids = null;
    protected string $other_categories_ids = '';

    /**
     * @var Episode[]|null
@@ -526,13 +523,10 @@ class Podcast extends Entity
        return $this->other_categories;
    }

    /**
     * @return int[]|string[]
     */
    public function getOtherCategoriesIds(): array
    public function getOtherCategoriesIds(): string
    {
        if ($this->other_categories_ids === null) {
            $this->other_categories_ids = array_column($this->getOtherCategories(), 'id');
        if ($this->other_categories_ids === '') {
            $this->other_categories_ids = implode(',', array_column($this->getOtherCategories(), 'id'));
        }

        return $this->other_categories_ids;
+15 −0
Original line number Diff line number Diff line
@@ -136,6 +136,21 @@ export class XMLEditor extends LitElement {
      overflow: hidden;
      border: 3px solid hsl(var(--color-border-contrast));
      background-color: hsl(var(--color-background-elevated));
      transition-property:
        color,
        background-color,
        border-color,
        text-decoration-color,
        fill,
        stroke,
        opacity,
        box-shadow,
        transform,
        filter,
        backdrop-filter,
        -webkit-backdrop-filter;
      transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
      transition-duration: 150ms;
    }
    .cm-editor.cm-focused {
      outline: 2px solid transparent;
+1 −1
Original line number Diff line number Diff line
@layer components {
  .form-radio-btn {
    @apply absolute right-4 top-4 border-contrast border-3 text-accent-base;
    @apply absolute right-4 top-4 border-contrast border-3 text-accent-base transition;

    &:focus {
      @apply ring-accent;
+3 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ use Override;

class Checkbox extends FormComponent
{
    protected array $props = ['hint', 'helper', 'isChecked'];
    protected array $props = ['hint', 'helper'];

    protected array $casts = [
        'isChecked' => 'boolean',
@@ -19,8 +19,6 @@ class Checkbox extends FormComponent

    protected string $helper = '';

    protected bool $isChecked = false;

    #[Override]
    public function render(): string
    {
@@ -28,10 +26,10 @@ class Checkbox extends FormComponent
            [
                'id'    => $this->id,
                'name'  => $this->name,
                'class' => 'form-checkbox bg-elevated text-accent-base border-contrast border-3 w-6 h-6',
                'class' => 'form-checkbox bg-elevated text-accent-base border-contrast border-3 focus:ring-accent w-6 h-6 transition',
            ],
            'yes',
            old($this->name) ? old($this->name) === 'yes' : $this->isChecked,
            in_array($this->getValue(), ['yes', 'true', 'on', '1'], true),
        );

        $hint = $this->hint === '' ? '' : (new Hint([
+3 −5
Original line number Diff line number Diff line
@@ -18,20 +18,18 @@ class CodeEditor extends FormComponent
        'class' => 'textarea',
    ];

    protected string $content = '';

    protected string $lang = '';

    public function setContent(string $value): void
    public function setValue(string $value): void
    {
        $this->content = htmlspecialchars_decode($value);
        $this->value = htmlspecialchars_decode($value);
    }

    #[Override]
    public function render(): string
    {
        $this->attributes['slot'] = 'textarea';
        $textarea = form_textarea($this->attributes, $this->content);
        $textarea = form_textarea($this->attributes, $this->getValue());

        return <<<HTML
            <code-editor lang="{$this->lang}">{$textarea}</code-editor>
Loading