* Adjust program and project module.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
$(function()
|
||||
{
|
||||
$('input[name^="mine"]').click(function()
|
||||
$('input[name^="showClosed"]').click(function()
|
||||
{
|
||||
var mine = $(this).is(':checked') ? 1 : 0;
|
||||
$.cookie('mine', mine, {expires:config.cookieLife, path:config.webRoot});
|
||||
var showClosed = $(this).is(':checked') ? 1 : 0;
|
||||
$.cookie('showClosed', showClosed, {expires:config.cookieLife, path:config.webRoot});
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
$('input[name^="showClosed"]').click(function()
|
||||
{
|
||||
var showClosed = $(this).is(':checked') ? 1 : 0;
|
||||
$.cookie('showClosed', showClosed, {expires:config.cookieLife, path:config.webRoot});
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
@@ -1,53 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
$("select[name^='parents']").change(function()
|
||||
{
|
||||
var $this = $(this);
|
||||
var programID = $this.val();
|
||||
var projectID = $this.attr("data-id");
|
||||
var oldParent = $this.attr("data-parent");
|
||||
var title = changeProgram.replace('%s', $this.attr("data-name"));
|
||||
|
||||
/* Determine whether the project can change the program set. */
|
||||
link = createLink('program', 'ajaxCheckProduct', 'programID=' + programID + '&projectID=' + projectID);
|
||||
$.getJSON(link, function(data)
|
||||
{
|
||||
var changed = true;
|
||||
|
||||
if(data && data.result)
|
||||
{
|
||||
changed = confirm(data.message);
|
||||
}
|
||||
|
||||
if(data && !data.result)
|
||||
{
|
||||
$('#promptTable tbody tr').remove();
|
||||
$('.modal-title').text(title);
|
||||
for(var i in data.message)
|
||||
{
|
||||
var product = data.message[i];
|
||||
$('#promptTable').append("<tr><td><i class='icon icon-product'></i> <strong>" + product +"</strong> " + linkedProjectsTip +"</td></tr>");
|
||||
for(var j in data.multiLinkedProjects)
|
||||
{
|
||||
if(i == j)
|
||||
{
|
||||
html = ''
|
||||
for(k in data.multiLinkedProjects[j])
|
||||
{
|
||||
var project = data.multiLinkedProjects[j][k];
|
||||
html += "<p><i class='icon icon-project'></i> " + project +"</p>";
|
||||
}
|
||||
$('#promptTable').append("<tr><td style='padding-left:40px'>" + html + "</td></tr>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changed = false;
|
||||
$('#promptBox').modal({show: true});
|
||||
}
|
||||
|
||||
if(!changed) $this.val(oldParent).trigger("chosen:updated");
|
||||
$this.attr('data-parent', $this.val());
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
$('#PRJMine1').click(function()
|
||||
{
|
||||
var PRJMine = $(this).is(':checked') ? 1 : 0;
|
||||
$.cookie('PRJMine', PRJMine, {expires:config.cookieLife, path:config.webRoot});
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
$('#project' + programID).addClass('active');
|
||||
$(".tree .active").parent('li').addClass('active');
|
||||
@@ -1,238 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
$('#copyProjects a').click(function()
|
||||
{
|
||||
setCopyProject($(this).data('id'));
|
||||
$('#copyProjectModal').modal('hide')
|
||||
});
|
||||
|
||||
setAclList($("#parent").val());
|
||||
|
||||
if(typeof(currentPlanID) == 'undefined')
|
||||
{
|
||||
$('#productsBox select[id^="products"]').each(function()
|
||||
{
|
||||
var branchID = 0;
|
||||
if($(this).closest('.input-group').find('select[id^="branch"]').size() > 0)
|
||||
{
|
||||
var branchID = $(this).closest('.input-group').find('select[id^="branch"]').val();
|
||||
}
|
||||
loadPlans($(this), branchID);
|
||||
});
|
||||
}
|
||||
|
||||
$('[data-toggle="popover"]').popover();
|
||||
});
|
||||
|
||||
/**
|
||||
* Set parent program.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setParentProgram()
|
||||
{
|
||||
var parentProgram = $("#parent").val();
|
||||
location.href = createLink('program', 'PRJCreate', 'model=' + model + '&programID=' + parentProgram + '&from=' + from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set copy project.
|
||||
*
|
||||
* @param int $copyProjectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setCopyProject(copyProjectID)
|
||||
{
|
||||
location.href = createLink('program', 'PRJCreate', 'model=' + model + '&programID=' + programID + '&from=' + from + '©ProjectID=' + copyProjectID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new product.
|
||||
*
|
||||
* @param obj $obj
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function addNewProduct(obj)
|
||||
{
|
||||
if($(obj).attr('checked'))
|
||||
{
|
||||
$('#productName').removeAttr('disabled', true);
|
||||
$('#productName').closest('tr').removeClass('hidden');
|
||||
$('#plansBox .col-sm-4').find('select').attr('disabled', true).trigger("chosen:updated");
|
||||
$('#plansBox').closest('tr').addClass('hidden');
|
||||
$('#productsBox .col-sm-4 .input-group').find('select').attr('disabled', true).trigger("chosen:updated");
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#productName').attr('disabled', true);
|
||||
$('#productName').closest('tr').addClass('hidden');
|
||||
$('#plansBox .col-sm-4').find('select').removeAttr('disabled', true).trigger("chosen:updated");
|
||||
$('#plansBox').closest('tr').removeClass('hidden');
|
||||
$('#productsBox .col-sm-4 .input-group').find('select').removeAttr('disabled').trigger("chosen:updated");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set access control box.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setAclList(programID)
|
||||
{
|
||||
if(programID != 0)
|
||||
{
|
||||
$('.aclBox').html($('#PGMAcl').html());
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.aclBox').html($('#PRJAcl').html());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load branches.
|
||||
*
|
||||
* @param int $product
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadBranches(product)
|
||||
{
|
||||
$('#productsBox select').each(function()
|
||||
{
|
||||
var $product = $(product);
|
||||
if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id'))
|
||||
{
|
||||
alert(errorSameProducts);
|
||||
$product.val(0);
|
||||
$product.trigger("chosen:updated");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if($('#productsBox .input-group:last select:first').val() != 0)
|
||||
{
|
||||
var length = $('#productsBox .input-group').size();
|
||||
var $html = $('#productsBox .col-sm-4:last').html();
|
||||
$('#productsBox .col-sm-4:last').find('.input-group-addon').remove();
|
||||
$('#productsBox .row').append('<div class="col-sm-4">' + $html + '</div>');
|
||||
if($('#productsBox .input-group:last select').size() >= 2) $('#productsBox .input-group:last select:last').remove();
|
||||
$('#productsBox .input-group:last .chosen-container').remove();
|
||||
$('#productsBox .input-group:last select:first').attr('name', 'products[' + length + ']').attr('id', 'products' + length);
|
||||
$('#productsBox .input-group:last .chosen').chosen();
|
||||
|
||||
adjustProductBoxMargin();
|
||||
}
|
||||
|
||||
var $inputgroup = $(product).closest('.input-group');
|
||||
if($inputgroup.find('select').size() >= 2) $inputgroup.removeClass('has-branch').find('select:last').remove();
|
||||
if($inputgroup.find('.chosen-container').size() >= 2) $inputgroup.find('.chosen-container:last').remove();
|
||||
|
||||
var index = $inputgroup.find('select:first').attr('id').replace('products' , '');
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val()), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
$inputgroup.addClass('has-branch').append(data);
|
||||
$inputgroup.find('select:last').attr('name', 'branch[' + index + ']').attr('id', 'branch' + index).attr('onchange', "loadPlans('#products" + index + "', this.value)").chosen();
|
||||
}
|
||||
});
|
||||
|
||||
loadPlans(product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load plans.
|
||||
*
|
||||
* @param obj $product
|
||||
* @param int $branchID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadPlans(product, branchID)
|
||||
{
|
||||
if($('#plansBox').size() == 0) return false;
|
||||
|
||||
var productID = $(product).val();
|
||||
var branchID = typeof(branchID) == 'undefined' ? 0 : branchID;
|
||||
var index = $(product).attr('id').replace('products', '');
|
||||
|
||||
if(productID != 0)
|
||||
{
|
||||
if(typeof(planID) == 'undefined') planID = 0;
|
||||
planID = $("select#plans" + productID).val() != '' ? $("select#plans" + productID).val() : planID;
|
||||
$.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=' + branchID + '&planID=' + planID + '&fieldID&needCreate=&expired=' + ((config.currentMethod == 'create' || config.currentMethod == 'edit') ? 'unexpired' : '')), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
if($("div#plan" + index).size() == 0) $("#plansBox .row").append('<div class="col-sm-4" id="plan' + index + '"></div>');
|
||||
$("div#plan" + index).html(data).find('select').attr('name', 'plans[' + productID + ']').attr('id', 'plans' + productID).chosen();
|
||||
|
||||
adjustPlanBoxMargin();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust product box margin.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function adjustProductBoxMargin()
|
||||
{
|
||||
var productRows = Math.ceil($('#productsBox > .row > .col-sm-4').length / 3);
|
||||
if(productRows > 1)
|
||||
{
|
||||
for(i = 1; i <= productRows - 1; i++)
|
||||
{
|
||||
$('#productsBox .col-sm-4:lt(' + (i * 3) + ')').css('margin-bottom', '10px');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust plan box margin.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function adjustPlanBoxMargin()
|
||||
{
|
||||
var planRows = Math.ceil($('#plansBox > .row > .col-sm-4').length / 3);
|
||||
if(planRows > 1)
|
||||
{
|
||||
for(j = 1; j <= planRows - 1; j++)
|
||||
{
|
||||
$('#plansBox .col-sm-4:lt(' + (j * 3) + ')').css('margin-bottom', '10px');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fuzzy search projects by project name.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
$('#projectName').on('keyup', function()
|
||||
{
|
||||
var name = $(this).val();
|
||||
name = name.replace(/\s+/g, '');
|
||||
link = createLink('program', 'ajaxGetCopyProjects');
|
||||
$.post(link, {name: name, cpoyProjectID : copyProjectID}, function(data)
|
||||
{
|
||||
$('#copyProjects').html(data);
|
||||
$('#copyProjects a').click(function()
|
||||
{
|
||||
setCopyProject($(this).data('id'));
|
||||
$('#copyProjectModal').modal('hide');
|
||||
});
|
||||
})
|
||||
})
|
||||
@@ -1,86 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
$('#parent').change(function()
|
||||
{
|
||||
var programID = $(this).val();
|
||||
|
||||
/* Determine whether the project can change the program set. */
|
||||
link = createLink('program', 'ajaxCheckProduct', 'programID=' + programID + '&projectID=' + projectID);
|
||||
$.getJSON(link, function(data)
|
||||
{
|
||||
var changed = true;
|
||||
|
||||
if(data && data.result)
|
||||
{
|
||||
changed = confirm(data.message);
|
||||
if(changed)
|
||||
{
|
||||
$('#productsBox select').prop('disabled', true).trigger("chosen:updated");
|
||||
}
|
||||
}
|
||||
|
||||
if(data && !data.result)
|
||||
{
|
||||
$('#promptTable tbody tr').remove();
|
||||
for(var i in data.message)
|
||||
{
|
||||
var product = data.message[i];
|
||||
$('#promptTable').append("<tr><td><i class='icon icon-product'></i> <strong>" + product +"</strong> " + linkedProjectsTip +"</td></tr>");
|
||||
for(var j in data.multiLinkedProjects)
|
||||
{
|
||||
if(i == j)
|
||||
{
|
||||
html = ''
|
||||
for(k in data.multiLinkedProjects[j])
|
||||
{
|
||||
var project = data.multiLinkedProjects[j][k];
|
||||
html += "<p><i class='icon icon-project'></i> " + project +"</p>";
|
||||
}
|
||||
$('#promptTable').append("<tr><td style='padding-left:40px'>" + html + "</td></tr>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changed = false;
|
||||
$('#promptBox').modal({show: true});
|
||||
}
|
||||
|
||||
if(!changed) $("#parent").val(oldParent).trigger("chosen:updated");
|
||||
oldParent = $('#parent').val();
|
||||
});
|
||||
});
|
||||
|
||||
adjustProductBoxMargin();
|
||||
adjustPlanBoxMargin();
|
||||
|
||||
/* If the story of the product which linked the execution under the project, you don't allow to remove the product. */
|
||||
$("#productsBox select").each(function()
|
||||
{
|
||||
var isExisted = $.inArray($(this).attr('data-last'), unmodifiableProducts);
|
||||
if(isExisted != -1)
|
||||
{
|
||||
$(this).prop('disabled', true).trigger("chosen:updated");
|
||||
$(this).siblings('div').find('span').attr('title', tip);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Set aclList.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setAclList(programID)
|
||||
{
|
||||
if(programID != 0)
|
||||
{
|
||||
$('.aclBox').html($('#PGMAcl').html());
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.aclBox').html($('#PRJAcl').html());
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Set role when select an account.
|
||||
*
|
||||
* @param string $account
|
||||
* @param int $roleID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setRole(account, roleID)
|
||||
{
|
||||
role = roles[account]; // get role according the account.
|
||||
roleOBJ = $('#role' + roleID); // get role object.
|
||||
roleOBJ.val(role) // set the role.
|
||||
}
|
||||
|
||||
function addItem(obj)
|
||||
{
|
||||
var item = $('#addItem').html().replace(/%i%/g, i);
|
||||
$(obj).closest('tr').after('<tr class="addedItem">' + item + '</tr>');
|
||||
var accounts = $('#hours' + i).closest('tr').find('select:first')
|
||||
accounts.trigger('liszt:updated');
|
||||
accounts.chosen();
|
||||
i ++;
|
||||
}
|
||||
|
||||
function deleteItem(obj)
|
||||
{
|
||||
$(obj).closest('tr').remove();
|
||||
}
|
||||
|
||||
function setDeptUsers(obj)
|
||||
{
|
||||
dept = $(obj).val(); // Get dept ID.
|
||||
link = createLink('program', 'PRJManageMembers', 'projectID=' + projectID + '&dept=' + dept); // Create manageMembers link.
|
||||
location.href=link;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
$(function()
|
||||
{
|
||||
$('#productsBox input:checkbox').each(function()
|
||||
{
|
||||
var $cb = $(this);
|
||||
if($cb.prop('checked')) $cb.closest('.product').addClass('checked');
|
||||
});
|
||||
|
||||
$('#productsBox input:checkbox').change(function()
|
||||
{
|
||||
var $cb = $(this);
|
||||
$cb.closest('.product').toggleClass('checked', $cb.prop('checked'));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user