From f37ca78f619ce45ce5508c2a9230abde41aa06c8 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 10 Nov 2022 10:07:26 +0800 Subject: [PATCH] * Add actions of program list. --- config/config.php | 4 ++ config/zentaopms.php | 2 +- module/common/view/header.lite.html.php | 1 - module/program/config.php | 31 +++++++-- module/program/model.php | 18 ++++++ zin/wg/dtable/v1.php | 84 ++++++++++++++++++++----- 6 files changed, 118 insertions(+), 22 deletions(-) diff --git a/config/config.php b/config/config.php index 6429afecfa..ecded65fd6 100644 --- a/config/config.php +++ b/config/config.php @@ -179,6 +179,10 @@ if(file_exists($myConfig)) include $myConfig; $zentaopmsConfig = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'zentaopms.php'; if(file_exists($zentaopmsConfig)) include $zentaopmsConfig; +/* 数据表格操作配置文件。dtable actions settings. */ +$actionsMapConfig = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'actionsmap.php'; +if(file_exists($actionsMapConfig)) include $actionsMapConfig; + /* API路由配置。API route settings. */ $routesConfig = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'routes.php'; if(file_exists($routesConfig)) include $routesConfig; diff --git a/config/zentaopms.php b/config/zentaopms.php index 713d636b8c..dc8a08ec04 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -412,4 +412,4 @@ $config->maxPriValue = '256'; $config->importWhiteList = array('user', 'task', 'story', 'bug', 'testcase', 'feedback', 'ticket'); $config->dtable = new stdclass(); -$config->dtable->colVars = array('width', 'type', 'flex', 'fixed', 'sortType', 'checkbox', 'nestedToggle', 'iconRender', 'statusMap'); +$config->dtable->colVars = array('width', 'type', 'flex', 'fixed', 'sortType', 'checkbox', 'nestedToggle', 'statusMap', 'actionsMap'); diff --git a/module/common/view/header.lite.html.php b/module/common/view/header.lite.html.php index 7b42abb762..932c8f84cb 100644 --- a/module/common/view/header.lite.html.php +++ b/module/common/view/header.lite.html.php @@ -44,7 +44,6 @@ $commonLang = array('zh-cn', 'zh-tw', 'en', 'fr', 'de'); if(defined('ZUI3')) { - js::import('https://zui.cyy.oop.cc/dist/zui-custom/zui-custom.js'); js::import('https://zui.cyy.oop.cc/dist/zui-custom/zui-custom.umd.cjs'); js::import('https://unpkg.com/htmx.org@1.8.2'); } diff --git a/module/program/config.php b/module/program/config.php index 75c4f8197a..51e0e90647 100644 --- a/module/program/config.php +++ b/module/program/config.php @@ -61,7 +61,7 @@ $config->program->dtable->fieldList['name']['type'] = 'link'; $config->program->dtable->fieldList['name']['flex'] = 1; $config->program->dtable->fieldList['name']['nestedToggle'] = true; $config->program->dtable->fieldList['name']['checkbox'] = true; -//$config->program->dtable->fieldList['name']['iconRender'] = 'icon-cards-view text-gray'; +$config->program->dtable->fieldList['name']['iconRender'] = true; $config->program->dtable->fieldList['status']['name'] = 'status'; $config->program->dtable->fieldList['status']['title'] = $lang->program->status; @@ -99,8 +99,27 @@ $config->program->dtable->fieldList['progress']['title'] = $lang->program->progr $config->program->dtable->fieldList['progress']['width'] = 100; $config->program->dtable->fieldList['progress']['type'] = 'circleProgress'; -$config->program->dtable->fieldList['actions']['name'] = 'actions'; -$config->program->dtable->fieldList['actions']['title'] = $lang->actions; -$config->program->dtable->fieldList['actions']['width'] = 160; -$config->program->dtable->fieldList['actions']['type'] = 'html'; -$config->program->dtable->fieldList['actions']['fixed'] = 'right'; +$config->program->dtable->fieldList['actions']['name'] = 'actions'; +$config->program->dtable->fieldList['actions']['title'] = $lang->actions; +$config->program->dtable->fieldList['actions']['width'] = 160; +$config->program->dtable->fieldList['actions']['type'] = 'actions'; +$config->program->dtable->fieldList['actions']['fixed'] = 'right'; +$config->program->dtable->fieldList['actions']['module'] = 'program'; + +global $app; +$app->loadLang('project'); +$config->program->actionsMap['normal'] = array('start', 'suspend', 'close', 'activate', 'edit', 'create', 'delete', 'team', 'group'); +$config->program->actionsMap['other'] = array('start', 'suspend', 'close', 'activate'); +$config->program->actionsMap['more'] = array('link', 'whitelist', 'delete'); +$config->program->actionsMap['hint']['create'] = $lang->program->children; +$config->program->actionsMap['hint']['delete'] = $lang->delete; +$config->program->actionsMap['hint']['team'] = $lang->project->team; +$config->program->actionsMap['hint']['group'] = $lang->project->group; +$config->program->actionsmap['text']['start'] = $lang->program->start; +$config->program->actionsmap['text']['suspend'] = $lang->program->suspend; +$config->program->actionsmap['text']['close'] = $lang->close; +$config->program->actionsmap['text']['activate'] = $lang->program->activate; +$config->program->actionsMap['text']['delete'] = $lang->delete; +$config->program->actionsmap['text']['link'] = $lang->project->manageProducts; +$config->program->actionsmap['text']['whitelist'] = $lang->project->whitelist; +$config->program->actionsMap['text']['delete'] = $lang->delete; diff --git a/module/program/model.php b/module/program/model.php index 9d81cc706e..bb272fbc64 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1614,6 +1614,7 @@ class programModel extends model $row->parent = $program->parent ? $program->parent : ''; $row->asParent = $program->type == 'program'; $row->type = $program->type; + $row->model = $program->model; $row->name = $program->name; $row->status = $program->status; $row->PM = empty($manager) ? '' : $manager->realname; @@ -1622,7 +1623,24 @@ class programModel extends model $row->begin = $program->begin; $row->end = $program->end == LONG_TIME ? $this->lang->program->longTime : $program->end; $row->progress = isset($progressList[$program->id]) ? round($progressList[$program->id]) : 0; + $row->actions = $this->buildActions($program); return $row; } + + public function buildActions($program) + { + $actions = array(); + if($program->type == 'program' && strpos(",{$this->app->user->view->programs},", ",$program->id,") !== false) + { + if($program->status == 'wait' || $program->status == 'suspended') $actions[] = 'start'; + if($program->status == 'doing') $actions[] = 'close'; + if($program->status == 'closed') $actions[] = 'activate'; + if(common::hasPriv('program', 'suspend') || (common::hasPriv('program', 'close') && $program->status != 'doing') || (common::hasPriv('program', 'activate') && $program->status != 'closed')) + { + $actions[] = 'other'; + } + } + return $actions; + } } diff --git a/zin/wg/dtable/v1.php b/zin/wg/dtable/v1.php index ed776eda68..606d50f7c2 100644 --- a/zin/wg/dtable/v1.php +++ b/zin/wg/dtable/v1.php @@ -116,19 +116,6 @@ class column extends wg return $this; } - /** - * Set column icon. - * - * @param string $icon - * @access public - * @return object - */ - public function iconRender($icon) - { - $this->iconRender = $icon; - return $this; - } - /** * Set status list. * @@ -141,6 +128,51 @@ class column extends wg $this->statusMap = $statusList; return $this; } + + /** + * Set actions list. + * + * @param string $module + * @access public + * @return object + */ + public function actionsMap($module) + { + global $config, $lang; + $actionsMap = new stdclass(); + $actionsList = $config->$module->actionsMap; + foreach($actionsList as $actionType => $actions) + { + if($actionType == 'normal') + { + foreach($actions as $action) + { + $actionsMap->$action = new stdclass(); + $actionsMap->$action->icon = $config->actionsMap->icon->$action; + } + } + elseif($actionType == 'other' or $actionType == 'more') + { + $actionsMap->$actionType = new stdclass(); + $actionsMap->$actionType = $config->actionsMap->$actionType; + + $actionsMap->$actionType->hint = $lang->more; + + $items = array(); + foreach($actions as $action) + { + $item = new stdclass(); + $item->name = $action; + $item->icon = $config->actionsMap->icon; + $items[] = $item; + } + $actionsMap->$actionType->dropdown->items = $items; + } + } + + $this->actionsMap = $actionsMap; + return $this; + } } class dtable @@ -224,13 +256,18 @@ class dtable */ public function buildCols($fieldList) { + $index = 0; foreach($fieldList as $field) { $col = $this->col($field['name'], $field['title']); foreach($field as $attr => $value) { if(in_array($attr, $this->config->dtable->colVars)) $col->$attr($value); + if($field['name'] == 'actions' and $attr == 'module') $col->actionsMap($value); + if($attr == 'iconRender') $this->iconRender = $index; } + + $index ++; } } @@ -311,8 +348,27 @@ class dtable if(!empty($this->search)) $html .= $this->search; $html .= '
'; - $html .= ''; + $html .= ''; return $html; } + + public function setIconRender() + { + $html = 'columns[' . $this->iconRender . '].iconRender = iconRender;'; + $html .= <<