This commit is contained in:
liugang
2017-10-31 14:08:22 +08:00
11 changed files with 94 additions and 6 deletions
+1
View File
@@ -97,3 +97,4 @@ CREATE TABLE `zt_score` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES ('*/5', '*', '*', '*', '*', 'moduleName=webhook&methodName=asyncSend', '异步发送Webhook', 'zentao', 1, 'normal', '0000-00-00 00:00:00');
ALTER TABLE `zt_projectstory` ADD `order` smallint(6) unsigned NOT NULL;
+2
View File
@@ -485,6 +485,8 @@ class file extends control
if(empty($file) or !file_exists($file->realPath)) return false;
$mime = in_array($file->extension, $this->config->file->imageExtensions) ? "image/{$file->extension}" : $this->config->file->mimes['default'];
ob_end_clean();
header("Content-type: $mime");
$handle = fopen($file->realPath, "r");
+2
View File
@@ -181,6 +181,8 @@ class productModel extends model
{
if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getProduct();
$product = $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch();
if(!$product) return false;
return $this->loadModel('file')->replaceImgURL($product, 'desc');
}
+2
View File
@@ -55,7 +55,9 @@
</tr>
</thead>
<tbody>
<?php if($this->loadModel('file'));?>
<?php foreach($plans as $plan):?>
<?php $plan = $this->file->replaceImgURL($plan, 'desc');?>
<tr class='text-center'>
<td class='cell-id'>
<input type='checkbox' name='planIDList[<?php echo $plan->id;?>]' value='<?php echo $plan->id;?>' />
+27 -1
View File
@@ -530,7 +530,7 @@ class project extends control
* @access public
* @return void
*/
public function story($projectID = 0, $orderBy = '', $type = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1)
public function story($projectID = 0, $orderBy = 'order', $type = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1)
{
/* Load these models. */
$this->loadModel('story');
@@ -1991,6 +1991,32 @@ class project extends control
}
}
/**
* Story sort.
*
* @param int $projectID
* @access public
* @return void
*/
public function storySort($projectID)
{
$idList = explode(',', trim($this->post->storys, ','));
$orderBy = $this->post->orderBy;
$stories = $this->dao->select('story,`order`')->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id')
->where('t1.story')->in($idList)
->andWhere('t1.project')->eq($projectID)
->orderBy($orderBy)
->fetchPairs('order', 'story');
foreach($stories as $order => $id)
{
$newID = array_shift($idList);
if($id == $newID) continue;
$this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('story')->eq($newID)->andWhere('project')->eq($projectID)->exec();
}
}
/**
* All project.
*
+7
View File
@@ -2,6 +2,13 @@ $(function()
{
ajaxGetSearchForm();
$('#storyList').on('sort.sortable', function(e, data)
{
var list = '';
for(i = 0; i < data.list.length; i++) list += $(data.list[i]).attr('data-id') + ',';
$.post(createLink('project', 'storySort', 'projectID=' + projectID), {'storys' : list, 'orderBy' : orderBy});
});
fixedTfootAction('#projectStoryForm');
fixedTheadOfList('#storyList');
+15 -1
View File
@@ -1217,11 +1217,13 @@ class projectModel extends model
/* Link stories. */
$projectStories = $this->loadModel('story')->getProjectStoryPairs($projectID);
$lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order');
foreach($stories as $storyID)
{
if(!isset($projectStories[$storyID]))
{
$story = $this->dao->findById($storyID)->fields("$projectID as project, id as story, product, version")->from(TABLE_STORY)->fetch();
$story->order = ++$lastOrder;
$this->dao->insert(TABLE_PROJECTSTORY)->data($story)->exec();
}
}
@@ -1377,7 +1379,8 @@ class projectModel extends model
{
if($this->post->stories == false) return false;
$this->loadModel('action');
$versions = $this->loadModel('story')->getVersions($this->post->stories);
$versions = $this->loadModel('story')->getVersions($this->post->stories);
$lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order');
foreach($this->post->stories as $key => $storyID)
{
$productID = (int)$this->post->products[$storyID];
@@ -1386,6 +1389,7 @@ class projectModel extends model
$data->product = $productID;
$data->story = $storyID;
$data->version = $versions[$storyID];
$data->order = ++$lastOrder;
$this->dao->insert(TABLE_PROJECTSTORY)->data($data)->exec();
$this->story->setStage($storyID);
$this->action->create('story', $storyID, 'linked2project', '', $projectID);
@@ -1403,8 +1407,18 @@ class projectModel extends model
public function unlinkStory($projectID, $storyID)
{
$this->dao->delete()->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('story')->eq($storyID)->limit(1)->exec();
$order = 1;
$storys = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order')->fetchAll();
foreach($storys as $projectstory)
{
if($projectstory->order != $order) $this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('project')->eq($projectID)->andWhere('story')->eq($projectstory->story)->exec();
$order++;
}
$this->loadModel('story')->setStage($storyID);
$this->loadModel('action')->create('story', $storyID, 'unlinkedfromproject', '', $projectID);
$tasks = $this->dao->select('id')->from(TABLE_TASK)->where('story')->eq($storyID)->andWhere('project')->eq($projectID)->andWhere('status')->in('wait,doing')->fetchPairs('id');
$this->dao->update(TABLE_TASK)->set('status')->eq('cancel')->where('id')->in($tasks)->exec();
foreach($tasks as $taskID)
+13 -3
View File
@@ -12,6 +12,7 @@
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/tablesorter.html.php';?>
<?php include '../../common/view/sortable.html.php';?>
<?php js::set('moduleID', ($type == 'byModule' ? $param : 0));?>
<?php js::set('productID', ($type == 'byProduct' ? $param : 0));?>
<?php js::set('confirmUnlinkStory', $lang->project->confirmUnlinkStory)?>
@@ -55,6 +56,7 @@
<div class='main'>
<script>setTreeBox();</script>
<form method='post' id='projectStoryForm'>
<?php $canOrder = common::hasPriv('project', 'storySort');?>
<table class='table tablesorter table-condensed table-fixed table-selectable' id='storyList'>
<thead>
<tr class='colhead'>
@@ -71,9 +73,12 @@
<th title='<?php echo $lang->story->bugCount?>' class='w-30px'><?php echo $lang->story->bugCountAB;?></th>
<th title='<?php echo $lang->story->caseCount?>' class='w-30px'><?php echo $lang->story->caseCountAB;?></th>
<th class='w-110px {sorter:false}'> <?php echo $lang->actions;?></th>
<?php if($canOrder):?>
<th class='w-50px {sorter:false}'> <?php common::printOrderLink('order', $orderBy, $vars, $lang->project->updateOrder);?></th>
<?php endif;?>
</tr>
</thead>
<tbody>
<tbody id='storyTableList' class='sortable'>
<?php
$totalEstimate = 0;
$canBatchEdit = common::hasPriv('story', 'batchEdit');
@@ -84,7 +89,7 @@
$storyLink = $this->createLink('story', 'view', "storyID=$story->id&version=$story->version&from=project&param=$project->id");
$totalEstimate += $story->estimate;
?>
<tr class='text-center' id="story<?php echo $story->id?>">
<tr class='text-center' id="story<?php echo $story->id?>" data-id='<?php echo $story->id ?>' data-order='<?php echo $story->order ?>'>
<td class='cell-id'>
<?php if($canBatchEdit or $canBatchClose):?>
<input type='checkbox' name='storyIDList[<?php echo $story->id;?>]' value='<?php echo $story->id;?>' />
@@ -147,12 +152,15 @@
}
?>
</td>
<?php if($canOrder):?>
<td class='sort-handler'><i class='icon-move'></i></td>
<?php endif;?>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='12'>
<td colspan='<?php echo $canOrder ? 13 : 12;?>'>
<div class='table-actions clearfix'>
<?php
$storyInfo = sprintf($lang->project->productStories, inlink('linkStory', "project={$project->id}"));
@@ -193,4 +201,6 @@
</table>
</form>
</div>
<?php js::set('projectID', $project->id);?>
<?php js::set('orderBy', $orderBy)?>
<?php include '../../common/view/footer.html.php';?>
+2
View File
@@ -186,11 +186,13 @@ class storyModel extends model
if($projectID != 0 and $story->status != 'draft')
{
$lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order');
$this->dao->insert(TABLE_PROJECTSTORY)
->set('project')->eq($projectID)
->set('product')->eq($this->post->product)
->set('story')->eq($storyID)
->set('version')->eq(1)
->set('order')->eq($lastOrder + 1)
->exec();
}
+1 -1
View File
@@ -198,8 +198,8 @@ class testreportModel extends model
{
$foundBugs[$bug->id] = $bug;
if($bug->status == 'active' OR $bug->resolvedDate > "$end 23:59:59") $legacyBugs[$bug->id] = $bug;
if($bug->case and !empty($bug->testtask) and in_array($bug->testtask, $taskIdList)) $byCaseNum ++;
}
if($bug->case and !empty($bug->testtask) and in_array($bug->testtask, $taskIdList)) $byCaseNum ++;
}
$severityGroups = $statusGroups = $openedByGroups = $resolvedByGroups = $resolutionGroups = $moduleGroups = $typeGroups = array();
+22
View File
@@ -1793,4 +1793,26 @@ class upgradeModel extends model
return !dao::isError();
}
/**
* Init project story order.
*
* @access public
* @return bool
*/
public function initProjectStoryOrder()
{
$storyGroup = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->orderBy('story_asc')->fetchGroup('project', 'story');
foreach($storyGroup as $projectID => $stories)
{
$order = 1;
foreach($stories as $storyID => $projectStory)
{
$this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('project')->eq($projectID)->andWhere('story')->eq($storyID)->exec();
$order++;
}
}
return true;
}
}