<?php

namespace Internetgalerie\IgDatapoolFe\ViewHelpers\Form\Tom;

use Internetgalerie\IgDatapoolFe\ViewHelpers\Form\Tom\SelectViewHelper;
use TYPO3\CMS\Core\Page\PageRenderer;

class TokenMultiselectViewHelper extends SelectViewHelper
{
    protected static $class = 'dp-tokenizer dp-tom-select';

    // remove if v12 is dropped
    protected PageRenderer $pageRenderer;

    public function injectPageRenderer(PageRenderer $pageRenderer): void
    {
        $this->pageRenderer = $pageRenderer;
    }

    public function initializeArguments(): void
    {
        parent::initializeArguments();
        $this->overrideArgument('options', 'mixed', 'Associative array with internal IDs as key, and the values are displayed in the select box', true);
        $this->overrideArgument('multiple', 'boolean', 'Associative array with internal IDs as key, and the values are displayed in the select box', false, true);
        $this->overrideArgument('style', 'string', '', false, 'width:100%;');
    }
    protected function loadTomSelectAssets(): void
    {
        parent::loadTomSelectAssets();
        $this->pageRenderer->loadJavaScriptModule('@dp/elements/tomTokenMultiSelect.js'); 
    }
}
