Merge remote-tracking branch 'origin/master'

This commit is contained in:
liuchenglong
2023-05-10 05:25:31 +00:00
10 changed files with 260 additions and 55 deletions
+25 -9
View File
@@ -37,8 +37,11 @@ class dom
public $buildList = null;
public $buildListInner = false;
/**
* Construct the dom object.
*
* @param wg $wg
* @param array $children
* @param array|string|object $selectors
@@ -120,6 +123,7 @@ class dom
{
return $this->wg->isMatch($selector);
}
/**
* Build the children dom list.
* @access public
@@ -127,7 +131,7 @@ class dom
*/
public function build()
{
if($this->buildList !== null) return $this->buildList;
if($this->buildList !== null && $this->buildListInner === $this->renderInner) return $this->buildList;
if(empty($this->selectors) && !empty($this->dataCommands))
{
@@ -144,7 +148,8 @@ class dom
if(!empty($this->selectors)) $list = static::filter($list, $this->selectors);
$this->buildList = $list;
$this->buildList = $list;
$this->buildListInner = $this->renderInner;
return $list;
}
@@ -226,7 +231,7 @@ class dom
{
foreach($this->dataCommands as $name => $command)
{
$output[] = array('name' => $name, 'data' => data($command));
$output[] = array('name' => $name, 'data' => data($command), 'type' => 'command');
}
}
@@ -324,6 +329,7 @@ class dom
/**
* Filter the dom list with selector.
*
* @param array $list
* @param object $selector
* @param array $filteredList
@@ -341,11 +347,13 @@ class dom
if($item->wg->isMatch($selector))
{
$item->renderInner = $selector->inner ?? false;
$item->renderType = $selector->type ?? null;
$item->dataGetters = $selector->data ?? null;
$filteredList[] = $item->wg->gid;
$results[] = $item;
$item->selector = $selector;
$item->renderInner = isset($selector->inner) ? $selector->inner : false;
$item->renderType = isset($selector->type) ? $selector->type : null;
$item->dataGetters = isset($selector->data) ? $selector->data : null;
$filteredList[] = $item->wg->gid;
$results[] = $item;
}
else
{
@@ -361,6 +369,14 @@ class dom
return $results;
}
/**
* Filter the dom list with selectors.
*
* @param array $domList
* @param array $selectors
* @access public
* @return array
*/
public static function filter(&$domList, $selectors)
{
if(empty($selectors)) return $domList;
@@ -370,7 +386,7 @@ class dom
foreach($selectors as $selector)
{
$results = static::filterList($domList, $selector, $filteredList);
if(!empty($results)) $list[$selector->name] = $results;
$list[$selector->name] = $results;
}
return $list;
+1 -1
View File
@@ -73,7 +73,7 @@ class pageBase extends wg
h::head
(
html($metas),
html("<title>$title</title>"),
h::title($title),
$this->block('headBefore'),
$zui ? h::importCss($config->zin->zuiPath . 'zui.zentao.css', set::id('zuiCSS')) : null,
$zui ? h::importJs($config->zin->zuiPath . 'zui.zentao.umd.cjs', set::id('zuiJS')) : null,
+111
View File
@@ -0,0 +1,111 @@
/**
* 计算两个时间的天数。
* Compute delta of two days.
*
* @param string date1
* @param string date2
* @access public
* @return int
*/
function computeDaysDelta(date1, date2)
{
date1 = convertStringToDate(date1);
date2 = convertStringToDate(date2);
delta = (date2 - date1) / (1000 * 60 * 60 * 24) + 1;
if(isNaN(delta)) return;
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
*/
function computeWorkDays(currentID)
{
isBactchEdit = false;
if(currentID)
{
index = currentID.replace('begins[', '');
index = index.replace('ends[', '');
index = index.replace(']', '');
if(!isNaN(index)) isBactchEdit = true;
}
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:radio[name='delta']:checked").val()) $("input:radio[name='delta']:checked").attr('checked', false);
if(endDate == longTime) $("#delta999").prop('checked', true);
}
if(beginDate && endDate)
{
if(isBactchEdit) $('#dayses\\[' + index + '\\]').val(computeDaysDelta(beginDate, endDate));
if(!isBactchEdit) $('#days').val(computeDaysDelta(beginDate, endDate));
}
else if($('input[checked="true"]').val())
{
computeEndDate();
}
outOfDateTip(isBactchEdit ? index : 0);
}
/**
* 计算并设置计划完成时间。
* Compute the end date for project.
*
* @param int delta
* @access public
* @return void
*/
function computeEndDate(delta)
{
beginDate = $('#begin').val();
if(!beginDate) return;
delta = parseInt(delta);
if(delta == 999)
{
$('#end').val(longTime).trigger('mousedown');
$('#daysBox').addClass('hidden');
$('#days').val(0).trigger('mousedown');
outOfDateTip();
return false;
}
$('#daysBox').removeClass('hidden');
beginDate = convertStringToDate(beginDate);
if((delta == 7 || delta == 14) && (beginDate.getDay() == 1))
{
delta = (weekend == 2) ? (delta - 2) : (delta - 1);
}
endDate = $.formatDate(beginDate.addDays(delta - 1), 'yyyy-MM-dd');
$('#end').val(endDate).datetimepicker('update').trigger('mousedown');
computeWorkDays();
$('#days').trigger('mousedown');
}
+27
View File
@@ -0,0 +1,27 @@
/**
* 处理项目类型改变的交互。
* Handle project type change style.
*
* @param string $type
* @access public
* @return void
*/
function changeType(type)
{
$('.project-type-1, .project-type-0').removeClass('primary-pale');
$('.project-type-' + type).addClass('primary-pale');
$('input[name=hasProduct]').val(type);
}
/**
* 设置计划结束时间。
* Set plan end date.
*
* @access public
* @return void
*/
function setDate()
{
const delta = $('input[name=delta]:checked').val();
computeEndDate(delta);
}
+5 -5
View File
@@ -1500,12 +1500,12 @@ class projectModel extends model
/* 更新项目的关联信息。*/
/* Update relation info of this project. */
$this->updateUserView($projectID, $project->acl); // 更新用户视图。
$this->updateShadowProduct($project, $oldProject); // 更新影子产品关联信息。
$this->updateWhitelist($project, $oldProject); // 更新关联的白名单列表
$this->updateProductStage($projectID, $oldProject->stageBy); // 更新关联的所有产品的阶段。
$this->updateUserView($projectID, $project->acl); // 更新用户视图。
$this->updateShadowProduct($project, $oldProject); // 更新影子产品关联信息。
$this->updateWhitelist($project, $oldProject); // 更新关联的白名单列表
$this->updateProductStage($projectID, $oldProject->stageBy); // 更新关联的所有产品的阶段。
$this->file->updateObjectID($this->post->uid, $projectID, 'project'); // 通过uid更新文件id。
$this->file->updateObjectID($this->post->uid, $projectID, 'project'); // 通过uid更新文件id。
if($oldProject->parent != $project->parent) $this->loadModel('program')->fixPath($projectID, $project->parent, $oldProject->path, $oldProject->grade); // 更新项目从属路径。
if(empty($oldProject->multiple) and $oldProject->model != 'waterfall') $this->loadModel('execution')->syncNoMultipleSprint($projectID); // 无迭代的非瀑布项目需要更新。
+32 -26
View File
@@ -90,8 +90,8 @@ formPanel
set::label($lang->project->code),
set::strong(true),
set::placeholder($lang->project->inputProjectCode)
) : NULL,
($model == 'waterfall') ? NULL : formGroup
) : null,
($model == 'waterfall') ? null : formGroup
(
set::width('1/2'),
set::name('multiple'),
@@ -99,7 +99,7 @@ formPanel
set::control(array('type' => 'radioList', 'inline' => true)),
set::items($lang->project->multipleList),
set::value($multiple),
empty($copyProjectID) ? NULL : formHidden('multiple', $multiple)
empty($copyProjectID) ? null : formHidden('multiple', $multiple)
),
formGroup
(
@@ -144,7 +144,7 @@ formPanel
'suffix' => $lang->project->tenThousandYuan,
'suffixWidth' => 60,
)),
$parentProgram ? NULL : formHidden('budgetUnit', $config->project->defaultCurrency)
$parentProgram ? null : formHidden('budgetUnit', $config->project->defaultCurrency)
),
formGroup
(
@@ -167,6 +167,7 @@ formPanel
(
set::name('begin'),
set::type('date'),
set('id', 'begin'),
set::value(date('Y-m-d')),
set::placeholder($lang->project->begin),
set::required(true),
@@ -177,6 +178,7 @@ formPanel
input
(
set::name('end'),
set('id', 'end'),
set::type('date'),
set::placeholder($lang->project->end),
set::required(true),
@@ -187,33 +189,37 @@ formPanel
),
formGroup
(
set::width('1/4'),
inputGroup
set::width('1/2'),
radioList
(
$lang->execution->days,
setClass('has-suffix'),
input
(
set::name('days'),
set::required(true),
),
div
(
setClass('input-control-suffix z-50'),
$lang->project->day
)
on::change('setDate'),
set::name('delta'),
set::inline(true),
set::items($lang->project->endList)
)
),
formGroup
),
formGroup
(
set::label($lang->project->days),
set::width('1/2'),
inputGroup
(
set::width('1/4'),
set::name('delta'),
set::control(array('type' => 'checkList', 'inline' => true)),
set::items(array('999' => $lang->project->endList['999']))
),
setClass('has-suffix'),
input
(
set::name('days'),
set::required(true),
),
div
(
setClass('input-control-suffix z-50'),
$lang->project->day
)
)
),
/* TODO handle !empty($products) */
$products ? NULL :
$products ? null :
formRow
(
formGroup
@@ -253,7 +259,7 @@ formPanel
select
(
set::name('plans[][]'),
set::items(NULL),
set::items(null),
set::multiple(false)
)
)
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/task.class.php';
zdTable('task')->config('task_checkhaschildren')->gen(12);
/**
title=taskModel->checkHasChildren();
timeout=0
cid=1
*/
$task = $tester->loadModel('task');
$parentTaskList = array(1, 2, 3);
$aloneTaskList = array(4, 5, 6);
$childTaskList = array(7, 8, 9, 10, 11, 12);
r($task->checkhaschildren($parentTaskList[0])) && p() && e('1'); // 测试任务1是否为父任务
r($task->checkhaschildren($parentTaskList[1])) && p() && e('1'); // 测试任务2是否为父任务
r($task->checkhaschildren($parentTaskList[2])) && p() && e('1'); // 测试任务3是否为父任务
r($task->checkhaschildren($aloneTaskList[0])) && p() && e('0'); // 测试任务4是否为父任务
r($task->checkhaschildren($aloneTaskList[1])) && p() && e('0'); // 测试任务5是否为父任务
r($task->checkhaschildren($aloneTaskList[2])) && p() && e('0'); // 测试任务6是否为父任务
r($task->checkhaschildren($childTaskList[0])) && p() && e('0'); // 测试任务7是否为父任务
r($task->checkhaschildren($childTaskList[1])) && p() && e('0'); // 测试任务8是否为父任务
r($task->checkhaschildren($childTaskList[2])) && p() && e('0'); // 测试任务9是否为父任务
r($task->checkhaschildren($childTaskList[3])) && p() && e('0'); // 测试任务10是否为父任务
r($task->checkhaschildren($childTaskList[4])) && p() && e('0'); // 测试任务11是否为父任务
r($task->checkhaschildren($childTaskList[5])) && p() && e('0'); // 测试任务12是否为父任务
@@ -0,0 +1,9 @@
---
title: zt_task
author: auto_checkhaschildren
version: "1.0"
fields:
- field: parent
range: "`-1`{3},0{3},1,2{2},3{3}"
...
+11 -10
View File
@@ -68,14 +68,15 @@ $thismonth = $todo->getListTest($typeList[4]) == $thisMonthNum ? '1' : '0';
$lastmonth = $todo->getListTest($typeList[5]) == $lastMonthNum ? '1' : '0';
$thisseason = $todo->getListTest($typeList[6]) == $thisSeasonNum ? '1' : '0';
r($thisweek) && p() && e('1'); // 获取type为thisweek 当前用户的代办数量
r($lastweek) && p() && e('1'); // 获取type为lastweek 当前用户的代办数量
r($thismonth) && p() && e('1'); // 获取type为thismonth 当前用户的代办数量
r($lastmonth) && p() && e('1'); // 获取type为lastmonth 当前用户的代办数量
r($thisweek) && p() && e('1'); // 获取type为thisweek 当前用户的待办数量
r($lastweek) && p() && e('1'); // 获取type为lastweek 当前用户的待办数量
r($thismonth) && p() && e('1'); // 获取type为thismonth 当前用户的待办数量
r($lastmonth) && p() && e('1'); // 获取type为lastmonth 当前用户的待办数量
r($thisseason) && p() && e('1'); // 获取type为thisseason 当前用户的待办数量
r($todo->getListTest($typeList[0])) && p() && e('1'); // 获取type为today 当前用户的代办数量
r($todo->getListTest($typeList[1])) && p() && e('2'); // 获取type为yesterday 当前用户的代办数量
r($todo->getListTest($typeList[7])) && p() && e('9'); // 获取type为thisyear 当前用户的代办数量
r($todo->getListTest($typeList[8])) && p() && e('0'); // 获取type为future 当前用户的代办数量
r($todo->getListTest($typeList[9])) && p() && e('9'); // 获取type为before 当前用户的代办数量
r($todo->getListTest($typeList[10])) && p() && e('0'); // 获取type为cycle 当前用户的代办数量
r($todo->getListTest($typeList[0])) && p() && e('1'); // 获取type为today 当前用户的待办数量
r($todo->getListTest($typeList[1])) && p() && e('2'); // 获取type为yesterday 当前用户的待办数量
r($todo->getListTest($typeList[7])) && p() && e('9'); // 获取type为thisyear 当前用户的待办数量
r($todo->getListTest($typeList[8])) && p() && e('0'); // 获取type为future 当前用户的待办数量
r($todo->getListTest($typeList[9])) && p() && e('9'); // 获取type为before 当前用户的待办数量
r($todo->getListTest($typeList[10])) && p() && e('0'); // 获取type为cycle 当前用户的待办数量
+4 -4
View File
@@ -304,7 +304,7 @@
function loadTable(url, id)
{
url = url || currentAppUrl;
id = id || $('.dtable').attr('id') || 'dtable';
id = id || $('.dtable').attr('id') || 'dtable';
if(!id) return;
fetchContent(url, 'table/#' + id + ':type=json&data=props,#featureBar>*', {id: '#' + id, target: '#' + id});
@@ -316,7 +316,7 @@
if (!selector && url.includes(' '))
{
const parts = url.split(' ', 2);
url = parts[0];
url = parts[0];
selector = parts[1];
}
if(DEBUG) console.log('[APP] ', 'load:', url);
@@ -442,8 +442,8 @@
if(!result.name.length)
{
if(result.id.length) result.name = result.id;
else if(result.tag) result.name = result.tag;
else result.name = selector;
else if(result.tag) result.name = result.tag;
else result.name = selector;
}
result.select = [result.tag, result.id.length ? '#' + result.id : '', result.class.length ? '.' + result.class.join('.') : ''].join('');