Merge branch 'zin_dev'

# Conflicts:
#	module/common/lang/zh-cn.php
#	module/product/lang/de.php
#	module/product/lang/en.php
#	module/product/lang/fr.php
#	module/product/lang/zh-cn.php
#	module/program/js/browse.js
#	module/program/lang/de.php
#	module/program/lang/en.php
#	module/program/lang/fr.php
#	module/program/lang/zh-cn.php
#	module/project/config.php
#	module/project/lang/de.php
#	module/project/lang/en.php
#	module/project/lang/fr.php
#	module/project/lang/zh-cn.php
#	module/search/view/buildform.html.php
#	module/task/control.php
This commit is contained in:
Hao Sun
2023-04-23 19:20:45 +08:00
196 changed files with 73923 additions and 354 deletions
+76 -51
View File
@@ -1,69 +1,94 @@
$(function()
{
var orderList = orderBy.split('_');
var orderField = orderList[0];
var orderType = orderList[1];
setTimeout(function()
{
$(document).find('.dtable-header div[data-col="' + orderField + '"] > a').addClass(orderType == 'asc' ? 'sort-up' : 'sort-down');
}, 100);
$('input#editProject1').click(function()
{
var editProject = $(this).is(':checked') ? 1 : 0;
$.cookie('editProject', editProject, {expires:config.cookieLife, path:config.webRoot});
showEditCheckbox(editProject);
dtableWithZentao.render({checkable: editProject});
});
if($.cookie('editProject') == 1) $('input#editProject1').prop('checked', 'true');
if($('input#editProject1').prop('checked')) showEditCheckbox(true);
$(document).on('click', ":checkbox[name^='projectIdList']", function()
{
var notCheckedLength = $(":checkbox[name^='projectIdList']:not(:checked)").length;
var checkedLength = $(":checkbox[name^='projectIdList']:checked").length;
if(checkedLength > 0) $('#programForm').addClass('has-row-checked');
if(notCheckedLength == 0) $('.table-footer #checkAll').prop('checked', true);
if(checkedLength == 0)
var isEditMode = $('input#editProject1').is(':checked');
var projectIdList = [];
dtableWithZentao.render({
checkable: isEditMode,
canRowCheckable(id)
{
$('.table-footer #checkAll').prop('checked', false);
$('#programForm').removeClass('has-row-checked');
}
var summary = checkedProjects.replace('%s', checkedLength);
if(cilentLang == "en" && checkedLength < 2) summary = summary.replace('items', 'item');
var statistic = "<div id='projectsSummary' class='table-statistic'>" + summary + "</div>";
if(checkedLength > 0)
{
$('#programSummary').addClass('hidden');
$('#projectsSummary').remove();
$('.editCheckbox').after(statistic);
}
else
{
$('#programSummary').removeClass('hidden');
$('#projectsSummary').addClass('hidden');
}
const rowInfo = this.getRowInfo(id);
return rowInfo.data?.type === 'project';
},
footToolbar: {
items: [
{size: 'sm', text: editLang, btnType: 'primary', className: 'edit-btn'},
],
},
footPager: {
items: [
{type: 'info', text: pagerLang.totalCountAB},
{type: 'size-menu', text: pagerLang.pageSizeAB},
{type: 'link', page: 'first', icon: 'icon-first-page', hint: pagerLang.firstPage},
{type: 'link', page: 'prev', icon: 'icon-angle-left', hint: pagerLang.previousPage},
{type: 'info', text: '{page}/{pageTotal}'},
{type: 'link', page: 'next', icon: 'icon-angle-right', hint: pagerLang.nextPage},
{type: 'link', page: 'last', icon: 'icon-last-page', hint: pagerLang.lastPage},
],
page: pageID,
recTotal: recTotal,
recPerPage: recPerPage,
linkCreator: pagerLink,
},
footer() {
const statistic = () => {
const checkedCount = this.getChecks().length;
const text = isEditMode && checkedCount ? checkedProjects.replace('%s', checkedCount) : programSummary;
projectIdList = this.getChecks();
return [{children: text, className: 'text-dark'}];
};
if (isEditMode) {
return [
'checkbox',
'toolbar',
statistic,
'flex',
'pager',
];
}
return [
statistic,
'flex',
'pager',
];
},
});
$(document).on('click', ".table-footer #checkAll", function()
$(document).on('click', ".dtable-footer .edit-btn.toolbar-item", function()
{
if($(this).prop('checked'))
{
$(":checkbox[name^='projectIdList']").prop('checked', true);
$('#programForm').addClass('has-row-checked');
var checkedLength = $(":checkbox[name^='projectIdList']:checked").length;
var summary = checkedProjects.replace('%s', checkedLength);
if(cilentLang == "en" && checkedLength < 2) summary = summary.replace('items', 'item');
var statistic = "<div id='projectsSummary' class='table-statistic'>" + summary + "</div>";
$('#programSummary').addClass('hidden');
$('#projectsSummary').remove();
$('.editCheckbox').after(statistic);
$(this).next('label').addClass('hover');
}
else
{
$(":checkbox[name^='projectIdList']").prop('checked', false);
$('#programForm').removeClass('has-row-checked');
$('#programSummary').removeClass('hidden');
$('#projectsSummary').addClass('hidden');
$(this).next('label').removeClass('hover');
}
var batchEditLink = createLink('project', 'batchEdit');
var tempform = document.createElement("form");
tempform.action = batchEditLink;
tempform.method = "post";
tempform.style.display = "none";
var opt = document.createElement("input");
opt.name = 'projectIdList';
opt.value = projectIdList;
tempform.appendChild(opt);
document.body.appendChild(tempform);
tempform.submit();
});
if(status == 'bySearch') $('.dtable-footer').hide();
/* Solve the problem that clicking the browser back button causes the checkbox to be selected by default. */
setTimeout(function()
{
+141
View File
@@ -0,0 +1,141 @@
window.onParentChange = (event) =>
{
const parentID = $(event.target).val();
const url = $.createLink('program', 'create', parentID ? ('parentProgramID=' + parentID) : '');
loadPage(url, '#budgetRow>*, #acl');
};
window.onBudgetChange = (event) =>
{
const $budget = $(event.target);
const currentBudget = $budget.val();
const budgetLeft = $budget.data('budget-left');
if(currentBudget > budgetLeft)
{
$('<div class="form-tip text-warning" id="budgetTip"></div>').text(lang.budgetOverrun + $budget.data('currency-symbol') + budgetLeft).append($('<a class="text-inherit ml-2 underline"></a>').text(lang.ignore).on('click', () => $('#budgetTip').remove())).appendTo($budget.closest('.form-group'));
}
};
window.onFutureChange = (event) =>
{
$('#budget,#budgetUnit').attr('disabled', $(event.target).prop('checked') ? 'disabled' : null);
$('#budgetTip').remove();
};
window.outOfDateTip = function()
{
console.warn('The method outOfDateTip is not implemented.');
};
/**
* Compute delta of two days.
*
* @param string date1
* @param string date2
* @access public
* @return int
*/
function computeDaysDelta(date1, date2)
{
date1 = zui.createDate(date1);
date2 = zui.createDate(date2);
const delta = (date2 - date1) / (1000 * 60 * 60 * 24) + 1;
let weekEnds = 0;
for(i = 0; i < delta; i++)
{
if((weekend == 2 && date1.getDay() == 6) || date1.getDay() == 0) weekEnds ++;
date1 = date1.valueOf();
date1 += 1000 * 60 * 60 * 24;
date1 = new Date(date1);
}
return delta - weekEnds;
}
/**
* Compute work days.
*
* @param string currentID
* @access public
* @return void
*/
window.computeWorkDays = function(currentID)
{
if(typeof currentID === 'object') currentID = $(currentID.target).val();
let isBactchEdit = false;
let index;
if(currentID)
{
index = currentID.replace('begins[', '');
index = index.replace('ends[', '');
index = index.replace(']', '');
if(!isNaN(index)) isBactchEdit = true;
}
let beginDate;
let endDate;
if(isBactchEdit)
{
beginDate = $('#begins\\[' + index + '\\]').val();
endDate = $('#ends\\[' + index + '\\]').val();
}
else
{
beginDate = $('#begin').val();
endDate = $('#end').val();
var begin = new Date(beginDate.replace(/-/g,"/"));
var end = new Date(endDate.replace(/-/g,"/"));
var time = end.getTime() - begin.getTime();
var days = parseInt(time / (1000 * 60 * 60 * 24)) + 1;
if(days != $('input[name="delta"]:checked').val()) $('input[name="delta"]:checked').attr('checked', false);
if(endDate == LONG_TIME) $('#delta999').prop('checked', true);
}
if(beginDate && endDate)
{
if(isBactchEdit) $('#dayses\\[' + index + '\\]').val(computeDaysDelta(beginDate, endDate));
else $('#days').val(computeDaysDelta(beginDate, endDate));
}
else if($('input[checked="true"]').val())
{
computeEndDate();
}
outOfDateTip();
};
/**
* Compute the end date for project.
*
* @param int $delta
* @access public
* @return void
*/
window.computeEndDate = function(delta)
{
delta = +$('input[name="delta"]:checked').val();
let beginDate = $('#begin').val();
if(!beginDate) return;
if(delta === 999)
{
$('#end').val(LONG_TIME);
outOfDateTip();
return false;
}
beginDate = zui.createDate(beginDate);
if((delta === 7 || delta === 14) && (beginDate.getDay() === 1))
{
delta = (weekend === 2) ? (delta - 2) : (delta - 1);
}
const endDate = zui.formatDate(beginDate.getTime() + ((delta - 1) * zui.TIME_DAY), 'yyyy-MM-dd');
$('#end').val(endDate);
computeWorkDays();
};
window.onAclChange = () =>
{
$('#whitelistRow').toggleClass('hidden', $('#acl_open').prop('checked'));
};
+29
View File
@@ -0,0 +1,29 @@
window.footerGenerator = function()
{
const count = this.layout.allRows.filter((x) => x.data.type === "product").length;
const statistic = summeryTpl.replace('%s', ' ' + count + ' ');
return [{children: statistic, className: "text-dark"}, "flex", "pager"];
}
window.renderCell = function(result, {col, row})
{
if(col.name === 'name')
{
if(row.data.postponed) result[result.length] = {html:'<span class="label size-sm circle danger-pale">' + langPostponed + '</span>', className:'flex items-end w-full', style:{flexDirection:"column"}};
return result;
}
if(col.name === 'budget')
{
result[0] = {html: '<div>' + row.data.budget + ' <span class="icon icon-exclamation-sign mr-2 text-danger"></span></div>', className:'flex items-end w-full items-end', style:{flexDirection:"column"}};
return result;
}
if(col.name === 'invested')
{
result[0] = {html: '<div>' + row.data.invested + ' <small class="text-gray">' + langManDay + '</small></div>', className:'flex items-end w-full items-end', style:{flexDirection:"column"}};
return result;
}
return result;
}