window.updateCurrentPicker = function(event, taskID, taskType)
{
    const $picker     = event.zui('picker');
    const getTaskLink = $.createLink('execution', 'ajaxGetRelationTasks', 'executionID=' + executionID + '&taskID=' + taskID + '&taskType=' + taskType);

    $.getJSON(getTaskLink, function(relations) {$picker.render({items: relations.message});});
}

window.renderRowData = function($row, index, relation)
{
    let $preTask  = $row.find('.form-batch-control[data-name="pretask"]');
    let $postTask = $row.find('.form-batch-control[data-name="task"]');

    if($preTask.length > 0)
    {
        $preTask.find('.picker-box').on('inited', function(e, info)
        {
            updateCurrentPicker($(e.target).find("[name^=pretask]"), relation.task, 'task');
        })
    }

    if($postTask.length > 0)
    {
        $postTask.find('.picker-box').on('inited', function(e, info)
        {
            updateCurrentPicker($(e.target).find("[name^=task]"), relation.pretask, 'pretask');
        })
    }
}
