From 2b004653dcdd77697c9164e7680870972a40fc13 Mon Sep 17 00:00:00 2001 From: daitingting Date: Wed, 7 Jun 2023 06:19:02 +0000 Subject: [PATCH] * Refactor the audit view of my. --- framework/helper.class.php | 10 ++-- module/my/config.php | 7 +++ module/my/config/table.php | 36 ++++++++++++++ module/my/ui/audit.html.php | 99 +++++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 module/my/ui/audit.html.php diff --git a/framework/helper.class.php b/framework/helper.class.php index 7f367d1549..e3951d9d04 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -439,6 +439,8 @@ function formatTime(string|null $time, string $format = ''): string */ function initTableData($items, &$fieldList, $checkModel) { + if(!isset($fieldList['actions'])) return array(); + foreach($fieldList['actions']['menu'] as $actionMenu) { if(is_array($actionMenu)) @@ -484,7 +486,7 @@ function initTableData($items, &$fieldList, $checkModel) $action = $actions[0]; foreach($actions as $actionName) { - if($checkModel->isClickable($item, $actionName)) + if(!method_exists($checkModel, 'isClickable') || $checkModel->isClickable($item, $actionName)) { $action = $actionName; $break = true; @@ -492,7 +494,7 @@ function initTableData($items, &$fieldList, $checkModel) } if(!common::hasPriv($app->rawModule, $action)) continue; - if($checkModel->isClickable($item, $action)) + if(!method_exists($checkModel, 'isClickable') || $checkModel->isClickable($item, $action)) { $item->actions[] = array('name' => $action); } @@ -510,11 +512,11 @@ function initTableData($items, &$fieldList, $checkModel) $action = $actions[0]; foreach($actions as $actionName) { - if($checkModel->isClickable($item, $actionName)) $action = $actionName; + if(!method_exists($checkModel, 'isClickable') || $checkModel->isClickable($item, $actionName)) $action = $actionName; } if(!common::hasPriv('task', $action)) continue; - if($checkModel->isClickable($item, $action)) + if(!method_exists($checkModel, 'isClickable') || $checkModel->isClickable($item, $action)) { $item->actions[] = array('name' => $action); } diff --git a/module/my/config.php b/module/my/config.php index d354bd4dde..02d2049f5a 100644 --- a/module/my/config.php +++ b/module/my/config.php @@ -58,3 +58,10 @@ $config->my->todo->actionList['delete']['icon'] = 'trash'; $config->my->todo->actionList['delete']['text'] = $lang->todo->delete; $config->my->todo->actionList['delete']['hint'] = $lang->todo->delete; $config->my->todo->actionList['delete']['url'] = helper::createLink('todo', 'delete', 'todoID={id}&confirm=yes'); + +$config->my->audit = new stdclass(); +$config->my->audit->actionList = array(); +$config->my->audit->actionList['review']['icon'] = 'glasses'; +$config->my->audit->actionList['review']['text'] = $lang->review->common; +$config->my->audit->actionList['review']['hint'] = $lang->review->common; +$config->my->audit->actionList['review']['data-toggle'] = 'modal'; diff --git a/module/my/config/table.php b/module/my/config/table.php index f1c02e7c5f..8b6f0c7116 100644 --- a/module/my/config/table.php +++ b/module/my/config/table.php @@ -109,3 +109,39 @@ $config->my->requirement->dtable->fieldList['actions']['name'] = 'actions'; $config->my->requirement->dtable->fieldList['actions']['title'] = $lang->actions; $config->my->requirement->dtable->fieldList['actions']['type'] = 'actions'; $config->my->requirement->dtable->fieldList['actions']['sortType'] = false; + +$config->my->audit->dtable = new stdclass(); +$config->my->audit->dtable->fieldList['id']['name'] = 'id'; +$config->my->audit->dtable->fieldList['id']['title'] = $lang->idAB; +$config->my->audit->dtable->fieldList['id']['fixed'] = 'left'; + +$config->my->audit->dtable->fieldList['title']['name'] = 'title'; +$config->my->audit->dtable->fieldList['title']['title'] = $lang->my->auditField->title; +$config->my->audit->dtable->fieldList['title']['type'] = 'title'; +$config->my->audit->dtable->fieldList['title']['link'] = helper::createLink('story', 'view', "id={id}"); +$config->my->audit->dtable->fieldList['title']['fixed'] = 'left'; +$config->my->audit->dtable->fieldList['title']['data-toggle'] = 'modal'; + +$config->my->audit->dtable->fieldList['type']['name'] = 'type'; +$config->my->audit->dtable->fieldList['type']['title'] = $lang->my->auditField->type; +$config->my->audit->dtable->fieldList['type']['type'] = 'catetory'; + +$config->my->audit->dtable->fieldList['time']['name'] = 'time'; +$config->my->audit->dtable->fieldList['time']['title'] = $lang->my->auditField->time; +$config->my->audit->dtable->fieldList['time']['type'] = 'datetime'; + +$config->my->audit->dtable->fieldList['result']['name'] = 'result'; +$config->my->audit->dtable->fieldList['result']['title'] = $lang->my->auditField->result; +$config->my->audit->dtable->fieldList['result']['type'] = 'text'; + +$config->my->audit->dtable->fieldList['status']['name'] = 'status'; +$config->my->audit->dtable->fieldList['status']['title'] = $lang->my->auditField->status; +$config->my->audit->dtable->fieldList['status']['type'] = 'status'; + +$config->my->audit->dtable->fieldList['actions']['name'] = 'actions'; +$config->my->audit->dtable->fieldList['actions']['title'] = $lang->actions; +$config->my->audit->dtable->fieldList['actions']['type'] = 'actions'; +$config->my->audit->dtable->fieldList['actions']['sortType'] = false; +$config->my->audit->dtable->fieldList['actions']['fixed'] = 'right'; +$config->my->audit->dtable->fieldList['actions']['list'] = $config->my->audit->actionList; +$config->my->audit->dtable->fieldList['actions']['menu'] = array('review'); diff --git a/module/my/ui/audit.html.php b/module/my/ui/audit.html.php new file mode 100644 index 0000000000..39ac185f0b --- /dev/null +++ b/module/my/ui/audit.html.php @@ -0,0 +1,99 @@ + + * @package my + * @link https://www.zentao.net + */ +namespace zin; + +$rawMethod = $this->app->rawMethod; +if($rawMethod != 'audit') $lang->my->featureBar[$rawMethod] = $lang->my->featureBar[$rawMethod]['audit']; + +$linkParam = "browseType={key}¶m=&orderBy=time_desc"; +if($rawMethod == 'contribute') $linkParam = "mode=$mode&$linkParam"; + +featurebar +( + set::current($browseType), + set::linkParams($linkParam), +); + +if($rawMethod != 'audit') unset($config->my->audit->dtable->fieldList['actions']); +if($rawMethod == 'contribute') $config->my->audit->dtable->fieldList['title']['sortType'] = false; +if($rawMethod != 'contribute' || $browseType != 'reviewedbyme') unset($config->my->audit->dtable->fieldList['result']); + +foreach($reviewList as $review) +{ + $type = $review->type == 'prejectreview' ? 'review' : $review->type; + $isOAObject = strpos(",{$config->my->oaObjectType},", ",$type,") !== false ? true : false; + + if(isset($lang->{$review->type}->common)) $typeName = $lang->{$review->type}->common; + if($type == 'story') $typeName = $review->storyType == 'story' ? $lang->SRCommon : $lang->URCommon; + if($review->type == 'projectreview') $typeName = $lang->project->common; + if(isset($flows[$review->type])) $typeName = $flows[$review->type]; + + $statusList = array(); + if(isset($lang->$type->statusList)) $statusList = $lang->$type->statusList; + if($type == 'attend') $statusList = $lang->attend->reviewStatusList; + + if(!in_array($type, array('story', 'testcase', 'feedback', 'review')) && !$isOAObject) + { + if($rawMethod == 'audit') $statusList = $lang->approval->nodeList; + + if(isset($flows[$review->type]) && $rawMethod != 'audit') $statusList = $lang->approval->statusList; + } + + $review->type = $typeName; + $review->status = zget($statusList, $review->status, ''); + + if($rawMethod == 'contribute' && $browseType == 'reviewedbyme') + { + $reviewResultList = array(); + if(isset($lang->$type)) $reviewResultList = zget($lang->$type, 'reviewResultList', array()); + if($isOAObject) $reviewResultList = zget($lang->$type, 'reviewStatusList', array()); + + $review->result = zget($reviewResultList, $review->result); + } + + $module = $type; + $method = 'review'; + $params = "id=$review->id"; + + if($isOAObject) $method = 'view'; + if(!in_array($module, array('story', 'testcase', 'feedback'))) $method = 'approvalreview'; + + if($module == 'review') + { + $method = 'assess'; + $params .= "&from={$rawMethod}"; + + unset($config->my->audit->actionList['review']['data-toggle']); + } + + $config->my->audit->actionList['review']['url'] = createLink($module, 'view', "id={$review->id}"); +} + +$reviewList = initTableData($reviewList, $config->my->audit->dtable->fieldList, $this->my); + +$cols = array_values($config->my->audit->dtable->fieldList); +$data = array_values($reviewList); + +dtable +( + set::cols($cols), + set::data($data), + set::footPager + ( + usePager(), + set::page($pager->pageID), + set::recPerPage($pager->recPerPage), + set::recTotal($pager->recTotal), + set::linkCreator(helper::createLink('my', 'audit', "browseType={$browseType}¶m=&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={recPerPage}&page={page}")) + ), +); + +render();