* use buildOperateMenu method for build and projectrelease module.

This commit is contained in:
wangyidong
2022-05-19 13:34:02 +08:00
parent 8e0d809caa
commit f289e08b9d
6 changed files with 123 additions and 76 deletions
+40 -6
View File
@@ -523,20 +523,54 @@ class buildModel extends model
*
* @param object $build
* @param string $type
* @param string $extra
* @access public
* @return string
*/
public function buildOperateMenu($build, $type = 'view')
public function buildOperateMenu($build, $type = 'view', $extra = '')
{
$canBeChanged = common::canBeChanged('build', $build);
if($build->deleted || !$canBeChanged) return '';
$extraParams = array();
if($extra) parse_str($extra, $extraParams);
$menu = '';
$params = "buildID=$build->id";
$menu .= $this->buildFlowMenu('build', $build, 'view', 'direct');
$menu .= $this->buildMenu('build', 'edit', $params, $build, $type);
$menu .= $this->buildMenu('build', 'delete', $params, $build, $type, 'trash', 'hiddenwin');
global $app;
$tab = $app->tab;
if($type == 'browse')
{
if(common::hasPriv('build', 'linkstory') and common::hasPriv('build', 'view') and common::canBeChanged('build', $build))
{
echo html::a(helper::createLink('build', 'view', "{$params}&type=story&link=true"), "<i class='icon icon-link'></i>", '', "class='btn' title='{$this->lang->build->linkStory}' data-app='{$tab}'");
}
$executionID = $tab == 'execution' ? $extraParams['executionID'] : $build->execution;
$menu .= $this->buildMenu('testtask', 'create', "product=$build->product&execution={$executionID}&build=$build->id", $build, $type, 'bullhorn', '', '', '', "data-app='{$tab}'");
if($tab == 'execution')
{
$this->lang->execution->bug = $this->lang->execution->viewBug;
$menu .= $this->buildMenu('execution', 'bug', "execution={$extraParams['executionID']}&productID={$extraParams['productID']}&orderBy=status&build=$build->id", $build, $type);
}
if($tab == 'project')
{
$this->lang->build->view = $this->lang->project->bug;
$menu .= $this->buildMenu('build', 'view', "buildID=$build->id&type=generatedBug", $build, $type, 'bug', '', '', '', "data-app='project'");
}
$menu .= $this->buildMenu('build', 'edit', $params, $build, $type);
$menu .= $this->buildMenu('build', 'delete', $params, $build, $type, 'trash', 'hiddenwin');
}
else
{
$canBeChanged = common::canBeChanged('build', $build);
if($build->deleted || !$canBeChanged) return '';
$menu .= $this->buildFlowMenu('build', $build, 'view', 'direct');
$editClickable = $this->buildMenu('build', 'edit', $params, $build, $type, '', '', '', '', '', '', false);
$deleteClickable = $this->buildMenu('build', 'delete', $params, $build, $type, '', '', '', '', '', '', false);
if(common::hasPriv('build', 'edit') and $editClickable) echo html::a(helper::createLink('build', 'edit', $params), "<i class='icon-common-edit icon-edit'></i> " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->build->edit}' data-app='{$app->tab}'");
if(common::hasPriv('build', 'delete') and $deleteClickable) echo html::a(helper::createLink('build', 'delete', $params), "<i class='icon-common-delete icon-trash'></i> " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->build->delete}' target='hiddenwin' data-app='{$app->tab}'");
}
return $menu;
}
+1 -13
View File
@@ -72,19 +72,7 @@
<td class="c-url" title="<?php echo $build->filePath?>"><?php echo strpos($build->filePath, 'http') === 0 ? html::a($build->filePath) : $build->filePath;?></td>
<td class="c-date"><?php echo $build->date?></td>
<td class="c-user em"><?php echo zget($users, $build->builder);?></td>
<td class="c-actions">
<?php
if(common::hasPriv('build', 'linkstory') and common::hasPriv('build', 'view') and common::canBeChanged('build', $build))
{
echo html::a($this->createLink('build', 'view', "buildID=$build->id&type=story&link=true"), "<i class='icon icon-link'></i>", '', "class='btn' title='{$lang->build->linkStory}'");
}
common::printIcon('testtask', 'create', "product=$build->product&execution=$execution->id&build=$build->id", $build, 'list', 'bullhorn');
$lang->execution->bug = $lang->execution->viewBug;
common::printIcon('execution', 'bug', "execution=$execution->id&productID=$productID&orderBy=status&build=$build->id", $build, 'list');
common::printIcon('build', 'edit', "buildID=$build->id", $build, 'list');
common::printIcon('build', 'delete', "buildID=$build->id", $build, 'list', 'trash', 'hiddenwin');
?>
</td>
<td class="c-actions"><?php echo $this->build->buildOperateMenu($build, 'browse', "executionID={$execution->id}&productID={$productID}");?></td>
</tr>
<?php endforeach;?>
<?php endforeach;?>
+1 -17
View File
@@ -71,23 +71,7 @@
<td class="c-url" title="<?php echo $build->filePath?>"><?php echo strpos($build->filePath, 'http') === 0 ? html::a($build->filePath) : $build->filePath;?></td>
<td class="c-date"><?php echo $build->date?></td>
<td class="c-user em"><?php echo zget($users, $build->builder);?></td>
<td class="c-actions">
<?php
if(common::hasPriv('build', 'linkstory') and common::hasPriv('build', 'view') and common::canBeChanged('build', $build))
{
echo html::a($this->createLink('build', 'view', "buildID=$build->id&type=story&link=true"), "<i class='icon icon-link'></i>", '', "class='btn' title='{$lang->build->linkStory}' data-app='project'");
}
common::printIcon('testtask', 'create', "product=$build->product&executionID={$build->execution}&build=$build->id&projectID=$projectID", $build, 'list', 'bullhorn', '', '', '', "data-app='project'");
$lang->build->view = $lang->project->bug;
common::printIcon('build', 'view', "buildID=$build->id&type=generatedBug", $build, 'list', 'bug', '', '', '', "data-app='project'");
common::printIcon('build', 'edit', "buildID=$build->id", $build, 'list');
if(common::hasPriv('build', 'delete', $build))
{
$deleteURL = $this->createLink('build', 'delete', "buildID=$build->id&confirm=yes");
echo html::a("###", '<i class="icon-trash"></i>', '', "onclick='ajaxDelete(\"$deleteURL\", \"buildList\", confirmDelete)' class='btn' title='{$lang->build->delete}'");
}
?>
</td>
<td class="c-actions"><?php echo $this->build->buildOperateMenu($build, 'browse');?></td>
</tr>
<?php endforeach;?>
<?php endforeach;?>
+78
View File
@@ -226,4 +226,82 @@ class projectreleaseModel extends model
if($action == 'notify') return $release->bugs or $release->stories;
return true;
}
/**
* Build project release action menu.
*
* @param object $release
* @param string $type
* @access public
* @return string
*/
public function buildOperateMenu($release, $type = 'view')
{
$function = 'buildOperate' . ucfirst($type) . 'Menu';
return $this->$function($release);
}
/**
* Build project release view action menu.
*
* @param object $release
* @access public
* @return string
*/
public function buildOperateViewMenu($release)
{
$canBeChanged = common::canBeChanged('projectrelease', $release);
if($release->deleted || !$canBeChanged || isonlybody()) return '';
$menu = '';
$params = "releaseID=$release->id";
if(common::hasPriv('projectrelease', 'changeStatus', $release))
{
$changedStatus = $release->status == 'normal' ? 'terminate' : 'normal';
$menu .= html::a(inlink('changeStatus', "$params&status=$changedStatus"), '<i class="icon-' . ($release->status == 'normal' ? 'pause' : 'play') . '"></i> ' . $this->lang->release->changeStatusList[$changedStatus], 'hiddenwin', "class='btn btn-link' title='{$this->lang->release->changeStatusList[$changedStatus]}'");
}
$menu .= "<div class='divider'></div>";
$menu .= $this->buildFlowMenu('release', $release, 'view', 'direct');
$menu .= "<div class='divider'></div>";
$menu .= $this->buildMenu('projectrelease', 'edit', $params, $release, 'view');
$menu .= $this->buildMenu('projectrelease', 'delete', $params, $release, 'view', 'trash', 'hiddenwin');
return $menu;
}
/**
* Build project release browse action menu.
*
* @param object $release
* @access public
* @return string
*/
public function buildOperateBrowseMenu($release)
{
$canBeChanged = common::canBeChanged('projectrelease', $release);
if(!$canBeChanged) return '';
$menu = '';
$params = "releaseID=$release->id";
$changedStatus = $release->status == 'normal' ? 'terminate' : 'normal';
if(common::hasPriv('projectrelease', 'linkStory')) $menu .= html::a(inlink('view', "$params&type=story&link=true"), '<i class="icon-link"></i> ', '', "class='btn' title='{$this->lang->release->linkStory}'");
if(common::hasPriv('projectrelease', 'linkBug')) $menu .= html::a(inlink('view', "$params&type=bug&link=true"), '<i class="icon-bug"></i> ', '', "class='btn' title='{$this->lang->release->linkBug}'");
$menu .= $this->buildMenu('projectrelease', 'changeStatus', "$params&status=$changedStatus", $release, 'browse', $release->status == 'normal' ? 'pause' : 'play', 'hiddenwin', '', '', '',$this->lang->release->changeStatusList[$changedStatus]);
$menu .= $this->buildMenu('projectrelease', 'edit', $params, $release, 'browse');
$menu .= $this->buildMenu('projectrelease', 'notify', $params, $release, 'browse', 'bullhorn', '', 'iframe', true);
$clickable = $this->buildMenu('projectrelease', 'delete', $params, $release, 'browse', '', '', '', '', '', '', false);
if(common::hasPriv('projectrelease', 'delete', $release))
{
$deleteURL = helper::createLink('projectrelease', 'delete', "$params&confirm=yes");
$class = 'btn';
if(!$clickable) $class .= ' disabled';
$menu .= html::a("javascript:ajaxDelete(\"$deleteURL\", \"releaseList\", confirmDelete)", '<i class="icon-trash"></i>', '', "class='{$class}' title='{$this->lang->release->delete}'");
}
return $menu;
}
}
+1 -22
View File
@@ -55,7 +55,6 @@
</thead>
<tbody>
<?php foreach($releases as $release):?>
<?php $canBeChanged = common::canBeChanged('projectrelease', $release);?>
<tr>
<td><?php echo html::a(inlink('view', "releaseID=$release->id"), sprintf('%03d', $release->id));?></td>
<td>
@@ -73,27 +72,7 @@
<span class="status-release status-<?php echo $release->status?>"><?php echo $status;?></span>
</td>
<?php foreach($extendFields as $extendField) echo "<td>" . $this->loadModel('flow')->getFieldValue($extendField, $release) . "</td>";?>
<td class='c-actions'>
<?php
if($canBeChanged)
{
if(common::hasPriv('projectrelease', 'linkStory')) echo html::a(inlink('view', "releaseID=$release->id&type=story&link=true"), '<i class="icon-link"></i> ', '', "class='btn' title='{$lang->release->linkStory}'");
if(common::hasPriv('projectrelease', 'linkBug')) echo html::a(inlink('view', "releaseID=$release->id&type=bug&link=true"), '<i class="icon-bug"></i> ', '', "class='btn' title='{$lang->release->linkBug}'");
if(common::hasPriv('projectrelease', 'changeStatus', $release))
{
$changedStatus = $release->status == 'normal' ? 'terminate' : 'normal';
echo html::a($this->createLink('projectrelease', 'changeStatus', "releaseID=$release->id&status=$changedStatus"), '<i class="icon-' . ($release->status == 'normal' ? 'pause' : 'play') . '"></i> ', 'hiddenwin', "class='btn' title='{$lang->release->changeStatusList[$changedStatus]}'");
}
common::printIcon('projectrelease', 'edit', "release=$release->id", $release, 'list');
common::printIcon('projectrelease', 'notify', "release=$release->id", $release, 'list', 'bullhorn', '', 'iframe', true);
if(common::hasPriv('projectrelease', 'delete', $release))
{
$deleteURL = $this->createLink('projectrelease', 'delete', "releaseID=$release->id&confirm=yes");
echo html::a("javascript:ajaxDelete(\"$deleteURL\", \"releaseList\", confirmDelete)", '<i class="icon-trash"></i>', '', "class='btn' title='{$lang->release->delete}'");
}
}
?>
</td>
<td class='c-actions'><?php echo $this->projectrelease->buildOperateMenu($release, 'browse');?></td>
</tr>
<?php endforeach;?>
</tbody>
+2 -18
View File
@@ -29,24 +29,8 @@
<?php endif; ?>
</div>
</div>
<div class='btn-toolbar pull-right'>
<?php
$canBeChanged = common::canBeChanged('projectrelease', $release);
if(!$release->deleted and $canBeChanged)
{
echo $this->buildOperateMenu($release, 'view');
if(common::hasPriv('projectrelease', 'changeStatus', $release))
{
$changedStatus = $release->status == 'normal' ? 'terminate' : 'normal';
echo html::a(inlink('changeStatus', "releaseID=$release->id&status=$changedStatus"), '<i class="icon-' . ($release->status == 'normal' ? 'pause' : 'play') . '"></i> ' . $lang->release->changeStatusList[$changedStatus], 'hiddenwin', "class='btn btn-link' title='{$lang->release->changeStatusList[$changedStatus]}'");
}
if(common::hasPriv('projectrelease', 'edit')) echo html::a(inlink('edit', "releaseID=$release->id"), "<i class='icon-common-edit icon-edit'></i> " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'");
if(common::hasPriv('projectrelease', 'delete')) echo html::a(inlink('delete', "releaseID=$release->id"), "<i class='icon-common-delete icon-trash'></i> " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'");
}
?>
</div>
<?php $canBeChanged = common::canBeChanged('projectrelease', $release);?>
<div class='btn-toolbar pull-right'><?php echo $this->projectrelease->buildOperateMenu($release, 'view');?></div>
</div>
<div id='mainContent' class='main-content'>
<div class='main-col'>