<?php

namespace App\Admin\Actions\Grid;

use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;
use App\Admin\Actions\Form\BatchEditEpisodeListForm;

class BatchEditEpisodeList extends BatchAction
{
    /**
     * @return string
     */
    protected $title = '批量设置';

    public function render()
    {
        $form = BatchEditEpisodeListForm::make();

        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            ->onLoad($this->getModalScript())
            ->button($this->title);
    }

    protected function getModalScript()
    {
        return <<<JS
//获取选中的ID
let key = {$this->getSelectedKeysScript()}
$("#batch-id").val(key)
JS;
    }
}
