From e4b7c55620a2bfd34aadd65589131075141dd2fd Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 20 Aug 2020 16:24:17 +0800 Subject: [PATCH] * Finish task #7628. --- module/design/control.php | 137 ++++++++++++++++++++++------- module/design/css/browse.css | 3 + module/design/css/edit.css | 1 + module/design/js/common.js | 11 +++ module/design/js/view.js | 6 ++ module/design/model.php | 119 +++++++++++++++++-------- module/design/view/browse.html.php | 101 +++++++-------------- module/design/view/commit.html.php | 19 +++- module/design/view/create.html.php | 28 +++--- module/design/view/edit.html.php | 25 +++--- module/design/view/view.html.php | 58 ++++++------ 11 files changed, 307 insertions(+), 201 deletions(-) create mode 100644 module/design/css/browse.css create mode 100644 module/design/css/edit.css create mode 100644 module/design/js/view.js diff --git a/module/design/control.php b/module/design/control.php index 7b7f7eb40e..b2a29bbdf6 100644 --- a/module/design/control.php +++ b/module/design/control.php @@ -1,7 +1,29 @@ + * @package design + * @version $Id: control.php 5107 2013-07-12 01:46:12Z chencongzhi520@gmail.com $ + * @link http://www.zentao.net + */ class design extends control { - public function browse($productID = 0,$type = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + /** + * Browse designs. + * + * @param int $productID + * @param string $type + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function browse($productID = 0, $type = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode')); @@ -33,27 +55,38 @@ class design extends control $this->display(); } + /** + * Create a design. + * + * @param int $productID + * @param string $prevModule + * @param int $prevID + * @access public + * @return void + */ public function create($productID = 0, $prevModule = '', $prevID = 0) { + $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode')); + $this->design->setProductMenu($productID); if($_POST) { - $productID = $_POST['product']; + $productID = $this->post->product; $designID = $this->design->create(); - if($designID) + if(dao::isError()) { - $this->loadModel('action')->create('design', $designID, 'created'); - - $response['result'] = 'success'; - $response['message'] = $this->lang->saveSuccess; - $response['locate'] = $this->createLink('design', 'browse', "productID=$productID"); + $response['result'] = 'fail'; + $response['message'] = dao::getError(); $this->send($response); } - $response['result'] = 'fail'; - $response['message'] = dao::getError(); + $this->loadModel('action')->create('design', $designID, 'created'); + + $response['result'] = 'success'; + $response['message'] = $this->lang->saveSuccess; + $response['locate'] = $this->createLink('design', 'browse', "productID=$productID"); $this->send($response); } @@ -69,26 +102,40 @@ class design extends control $this->display(); } + /** + * View a design. + * + * @param int $designID + * @access public + * @return void + */ public function view($designID = 0) { - $data = $this->design->getById($designID); - $data->productName = $this->dao->findByID($data->product)->from(TABLE_PRODUCT)->fetch('name'); - $data->files = $this->loadModel('file')->getByObject('design', $designID); + $design = $this->design->getById($designID); + $design->productName = $this->dao->findByID($design->product)->from(TABLE_PRODUCT)->fetch('name'); + $design->files = $this->loadModel('file')->getByObject('design', $designID); - $relations = $this->loadModel('common')->getRelations('design', $data->id, 'commit'); - $data->commit = ''; - foreach($relations as $relation) $data->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID", '', true), "#$relation->BID", '', "class='iframe' data-width='80%' data-height='550'"); + $relations = $this->loadModel('common')->getRelations('design', $design->id, 'commit'); + $storyTitle = $this->dao->findByID($design->story)->from(TABLE_STORY)->fetch('title'); + $design->commit = ''; + if(!empty($_GET['onlybody'])) + { + foreach($relations as $relation) $design->commit .= " #$relation->BID"; + $design->story = $storyTitle; + } + else + { + foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID", '', true), "#$relation->BID", '', "class='iframe' data-width='80%' data-height='550'"); + $design->story = $storyTitle ? html::a($this->createLink('story', 'view', "id=$design->story"), $storyTitle) : ''; + } - $storyTitle = $this->dao->findByID($data->story)->from(TABLE_STORY)->fetch('title'); - $data->story = $storyTitle ? html::a($this->createLink('story', 'view', "id=$data->story"), $storyTitle) : ''; - - $actions = $this->loadModel('action')->getList('design', $data->id); + $actions = $this->loadModel('action')->getList('design', $design->id); $this->view->title = $this->lang->design->designView; $this->view->position[] = $this->lang->design->designView; - $this->view->productID = $data->product; - $this->view->data = $data; + $this->view->productID = $design->product; + $this->view->design = $design; $this->view->relations = $relations; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->actions = $actions; @@ -96,6 +143,13 @@ class design extends control $this->display(); } + /** + * Edit a design. + * + * @param int $designID + * @access public + * @return void + */ public function edit($designID = 0) { $design = $this->design->getByID($designID); @@ -105,13 +159,16 @@ class design extends control if($_POST) { $changes = $this->design->update($designID); - if($changes) + if(dao::isError()) { - $actionID = $this->loadModel('action')->create('design', $designID, 'changed'); - $this->action->logHistory($actionID, $changes); - + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + $this->send($response); } + $actionID = $this->loadModel('action')->create('design', $designID, 'changed'); + $this->action->logHistory($actionID, $changes); + $response['result'] = 'success'; $response['message'] = $this->lang->saveSuccess; $response['locate'] = $this->createLink('design', 'view', "id=$design->id"); @@ -129,18 +186,30 @@ class design extends control $this->display(); } + /** + * Commit a design. + * + * @param int $designID + * @param string $begin + * @param string $end + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ public function commit($designID, $begin = '', $end = '', $recTotal = 0, $recPerPage = 50, $pageID = 1) { $this->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); + $pager = new pager($recTotal, $recPerPage, $pageID); $program = $this->loadModel('project')->getByID($this->session->program); $begin = $begin ? date('Y-m-d', strtotime($begin)) : $program->begin; $end = $end ? date('Y-m-d', strtotime($end)) : helper::today(); - $repoID = $this->session->repoID; - $repo = $this->loadModel('repo')->getRepoByID($repoID); - $revisions = $this->repo->getCommits($repo, '', 'HEAD', '', $pager, $begin, $end); + $repoID = $this->session->repoID; + $repo = $this->loadModel('repo')->getRepoByID($repoID); + $revisions = $this->repo->getCommits($repo, '', 'HEAD', '', $pager, $begin, $end); if($_POST) { @@ -172,6 +241,14 @@ class design extends control $this->display(); } + /** + * Delete a design. + * + * @param int $designID + * @param string $confirm + * @access public + * @return void + */ public function delete($designID, $confirm = 'no') { if($confirm == 'no') diff --git a/module/design/css/browse.css b/module/design/css/browse.css new file mode 100644 index 0000000000..e86f93c99b --- /dev/null +++ b/module/design/css/browse.css @@ -0,0 +1,3 @@ +#featurebar{display:inline-block;} +.modal-dialog{width:70% !important} +table td{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;} diff --git a/module/design/css/edit.css b/module/design/css/edit.css new file mode 100644 index 0000000000..98893529a9 --- /dev/null +++ b/module/design/css/edit.css @@ -0,0 +1 @@ +.tabs .tab-pane .table{border: 1px solid #ddd; border-top: none} diff --git a/module/design/js/common.js b/module/design/js/common.js index 7005b0242f..228284b775 100644 --- a/module/design/js/common.js +++ b/module/design/js/common.js @@ -3,3 +3,14 @@ $(document).on('click', '.ajaxPager', function() $('#logBox').load($(this).attr('href')); return false; }) +$('#product').change(function() +{ + productID = $(this).val(); + var link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID); + $.post(link, function(data) + { + $('#story').replaceWith(data); + $('#story_chosen').remove(); + $('#story').chosen(); + }) +}) diff --git a/module/design/js/view.js b/module/design/js/view.js new file mode 100644 index 0000000000..829a9efbdc --- /dev/null +++ b/module/design/js/view.js @@ -0,0 +1,6 @@ +$('.main-actions').width($('.main-col').outerWidth()); +if(showAction == 'hidden') +{ + $('.main-actions').remove(); + $('.pull-left').children('a').remove(); +}; diff --git a/module/design/model.php b/module/design/model.php index 1e04ea5d05..741d78913a 100644 --- a/module/design/model.php +++ b/module/design/model.php @@ -1,6 +1,24 @@ + * @package design + * @version $Id: model.php 5079 2013-07-10 00:44:34Z chencongzhi520@gmail.com $ + * @link http://www.zentao.net + */ +?> +dao->insert(TABLE_DESIGN)->data($design)->autoCheck()->batchCheck('name,type', 'notempty')->exec(); if(!dao::isError()) - { + { $designID = $this->dao->lastInsertID(); $this->file->updateObjectID($this->post->uid, $designID, 'design'); $files = $this->file->saveUpload('design', $designID); @@ -30,11 +48,18 @@ class designModel extends model $this->dao->insert(TABLE_DESIGNSPEC)->data($spec)->exec(); return $designID; - } + } return false; } + /** + * Update a design. + * + * @param int $designID + * @access public + * @return bool + */ public function update($designID) { $oldDesign = $this->getByID($designID); @@ -57,7 +82,7 @@ class designModel extends model if($designChanged) { $design = $this->getByID($designID); - $version = $design->version + 1; + $version = $design->version + 1; $spec = new stdclass(); $spec->design = $designID; $spec->version = $version; @@ -70,16 +95,23 @@ class designModel extends model } return common::createChanges($oldDesign, $design); - } + } return false; } - + + /** + * LinkCommit a design. + * + * @param int $designID + * @access public + * @return void + */ public function linkCommit($designID) { $this->dao->delete()->from(TABLE_RELATION)->where('AType')->eq('design')->andWhere('AID')->eq($designID)->andWhere('BType')->eq('commit')->andWhere('relation')->eq('completedin')->exec(); $this->dao->delete()->from(TABLE_RELATION)->where('AType')->eq('commit')->andWhere('BID')->eq($designID)->andWhere('BType')->eq('design')->andWhere('relation')->eq('completedfrom')->exec(); - $revisions = $_POST['revision']; + $revisions = $_POST['revision']; foreach($revisions as $revision) { @@ -105,38 +137,15 @@ class designModel extends model } } - public function setFlowActionFields($module, $action) - { - $flow = $this->loadModel('workflow', 'flow')->getByModule($module); - $action = $this->loadModel('workflowaction', 'flow')->getByModuleAndAction($flow->module, $action); - $fields = $this->workflowaction->getFields($flow->module, $action->action); - - return array($flow, $action, $fields); - } - - public function setFlowChild($module, $action, $fields, $dataID = 0) - { - $this->loadModel('workflowlayout', 'flow'); - - $childFields = array(); - $childDatas = array(); - $childModules = $this->loadModel('workflow', 'flow')->getList($module, 'table'); - foreach($childModules as $childModule) - { - $key = 'sub_' . $childModule->module; - - if(isset($fields[$key]) && $fields[$key]->show) - { - $childFields[$key] = $this->workflowaction->getFields($childModule->module, $action); - $childDatas[$key] = $this->flow->getDataList($childModule, '', 0, $dataID); - } - } - - return array($childFields, $childDatas); - } - + /** + * SetProductMenu + * + * @param int $productID + * @access public + * @return void + */ public function setProductMenu($productID = 0) - { + { $programID = $this->session->program; $products = $this->loadModel('product')->getPairs($programID); $productID = in_array($productID, array_keys($products)) ? $productID : key($products); @@ -145,12 +154,27 @@ class designModel extends model $this->loadModel('product')->setMenu($products, $productID); } + /** + * GetByID + * + * @param int $designID + * @access public + * @return object + */ public function getByID($designID) { $design = $this->dao->select('*')->from(TABLE_DESIGN)->where('id')->eq($designID)->fetch(); return $this->loadModel('file')->replaceImgURL($design, 'desc'); } + /** + * GetDesignPairs + * + * @param int $productID + * @param string $type + * @access public + * @return object + */ public function getDesignPairs($productID = 0, $type = 'detailed') { $designs = $this->dao->select('id, name')->from(TABLE_DESIGN) @@ -158,13 +182,20 @@ class designModel extends model ->andWhere('deleted')->eq(0) ->andWhere('type')->eq($type) ->fetchPairs(); - foreach($designs as $id => $name) $designs[$id] = $id . ':' . $name; + foreach($designs as $id => $name) $designs[$id] = $id . ':' . $name; return $designs; } + /** + * GetAffectedScope + * + * @param int $design + * @access public + * @return object + */ public function getAffectedScope($design) - { + { /* Get affected tasks. */ $design->tasks = $this->dao->select('*')->from(TABLE_TASK) ->where('deleted')->eq(0) @@ -175,6 +206,16 @@ class designModel extends model return $design; } + /** + * GetList + * + * @param int $productID + * @param int $type + * @param int $orderBy + * @param int $pager + * @access public + * @return array + */ public function getList($productID, $type, $orderBy, $pager) { return $this->dao->select('*')->from(TABLE_DESIGN) diff --git a/module/design/view/browse.html.php b/module/design/view/browse.html.php index 91e63a28da..686f171887 100644 --- a/module/design/view/browse.html.php +++ b/module/design/view/browse.html.php @@ -1,32 +1,16 @@ - * @package flow - * @version $Id$ - * @link http://www.ranzhico.com + * @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com) + * @license ZPL (http://zpl.pub/page/zplv12.html) + * @author Chunsheng Wang + * @package design + * @version $Id: browse.html.php 5102 2013-07-12 00:59:54Z chencongzhi520@gmail.com $ + * @link http://www.zentao.net */ ?> -loadModel('common')->getRelations('design', $data->id, 'commit'); - $data->commit = ''; - foreach($relations as $relation) $data->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID", '', true), "#$relation->BID", '', "class='iframe' data-width='80%' data-height='550'"); - } -} -?> - - + {$pager->recTotal}"; - echo html::a(inlink('browse', "productID={$productID}&type=all"), "{$lang->design->typeList['all']}" . ($type == 'all' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'all' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink('browse', "productID={$productID}&type=HLDS"), "{$lang->design->typeList['HLDS']}" . ($type == 'HLDS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'HLDS' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink('browse', "productID={$productID}&type=DDS"), "{$lang->design->typeList['DDS']}" . ($type == 'DDS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'DDS' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink('browse', "productID={$productID}&type=DBDS"), "{$lang->design->typeList['DBDS']}" . ($type == 'DBDS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'DBDS' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink('browse', "productID={$productID}&type=ADS"), "{$lang->design->typeList['ADS']}" . ($type == 'ADS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'ADS' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink('browse', "productID={$productID}&type=all"), "{$lang->design->typeList['all']}" . ($type == 'all' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'all' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink('browse', "productID={$productID}&type=HLDS"), "{$lang->design->typeList['HLDS']}" . ($type == 'HLDS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'HLDS' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink('browse', "productID={$productID}&type=DDS"), "{$lang->design->typeList['DDS']}" . ($type == 'DDS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'DDS' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink('browse', "productID={$productID}&type=DBDS"), "{$lang->design->typeList['DBDS']}" . ($type == 'DBDS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'DBDS' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink('browse', "productID={$productID}&type=ADS"), "{$lang->design->typeList['ADS']}" . ($type == 'ADS' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'ADS' ? ' btn-active-text' : '') . "'"); ?>
- createLink('design', 'create', "productID=$productID&designID=0"), " {$lang->design->create}", '', "class='btn btn-primary'"); - ?> + createLink('design', 'create', "productID=$productID&designID=0"), " {$lang->design->create}", '', "class='btn btn-primary'");?>
-

