* finish task #2937.

This commit is contained in:
wangyidong
2017-03-10 15:00:33 +08:00
parent eaeab89f53
commit af8ad0420f
9 changed files with 83 additions and 10 deletions
+20 -3
View File
@@ -49,9 +49,10 @@ class block extends control
if(!common::hasPriv($moduleKey, 'index')) unset($modules[$moduleKey]);
}
$modules['dynamic'] = $this->lang->block->dynamic;
$modules['flowchart'] = $this->lang->block->lblFlowchart;
$modules['html'] = 'HTML';
$closedBlock = isset($this->config->block->closed) ? $this->config->block->closed : '';
if(strpos(",$closedBlock,", ",|dynamic,") === false) $modules['dynamic'] = $this->lang->block->dynamic;
if(strpos(",$closedBlock,", ",|flowchart,") === false) $modules['flowchart'] = $this->lang->block->lblFlowchart;
if(strpos(",$closedBlock,", ",|html,") === false) $modules['html'] = 'HTML';
$modules = array('' => '') + $modules;
$hiddenBlocks = $this->block->getHiddenBlocks();
@@ -614,4 +615,20 @@ class block extends control
{
$this->display();
}
/**
* Close block forever.
*
* @param int $blockID
* @access public
* @return void
*/
public function close($blockID)
{
$block = $this->block->getByID($blockID);
$closedBlock = isset($this->config->block->closed) ? $this->config->block->closed : '';
$this->dao->delete()->from(TABLE_BLOCK)->where('source')->eq($block->source)->andWhere('block')->eq($block->block)->exec();
$this->loadModel('setting')->setItem('system.block.closed', $closedBlock . ",{$block->source}|{$block->block}");
die(js::reload('parent'));
}
}
+3
View File
@@ -31,6 +31,9 @@ $lang->block->createBlock = '添加区块';
$lang->block->editBlock = '编辑区块';
$lang->block->ordersSaved = '排序已保存';
$lang->block->confirmRemoveBlock = '确定移除区块【{0}】吗?';
$lang->block->foreverClose = '永久关闭';
$lang->block->confirmClose = '确定永久关闭该区块吗?关闭后,所有人将都不会显示该区块';
$lang->block->remove = '移除';
$lang->block->refresh = '刷新';
$lang->block->hidden = '隐藏';
$lang->block->dynamicInfo = "%s, %s <em>%s</em> %s <a href='%s'>%s</a>。";
+10 -2
View File
@@ -173,8 +173,16 @@ class blockModel extends model
*/
public function getAvailableBlocks($module = '')
{
if($module and isset($this->lang->block->modules[$module]))return json_encode($this->lang->block->modules[$module]->availableBlocks);
return json_encode($this->lang->block->availableBlocks);
$blocks = $this->lang->block->availableBlocks;
if($module and isset($this->lang->block->modules[$module])) $blocks = $this->lang->block->modules[$module]->availableBlocks;
if(isset($this->config->block->closed))
{
foreach($blocks as $blockKey => $blockName)
{
if(strpos(",{$this->config->block->closed},", ",{$module}|{$blockKey},") !== false) unset($blocks->$blockKey);
}
}
return json_encode($blocks);
}
/**
+6 -2
View File
@@ -18,7 +18,7 @@ $useGuest = $this->app->user->account == 'guest';
?>
<?php include '../../common/view/tablesorter.html.php';?>
<div class='dashboard' id='dashboard' data-confirm-remove-block='<?php echo $lang->block->confirmRemoveBlock;?>'>
<?php if($this->loadModel('user')->isLogon()):?>
<?php if(!$useGuest):?>
<div class='dashboard-actions'><a href='<?php echo $this->createLink("block", "admin", "id=0&module=$module"); ?>' data-toggle='modal' data-type='ajax' data-width='700' data-title='<?php echo $lang->block->createBlock?>'><i class='icon icon-plus' title='<?php echo $lang->block->createBlock?>' data-toggle='tooltip' data-placement='left'></i></a></div>
<div class='dashboard-empty-message hide'>
<a href='<?php echo $this->createLink("block", "admin", "id=0&module=$module"); ?>' data-toggle='modal' data-type='ajax' data-width='700' class='btn btn-primary'><i class='icon icon-plus'></i> <?php echo $lang->block->createBlock?></a>
@@ -26,6 +26,7 @@ $useGuest = $this->app->user->account == 'guest';
<?php endif;?>
<div class='row'>
<?php foreach($blocks as $index => $block):?>
<?php if(isset($config->block->closed) and strpos(",{$config->block->closed},", ",{$block->source}|{$block->block},") !== false) continue;?>
<div class='col-sm-6 col-md-<?php echo $block->grid;?>'>
<div class='panel panel-block <?php if(isset($block->params->color)) echo 'panel-' . $block->params->color;?>' id='block<?php echo $block->id?>' data-id='<?php echo $block->id?>' data-name='<?php echo $block->title?>' data-url='<?php echo $block->blockLink?>'>
<div class='panel-heading'>
@@ -42,7 +43,10 @@ $useGuest = $this->app->user->account == 'guest';
<?php if(!$block->source and $block->block == 'html'):?>
<li><a href="javascript:hiddenBlock(<?php echo $index;?>)" class="hidden-panel"><i class='icon-eye-close'></i><?php echo $lang->block->hidden; ?></a></li>
<?php endif;?>
<li><a href='javascript:;' class='remove-panel'><i class='icon-remove'></i> <?php echo $lang->delete; ?></a></li>
<li><a href='javascript:;' class='remove-panel'><i class='icon-remove'></i> <?php echo $lang->block->remove; ?></a></li>
<?php endif;?>
<?php if(strpos($this->app->company->admins, ",{$this->app->user->account},") !== false):?>
<li><?php echo html::a($this->createLink('block', 'close', "blockID={$block->id}"), "<i class='icon-eye-close'></i> {$lang->block->foreverClose}", 'hiddenwin', "class='close-block' onclick=\"return confirm('{$lang->block->confirmClose}')\"")?>
<?php endif;?>
</ul>
</div>
+28
View File
@@ -63,6 +63,30 @@ class custom extends control
$this->app->loadConfig('bug');
$this->view->longlife = $this->config->bug->longlife;
}
if($module == 'user' && $field == 'closedBlock')
{
$this->loadModel('block');
$closedBlock = isset($this->config->block->closed) ? $this->config->block->closed : '';
$blockPairs = array();
foreach(explode(',', $closedBlock) as $block)
{
$block = trim($block);
if(empty($block)) continue;
list($moduleName, $blockKey) = explode('|', $block);
if(empty($moduleName))
{
if($blockKey == 'html') $blockPairs[$block] = 'HTML';
if($blockKey == 'flowchart') $blockPairs[$block] = $this->lang->block->lblFlowchart;
if($blockKey == 'dynamic') $blockPairs[$block] = $this->lang->block->dynamic;
}
else
{
$blockPairs[$block] = "{$this->lang->block->moduleList[$moduleName]}|{$this->lang->block->modules[$moduleName]->availableBlocks->$blockKey}";
}
}
$this->view->closedBlock = $closedBlock;
$this->view->blockPairs = $blockPairs;
}
if(!empty($_POST))
{
@@ -79,6 +103,10 @@ class custom extends control
{
$this->loadModel('setting')->setItems('system.bug', fixer::input('post')->get());
}
elseif($module == 'user' && $field == 'closedBlock')
{
$this->loadModel('setting')->setItems('system.block', fixer::input('post')->join('closed', ',')->get());
}
else
{
$lang = $_POST['lang'];
+3 -2
View File
@@ -61,8 +61,9 @@ $lang->custom->todo->fields['typeList'] = '类型';
$lang->custom->todo->fields['statusList'] = '状态';
$lang->custom->user = new stdClass();
$lang->custom->user->fields['roleList'] = '职位';
$lang->custom->user->fields['statusList'] = '状态';
$lang->custom->user->fields['roleList'] = '职位';
$lang->custom->user->fields['statusList'] = '状态';
$lang->custom->user->fields['closedBlock'] = '关闭的区块';
$lang->custom->currentLang = '适用当前语言';
$lang->custom->allLang = '适用所有语言';
+11
View File
@@ -109,6 +109,17 @@ EOT;
</tr>
</table>
<div class='alert alert-info alert-block'><?php echo $lang->custom->notice->longlife;?></div>
<?php elseif($module == 'user' and $field == 'closedBlock'):?>
<table class='table table-form mw-600px'>
<tr>
<th class='w-100px'><?php echo $lang->custom->user->fields['closedBlock'];?></th>
<td><?php echo html::select('closed[]', $blockPairs, $closedBlock, "class='form-control chosen' multiple");?></td>
</tr>
<tr>
<td></td>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
<?php else:?>
<table class='table table-form active-disabled table-condensed mw-600px'>
<tr class='text-center'>
+1 -1
View File
@@ -845,7 +845,7 @@ class testcaseModel extends model
foreach($caseSteps as $key => $caseStep)
{
$expect = $key + 1 == $stepCount ? $caseExpect : '';
$caseSteps[$key] = (object)array('desc' => trim($caseStep), 'expect' => $expect);
$caseSteps[$key] = (object)array('desc' => trim($caseStep), 'expect' => $expect, 'type' => 'item');
}
return $caseSteps;
}
+1
View File
@@ -170,6 +170,7 @@
<?php echo html::textarea('steps[]', $step->desc, "rows='1' class='form-control autosize step-steps'") ?>
<span class="input-group-addon">
<label class="checkbox-inline">
<?php if(!isset($step->type)) $step->type = 'item';?>
<input type='checkbox' name='stepType[]' value='parent' class='step-type' <?php if($step->type == 'group') echo 'checked'?>> <?php echo $lang->testcase->group ?>
</label>
</span>