| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- /**
- * Load all users as assignedTo list.
- *
- * @access public
- * @return void
- */
- function loadAllUsers()
- {
- link = createLink('bug', 'ajaxLoadAllUsers', 'selectedUser=' + $('#assignedTo').val());
- $('#assignedToBox').load(link, function()
- {
- moduleID = $('#module').val();
- productID = $('#product').val();
- setAssignedTo(moduleID, productID);
- });
- }
- /**
- * Load by branch.
- *
- * @access public
- * @return void
- */
- function loadBranch()
- {
- $('#taskIdBox').innerHTML = '<select id="task"></select>'; // Reset the task.
- productID = $('#product').val();
- loadProductModules(productID);
- loadProductExecutions(productID);
- loadProductBuilds(productID);
- loadProductplans(productID);
- loadProductStories(productID);
- }
- /**
- * Load product modules.
- *
- * @param productID $productID
- * @access public
- * @return void
- */
- function loadProductModules(productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=bug&branch=' + branch + '&rootModuleID=0&returnType=mhtml&needManage=true');
- $('#moduleIdBox').load(link);
- }
- /**
- * Load product plans.
- *
- * @param productID $productID
- * @access public
- * @return void
- */
- function loadProductplans(productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- link = createLink('productplan', 'ajaxGetProductplans', 'productID=' + productID + '&branch=' + branch);
- $('#planIdBox').load(link);
- }
- /**
- * Load executions of product.
- *
- * @param int $productID
- * @access public
- * @return void
- */
- function loadProductExecutions(productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(typeof(oldExecutionID) == 'undefined') oldExecutionID = 0;
- link = createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&executionID=' + oldExecutionID + '&branch=' + branch);
- $('#executionIdBox').load(link);
- }
- /**
- * load assignedTo and stories of module.
- *
- * @access public
- * @return void
- */
- function loadModuleRelated()
- {
- moduleID = $('#module').val();
- productID = $('#product').val();
- setAssignedTo(moduleID, productID);
- setStories(moduleID, productID);
- }
- /**
- * Set the assignedTo field.
- *
- * @access public
- * @return void
- */
- function setAssignedTo(moduleID, productID)
- {
- if(typeof(productID) == 'undefined') productID = $('#product').val();
- if(typeof(moduleID) == 'undefined') moduleID = $('#module').val();
- link = createLink('bug', 'ajaxGetModuleOwner', 'moduleID=' + moduleID + '&productID=' + productID);
- $.get(link, function(owner)
- {
- owner = JSON.parse(owner);
- var account = owner[0];
- var realName = owner[1];
- var isExist = false;
- var count = $('#assignedTo').find('option').length;
- for(var i = 0; i < count; i++)
- {
- if($('#assignedTo').get(0).options[i].value == account)
- {
- isExist = true;
- break;
- }
- }
- if(!isExist && account)
- {
- option = "<option title='" + realName + "' value='" + account + "'>" + realName + "</option>";
- $("#assignedTo").append(option);
- }
- $('#assignedTo').val(account);
- });
- }
- /**
- * Load execution related bugs and tasks.
- *
- * @param int $executionID
- * @access public
- * @return void
- */
- function loadExecutionRelated(executionID)
- {
- if(executionID)
- {
- loadExecutionTasks(executionID);
- loadExecutionStories(executionID);
- loadExecutionBuilds(executionID);
- loadAssignedTo(executionID);
- }
- else
- {
- $('#taskIdBox').innerHTML = '<select id="task"></select>'; // Reset the task.
- loadProductStories($('#product').val());
- loadProductBuilds($('#product').val());
- }
- }
- /**
- *Load all builds of one execution or product.
- *
- * @access public
- * @return void
- */
- function loadAllBuilds(that)
- {
- productID = $('#product').val();
- executionID = $('#execution').val();
- if(page == 'edit') buildBox = $(that).parent().prev().filter('span').attr('id');
- if(executionID)
- {
- loadAllExecutionBuilds(executionID, productID);
- }
- else
- {
- loadAllProductBuilds(productID);
- }
- }
- /**
- * Load all builds of the execution.
- *
- * @param int $executionID
- * @param int $productID
- * @access public
- * @return void
- */
- function loadAllExecutionBuilds(executionID, productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(page == 'create')
- {
- oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0;
- link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&needCreate=true&type=all');
- $('#buildBox').load(link, function(){ notice();});
- }
- if(page == 'edit')
- {
- if(buildBox == 'openedBuildBox')
- {
- link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&needCreate=true&type=all');
- $('#openedBuildBox').load(link);
- }
- if(buildBox == 'resolvedBuildBox')
- {
- link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&needCreate=true&type=all');
- $('#resolvedBuildBox').load(link);
- }
- }
- }
- /**
- * Load all builds of the product.
- *
- * @param int $productID
- * @access public
- * @return void
- */
- function loadAllProductBuilds(productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(page == 'create')
- {
- oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0;
- link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&type=all');
- $('#buildBox').load(link, function(){ notice();});
- }
- if(page == 'edit')
- {
- if(buildBox == 'openedBuildBox')
- {
- link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&type=all');
- $('#openedBuildBox').load(link);
- }
- if(buildBox == 'resolvedBuildBox')
- {
- link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&type=all');
- $('#resolvedBuildBox').load(link);
- }
- }
- }
- /**
- * Load product stories
- *
- * @param int $productID
- * @access public
- * @return void
- */
- function loadProductStories(productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(typeof(oldStoryID) == 'undefined') oldStoryID = 0;
- link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleId=0&storyID=' + oldStoryID);
- $('#storyIdBox').load(link);
- }
- /**
- * Load product builds.
- *
- * @param productID $productID
- * @access public
- * @return void
- */
- function loadProductBuilds(productID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(typeof(oldOpenedBuild) == 'undefined') oldOpenedBuild = 0;
- link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch);
- if(page == 'create')
- {
- $('#buildBox').load(link, function(){ notice();});
- }
- else
- {
- $('#openedBuildBox').load(link);
- link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=' + branch);
- $('#resolvedBuildBox').load(link);
- }
- }
- /**
- * Load execution tasks.
- *
- * @param executionID $executionID
- * @access public
- * @return void
- */
- function loadExecutionTasks(executionID)
- {
- link = createLink('task', 'ajaxGetExecutionTasks', 'executionID=' + executionID + '&taskID=' + oldTaskID);
- $('#taskIdBox').load(link);
- }
- /**
- * Load execution stories.
- *
- * @param executionID $executionID
- * @access public
- * @return void
- */
- function loadExecutionStories(executionID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(typeof(oldStoryID) == 'undefined') oldStoryID = 0;
- link = createLink('story', 'ajaxGetExecutionStories', 'executionID=' + executionID + '&productID=' + $('#product').val() + '&branch=' + branch + '&moduleID=0&storyID=' + oldStoryID);
- $('#storyIdBox').load(link);
- }
- /**
- * Load builds of a execution.
- *
- * @param int $executionID
- * @access public
- * @return void
- */
- function loadExecutionBuilds(executionID)
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- productID = $('#product').val();
- if(page == 'create') oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0;
- if(page == 'create')
- {
- link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + "&branch=" + branch + "&index=0&needCreate=true");
- $('#buildBox').load(link, function(){ notice();});
- }
- else
- {
- link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch);
- $('#openedBuildBox').load(link);
- link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=' + branch);
- $('#resolvedBuildBox').load(link);
- }
- }
- /**
- * Set story field.
- *
- * @param moduleID $moduleID
- * @param productID $productID
- * @access public
- * @return void
- */
- function setStories(moduleID, productID)
- {
- var branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID);
- $.get(link, function(stories)
- {
- if(!stories) stories = '<select id="story" name="story" class="form-control"></select>';
- $('#story').replaceWith(stories);
- });
- }
- /**
- * Load team members of the execution as assignedTo list.
- *
- * @param int $executionID
- * @access public
- * @return void
- */
- function loadAssignedTo(executionID)
- {
- link = createLink('bug', 'ajaxLoadAssignedTo', 'executionID=' + executionID + '&selectedUser=' + $('#assignedTo').val());
- $('#assignedToBox').load(link);
- }
- /**
- * notice for create build.
- *
- * @access public
- * @return void
- */
- function notice()
- {
- $('#buildBoxActions').empty().hide();
- if($('#openedBuild').find('option').length < 1)
- {
- var html = '';
- if($('#execution').val() == '')
- {
- branch = $('#branch').val();
- if(typeof(branch) == 'undefined') branch = 0;
- html += '<a href="' + createLink('release', 'create', 'productID=' + $('#product').val() + '&branch=' + branch) + '" target="_blank" style="padding-right:5px">' + createRelease + '</a> ';
- html += '<a href="javascript:loadProductBuilds(' + $('#product').val() + ')">' + refresh + '</a>';
- }
- else
- {
- html += '<a href="' + createLink('build', 'create','executionID=' + $('#execution').val()) + '" target="_blank" style="padding-right:5px">' + createBuild + '</a> ';
- html += '<a href="javascript:loadExecutionBuilds(' + $('#execution').val() + ')">' + refresh + '</a>';
- }
- var $bba = $('#buildBoxActions');
- if($bba.length)
- {
- $bba.html(html);
- $bba.show();
- }
- else
- {
- if($('#buildBox').closest('tr').find('td').length > 1)
- {
- $('#buildBox').closest('td').next().attr('id', 'buildBoxActions');
- $('#buildBox').closest('td').next().html(html);
- }
- else
- {
- html = "<td id='buildBoxActions'>" + html + '</td>';
- $('#buildBox').closest('td').after(html);
- }
- }
- }
- }
- /**
- * Set duplicate.
- *
- * @param string $resolution
- * @access public
- * @return void
- */
- function setDuplicate(resolution)
- {
- if(resolution == 'duplicate')
- {
- $('#duplicateBugBox').removeClass('hidden');
- }
- else
- {
- $('#duplicateBugBox').addClass('hidden');
- }
- }
- $(function()
- {
- if($('#execution').val()) loadExecutionRelated($('#execution').val());
- });
|