From 51a786f73d1b4e226b39570ed2c01efb66969eb8 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 8 Nov 2022 14:33:53 +0800 Subject: [PATCH] * Finish task #73291. --- config/zentaopms.php | 2 +- module/program/config.php | 35 +++++++------ module/program/js/browse.js | 4 +- module/program/model.php | 83 ++++++++----------------------- module/program/ui/browse.html.php | 11 +--- zin/wg/dtable/v1.php | 53 ++++++++++++++++---- 6 files changed, 91 insertions(+), 97 deletions(-) diff --git a/config/zentaopms.php b/config/zentaopms.php index 5e918cbaf7..713d636b8c 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'); +$config->dtable->colVars = array('width', 'type', 'flex', 'fixed', 'sortType', 'checkbox', 'nestedToggle', 'iconRender', 'statusMap'); diff --git a/module/program/config.php b/module/program/config.php index a1fc04c086..75c4f8197a 100644 --- a/module/program/config.php +++ b/module/program/config.php @@ -55,36 +55,43 @@ $config->program->search['params']['closedDate'] = array('operator' => '=', global $lang; $config->program->dtable = new stdclass(); -$config->program->dtable->fieldList['name']['name'] = 'name'; -$config->program->dtable->fieldList['name']['title'] = $lang->nameAB; -$config->program->dtable->fieldList['name']['type'] = 'html'; -$config->program->dtable->fieldList['name']['flex'] = 1; +$config->program->dtable->fieldList['name']['name'] = 'name'; +$config->program->dtable->fieldList['name']['title'] = $lang->nameAB; +$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['status']['name'] = 'status'; -$config->program->dtable->fieldList['status']['title'] = $lang->program->status; -$config->program->dtable->fieldList['status']['width'] = 65; -$config->program->dtable->fieldList['status']['type'] = 'html'; -$config->program->dtable->fieldList['status']['sortType'] = 1; +$config->program->dtable->fieldList['status']['name'] = 'status'; +$config->program->dtable->fieldList['status']['title'] = $lang->program->status; +$config->program->dtable->fieldList['status']['width'] = 65; +$config->program->dtable->fieldList['status']['type'] = 'status'; +$config->program->dtable->fieldList['status']['sortType'] = 1; +$config->program->dtable->fieldList['status']['statusMap'] = $lang->program->statusList; -$config->program->dtable->fieldList['pm']['name'] = 'pm'; -$config->program->dtable->fieldList['pm']['title'] = $lang->program->PM; -$config->program->dtable->fieldList['pm']['width'] = 100; -$config->program->dtable->fieldList['pm']['type'] = 'html'; -$config->program->dtable->fieldList['pm']['sortType'] = 1; +$config->program->dtable->fieldList['PM']['name'] = 'PM'; +$config->program->dtable->fieldList['PM']['title'] = $lang->program->PM; +$config->program->dtable->fieldList['PM']['width'] = 100; +$config->program->dtable->fieldList['PM']['type'] = 'avatarBtn'; +$config->program->dtable->fieldList['PM']['sortType'] = 1; $config->program->dtable->fieldList['budget']['name'] = 'budget'; $config->program->dtable->fieldList['budget']['title'] = $lang->program->budget; $config->program->dtable->fieldList['budget']['width'] = 100; +$config->program->dtable->fieldList['budget']['type'] = 'format'; $config->program->dtable->fieldList['budget']['sortType'] = 1; $config->program->dtable->fieldList['begin']['name'] = 'begin'; $config->program->dtable->fieldList['begin']['title'] = $lang->program->begin; $config->program->dtable->fieldList['begin']['width'] = 100; +$config->program->dtable->fieldList['begin']['type'] = 'datetime'; $config->program->dtable->fieldList['begin']['sortType'] = 1; $config->program->dtable->fieldList['end']['name'] = 'end'; $config->program->dtable->fieldList['end']['title'] = $lang->program->end; $config->program->dtable->fieldList['end']['width'] = 100; +$config->program->dtable->fieldList['end']['type'] = 'datetime'; $config->program->dtable->fieldList['end']['sortType'] = 1; $config->program->dtable->fieldList['progress']['name'] = 'progress'; diff --git a/module/program/js/browse.js b/module/program/js/browse.js index b8d9613c40..e5ef6a94ae 100644 --- a/module/program/js/browse.js +++ b/module/program/js/browse.js @@ -4,10 +4,12 @@ $(function() { var editProject = $(this).is(':checked') ? 1 : 0; $.cookie('editProject', editProject, {expires:config.cookieLife, path:config.webRoot}); - showEditCheckbox(editProject); + dtableWithZentao.render({checkable: editProject}); }); if($.cookie('editProject') == 1) $('input#editProject1').prop('checked', 'true'); + dtableWithZentao.render({checkable: $('input#editProject1').is(':checked')}); + if($('input#editProject1').prop('checked')) { setTimeout(function() diff --git a/module/program/model.php b/module/program/model.php index 4d2bc7af88..9d81cc706e 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1595,75 +1595,34 @@ class programModel extends model } /** - * Build datatable cell. + * Build row data. * - * @param array $field - * @param object $program - * @param array $users - * @param array $userIdPairs + * @param string $program * @param array $PMList * @param array $progressList * @access public - * @return string + * @return object */ - public function buildCell($field, $program, $users, $usersAvatar, $userIdPairs, $PMList, $progressList) + public function buildRowData($program, $PMList, $progressList) { - $id = $field['name']; - $html = ''; - switch($id) - { - case 'name': - if($program->type == 'program') $icon = ' icon-program'; - if($program->type == 'project') $icon = ' icon-common icon-' . $program->model; - $class = $program->type == 'program' ? ' table-nest-toggle' : ''; - $html = ""; + $row = new stdclass(); - if($program->type == 'program') - { - $html .= ""; - $html .= ($this->app->user->admin or strpos(",{$this->app->user->view->programs},", ",$program->id,") !== false) ? html::a(helper::createLink('program', 'product', "programID=$program->id"), $program->name) : $program->name; - } - else - { - $projectType = $this->lang->project->{$program->model}; - $html .= html::a(helper::createLink('project', 'index', "projectID=$program->id", '', '', $program->id), $program->name, '', "class='text-ellipsis text-primary' title='{$program->name} ($projectType)'"); + $manager = isset($PMList[$program->PM]) ? $PMList[$program->PM] : ''; + $programBudget = $this->project->getBudgetWithUnit($program->budget); - if($program->status != 'done' and $program->status != 'closed' and $program->status != 'suspended') - { - $delay = helper::diffDate(helper::today(), $program->end); - if($delay > 0) $html .= "{$this->lang->project->statusList['delay']}"; - } - } - break; - case 'status': - $html = "" . zget($this->lang->project->statusList, $program->status, '') . ''; - break; - case 'pm': - if(!empty($program->PM)) - { - $userName = zget($users, $program->PM); - $html = html::smallAvatar(array('avatar' => $usersAvatar[$program->PM], 'account' => $program->PM, 'name' => $userName), (($program->type == 'program' and $program->grade == 1 )? 'avatar-circle avatar-top avatar-' : 'avatar-circle avatar-') . zget($userIdPairs, $program->PM)); - $userID = isset($PMList[$program->PM]) ? $PMList[$program->PM]->id : ''; - $html .= html::a(helper::createLink('user', 'profile', "userID=$userID", '', true), $userName, '', "title='{$userName}' data-toggle='modal' data-type='iframe' data-width='600'"); - } - break; - case 'budget': - $programBudget = $this->project->getBudgetWithUnit($program->budget); - $html = $program->budget != 0 ? zget($this->lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $this->lang->project->future; - break; - case 'begin': - $html = $program->begin; - break; - case 'end': - $html = $program->end == LONG_TIME ? $this->lang->program->longTime : $program->end; - break; - case 'progress': - $html = isset($progressList[$program->id]) ? round($progressList[$program->id]) : 0; - break; - case 'actions': - $html = $this->buildOperateMenu($program, 'browse'); - break; - } - return $html; + $row->id = $program->id; + $row->parent = $program->parent ? $program->parent : ''; + $row->asParent = $program->type == 'program'; + $row->type = $program->type; + $row->name = $program->name; + $row->status = $program->status; + $row->PM = empty($manager) ? '' : $manager->realname; + $row->PMAvatar = empty($manager) ? '' : $manager->avatar; + $row->budget = $program->budget != 0 ? zget($this->lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $this->lang->project->future; + $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; + + return $row; } } diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index 542fe2bb71..b462c6471e 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -42,16 +42,7 @@ $rows = array(); $this->loadModel('project'); foreach($programs as $program) { - $row = new stdclass(); - foreach($this->config->program->dtable->fieldList as $field) - { - $fieldName = $field['name']; - $row->$fieldName = $this->program->buildCell($field, $program, $users, $usersAvatar, $userIdPairs, $PMList, $progressList); - } - - $row->id = $program->id; - $row->parent = $program->parent; - $rows[] = $row; + $rows[] = $this->program->buildRowData($program, $PMList, $progressList); } $table->search($status, $moduleName); diff --git a/zin/wg/dtable/v1.php b/zin/wg/dtable/v1.php index 505ea66939..ed776eda68 100644 --- a/zin/wg/dtable/v1.php +++ b/zin/wg/dtable/v1.php @@ -93,12 +93,52 @@ class column extends wg /** * Set checkbox. * + * @param bool $value * @access public - * @return void + * @return object */ - public function checkbox() + public function checkbox($value) { - $this->checkbox = 1; + $this->checkbox = $value; + return $this; + } + + /** + * Set nested Toggle. + * + * @param bool $value + * @access public + * @return object + */ + public function nestedToggle($value) + { + $this->nestedToggle = $value; + return $this; + } + + /** + * Set column icon. + * + * @param string $icon + * @access public + * @return object + */ + public function iconRender($icon) + { + $this->iconRender = $icon; + return $this; + } + + /** + * Set status list. + * + * @param array $statusList + * @access public + * @return object + */ + public function statusMap($statusList) + { + $this->statusMap = $statusList; return $this; } } @@ -269,14 +309,9 @@ class dtable { $html = ''; if(!empty($this->search)) $html .= $this->search; - if(!empty($this->form)) $html .= $this->form; $html .= '
'; - - if(!empty($this->footer)) $html .= $this->footer; - if(!empty($this->form)) $html .= ''; - - $html .= ''; + $html .= ''; return $html; }