* Refactor mergeChartOption method.
This commit is contained in:
@@ -2063,13 +2063,14 @@ class taskModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 将默认图表设置与当前图表设置合并。
|
||||
* Merge the default chart settings and the settings of current chart.
|
||||
*
|
||||
* @param string $chartType
|
||||
* @param string $chartType
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function mergeChartOption($chartType)
|
||||
public function mergeChartOption(string $chartType)
|
||||
{
|
||||
$chartOption = $this->lang->task->report->$chartType;
|
||||
$commonOption = $this->lang->task->report->options;
|
||||
@@ -2082,7 +2083,8 @@ class taskModel extends model
|
||||
/* merge configuration */
|
||||
foreach($commonOption->graph as $key => $value)
|
||||
{
|
||||
if(!isset($chartOption->graph->$key)) $chartOption->graph->$key = $value;
|
||||
if(isset($chartOption->graph->$key)) continue;
|
||||
$chartOption->graph->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/task.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=taskModel->mergeChartOption();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
$chartTypeList = array('tasksPerExecution', 'tasksPerModule', 'tasksPerAssignedTo', 'tasksPerType', 'tasksPerPri', 'tasksPerStatus', 'tasksPerDeadline', 'tasksPerEstimate', 'tasksPerLeft', 'tasksPerConsumed', 'tasksPerFinishedBy', 'tasksPerClosedReason', 'finishedTasksPerDay');
|
||||
|
||||
$taskTester = new taskTest();
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[0])) && p('graph:xAxisName,caption') && e('迭代,按迭代任务数统计'); // 合并按迭代任务数统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[1])) && p('graph:xAxisName,caption') && e('模块,按模块任务数统计'); // 合并按模块任务数统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[2])) && p('graph:xAxisName,caption') && e('用户,按指派给统计'); // 合并按指派给统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[3])) && p('graph:xAxisName,caption') && e('类型,按任务类型统计'); // 合并按任务类型统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[4])) && p('graph:xAxisName,caption') && e('优先级,按优先级统计'); // 合并按优先级统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[5])) && p('graph:xAxisName,caption') && e('状态,按任务状态统计'); // 合并按任务状态统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[6])) && p('graph:xAxisName,caption') && e('日期,按截止日期统计'); // 合并按截止日期统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[7])) && p('graph:xAxisName,caption') && e('时间,按预计时间统计'); // 合并按预计时间统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[8])) && p('graph:xAxisName,caption') && e('时间,按剩余时间统计'); // 合并按剩余时间统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[9])) && p('graph:xAxisName,caption') && e('时间,按消耗时间统计'); // 合并按消耗时间统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[10])) && p('graph:xAxisName,caption') && e('用户,按由谁完成统计'); // 合并按由谁完成统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[11])) && p('graph:xAxisName,caption') && e('关闭原因,按关闭原因统计'); // 合并按关闭原因统计报表的配置
|
||||
r($taskTester->mergeChartOptionTest($chartTypeList[12])) && p('graph:xAxisName,caption') && e('日期,按每天完成统计'); // 合并按每天完成统计报表的配置
|
||||
@@ -1997,4 +1997,20 @@ class taskTest
|
||||
|
||||
return $this->objectModel->reportCondition();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将默认图表设置与当前图表设置合并。
|
||||
* Merge the default chart settings and the settings of current chart.
|
||||
*
|
||||
* @param string $chartType
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function mergeChartOptionTest(string $chartType): object
|
||||
{
|
||||
global $lang;
|
||||
$this->objectModel->mergeChartOption($chartType);
|
||||
|
||||
return $lang->task->report->$chartType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user