- Remove unused method and its unit test, storyModel::buildOperateMenu.

This commit is contained in:
liumengyi
2024-03-27 14:40:58 +08:00
parent b53abbc4e8
commit 055ea2a355
2 changed files with 0 additions and 165 deletions
-70
View File
@@ -3215,76 +3215,6 @@ class storyModel extends model
return true;
}
/**
* Build operate menu.
*
* @param object $story
* @param string $type
* @param object $execution
* @param string $storyType story|requirement
* @access public
* @return string
*/
public function buildOperateMenu(object $story, string $type = 'view', object|null $execution = null, string $storyType = 'story'): array
{
$menu = array();
$suffixMenu = array();
$isInModal = isInModal();
$params = "storyID=$story->id";
if($type == 'view')
{
$menu[] = commonModel::buildActionItem('story', 'change', $params, $story, array('icon' => 'alter', 'text' => $this->lang->story->change, 'data-app' => $this->app->tab));
if(str_contains('draft,changing', $story->status)) $menu[] = commonModel::buildActionItem('story', 'submitReview', $params . "&storyType=$story->type", $story, array('icon' => 'confirm', 'text' => $this->lang->story->submitReview, 'data-toggle' => 'modal'));
$title = $story->status == 'changing' ? $this->lang->story->recallChange : $this->lang->story->recall;
$menu[] = commonModel::buildActionItem('story', 'recall', $params . "&from=view&confirm=no&storyType={$story->type}", $story, array('icon' => 'undo', 'text' => $title, 'class' => 'ajax-submit', 'data-app' => $this->app->tab));
$menu[] = commonModel::buildActionItem('story', 'review', $params . "&from={$this->app->tab}&storyType={$story->type}", $story, array('icon' => 'search', 'text' => $this->lang->story->review, 'data-app' => $this->app->tab));
$executionID = empty($execution) ? 0 : $execution->id;
if(!helper::isAjaxRequest('modal') && $this->config->vision != 'lite')
{
$menu[] = commonModel::buildActionItem('story', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=$story->module&$params&executionID=$executionID&plan=0&storyType=story", $story, array('icon' => 'split', 'text' => $this->lang->story->subdivide, 'data-app' => $this->app->tab));
}
$menu[] = commonModel::buildActionItem('story', 'assignTo', $params . "&kanbanGroup=default&from=&storyType=$story->type", $story, array('icon' => 'hand-right', 'text' => $this->lang->story->assignTo, 'data-toggle' => 'modal'));
$menu[] = commonModel::buildActionItem('story', 'close', $params . "&from=&storyType=$story->type", $story, array('icon' => 'off', 'text' => $this->lang->story->close, 'data-toggle' => 'modal'));
$menu[] = commonModel::buildActionItem('story', 'activate', $params . "&storyType=$story->type", $story, array('icon' => 'magic', 'text' => $this->lang->story->activate, 'data-toggle' => 'modal'));
$disabledFeatures = ",{$this->config->disabledFeatures},";
if(in_array($this->config->edition, array('max', 'ipd')) && $this->app->tab == 'project' && common::hasPriv('story', 'importToLib') && strpos($disabledFeatures, ',assetlibStorylib,') === false && strpos($disabledFeatures, ',assetlib,') === false)
{
$menu[] = array('url' => '#importToLib', 'icon' => 'assets', 'text' => $this->lang->story->importToLib, 'data-toggle' => 'modal');
}
/* Print testcate actions. */
if($this->config->vision != 'lite' && $story->parent >= 0 && $story->type != 'requirement' && (common::hasPriv('testcase', 'create', $story) || common::hasPriv('testcase', 'batchCreate', $story)))
{
$this->app->loadLang('testcase');
$dropMenuItems = array();
$dropMenuItems[] = commonModel::buildActionItem('testcase', 'create', "productID=$story->product&branch=$story->branch&moduleID=0&from=&param=0&$params", $story, array('text' => $this->lang->testcase->create, 'data-toggle' => 'modal', 'data-size' => 'lg'));
$dropMenuItems[] = commonModel::buildActionItem('testcase', 'batchCreate', "productID=$story->product&branch=$story->branch&moduleID=0&$params", null, array('text' => $this->lang->testcase->batchCreate, 'data-toggle' => 'modal', 'data-size' => 'lg'));
$menu[] = array('type' => 'dropdown', 'text' => $this->lang->testcase->common, 'items' => $dropMenuItems, 'placement' => 'top-end', 'caret' => 'up');
}
if(($this->app->tab == 'execution' || (!empty($execution) && $execution->multiple == '0')) && $story->status == 'active' && $story->type == 'story')
{
$menu[] = commonModel::buildActionItem('task', 'create', "execution={$this->session->execution}&{$params}&moduleID=$story->module", $story, array('icon' => 'plus', 'text' => $this->lang->task->create, 'data-toggle' => 'modal', 'data-size' => 'lg', 'data-app' => (!empty($execution) && $execution->multiple == '0') ? 'project' : ''));
}
if(!$isInModal) $suffixMenu[] = commonModel::buildActionItem('story', 'edit', $params . "&kanbanGroup=default&storyType=$story->type", $story, array('icon' => 'edit', 'data-app' => $this->app->tab));
if(!$isInModal) $suffixMenu[] = commonModel::buildActionItem('story', 'create', "productID=$story->product&branch=$story->branch&moduleID=$story->module&{$params}&executionID=0&bugID=0&planID=0&todoID=0&extra=&storyType=$story->type", $story, array('icon' => 'copy', 'data-app' => $this->app->tab));
if(common::hasPriv('story', 'delete')) $suffixMenu[] = array('url' => helper::createLink('story', 'delete', $params), 'class' => 'ajax-submit', 'icon' => 'trash');
}
if($suffixMenu)
{
$menu[] = array('type' => 'divider');
$menu = array_merge($menu, $suffixMenu);
}
return array_values(array_filter($menu));
}
/**
* Merge story reviewers.
*
@@ -1,95 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 storyModel->buildOperateMenu();
cid=0
- 查看用户需求详情操作菜单的第一个链接
- 第0条的icon属性 @confirm
- 第0条的data-toggle属性 @modal
- 第0条的url属性 @/story-submitReview-1-requirement.html
- 查看用户需求详情操作菜单的第二个链接
- 第1条的icon属性 @hand-right
- 第1条的data-toggle属性 @modal
- 第1条的url属性 @/story-assignTo-1-default--requirement.html
- 查看用户需求详情操作菜单的第三个链接
- 第2条的icon属性 @off
- 第2条的data-toggle属性 @modal
- 第2条的url属性 @/story-close-1--requirement.html
- 查看用户需求详情操作菜单的第一个链接
- 第0条的icon属性 @confirm
- 第0条的url属性 @/story-submitReview-1-requirement.html
- 查看用户需求详情操作菜单的第二个链接
- 第1条的icon属性 @hand-right
- 第1条的url属性 @/story-assignTo-1-default--requirement.html
- 查看用户需求详情操作菜单的第三个链接
- 第2条的icon属性 @off
- 第2条的url属性 @/story-close-1--requirement.html
- 查看用户需求详情操作菜单的第一个链接
- 第0条的icon属性 @alter
- 第0条的url属性 @/story-change-2.html
- 查看软件需求详情操作菜单的第二个链接
- 第1条的icon属性 @hand-right
- 第1条的data-toggle属性 @modal
- 第1条的url属性 @/story-assignTo-2-default--story.html
- 查看软件需求详情操作菜单的第三个链接
- 第2条的icon属性 @off
- 第2条的data-toggle属性 @modal
- 第2条的url属性 @/story-close-2--story.html
- 查看软件需求详情操作菜单的第一个链接
- 第0条的icon属性 @alter
- 第0条的url属性 @/story-change-2.html
- 查看软件需求详情操作菜单的第二个链接
- 第1条的icon属性 @hand-right
- 第1条的url属性 @/story-assignTo-2-default--story.html
- 查看软件需求详情操作菜单的第三个链接
- 第2条的icon属性 @off
- 第2条的url属性 @/story-close-2--story.html
- 查看软件需求详情操作菜单的第一个链接
- 第0条的icon属性 @alter
- 第0条的url属性 @/story-change-2.html
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
su('admin');
zdTable('story')->gen(10);
zdTable('project')->gen(20);
global $tester;
$tester->loadModel('story');
$tester->story->config->requestType = 'PATH_INFO';
$tester->story->config->webRoot = '/';
$tester->story->app->user->admin = true;
$tester->story->app->moduleName = 'story';
$tester->story->app->methodName = 'view';
include($tester->story->app->basePath . DS . 'module' . DS . 'story' . DS . 'control.php');
$tester->story->app->control = new story();
$requirement = $tester->story->fetchById(1);
$story = $tester->story->fetchById(2);
$execution = $tester->story->loadModel('project')->fetchById(11);
$config->requestType = 'PATH_INFO';
$requirementOperateMenu1 = $tester->story->buildOperateMenu($requirement, 'view', null, 'requirement');
$storyOperateMenu1 = $tester->story->buildOperateMenu($story, 'view', null, 'story');
$execution->multiple = 0;
$tester->story->app->tab = 'execution';
$storyOperateMenu2 = $tester->story->buildOperateMenu($story, 'view', $execution, 'story');
r($requirementOperateMenu1) && p('0:icon,data-toggle,url') && e('confirm,modal,/story-submitReview-1-requirement.html'); // 查看用户需求详情操作菜单的第一个链接
r($requirementOperateMenu1) && p('1:icon,data-toggle,url') && e('hand-right,modal,/story-assignTo-1-default--requirement.html'); // 查看用户需求详情操作菜单的第二个链接
r($requirementOperateMenu1) && p('2:icon,data-toggle,url') && e('off,modal,/story-close-1--requirement.html'); // 查看用户需求详情操作菜单的第三个链接
r($requirementOperateMenu1) && p('0:icon,url') && e('confirm,/story-submitReview-1-requirement.html'); // 查看用户需求详情操作菜单的第一个链接
r($requirementOperateMenu1) && p('1:icon,url') && e('hand-right,/story-assignTo-1-default--requirement.html'); // 查看用户需求详情操作菜单的第二个链接
r($requirementOperateMenu1) && p('2:icon,url') && e('off,/story-close-1--requirement.html'); // 查看用户需求详情操作菜单的第三个链接
r($storyOperateMenu1) && p('0:icon,url') && e('alter,/story-change-2.html'); // 查看用户需求详情操作菜单的第一个链接
r($storyOperateMenu1) && p('1:icon,data-toggle,url') && e('hand-right,modal,/story-assignTo-2-default--story.html'); // 查看软件需求详情操作菜单的第二个链接
r($storyOperateMenu1) && p('2:icon,data-toggle,url') && e('off,modal,/story-close-2--story.html'); // 查看软件需求详情操作菜单的第三个链接
r($storyOperateMenu1) && p('0:icon,url') && e('alter,/story-change-2.html'); // 查看软件需求详情操作菜单的第一个链接
r($storyOperateMenu1) && p('1:icon,url') && e('hand-right,/story-assignTo-2-default--story.html'); // 查看软件需求详情操作菜单的第二个链接
r($storyOperateMenu1) && p('2:icon,url') && e('off,/story-close-2--story.html'); // 查看软件需求详情操作菜单的第三个链接
r($storyOperateMenu2) && p('0:icon,url') && e('alter,/story-change-2.html'); // 查看软件需求详情操作菜单的第一个链接