From 0f91511fe424d031130b1bb1864698950dc79e6c Mon Sep 17 00:00:00 2001
From: Yagami <976204163@qq.com>
Date: Thu, 20 Aug 2020 17:28:02 +0800
Subject: [PATCH] * Fix design details.
---
module/design/control.php | 79 +++++++++++++-----------------
module/design/js/view.js | 6 ---
module/design/lang/zh-cn.php | 4 +-
module/design/model.php | 32 +++++++++---
module/design/view/browse.html.php | 41 +++++++---------
module/design/view/create.html.php | 7 ---
module/design/view/edit.html.php | 7 ---
module/design/view/view.html.php | 63 ++++++++++++------------
module/group/lang/resource.php | 8 +--
9 files changed, 116 insertions(+), 131 deletions(-)
delete mode 100644 module/design/js/view.js
diff --git a/module/design/control.php b/module/design/control.php
index b2a29bbdf6..74e0554192 100644
--- a/module/design/control.php
+++ b/module/design/control.php
@@ -29,28 +29,27 @@ class design extends control
$this->design->setProductMenu($productID);
$product = $this->loadModel('product')->getById($productID);
- $project = $this->loadModel('project')->getById($product->program);
+ $program = $this->loadModel('project')->getById($product->program);
$this->app->session->set('designList', $this->app->getURI(true));
$this->app->loadClass('pager', $static = true);
if($this->app->getViewType() == 'mhtml') $recPerPager = 10;
- $pager = pager::init($recTotal, $recPerPage, $pageID);
+ $pager = pager::init($recTotal, $recPerPage, $pageID);
$designs = $this->design->getList($productID, $type, $orderBy, $pager);
- $this->view->title = $this->lang->design->browse;
- $this->view->position[] = $this->lang->design->browse;
+ $this->view->title = $this->lang->design->browse;
+ $this->view->position[] = $this->lang->design->browse;
- $this->view->designs = $designs;
- $this->view->type = $type;
- $this->view->recTotal = $recTotal;
- $this->view->recPerPage = $recPerPage;
- $this->view->pageID = $pageID;
- $this->view->orderBy = $orderBy;
- $this->view->productID = $productID;
- $this->view->program = $project;
- $this->view->pager = $pager;
+ $this->view->designs = $designs;
+ $this->view->type = $type;
+ $this->view->recTotal = $recTotal;
+ $this->view->recPerPage = $recPerPage;
+ $this->view->pageID = $pageID;
+ $this->view->orderBy = $orderBy;
+ $this->view->productID = $productID;
+ $this->view->pager = $pager;
$this->display();
}
@@ -67,14 +66,12 @@ class design extends control
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 = $this->post->product;
-
- $designID = $this->design->create();
+ $designID = $this->design->create();
if(dao::isError())
{
$response['result'] = 'fail';
@@ -93,11 +90,11 @@ class design extends control
$this->view->title = $this->lang->design->create;
$this->view->position[] = $this->lang->design->create;
- $this->view->users = $this->loadModel('user')->getPairs('noclosed');
- $this->view->stories = $this->loadModel('story')->getProductStoryPairs($productID);
- $this->view->products = $this->loadModel('product')->getPairs($this->session->program);
- $this->view->productID = $productID;
- $this->view->program = $this->loadModel('project')->getByID($this->session->program);
+ $this->view->users = $this->loadModel('user')->getPairs('noclosed');
+ $this->view->stories = $this->loadModel('story')->getProductStoryPairs($productID);
+ $this->view->products = $this->loadModel('product')->getPairs($this->session->program);
+ $this->view->productID = $productID;
+ $this->view->program = $this->loadModel('project')->getByID($this->session->program);
$this->display();
}
@@ -111,34 +108,16 @@ class design extends control
*/
public function view($designID = 0)
{
- $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', $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) : '';
- }
-
- $actions = $this->loadModel('action')->getList('design', $design->id);
+ $design = $this->design->getById($designID);
+ $this->design->setProductMenu($design->product);
$this->view->title = $this->lang->design->designView;
$this->view->position[] = $this->lang->design->designView;
- $this->view->productID = $design->product;
$this->view->design = $design;
- $this->view->relations = $relations;
+ $this->view->stories = $this->loadModel('story')->getProductStoryPairs($design->product);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
- $this->view->actions = $actions;
+ $this->view->actions = $this->loadModel('action')->getList('design', $design->id);
$this->display();
}
@@ -166,8 +145,11 @@ class design extends control
$this->send($response);
}
- $actionID = $this->loadModel('action')->create('design', $designID, 'changed');
- $this->action->logHistory($actionID, $changes);
+ if(!empty($changes))
+ {
+ $actionID = $this->loadModel('action')->create('design', $designID, 'changed');
+ $this->action->logHistory($actionID, $changes);
+ }
$response['result'] = 'success';
$response['message'] = $this->lang->saveSuccess;
@@ -241,6 +223,13 @@ class design extends control
$this->display();
}
+ public function revision($repoID)
+ {
+ $repo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('id')->eq($repoID)->fetch();
+ $repoURL = $this->createLink('repo', 'revision', "repoID=$repo->repo&revistion=$repo->revision");
+ header("location:" . $repoURL);
+ }
+
/**
* Delete a design.
*
diff --git a/module/design/js/view.js b/module/design/js/view.js
deleted file mode 100644
index 829a9efbdc..0000000000
--- a/module/design/js/view.js
+++ /dev/null
@@ -1,6 +0,0 @@
-$('.main-actions').width($('.main-col').outerWidth());
-if(showAction == 'hidden')
-{
- $('.main-actions').remove();
- $('.pull-left').children('a').remove();
-};
diff --git a/module/design/lang/zh-cn.php b/module/design/lang/zh-cn.php
index 78f3a669d2..15dda2b700 100644
--- a/module/design/lang/zh-cn.php
+++ b/module/design/lang/zh-cn.php
@@ -28,9 +28,9 @@ $lang->design->designView = '查看详情';
$lang->design->reviewObject = '评审对象';
$lang->design->createdBy = '由谁创建';
$lang->design->createdDate = '创建时间';
+$lang->design->basicInfo = '基本信息';
$lang->design->typeList = array();
-$lang->design->typeList['all'] = '所有';
$lang->design->typeList['HLDS'] = '概要设计';
$lang->design->typeList['DDS'] = '详细设计';
$lang->design->typeList['DBDS'] = '数据库设计';
@@ -44,3 +44,5 @@ $lang->design->rangeList = array();
$lang->design->rangeList['all'] = '全部记录';
$lang->design->rangeList['assign'] = '选中记录';
+$lang->design->featureBar['all'] = '所有';
+$lang->design->featureBar += $lang->design->typeList;
diff --git a/module/design/model.php b/module/design/model.php
index 741d78913a..d14bf74f0e 100644
--- a/module/design/model.php
+++ b/module/design/model.php
@@ -27,7 +27,7 @@ class designModel extends model
->add('createdDate', helper::now())
->add('program', $this->session->program)
->add('version', 1)
- ->remove('file,files,labels,children, toList')
+ ->remove('file,files,labels,children,toList')
->get();
$design = $this->loadModel('file')->processImgURL($design, 'desc', $this->post->uid);
@@ -67,7 +67,7 @@ class designModel extends model
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::now())
->stripTags($this->config->design->editor->edit['id'], $this->config->allowedTags)
- ->remove('file,files,labels,children, toList')
+ ->remove('file,files,labels,children,toList')
->get();
$design = $this->loadModel('file')->processImgURL($design, 'desc', $this->post->uid);
@@ -147,11 +147,12 @@ class designModel extends model
public function setProductMenu($productID = 0)
{
$programID = $this->session->program;
+ $program = $this->loadModel('project')->getByID($programID);
$products = $this->loadModel('product')->getPairs($programID);
$productID = in_array($productID, array_keys($products)) ? $productID : key($products);
$productID = $this->loadModel('product')->saveState($productID, $products);
- $this->loadModel('product')->setMenu($products, $productID);
+ if($program->category == 'multiple') $this->loadModel('product')->setMenu($products, $productID);
}
/**
@@ -164,7 +165,14 @@ class designModel extends model
public function getByID($designID)
{
$design = $this->dao->select('*')->from(TABLE_DESIGN)->where('id')->eq($designID)->fetch();
- return $this->loadModel('file')->replaceImgURL($design, 'desc');
+ $design->files = $this->loadModel('file')->getByObject('design', $designID);
+ $design->productName = $this->dao->findByID($design->product)->from(TABLE_PRODUCT)->fetch('name');
+
+
+ $design->commit = '';
+ $relations = $this->loadModel('common')->getRelations('design', $designID, 'commit');
+ foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID"), "#$relation->BID", '_blank');
+ return $this->loadModel('file')->replaceImgURL($design, 'desc');
}
/**
@@ -216,16 +224,24 @@ class designModel extends model
* @access public
* @return array
*/
- public function getList($productID, $type, $orderBy, $pager)
+ public function getList($productID, $type = 'all', $orderBy = 'id_desc', $pager = null)
{
- return $this->dao->select('*')->from(TABLE_DESIGN)
+ $designs = $this->dao->select('*')->from(TABLE_DESIGN)
->where('deleted')->eq(0)
->beginIF($this->session->program)->andWhere('program')->eq($this->session->program)->fi()
- ->beginIF(!$this->app->user->admin)->andWhere('product')->in($this->app->user->view->products)->fi()
- ->beginIF($type !='all')->andWhere('type')->in($type)->fi()
+ ->beginIF($type != 'all')->andWhere('type')->in($type)->fi()
->andWhere('product')->eq($productID)
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
+
+ foreach($designs as $id => $design)
+ {
+ $design->commit = '';
+ $relations = $this->loadModel('common')->getRelations('design', $id, 'commit');
+ foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID", '', true), "#$relation->BID", '_blank');
+ }
+
+ return $designs;
}
}
diff --git a/module/design/view/browse.html.php b/module/design/view/browse.html.php
index 686f171887..c6b8fc4a37 100644
--- a/module/design/view/browse.html.php
+++ b/module/design/view/browse.html.php
@@ -12,20 +12,15 @@
?>
-
-category == 'single' ? 'hidden' : 'show';
-js::set('showSubHeader', $showSubHeader);
-?>
{$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' : '') . "'");
+ foreach($lang->design->featureBar as $key => $label)
+ {
+ $active = $key == $type ? 'btn-active-text' : '';
+ $recTotalLabel = $key == $type ? " {$pager->recTotal}" : '';
+ echo html::a(inlink('browse', "productID={$productID}&type=$key"), "$label" . $recTotalLabel, '', "class='btn btn-link $active'");
+ }
?>