* Remove unused code, compatible story view.
This commit is contained in:
@@ -10,7 +10,6 @@ class linkedStoryList extends storyList
|
||||
protected static array $defineProps = array
|
||||
(
|
||||
'story' => '?object', // 被关联的需求。
|
||||
'relationType' => '?string', // 关联类型。
|
||||
'unlinkBtn' => '?array|bool', // 取消关联按钮。
|
||||
'unlinkStoryTip' => '?string', // 取消关联提示信息。
|
||||
'unlinkUrl' => '?string', // 取消关联需求链接
|
||||
@@ -42,21 +41,12 @@ class linkedStoryList extends storyList
|
||||
|
||||
protected null|array|bool $unlinkBtn = null;
|
||||
|
||||
protected ?string $relationType = null;
|
||||
|
||||
protected function beforeBuild()
|
||||
{
|
||||
$story = $this->prop('story');
|
||||
if(!$story) $story = data('story');
|
||||
if(!$story) return;
|
||||
|
||||
$relationType = $this->prop('relationType');
|
||||
if(!$relationType) $relationType = $story->type == 'story' ? 'requirement' : 'story';
|
||||
|
||||
$viewUrl = $this->prop('viewUrl');
|
||||
if($viewUrl === null) $viewUrl = hasPriv($relationType, 'view', null, "storyType=$relationType");
|
||||
if($viewUrl === true) $viewUrl = createLink('story', 'view', "id={id}&version=0¶m=0&storyType=$relationType");
|
||||
|
||||
$unlinkUrl = $this->prop('unlinkUrl');
|
||||
if($unlinkUrl === null) $unlinkUrl = createLink('story', 'linkStory', "storyID={$story->id}&type=remove&linkedID={id}&browseType=&queryID=0&storyType=$story->type");
|
||||
|
||||
@@ -64,11 +54,9 @@ class linkedStoryList extends storyList
|
||||
$unlinkBtn = $this->prop('unlinkBtn');
|
||||
if($unlinkBtn === null) $unlinkBtn = $canLink;
|
||||
|
||||
$this->story = $story;
|
||||
$this->relationType = $relationType;
|
||||
$this->viewUrl = $viewUrl;
|
||||
$this->unlinkUrl = $unlinkUrl;
|
||||
$this->unlinkBtn = $unlinkBtn;
|
||||
$this->story = $story;
|
||||
$this->unlinkUrl = $unlinkUrl;
|
||||
$this->unlinkBtn = $unlinkBtn;
|
||||
}
|
||||
|
||||
protected function getItem(object $story): array
|
||||
@@ -90,7 +78,7 @@ class linkedStoryList extends storyList
|
||||
'data-url' => str_replace('{id}', "$story->id", $this->unlinkUrl),
|
||||
'data-params' => 'event',
|
||||
'data-call' => 'unlinkStory',
|
||||
'hint' => $story->type == 'requirement' ? str_replace($lang->SRCommon, $lang->URCommon, $lang->story->unlinkStory) : $lang->story->unlinkStory
|
||||
'hint' => $lang->story->unlink
|
||||
);
|
||||
|
||||
if(is_array($unlinkBtn)) $btn = array_merge($btn, $unlinkBtn);
|
||||
|
||||
@@ -10,4 +10,28 @@ class storyList extends entitylist
|
||||
(
|
||||
'type' => 'story'
|
||||
);
|
||||
|
||||
protected function getItem(object $entity): array
|
||||
{
|
||||
$item = array
|
||||
(
|
||||
'innerClass' => 'px-0 relative group',
|
||||
'leading' => array(),
|
||||
'innerTag' => 'div',
|
||||
'titleClass' => 'flex gap-2 items-center flex-auto min-w-0',
|
||||
'textClass' => 'flex-none',
|
||||
'actionsClass' => $this->compact ? 'absolute top-0.5 right-0' : null,
|
||||
'hint' => $entity->title,
|
||||
'title' => span(setClass('text-clip'), $entity->title),
|
||||
'leading' => idLabel::create($entity->id)
|
||||
);
|
||||
|
||||
if(hasPriv($entity->type, 'view'))
|
||||
{
|
||||
$item['titleAttrs'] = array('data-toggle' => 'modal', 'data-size' => 'lg');
|
||||
$item['url'] = createLink($entity->type, 'view', "id=$entity->id");
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ class storyRelatedList extends relatedList
|
||||
$cases = $this->prop('cases', data('cases'));
|
||||
$builds = $this->prop('builds', data('builds'));
|
||||
$releases = $this->prop('releases', data('releases'));
|
||||
$storyProducts = $this->prop('storyProducts', data('storyProducts'));
|
||||
$linkedMRs = $this->prop('linkedMRs', data('linkedMRs'));
|
||||
$linkedCommits = $this->prop('linkedCommits', data('linkedCommits'));
|
||||
$data = array();
|
||||
@@ -90,26 +89,6 @@ class storyRelatedList extends relatedList
|
||||
);
|
||||
}
|
||||
|
||||
$data['story'] = array
|
||||
(
|
||||
'title' => $lang->story->linkStories,
|
||||
'items' => isset($story->linkStoryList) ? $story->linkStoryList : array(),
|
||||
'url' => false,
|
||||
'statusList' => $lang->story->statusList,
|
||||
'onRender' => function($item, $linkedStory) use($storyProducts, $story, $app)
|
||||
{
|
||||
$storyID = $linkedStory->id;
|
||||
$hasPriv = ($app->user->admin || str_contains(",{$app->user->view->products},", ",{$storyProducts[$story->id]},"));
|
||||
$item['url'] = $hasPriv ? createLink('story', 'view', "storyID=$storyID&version=0¶m=0&storyType=$story->type") : false;
|
||||
if($hasPriv)
|
||||
{
|
||||
$item['data-toggle'] = 'modal';
|
||||
$item['data-size'] = 'lg';
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
);
|
||||
|
||||
if($isStoryType && helper::hasFeature('devops'))
|
||||
{
|
||||
$data['mr'] = array
|
||||
|
||||
+1
-38
@@ -44,10 +44,7 @@ class storyModel extends model
|
||||
if($setImgSize) $story->spec = $this->file->setImgSize($story->spec);
|
||||
if($setImgSize) $story->verify = $this->file->setImgSize($story->verify);
|
||||
|
||||
/* Get relation story ID.*/
|
||||
$story->relationStoryID = $this->getRelationStoryID($story->id, $story->type);
|
||||
|
||||
$storyIdList = $storyID . ($story->relationStoryID ? "," . trim($story->relationStoryID, ',') : '') . ($story->twins ? "," . trim($story->twins, ',') : '');
|
||||
$storyIdList = $storyID . ($story->twins ? "," . trim($story->twins, ',') : '');
|
||||
$story->executions = $this->dao->select('t1.project, t2.id, t2.name, t2.status, t2.type, t2.multiple')->from(TABLE_PROJECTSTORY)->alias('t1')
|
||||
->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project = t2.id')
|
||||
->where('t2.type')->in('sprint,stage,kanban')
|
||||
@@ -85,22 +82,6 @@ class storyModel extends model
|
||||
$extraStories = array_unique($extraStories);
|
||||
if(!empty($extraStories)) $story->extraStories = $this->dao->select('id,title')->from(TABLE_STORY)->where('id')->in($extraStories)->fetchPairs();
|
||||
|
||||
$linkStoryField = $story->type == 'story' ? 'linkStories' : 'linkRequirements';
|
||||
if($story->{$linkStoryField})
|
||||
{
|
||||
$multiBranches = $this->loadModel('branch')->getAllPairs('noproductname');
|
||||
$multiProducts = $this->loadModel('product')->getMultiBranchPairs();
|
||||
$linkStoryList = $this->dao->select('id,title,product,branch,status')->from(TABLE_STORY)->where('id')->in($story->{$linkStoryField})->fetchAll('id');
|
||||
$linkStoryTitles = array();
|
||||
foreach($linkStoryList as $linkStory)
|
||||
{
|
||||
$linkStoryTitles[$linkStory->id] = $linkStory->title;
|
||||
if(isset($multiProducts[$linkStory->product]) && isset($multiBranches[$linkStory->branch])) $linkStory->branchName = $multiBranches[$linkStory->branch];
|
||||
}
|
||||
$story->linkStoryList = $linkStoryList;
|
||||
$story->linkStoryTitles = $linkStoryTitles;
|
||||
}
|
||||
|
||||
$story->openedDate = helper::isZeroDate($story->openedDate) ? '' : substr($story->openedDate, 0, 19);
|
||||
$story->assignedDate = helper::isZeroDate($story->assignedDate) ? '' : substr($story->assignedDate, 0, 19);
|
||||
$story->reviewedDate = helper::isZeroDate($story->reviewedDate) ? '' : substr($story->reviewedDate, 0, 19);
|
||||
@@ -226,24 +207,6 @@ class storyModel extends model
|
||||
return $story;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户需求细分的软件需求。
|
||||
* Get relation story ID.
|
||||
*
|
||||
* @param int $storyID
|
||||
* @param string $storyType
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRelationStoryID(int $storyID, string $storyType = 'requirement'): string
|
||||
{
|
||||
$relationStoryIdList = array();
|
||||
$relationStoryList = $this->getStoryRelation($storyID, $storyType);
|
||||
foreach($relationStoryList as $relationStory) $relationStoryIdList[$relationStory->id] = $relationStory->id;
|
||||
|
||||
return implode(',', $relationStoryIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get requirements for story.
|
||||
*
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 storyModel->getStoryRelation();
|
||||
cid=0
|
||||
|
||||
*/
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
su('admin');
|
||||
|
||||
zenData('storyspec')->gen(60);
|
||||
$story = zenData('story');
|
||||
$story->product->range(1);
|
||||
$story->parent->range('0{18},`-1`,19');
|
||||
$story->type->range('requirement{10},story{10}');
|
||||
$story->gen(20);
|
||||
|
||||
$relation = zenData('relation');
|
||||
$relation->product->range(1);
|
||||
$relation->AID->range('1,11,1,2,12,2,3,13,3,4,14,4,5,15,5,6,16,6,7,17,7,8,18,8');
|
||||
$relation->BID->range('11,1,1,12,2,2,13,3,3,14,4,4,15,5,5,16,6,6,17,7,7,18,8,8');
|
||||
$relation->AType->range('requirement,story,design');
|
||||
$relation->BType->range('story,requirement,commit');
|
||||
$relation->relation->range('subdivideinto,subdividedfrom,completedin');
|
||||
$relation->gen(24);
|
||||
|
||||
global $tester;
|
||||
$relations1 = $tester->loadModel('story')->getRelationStoryID(1, 'requirement');
|
||||
$relations2 = $tester->story->getRelationStoryID(11, 'story');
|
||||
|
||||
r($relations1) && p() && e('11'); // 获取用户需求1关联的软件需求
|
||||
r($relations2) && p() && e('1'); // 获取软件需求11关联的用户需求
|
||||
Reference in New Issue
Block a user