design->noDesign;?>

+

design->noDesign;?>

@@ -61,34 +43,15 @@ js::set('showSubHeader', $showSubHeader); recTotal&recPerPage=$pager->recPerPage&pageID=$pager->pageID";?> - -
- idAB);?> - - - design->type);?> - - - design->name);?> - - - design->submission);?> - - - design->version);?> - - - design->createdBy);?> - - - design->createdDate);?> - - - design->assignedTo);?> - - - design->actions;?> - + idAB);?> + design->type);?> + design->name);?> + design->submission);?> + design->version);?> + design->createdBy);?> + design->createdDate);?> + design->assignedTo);?> + design->actions;?> @@ -103,21 +66,21 @@ js::set('showSubHeader', $showSubHeader); createdDate;?> assignedTo;?> - id}"; - common::printIcon('design', 'edit', $vars, $design, 'list', 'fork', '', '', '', '', '', $design->program); - common::printIcon('design', 'commit', $vars, $design, 'list', 'link', '', 'iframe showinonlybody', true); - common::printIcon('design', 'delete', $vars, $design, 'list', 'trash', 'hiddenwin', '', '', '', '', $design->program); - ?> + id}"; + common::printIcon('design', 'edit', $vars, $design, 'list', 'fork', '', '', '', '', '', $design->program); + common::printIcon('design', 'commit', $vars, $design, 'list', 'link', '', 'iframe showinonlybody', true); + common::printIcon('design', 'delete', $vars, $design, 'list', 'trash', 'hiddenwin', '', '', '', '', $design->program); + ?>
- + diff --git a/module/design/view/commit.html.php b/module/design/view/commit.html.php index edd4424200..1ee3f9c087 100644 --- a/module/design/view/commit.html.php +++ b/module/design/view/commit.html.php @@ -1,5 +1,16 @@ + + * @package design + * @version $Id: commit.html.php 4903 2013-06-26 05:32:59Z wyd621@gmail.com $ + * @link http://www.zentao.net + */ +?> -

