* Refactor transfer model: processLinkStories method.
This commit is contained in:
@@ -392,7 +392,7 @@ class transferModel extends model
|
||||
{
|
||||
$multiple = '';
|
||||
$separator = $field == 'mailto' ? ',' : "\n";
|
||||
$multipleLsit = explode(',', $value);
|
||||
$multipleLsit = explode(',', (string) $value);
|
||||
|
||||
foreach($multipleLsit as $key => $tmpValue) $multipleLsit[$key] = zget($exportDatas[$field], $tmpValue);
|
||||
$multiple = implode($separator, $multipleLsit);
|
||||
@@ -533,40 +533,13 @@ class transferModel extends model
|
||||
/* Deal children datas and multiple tasks. */
|
||||
if($moduleDatas) $moduleDatas = $this->transferTao->updateChildDatas($moduleDatas);
|
||||
|
||||
/* 设置导出用户需求相关相关研发需求数据。*/
|
||||
/* Deal linkStories datas. */
|
||||
if($moduleDatas and isset($fieldList['linkStories'])) $moduleDatas = $this->updateLinkStories($moduleDatas);
|
||||
if($moduleDatas and isset($fieldList['linkStories'])) $moduleDatas = $this->transferTao->processLinkStories($moduleDatas);
|
||||
|
||||
return $moduleDatas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update LinkStories datas.
|
||||
*
|
||||
* @param array $stories
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function updateLinkStories($stories)
|
||||
{
|
||||
$productIDList = array();
|
||||
foreach($stories as $story) $productIDList[] = $story->product;
|
||||
$productIDList = array_unique($productIDList);
|
||||
|
||||
$storyDatas = end($stories);
|
||||
$lastType = $storyDatas->type;
|
||||
|
||||
if($storyDatas->type == 'requirement')
|
||||
{
|
||||
$stories = $this->loadModel('story')->mergePlanTitleAndChildren($productIDList, $stories, $lastType);
|
||||
}
|
||||
elseif($storyDatas->type == 'story')
|
||||
{
|
||||
return $stories;
|
||||
}
|
||||
|
||||
return $stories;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询数据。
|
||||
* Get query datas.
|
||||
|
||||
@@ -322,4 +322,27 @@ class transferTao extends transferModel
|
||||
|
||||
return $objectDatas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置导出用户需求相关相关研发需求数据。
|
||||
* Process LinkStories datas.
|
||||
*
|
||||
* @param array $stories
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function processLinkStories($stories)
|
||||
{
|
||||
$storyDatas = end($stories);
|
||||
$lastType = $storyDatas->type;
|
||||
if($storyDatas->type == 'story') return $stories;
|
||||
|
||||
/* 获取产品ID列表。*/
|
||||
/* Get product id list. */
|
||||
$productIDList = array();
|
||||
foreach($stories as $story) $productIDList[] = $story->product;
|
||||
$productIDList = array_unique($productIDList);
|
||||
|
||||
return $this->loadModel('story')->mergePlanTitleAndChildren($productIDList, $stories, $lastType);
|
||||
}
|
||||
}
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/transfer.class.php';
|
||||
|
||||
$productplan = zdTable('productplan');
|
||||
$productplan->title->range('计划1,计划2');
|
||||
$productplan->createdDate->range('`' . date('Y-m-d') . '`');
|
||||
$productplan->gen(2);
|
||||
|
||||
zdTable('story')->gen(20);
|
||||
$relation = zdTable('relation');
|
||||
$relation->AID->range('1,11,2,12,3,13,4,14,5,15,6,16,7,17,8,18,9,19');
|
||||
$relation->BID->range('11,1,12,2,13,3,14,4,15,5,16,6,17,7,18,8,19,9');
|
||||
$relation->gen(18);
|
||||
|
||||
$stories[12] = new stdclass();
|
||||
$stories[12]->id = 12;
|
||||
$stories[12]->parent = 0;
|
||||
$stories[12]->plan = '1';
|
||||
$stories[12]->type = 'story';
|
||||
$stories[12]->product = 1;
|
||||
$stories[13] = new stdclass();
|
||||
$stories[13]->id = 13;
|
||||
$stories[13]->parent = -1;
|
||||
$stories[13]->plan = '0';
|
||||
$stories[13]->type = 'requirement';
|
||||
$stories[13]->product = 4;
|
||||
$stories[14] = new stdclass();
|
||||
$stories[14]->id = 14;
|
||||
$stories[14]->parent = 13;
|
||||
$stories[14]->plan = '0';
|
||||
$stories[14]->type = 'story';
|
||||
$stories[14]->product = 4;
|
||||
$stories[15] = new stdclass();
|
||||
$stories[15]->id = 15;
|
||||
$stories[15]->parent = 11;
|
||||
$stories[15]->plan = '0';
|
||||
$stories[15]->product = 4;
|
||||
$stories[15]->type = 'requirement';
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 transfer->getCascadeList();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
global $tester;
|
||||
$transfer = $tester->loadModel('transfer');
|
||||
|
||||
r($transfer->processLinkStories($stories)) && p('12:planTitle') && e('计划1'); //查看planTitle字段。
|
||||
r($transfer->processLinkStories($stories)) && p('14:parentName') && e('用户需求13'); //查看parentName字段
|
||||
@@ -39,7 +39,7 @@ class transferTest
|
||||
switch ($module)
|
||||
{
|
||||
case 'story':
|
||||
$app->config->story->templateFields = 'product,branch,module,source,sourceNote,title,spec,verify,keywords,pri,estimate,reviewer';
|
||||
$app->config->story->templateFields = 'product,branch,module,source,sourceNote,title,spec,verify,keywords,pri,estimate,reviewer,linkStories';
|
||||
$app->config->story->listFields = 'product,branch,module,pri';
|
||||
$app->config->story->dtable->fieldList['product']['control'] = 'select';
|
||||
$app->config->story->dtable->fieldList['module']['control'] = 'multiple';
|
||||
|
||||
Reference in New Issue
Block a user