* Build operate menu for productplan module.

This commit is contained in:
daitingting
2022-05-11 01:39:53 +00:00
parent d09a097714
commit 0fba3427af
4 changed files with 102 additions and 89 deletions
+1 -1
View File
@@ -326,7 +326,7 @@ class control extends baseControl
if(!isset($this->config->bizVersion)) return false;
$moduleName = $this->moduleName;
if(strpos(',bug,feedback,caselib,testsuite,testtask,testcase,product,', ",{$moduleName},") !== false) return $this->$moduleName->buildOperateMenu($object, $type);
if(strpos(',bug,feedback,caselib,testsuite,testtask,testcase,product,productplan,', ",{$moduleName},") !== false) return $this->$moduleName->buildOperateMenu($object, $type);
$flow = $this->loadModel('workflow')->getByModule($moduleName);
return $this->loadModel('flow')->buildOperateMenu($flow, $object, $type);
+99 -2
View File
@@ -1002,17 +1002,21 @@ class productplanModel extends model
*
* @param object $plan
* @param string $action
* @param string $module
* @access public
* @return void
*/
public static function isClickable($plan, $action)
public static function isClickable($plan, $action, $module = 'productplan')
{
$action = strtolower($action);
$clickable = commonModel::hasPriv('productplan', $action);
$clickable = commonModel::hasPriv($module, $action);
if(!$clickable) return false;
switch($action)
{
case 'create' :
if($plan->parent > 0 or strpos('done,closed', $plan->status) !== false) return false;
break;
case 'start' :
if($plan->status != 'wait' or $plan->parent < 0) return false;
break;
@@ -1025,8 +1029,101 @@ class productplanModel extends model
case 'activate' :
if($plan->status == 'wait' or $plan->status == 'doing' or $plan->parent < 0) return false;
break;
case 'delete' :
if($plan->parent < 0) return false;
break;
}
if($module == 'execution' && $action == 'create')
{
if($plan->parent < 0 || $plan->expired || in_array($plan->status, array('done', 'closed'))) return false;
$product = $this->loadModel('product')->getById($plan->product);
$branchList = $this->loadModel('branch')->getList($plan->product, 0, 'all');
$branchStatusList = array();
foreach($branchList as $productBranch) $branchStatusList[$productBranch->id] = $productBranch->status;
if($product->type != 'normal')
{
$branchStatus = isset($branchStatusList[$plan->branch]) ? $branchStatusList[$plan->branch] : '';
if($branchStatus == 'closed') return false;
}
}
return true;
}
/**
* Build operate menu.
*
* @param object $plan
* @param string $type
* @access public
* @return string
*/
public function buildOperateMenu($plan, $type = 'view')
{
$params = "planID=$plan->id";
$menu = '';
$menu .= $this->buildMenu('productplan', 'start', $params, $plan, $type, 'play', 'hiddenwin', '', false, '', $this->lang->productplan->startAB);
$menu .= $this->buildMenu('productplan', 'finish', $params, $plan, $type, 'checked', 'hiddenwin', '', false, '', $this->lang->productplan->finishAB);
$menu .= $this->buildMenu('productplan', 'close', $params, $plan, $type, 'off', 'hiddenwin', 'iframe', true, '', $this->lang->productplan->closeAB);
if($type == 'view') $menu .= $this->buildMenu('productplan', 'activate', $params, $plan, $type, 'magic', 'hiddenwin', '', false, '', $this->lang->productplan->activateAB);
if($type == 'browse')
{
if($this->isClickable($plan, 'create', 'execution'))
{
$executionLink = $this->config->systemMode == 'new' ? '#projects' : helper::createLink('execution', 'create', "projectID=0&executionID=0&copyExecutionID=0&plan=$plan->id&confirm=no&productID=$plan->product");
if($this->config->systemMode == 'new')
{
$menu .= html::a($executionLink, '<i class="icon-plus"></i>', '', "data-toggle='modal' data-id='$plan->id' onclick='getPlanID(this, $plan->branch)' class='btn' title='{$this->lang->productplan->createExecution}'");
}
else
{
$menu .= html::a($executionLink, '<i class="icon-plus"></i>', '', "class='btn' title='{$this->lang->productplan->createExecution}'");
}
}
else
{
$menu .= "<button type='button' class='btn disabled'><i class='icon-plus' title='{$this->lang->productplan->createExecution}'></i></button>";
}
if(common::hasPriv('productplan', 'linkStory', $plan) and $plan->parent >= 0)
{
$menu .= $this->buildMenu('productplan', 'view', "{$params}&type=story&orderBy=id_desc&link=true", $plan, $type, 'link', '', '', '', '', $this->lang->productplan->linkStory);
}
else
{
$menu .= "<button type='button' class='disabled btn'><i class='icon-link' title='{$this->lang->productplan->linkStory}'></i></button>";
}
if(common::hasPriv('productplan', 'linkBug', $plan) and $plan->parent >= 0)
{
$menu .= $this->buildMenu('productplan', 'view', "{$params}&type=bug&orderBy=id_desc&link=true", $plan, $type, 'bug', '', '', '', '', $this->lang->productplan->linkBug);
}
else
{
$menu .= "<button type='button' class='disabled btn'><i class='icon-bug' title='{$this->lang->productplan->linkBug}'></i></button>";
}
$menu .= $this->buildMenu('productplan', 'edit', $params, $plan, $type);
}
$menu .= $this->buildMenu('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}", $plan, $type, 'split', '', '', '', '', $this->lang->productplan->children);
if($type == 'browse') $menu .= $this->buildMenu('productplan', 'delete', "{$params}&confirm=no", $plan, $type, 'trash', 'hiddenwin', '', '', $this->lang->productplan->delete);
if($type == 'view')
{
if(common::hasPriv('productplan', 'edit', $plan)) $menu .= html::a(helper::createLink('productplan', 'edit', $params), "<i class='icon-common-edit icon-edit'></i> " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'");
if($plan->parent >= 0 && common::hasPriv('productplan', 'delete', $plan)) $menu .= html::a(helper::createLink('productplan', 'delete', $params), "<i class='icon-common-delete icon-trash'></i> " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'");
}
return $menu;
}
}
+1 -61
View File
@@ -144,67 +144,7 @@
<div title='<?php echo $desc;?>'><?php echo nl2br($desc);?></div>
</td>
<?php foreach($extendFields as $extendField) echo "<td>" . $this->loadModel('flow')->getFieldValue($extendField, $plan) . "</td>";?>
<td class='c-actions'>
<?php
if($plan->parent >= 0 )
{
$attr = "target='hiddenwin'";
common::printIcon('productplan', 'start', "planID=$plan->id", $plan, 'list', 'play', '', '', false, $attr);
common::printIcon('productplan', 'finish', "planID=$plan->id", $plan, 'list', 'checked', '', '', false, $attr);
common::printIcon('productplan', 'close', "planID=$plan->id", $plan, 'list', 'off', '', 'iframe', true);
}
$attr = $plan->expired ? "disabled='disabled'" : '';
$class = '';
if($product->type != 'normal')
{
$branchStatus = isset($branchStatusList[$plan->branch]) ? $branchStatusList[$plan->branch] : '';
if($branchStatus == 'closed') $class = 'disabled';
}
if(common::hasPriv('execution', 'create', $plan) and $plan->parent >= 0)
{
$disabled = '';
$executionLink = $config->systemMode == 'new' ? '#projects' : $this->createLink('execution', 'create', "projectID=0&executionID=0&copyExecutionID=0&plan=$plan->id&confirm=no&productID=$productID");
if(in_array($plan->status, array('done', 'closed'))) $disabled = 'disabled';
if($config->systemMode == 'new')
{
echo html::a($executionLink, '<i class="icon-plus"></i>', '', "data-toggle='modal' data-id='$plan->id' onclick='getPlanID(this, $plan->branch)' class='btn {$disabled} {$class}' title='{$lang->productplan->createExecution}' $attr");
}
else
{
echo html::a($executionLink, '<i class="icon-plus"></i>', '', "class='btn {$disabled}' title='{$lang->productplan->createExecution}' $attr");
}
}
if(common::hasPriv('productplan', 'linkStory', $plan) and $plan->parent >= 0) echo html::a(inlink('view', "planID=$plan->id&type=story&orderBy=id_desc&link=true"), '<i class="icon-link"></i>', '', "class='btn' title='{$lang->productplan->linkStory}'");
if(common::hasPriv('productplan', 'linkBug', $plan) and $plan->parent >= 0) echo html::a(inlink('view', "planID=$plan->id&type=bug&orderBy=id_desc&link=true"), '<i class="icon-bug"></i>', '', "class='btn' title='{$lang->productplan->linkBug}'");
common::printIcon('productplan', 'edit', "planID=$plan->id", $plan, 'list');
if(common::hasPriv('productplan', 'create', $plan))
{
if($plan->parent > 0 or strpos('done,closed', $plan->status) !== false)
{
echo "<button type='button' class='disabled btn'><i class='disabled icon-split' title='{$this->lang->productplan->children}'></i></button> ";
}
else
{
echo html::a($this->createLink('productplan', 'create', "product=$productID&branch=$branch&parent={$plan->id}"), "<i class='icon-split'></i>", '', "class='btn {$class}' title='{$this->lang->productplan->children}'");
}
}
if(common::hasPriv('productplan', 'delete', $plan))
{
$deleteURL = '###';
$disabled = 'disabled';
if($plan->parent >= 0)
{
$deleteURL = $this->createLink('productplan', 'delete', "planID=$plan->id&confirm=no");
$disabled = '';
}
echo html::a($deleteURL, '<i class="icon-trash"></i>', 'hiddenwin', "class='btn {$disabled}' title='{$lang->productplan->delete}'");
}
?>
</td>
<td class='c-actions'><?php echo $this->buildOperateMenu($plan, 'browse'); ?></td>
</tr>
<?php endforeach;?>
</tbody>
+1 -25
View File
@@ -38,31 +38,7 @@
</div>
</div>
<div class='btn-toolbar pull-right' id='actionsBox'>
<?php
if(!$plan->deleted && !isonlybody())
{
echo $this->buildOperateMenu($plan, 'view');
if($plan->parent >= 0)
{
$attr = "target='hiddenwin'";
$class = $plan->status == 'wait' ? '' : 'disabled';
common::printLink('productplan', 'start', "planID=$plan->id", "<i class='icon-play'></i>{$lang->productplan->startAB}", '', "class='btn btn-link {$class}'{$attr} title='{$lang->productplan->start}'", '', false, $plan);
$class = $plan->status == 'doing' ? '' : 'disabled';
common::printLink('productplan', 'finish', "planID=$plan->id", "<i class='icon-checked'></i>{$lang->productplan->finishAB}", '', "class='btn btn-link {$class}' target='hiddenwin' title='{$lang->productplan->finish}'", '', false, $plan);
$class = $plan->status !== 'closed' ? 'iframe' : 'disabled';
common::printLink('productplan', 'close', "planID=$plan->id", "<i class='icon-off'></i>{$lang->productplan->closeAB}", '', "class='btn btn-link {$class}' title='{$lang->productplan->close}'", '', true, $plan);
$class = in_array($plan->status, array('closed', 'done')) ? '' : 'disabled';
common::printLink('productplan', 'activate', "planID=$plan->id", "<i class='icon-magic'></i>{$lang->productplan->activateAB}", '', "class='btn btn-link {$class}' target='hiddenwin' title='{$lang->productplan->activate}'", '', false, $plan);
}
$class = (isset($branchStatus) and $branchStatus == 'closed') ? 'disabled' : '';
if(common::hasPriv('productplan', 'create', $plan) and $plan->parent <= 0 and strpos('wait,doing', $plan->status) !== false) echo html::a($this->createLink('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}"), "<i class='icon-split'></i> " . $this->lang->productplan->children , '', "class='btn btn-link {$class}' title='{$this->lang->productplan->children}'");
if(common::hasPriv('productplan', 'edit', $plan)) echo html::a($this->createLink('productplan', 'edit', "planID=$plan->id"), "<i class='icon-common-edit icon-edit'></i> " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'");
if(common::hasPriv('productplan', 'delete', $plan) and $plan->parent >= 0) echo html::a($this->createLink('productplan', 'delete', "planID=$plan->id"), "<i class='icon-common-delete icon-trash'></i> " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'");
}
?>
<?php if(!$plan->deleted && !isonlybody()) echo $this->buildOperateMenu($plan, 'view'); ?>
</div>
</div>
<div id='mainContent' class='main-content'>