diff --git a/module/execution/control.php b/module/execution/control.php index 979cf14e39..63d138e45c 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3941,6 +3941,21 @@ class execution extends control $this->display(); } + /** + * 获取执行下拉列表用于切换不同的执行。 + * Drop menu page. + * + * @param int $executionID 已经打开的页面对应的执行ID + * @param string $module 链接里要访问的模块 + * @param string $method 链接里要访问的方法 + * @access public + * @return void + */ + public function ajaxGetDropMenuData(int $executionID, string $module, string $method) + { + $this->ajaxGetDropMenu($executionID, $module, $method, ''); + } + /** * Update order. * diff --git a/module/execution/ui/ajaxgetdropmenudata.html.php b/module/execution/ui/ajaxgetdropmenudata.html.php new file mode 100644 index 0000000000..79e6c3ab7f --- /dev/null +++ b/module/execution/ui/ajaxgetdropmenudata.html.php @@ -0,0 +1,87 @@ + + * @package execution + * @version $Id + * @link https://www.zentao.net + */ +namespace zin; + +/** + * 获取项目所属分组。 + * Get execution group. + * + * @param object $execution + * @return string + */ +$getExecutionGroup = function($execution): string +{ + global $app; + if($execution->status != 'done' and $execution->status != 'closed' and ($execution->PM == $app->user->account or isset($execution->teams[$app->user->account]))) return 'my'; + if($execution->status != 'done' and $execution->status != 'closed' and $execution->PM != $app->user->account and !isset($execution->teams[$app->user->account])) return 'other'; + if($execution->status == 'done' or $execution->status == 'closed') return 'closed'; +}; + +/** + * 定义每个分组下的选项数据列表。 + * Define the grouped data list. + */ +$data = array('my' => array(), 'other' => array(), 'closed' => array()); + +/* 处理分组数据。Process grouped data. */ +foreach($projectExecutions as $projectID => $executions) +{ + $projectItem = array(); + $projectItem['id'] = $projectID; + $projectItem['type'] = 'project'; + $projectItem['text'] = zget($projects, $projectID); + $projectItem['items'] = array(); + + foreach($executions as $index => $execution) + { + $group = $getExecutionGroup($execution); + + $item = array(); + $item['id'] = $execution->id; + $item['text'] = $execution->name; + $item['keys'] = zget(common::convert2Pinyin(array($execution->name)), $execution->name, ''); + + if(!isset($data[$group][$projectID])) $data[$group][$projectID] = $projectItem; + $data[$group][$projectID]['items'][] = $item; + } +} + +/* 将分组数据转换为索引数组。Format grouped data to indexed array. */ +foreach ($data as $key => $value) $data[$key] = array_values($value); + +/** + * 定义每个分组名称信息,包括可展开的已关闭分组。 + * Define every group name, include expanded group. + */ +$tabs = array(); +$tabs[] = array('name' => 'my', 'text' => $lang->execution->mine); +$tabs[] = array('name' => 'other', 'text' => $lang->execution->other); +$tabs[] = array('name' => 'closed', 'text' => $lang->execution->closedExecution); + +/** + * 定义最终的 JSON 数据。 + * Define the final json data. + */ +$json = array(); +$json['data'] = $data; +$json['tabs'] = $tabs; +$json['searchHint'] = $lang->searchAB; +$json['link'] = array('execution' => sprintf($link, '{id}')); +$json['labelMap'] = array('project' => $lang->project->common); +$json['expandName'] = 'closed'; +$json['itemType'] = 'execution'; + +/** + * 渲染 JSON 字符串并发送到客户端。 + * Render json data to string and send to client. + */ +renderJson($json); diff --git a/module/project/control.php b/module/project/control.php index f8fa91219c..611c5b2a08 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -157,6 +157,21 @@ class project extends control $this->display(); } + /** + * 设置1.5级项目下拉菜单。 + * Ajax get project drop menu for zui3. + * + * @param int $projectID + * @param string $module + * @param string $method + * @access public + * @return void + */ + public function ajaxGetDropMenuData(int $projectID, string $module, string $method) + { + $this->ajaxGetDropMenu($projectID, $module, $method); + } + /** * Ajax get projects. * diff --git a/module/project/ui/ajaxgetdropmenudata.html.php b/module/project/ui/ajaxgetdropmenudata.html.php new file mode 100644 index 0000000000..33284c21dd --- /dev/null +++ b/module/project/ui/ajaxgetdropmenudata.html.php @@ -0,0 +1,92 @@ + + * @package project + * @version $Id + * @link https://www.zentao.net + */ +namespace zin; + +/** + * 获取项目所属分组。 + * Get project group. + * + * @param object $project + * @return string + */ +$getProjectGroup = function($project): string +{ + global $app; + if($project->status != 'done' and $project->status != 'closed' and $project->PM == $app->user->account) return 'my'; + if($project->status != 'done' and $project->status != 'closed' and $project->PM != $app->user->account) return 'other'; + return 'closed'; +}; + +/** + * 定义每个分组下的选项数据列表。 + * Define the grouped data list. + */ +$data = array('my' => array(), 'other' => array(), 'closed' => array()); + +/* 处理分组数据。Process grouped data. */ +foreach($projects as $programID => $programProjects) +{ + $programID = isset($programs[$programID]) ? $programID : 0; + + $programItem = array(); + $programItem['id'] = $programID; + $programItem['type'] = 'program'; + $programItem['text'] = isset($programs[$programID]) ? zget($programs, $programID) : $lang->project->emptyProgram; + $programItem['items'] = array(); + + if(!$programID) $programItem['label'] = ''; + + foreach($programProjects as $index => $project) + { + $group = $getProjectGroup($project); + + $item = array(); + $item['id'] = $project->id; + $item['text'] = $project->name; + $item['icon'] = $project->model == 'scrum' ? 'sprint' : $project->model; + $item['keys'] = zget(common::convert2Pinyin(array($project->name)), $project->name, ''); + + if(!isset($data[$group][$programID])) $data[$group][$programID] = $programItem; + $data[$group][$programID]['items'][] = $item; + } +} + +/* 将分组数据转换为索引数组。Format grouped data to indexed array. */ +foreach ($data as $key => $value) $data[$key] = array_values($value); + +/** + * 定义每个分组名称信息,包括可展开的已关闭分组。 + * Define every group name, include expanded group. + */ +$tabs = array(); +$tabs[] = array('name' => 'my', 'text' => $lang->project->mine); +$tabs[] = array('name' => 'other', 'text' => $lang->project->other); +$tabs[] = array('name' => 'closed', 'text' => $lang->project->closedProject); + +/** + * 定义最终的 JSON 数据。 + * Define the final json data. + */ +$json = array(); +$json['data'] = $data; +$json['tabs'] = $tabs; +$json['searchHint'] = $lang->searchAB; +$json['link'] = array('project' => sprintf($link, '{id}')); +$json['labelMap'] = array('program' => $lang->program->common); +$json['expandName'] = 'closed'; +$json['itemType'] = 'project'; + +/** + * 渲染 JSON 字符串并发送到客户端。 + * Render json data to string and send to client. + */ +renderJson($json);