<?php

namespace App\Admin\Actions\Grid;

use Dcat\Admin\Actions\Response;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\BatchAction;
use Illuminate\Http\Request;
use App\Admin\Forms\InquiryAssignment as InquiryAssignmentForm;
use Dcat\Admin\Widgets\Modal;



class InquiryAssignment extends BatchAction
{
    /**
     * @return string
     */
	protected $title = 'Inquiry Assignment';


    /**
     * 初始化操作
     */
    public function render()
    {
        // 实例化表单类
        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body(InquiryAssignmentForm::make())
            //->on('click',$this->getModalScript2())
            ->onShow($this->getModalScript())
            // 因为此处使用了表单异步加载功能，所以一定要用 onLoad 方法
            ->button('<button type="button" class="btn btn-success"">Assignment</button>');
    }


    /**
     * 设置动作发起请求前的回调函数，返回false可以中断请求.
     *
     * @return string
     */
    public function getModalScript(){
        $warning = __('No data selected!');
        return <<<JS
            var key = {$this->getSelectedKeysScript()}
            $('#inquiryIds').val(key);
        JS;
    }

    public function getSelectedKeysScript()
    {
        return "Dcat.grid.selected('{$this->parent->getName()}')";
    }

}
