");
setLineIndex();
}
window.loadStories = function()
{
const executionID = $('[name=execution]').val();
const storyID = $('[name=story]').val();
const moduleID = $('[name=module]').val();
const link = $.createLink('story', 'ajaxGetExecutionStories', 'executionID=' + executionID + '&productID=0&branch=all&moduleID=' + moduleID + '&storyID=' + storyID + '&pageType=&type=full&status=active');
$.getJSON(link, function(storyItems)
{
let $storyPicker = $('[name=story]').zui('picker');
$storyPicker.render({items: storyItems});
$storyPicker.$.setValue(storyID);
});
}
window.setStoryModule = function()
{
var storyID = $('input[name=story]').val();
if(storyID)
{
var link = $.createLink('story', 'ajaxGetInfo', 'storyID=' + storyID);
$.getJSON(link, function(storyInfo)
{
if(storyInfo) $('input[name=module]').zui('picker').$.setValue(storyInfo.moduleID);
});
}
}
window.clickSubmit = async function(e)
{
if(confirmSyncTip.length == 0 || $('[name=story]').length == 0 || $('[name=story]').val() == '' || $('[name=story]').val() == '0' || $('[name=story]').val() == taskStory) return true;
await zui.Modal.confirm(confirmSyncTip).then((res) =>
{
const $taskForm = $('[formid=taskEditForm' + taskID + ']');
$taskForm.find('[name=syncChildren]').remove();
$taskForm.append('');
});
return true;
};
window.statusChange = function(target)
{
const status = $(target).val();
const $assignedToPicker = $('[name=assignedTo]').zui('picker');
let hasClosed = false;
let assignedToItems = JSON.parse(JSON.stringify($assignedToPicker.options.items));
if(status == 'closed')
{
for(let i = 0; i < assignedToItems.length; i++)
{
if(assignedToItems[i].value == 'closed') hasClosed = true;
}
if(!hasClosed) assignedToItems.push({key: "closed", keys: "closed c", text : "Closed", value : 'closed'});
$assignedToPicker.render({items: assignedToItems, disabled: true});
$assignedToPicker.$.setValue('closed');
}
else
{
for(let i = 0; i < assignedToItems.length; i++)
{
if(assignedToItems[i].value == 'closed')
{
assignedToItems.splice(i, 1);
$assignedToPicker.render({items: assignedToItems, disabled: false});
$assignedToPicker.$.setValue('');
}
}
}
}
window.loadStories = function()
{
const executionID = $('[name=execution]').val();
const storyID = $('[name=story]').val();
const moduleID = $('[name=module]').val();
const link = $.createLink('story', 'ajaxGetExecutionStories', 'executionID=' + executionID + '&productID=0&branch=all&moduleID=' + moduleID + '&storyID=' + storyID + '&pageType=&type=full&status=active');
$.getJSON(link, function(storyItems)
{
let $storyPicker = $('[name=story]').zui('picker');
$storyPicker.render({items: storyItems});
$storyPicker.$.setValue(storyID);
});
}
window.setStoryModule = function()
{
var storyID = $('input[name=story]').val();
if(storyID)
{
var link = $.createLink('story', 'ajaxGetInfo', 'storyID=' + storyID);
$.getJSON(link, function(storyInfo)
{
if(storyInfo) $('input[name=module]').zui('picker').$.setValue(storyInfo.moduleID);
});
}
}
getParentEstStartedAndDeadline = function()
{
const $parent = $('[name=parent]');
const parent = $parent.val();
if(!parent)
{
if(taskDateLimit != 'limit') return;
const $form = $parent.closest('form');
$form.find('[name=estStarted]').zui('datePicker').render({disabled: false});
$form.find('[name=deadline]').zui('datePicker').render({disabled: false});
return;
}
const link = $.createLink('task', 'ajaxGetTaskEstStartedAndDeadline', 'taskID=' + parent);
$.getJSON(link, function(data)
{
parentEstStarted = data.estStarted;
parentDeadline = data.deadline;
overParentEstStartedLang = data.overParentEstStartedLang;
overParentDeadlineLang = data.overParentDeadlineLang;
window.checkEstStartedAndDeadline({target: $('[name=estStarted]')});
window.checkEstStartedAndDeadline({target: $('[name=deadline]')});
});
}
function checkEstStartedAndDeadline(event)
{
if(taskDateLimit != 'limit') return;
const $form = $(event.target).closest('form');
const field = $(event.target).attr('name')
const $estStarted = $form.find('[name=estStarted]');
const estStarted = $estStarted.val();
const $deadline = $form.find('[name=deadline]');
const deadline = $deadline.val();
const hasParent = $('[name=parent]').val() != '';
const $estStartedDiv = $estStarted.closest('.form-group');
if(field == 'estStarted' && estStarted.length > 0)
{
$estStartedDiv.find('#estStartedTip').remove();
let $datetip = $('');
if(hasParent && parentEstStarted.length > 0 && estStarted < parentEstStarted) $datetip.append('' + overParentEstStartedLang + '
');
if(childDateLimit['estStarted'].length > 0 && estStarted > childDateLimit['estStarted'])
{
$datetip.append('' + overChildEstStartedLang + '' + ignoreLang + '
');
$datetip.off('click', '.ignore-child').on('click', '.ignore-child', function (e) { ignoreTip(e) });
}
$estStartedDiv.append($datetip);
}
const $deadlineDiv = $deadline.closest('.form-group');
if(field == 'deadline' && deadline.length > 0)
{
$deadlineDiv.find('#deadlineTip').remove();
let $datetip = $('');
if(hasParent && parentDeadline.length > 0 && deadline > parentDeadline) $datetip.append('' + overParentDeadlineLang + '
');
if(childDateLimit['deadline'].length > 0 && deadline < childDateLimit['deadline'])
{
$datetip.append('' + overChildDeadlineLang + '' + ignoreLang + '
');
$datetip.off('click', '.ignore-child').on('click', '.ignore-child', function (e) { ignoreTip(e) });
}
$deadlineDiv.append($datetip);
}
if(hasParent)
{
let $estStartedPicker = $estStarted.zui('datePicker');
let $deadlinePicker = $deadline.zui('datePicker');
$estStartedPicker.render({disabled: parentEstStarted == ''});
$deadlinePicker.render({disabled: parentDeadline == ''});
if(parentEstStarted == '') $estStartedPicker.$.setValue('');
if(parentDeadline == '') $deadlinePicker.$.setValue('');
}
}