* improve dashboard UI.

This commit is contained in:
Catouse
2016-04-14 09:08:32 +08:00
parent 32eb12d2cc
commit 3edba12cc7
9 changed files with 58 additions and 33 deletions
+7 -7
View File
@@ -54,7 +54,7 @@ class block extends control
$hiddenBlocks = $this->block->getHiddenBlocks();
foreach($hiddenBlocks as $block) $modules['hiddenBlock' . $block->id] = $block->title;
$this->view->modules = $modules;
$this->view->modules = $modules;
}
elseif(isset($this->lang->block->moduleList[$module]))
{
@@ -62,7 +62,7 @@ class block extends control
$this->view->blocks = $this->fetch('block', 'main', "module=$module&id=$id");
}
$this->view->block = $this->block->getBlock($id);
$this->view->block = $this->block->getByID($id);
$this->view->blockID = $id;
$this->view->title = $title;
$this->display();
@@ -78,7 +78,7 @@ class block extends control
*/
public function set($id, $type, $source = '')
{
if($_POST)
if($_POST)
{
$source = isset($this->lang->block->moduleList[$source]) ? $source : '';
$this->block->save($id, $source, $type, $this->session->blockModule);
@@ -86,7 +86,7 @@ class block extends control
die(js::reload('parent'));
}
$block = $this->block->getBlock($id);
$block = $this->block->getByID($id);
if($block) $type = $block->block;
if(isset($this->lang->block->moduleList[$source]))
@@ -217,7 +217,7 @@ class block extends control
*/
public function printBlock($id, $module = 'my')
{
$block = $this->block->getBlock($id, $module);
$block = $this->block->getByID($id);
if(empty($block)) return false;
@@ -272,11 +272,11 @@ class block extends control
$blocks = json_decode($blocks, true);
$blockPairs = array('' => '') + $blocks;
$block = $this->block->getBlock($id);
$block = $this->block->getByID($id);
echo "<th>{$this->lang->block->lblBlock}</th>";
echo '<td>' . html::select('moduleBlock', $blockPairs, ($block and $block->source != '') ? $block->block : '', "class='form-control' onchange='getBlockParams(this.value, \"$module\")'") . '</td>';
if(isset($block->source)) echo "<script>$(function(){getBlockParams($('#moduleBlock').val(), '{$block->source}')})</script>";
if(isset($block->source)) echo "<script>$(function(){console.log(1, window.getBlockParams); getBlockParams($('#moduleBlock').val(), '{$block->source}')})</script>";
}
elseif($mode == 'getblockform')
{
+5 -1
View File
@@ -12,7 +12,11 @@ body {background: #fafafa;}
.dashboard .panel-action:hover, .dashboard .panel-actions > .dropdown > a:hover {color: #333; background-color: #ddd; background-color: rgba(0,0,0,0.1)}
.dashboard .panel-title {font-size: 13px; color: #333}
.dashboard a.panel-title:hover {color: #1a53ff}
.dashboard .panel {box-shadow: none}
.dashboard .panel {box-shadow: none; position: relative}
.dashboard .panel-heading + .panel-body {position: absolute; left: 0; top: 30px; right: 0; bottom: 0}
.dashboard .panel-dragging-shadow {position: absolute;}
.dashboard-empty-message {text-align: center; margin-top: 100px;}
.dashboard-empty-message > h5 {margin-bottom: 20px;}
.outer > .dashboard {margin-left: -10px; margin-right: -10px;}
-2
View File
@@ -7,7 +7,6 @@
*/
function getBlocks(moduleID)
{
console.log('getBlocks', moduleID);
var moduleBlock = $('#modules').parent().parent().next();
$(moduleBlock).hide();
@@ -27,7 +26,6 @@ function getBlocks(moduleID)
$.get(createLink('block', 'main', 'module=' + moduleID + '&id=' + blockID), {mode:'getblocklist'}, function(data)
{
console.log('GET BLOCKS', moduleID, data);
$(moduleBlock).html(data);
$(moduleBlock).show();
})
+34 -17
View File
@@ -1,19 +1,3 @@
$(function()
{
var $dashboard = $('#dashboard').dashboard(
{
height : 240,
draggable : true,
shadowType : false,
afterOrdered : sortBlocks,
afterPanelRemoved : deleteBlock,
sensitive : true,
panelRemovingTip : config.confirmRemoveBlock
});
$dashboard.find('ul.dashboard-actions').addClass('hide').children('li').addClass('right').appendTo($('#modulemenu > .nav'));
});
/**
* Delete block.
*
@@ -29,7 +13,8 @@ function deleteBlock(index)
{
alert(data.message);
return false;
}
}
else {checkEmpty();}
})
}
@@ -53,3 +38,35 @@ function sortBlocks(orders)
if(data.result == 'success') $.zui.messager.success(config.ordersSaved);
});
}
/**
* Check dashboard wether is empty
* @access public
* @return void
*/
function checkEmpty()
{
var $dashboard = $('#dashboard');
var hasBlocks = !!$dashboard.children('.row').children().length;
$dashboard.find('.dashboard-empty-message').toggleClass('hide', hasBlocks);
}
$(function()
{
var $dashboard = $('#dashboard').dashboard(
{
height : 240,
draggable : true,
shadowType : false,
afterOrdered : sortBlocks,
afterPanelRemoved : deleteBlock,
sensitive : true,
panelRemovingTip : config.confirmRemoveBlock
});
$dashboard.find('ul.dashboard-actions').addClass('hide').children('li').addClass('right').appendTo($('#modulemenu > .nav'));
checkEmpty();
});
+1
View File
@@ -30,6 +30,7 @@ $lang->block->createBlock = 'Add block';
$lang->block->editBlock = 'Edit block';
$lang->block->ordersSaved = 'Sort have been saved';
$lang->block->confirmRemoveBlock = 'Are you sure remove block [{0}] ?';
$lang->block->emptyMessage = 'Nothing here, custom it now!';
$lang->block->default['product']['1']['title'] = $lang->productCommon . ' list';
$lang->block->default['product']['1']['block'] = 'list';
+1
View File
@@ -30,6 +30,7 @@ $lang->block->createBlock = '添加区块';
$lang->block->editBlock = '编辑区块';
$lang->block->ordersSaved = '排序已保存';
$lang->block->confirmRemoveBlock = '确定移除区块【{0}】吗?';
$lang->block->emptyMessage = '这里什么也没有。快来定制你的页面!';
$lang->block->default['product']['1']['title'] = $lang->productCommon . '列表';
$lang->block->default['product']['1']['block'] = 'list';
+4 -4
View File
@@ -14,7 +14,7 @@ class blockModel extends model
/**
* Save params
*
* @param int $index
* @param int $id
* @param string $type
* @param string $appName
* @param int $blockID
@@ -23,10 +23,11 @@ class blockModel extends model
*/
public function save($id, $source, $type, $module = 'my')
{
$block = $id ? $this->getByID($id) : null;
$data = fixer::input('post')
->add('account', $this->app->user->account)
->setIF($id, 'id', $id)
->setIF(!$id, 'order', $this->getLastKey($module) + 1)
->add('order', $block ? $block->order : ($this->getLastKey($module) + 1))
->add('module', $module)
->add('hidden', 0)
->setDefault('grid', '4')
@@ -65,12 +66,11 @@ class blockModel extends model
* @access public
* @return object
*/
public function getBlock($id, $module = 'my')
public function getBlock($id)
{
$block = $this->dao->select('*')->from(TABLE_BLOCK)
->where('`id`')->eq($id)
->andWhere('account')->eq($this->app->user->account)
->andWhere('module')->eq($module)
->fetch();
if(empty($block)) return false;
+2 -2
View File
@@ -11,6 +11,8 @@
*/
?>
<?php if(isset($pageCSS)) css::internal($pageCSS); ?>
<?php js::set('blockID', $blockID)?>
<?php if(isset($pageJS)) js::execute($pageJS);?>
<table class='table table-form'>
<tr><th class='w-100px'></th><td></td></tr>
<?php if(!empty($modules)):?>
@@ -26,5 +28,3 @@
<tr><?php if(!empty($blocks)) echo $blocks;?></tr>
</table>
<div id='blockParam'></div>
<?php js::set('blockID', $blockID)?>
<?php if(isset($pageJS)) js::execute($pageJS);?>
+4
View File
@@ -17,6 +17,10 @@ if(isset($pageCSS)) css::internal($pageCSS);
?>
<div class='dashboard dashboard-draggable' id='dashboard' data-confirm-remove-block='<?php echo $lang->block->confirmRemoveBlock;?>'>
<ul class='dashboard-actions hide'><li><a href='<?php echo $this->createLink("block", "admin", "id=0&module=$module"); ?>' data-toggle='modal' data-type='ajax' data-width='600'><i class='icon icon-list-alt'></i> <?php echo $lang->block->createBlock?></a></li></ul>
<div class='dashboard-empty-message hide'>
<h5 class='text-success'><?php echo $lang->block->emptyMessage ?></h5>
<a href='<?php echo $this->createLink("block", "admin", "id=0&module=$module"); ?>' data-toggle='modal' data-type='ajax' data-width='600' class='btn btn-primary'><i class='icon icon-plus'></i> <?php echo $lang->block->createBlock?></a>
</div>
<div class='row'>
<?php foreach($blocks as $index => $block):?>
<div class='col-sm-6 col-md-<?php echo $block->grid;?>'>