* finish task #2776.

This commit is contained in:
wangyidong
2016-11-21 12:03:44 +08:00
parent 21c11b9edb
commit c4e8cef7f8
7 changed files with 65 additions and 10 deletions
+46 -1
View File
@@ -12,8 +12,20 @@ function setStories(moduleID, projectID, num)
var storyID = $('#story' + num).val();
if(!stories) stories = '<select id="story' + num + '" name="story[' + num + ']" class="form-control"></select>';
$('#story' + num).replaceWith(stories);
if(moduleID == 0) $('#story' + num).append("<option value='ditto'>" + ditto + "</option>")
if(moduleID == 0) $('#story' + num).append("<option value='ditto'>" + ditto + "</option>");
$('#story' + num).val(storyID);
if($('#zeroTaskStory').hasClass('zeroTask'))
{
$('#story' + num).find('option').each(function()
{
value = $(this).attr('value');
if(value != 'ditto' && storyTasks[value] > 0)
{
$(this).hide();
if(storyID == value) $('#story' + num).val('');
}
})
}
$("#story" + num + "_chosen").remove();
$("#story" + num).chosen(defaultChosenOptions);
});
@@ -44,6 +56,38 @@ function setStoryRelated(num)
}
}
/* Toggle zero task story. */
function toggleZeroTaskStory()
{
if($('#zeroTaskStory').hasClass('zeroTask'))
{
$('#zeroTaskStory').removeClass('zeroTask');
zeroTask = false;
}
else
{
$('#zeroTaskStory').addClass('zeroTask');
zeroTask = true;
}
$.cookie('zeroTask', zeroTask, {expires:config.cookieLife, path:config.webRoot});
$('select[name^="story"]').each(function()
{
selectVal = $(this).val();
$(this).find('option').each(function()
{
value = $(this).attr('value');
$(this).show();
if(value != 'ditto' && storyTasks[value] > 0 && zeroTask)
{
$(this).hide();
if(selectVal == value) selectVal = '';
}
})
$(this).val(selectVal);
$(this).trigger("chosen:updated");
})
}
$(document).on('click', '.chosen-with-drop', function()
{
var select = $(this).prev('select');
@@ -94,4 +138,5 @@ $(function()
/* Adjust width for ie chosen width. */
$('#module0_chosen').width($('#module1_chosen').width());
$('#story0_chosen').width($('#story1_chosen').width());
if($.cookie('zeroTask') == 'true') toggleZeroTaskStory();
})