@@ -9,9 +20,9 @@

method='post'> diff --git a/module/design/view/create.html.php b/module/design/view/create.html.php index 504da92c35..50b0332af7 100644 --- a/module/design/view/create.html.php +++ b/module/design/view/create.html.php @@ -1,3 +1,15 @@ + + * @package design + * @version $Id: create.html.php 4903 2013-06-26 05:32:59Z wyd621@gmail.com $ + * @link http://www.zentao.net + */ +?> - category == 'single'):?> - - + category == 'single') echo html::hidden('product', $productID);?> design->story;?> @@ -54,18 +64,6 @@ js::set('showSubHeader', $showSubHeader);
diff --git a/module/design/view/edit.html.php b/module/design/view/edit.html.php index 4878f0beea..8451e73528 100644 --- a/module/design/view/edit.html.php +++ b/module/design/view/edit.html.php @@ -1,10 +1,21 @@ + + * @package design + * @version $Id: edit.html.php 4903 2013-06-26 05:32:59Z wyd621@gmail.com $ + * @link http://www.zentao.net + */ +?> category == 'single' ? 'hidden' : 'show'; js::set('showSubHeader', $showSubHeader); ?> -
@@ -90,18 +101,6 @@ js::set('showSubHeader', $showSubHeader);
diff --git a/module/design/view/view.html.php b/module/design/view/view.html.php index 3926d89ba4..118b360d90 100644 --- a/module/design/view/view.html.php +++ b/module/design/view/view.html.php @@ -1,19 +1,23 @@ - commit = ''; - foreach($relations as $relation) $data->commit .= " #$relation->BID"; - $data->story = $storyTitle; -} +/** + * The view of design module of ZenTaoPMS. + * + * @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com) + * @license ZPL (http://zpl.pub/page/zplv12.html) + * @author Chunsheng Wang + * @package design + * @version $Id: view.html.php 4903 2013-06-26 05:32:59Z wyd621@gmail.com $ + * @link http://www.zentao.net + */ ?> + @@ -23,8 +27,8 @@ if(!empty($_GET['onlybody']))
design->desc;?>
- desc;?> - fetch('file', 'printFiles', array('files' => $data->files, 'fieldset' => 'true'));?> + desc;?> + fetch('file', 'printFiles', array('files' => $design->files, 'fieldset' => 'true'));?>
@@ -33,13 +37,13 @@ if(!empty($_GET['onlybody']))
session->designList);?>
";?> - deleted):?> + deleted):?> id", $data, 'button', 'link', '', 'iframe showinonlybody', true); - common::printIcon('design', 'edit', "designID=$data->id", $data, 'button', '', '', '', true); - common::printIcon('design', 'delete', "designID=$data->id", $data, 'button', 'trash', 'hiddenwin'); + common::printIcon('design', 'commit', "designID=$design->id", $design, 'button', 'link', '', 'iframe showinonlybody', true); + common::printIcon('design', 'edit', "designID=$design->id", $design, 'button', '', '', '', true); + common::printIcon('design', 'delete', "designID=$design->id", $design, 'button', 'trash', 'hiddenwin'); ?> - + @@ -49,39 +53,31 @@ if(!empty($_GET['onlybody'])) - + - + - + - + - + - +
design->type;?>design->typeList, $data->type);?>design->typeList, $design->type);?>
design->product;?>productName;?>productName;?>
design->story;?>story;?>story;?>
design->commit;?>commit;?>commit;?>
design->createdBy;?>createdBy);?>createdBy);?>
design->createdDate;?>createdDate;?>createdDate;?>
- - +