* Adjust block table block field to code field.

This commit is contained in:
Wangyuting
2023-04-28 09:46:01 +08:00
parent ff772ca202
commit ac0c5b9aae
7 changed files with 78 additions and 75 deletions
+6 -2
View File
@@ -1,5 +1,9 @@
ALTER TABLE `zt_block` ADD `dashboard` varchar(20) NOT NULL DEFAULT '' AFTER `account`;
UPDATE `zt_block` SET `dashboard` = `module`;
UPDATE `zt_block` SET `module` = IF(`source` != '', `source`, `block`);
ALTER TABLE `zt_block` CHANGE `block` `code` varchar(30) NOT NULL DEFAULT '' AFTER `module`;
ALTER TABLE `zt_block` MODIFY `vision` varchar(10) NOT NULL DEFAULT 'rnd' AFTER `hidden`;
ALTER TABLE `zt_todo` CHANGE `idvalue` `objectID` mediumint(8) unsigned default '0' NOT NULL AFTER `type`;
UPDATE `zt_block` SET `dashboard` = `module`;
UPDATE `zt_block` SET `module` = IF(`source` != '', `source`, `code`);
+7 -8
View File
@@ -283,16 +283,15 @@ $config->block->modules['doc']->moreLinkList->projectdoc = 'doc|projectspac
$config->block->form = new stdclass();
$config->block->form->create = array();
$config->block->form->create['module'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['block'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['code'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['title'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['grid'] = array('type' => 'int', 'required' => false, 'default' => '4');
$config->block->form->create['hidden'] = array('type' => 'int', 'required' => false, 'default' => '0');
$config->block->form->create['params'] = array('type' => 'array', 'required' => false, 'default' => array());
$config->block->form = new stdclass();
$config->block->form->create = array();
$config->block->form->create['module'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['block'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['title'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->create['grid'] = array('type' => 'int', 'required' => false, 'default' => '4');
$config->block->form->create['params'] = array('type' => 'array', 'required' => false, 'default' => array());
$config->block->form->edit = array();
$config->block->form->edit['module'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->edit['code'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->edit['title'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->block->form->edit['grid'] = array('type' => 'int', 'required' => false, 'default' => '4');
$config->block->form->edit['params'] = array('type' => 'array', 'required' => false, 'default' => array());
+35 -36
View File
@@ -30,11 +30,11 @@ class block extends control
*
* @param string $dashboard
* @param string $module
* @param string $block
* @param string $code
* @access public
* @return void
*/
public function create(string $dashboard, string $module = '', string $block = '')
public function create(string $dashboard, string $module = '', string $code = '')
{
if($_POST)
{
@@ -53,10 +53,10 @@ class block extends control
$this->view->title = $this->lang->block->createBlock;
$this->view->dashboard = $dashboard;
$this->view->module = $module;
$this->view->block = $block;
$this->view->code = $code;
$this->view->modules = $this->blockZen->getAvailableModules($dashboard);
$this->view->blocks = $this->blockZen->getAvailableBlocks($dashboard, $module);
$this->view->params = $this->blockZen->getAvailableParams($dashboard, $module, $block);
$this->view->codes = $this->blockZen->getAvailableBlocks($dashboard, $module);
$this->view->params = $this->blockZen->getAvailableParams($dashboard, $module, $code);
$this->display();
}
@@ -65,11 +65,11 @@ class block extends control
*
* @param string $dashboard
* @param string $module
* @param string $block
* @param string $code
* @access public
* @return void
*/
public function edit(string $blockID, string $module = '', string $block = '')
public function edit(string $blockID, string $module = '', string $code = '')
{
$blockID = (int)$blockID;
if($_POST)
@@ -83,22 +83,22 @@ class block extends control
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true, 'callback' => 'loadCurrentPage()'));
}
$blockData = $this->block->getByID($blockID);
$block = $this->block->getByID($blockID);
$this->view->title = $this->lang->block->editBlock;
$this->view->blockData = $blockData;
$this->view->block = $block ? $block : $blockData->block;
$this->view->module = $module ? $module : $blockData->module;
$this->view->block = $block;
$this->view->module = $module ? $module : $block->module;
$this->view->code = $code ? $code : $block->code;
$this->view->modules = $this->blockZen->getAvailableModules($blockData->dashboard);
$this->view->blocks = $this->blockZen->getAvailableBlocks($blockData->dashboard, $this->view->module);
$this->view->params = $this->blockZen->getAvailableParams($blockData->dashboard, $this->view->module, $this->view->block);
$this->view->codes = $this->blockZen->getAvailableBlocks($blockData->dashboard, $this->view->module);
$this->view->params = $this->blockZen->getAvailableParams($blockData->dashboard, $this->view->module, $this->view->code);
$this->display();
}
public function set($id, $type, $module = '')
{
$block = $this->block->getByID($id);
if($block and empty($type)) $type = $block->block;
if($block and empty($type)) $type = $block->code;
if(isset($block->params->num) and !isset($block->params->count))
{
$block->params->count = $block->params->num;
@@ -206,7 +206,6 @@ class block extends control
* Display dashboard for app.
*
* @param string $module
* @param string $type
* @param int $projectID
* @access public
* @return void
@@ -235,25 +234,25 @@ class block extends control
/* Init block when vist index first. */
if((empty($blocks) and !$inited and !defined('TUTORIAL')))
{
if($this->block->initBlock($module, $type)) return print(js::reload());
if($this->block->initBlock($module)) return print(js::reload());
}
$acls = $this->app->user->rights['acls'];
$shortBlocks = $longBlocks = array();
foreach($blocks as $key => $block)
{
if(in_array($block->block, array('waterfallrisk', 'waterfallissue')))
if(in_array($block->code, array('waterfallrisk', 'waterfallissue')))
{
$model = isset($project->model) ? $project->model : 'waterfall';
if($block->block == 'waterfallrisk' and !helper::hasFeature("{$model}_risk")) continue;
if($block->block == 'waterfallissue' and !helper::hasFeature("{$model}_issue")) continue;
if($block->code == 'waterfallrisk' and !helper::hasFeature("{$model}_risk")) continue;
if($block->code == 'waterfallissue' and !helper::hasFeature("{$model}_issue")) continue;
}
if(in_array($block->block, array('scrumrisk', 'scrumissue')))
if(in_array($block->code, array('scrumrisk', 'scrumissue')))
{
$model = isset($project->model) ? $project->model : 'scrum';
if($block->block == 'scrumrisk' and !helper::hasFeature("{$model}_risk")) continue;
if($block->block == 'scrumissue' and !helper::hasFeature("{$model}_issue")) continue;
if($block->code == 'scrumrisk' and !helper::hasFeature("{$model}_risk")) continue;
if($block->code == 'scrumissue' and !helper::hasFeature("{$model}_issue")) continue;
}
if(!empty($block->source) and $block->source != 'todo' and !empty($acls['views']) and !isset($acls['views'][$block->source]))
@@ -265,14 +264,14 @@ class block extends control
$block->params = json_decode($block->params);
if(isset($block->params->num) and !isset($block->params->count)) $block->params->count = $block->params->num;
$blockID = $block->block;
$source = empty($block->source) ? 'common' : $block->source;
$code = $block->code;
$source = empty($block->source) ? 'common' : $block->source;
$block->blockLink = $this->createLink('block', 'printBlock', "id=$block->id&module=$block->module");
$block->moreLink = '';
if(isset($this->config->block->modules[$source]->moreLinkList->{$blockID}))
if(isset($this->config->block->modules[$source]->moreLinkList->{$code}))
{
list($moduleName, $method, $vars) = explode('|', sprintf($this->config->block->modules[$source]->moreLinkList->{$blockID}, isset($block->params->type) ? $block->params->type : ''));
list($moduleName, $method, $vars) = explode('|', sprintf($this->config->block->modules[$source]->moreLinkList->{$code}, isset($block->params->type) ? $block->params->type : ''));
/* The list assigned to me jumps to the work page when click more button. */
$block->moreLink = $this->createLink($moduleName, $method, $vars);
@@ -298,7 +297,7 @@ class block extends control
}
}
elseif($block->block == 'dynamic')
elseif($block->code == 'dynamic')
{
$block->moreLink = $this->createLink('company', 'dynamic');
}
@@ -399,7 +398,7 @@ class block extends control
if(empty($block)) return false;
$html = '';
if($block->block == 'html')
if($block->code == 'html')
{
if (empty($block->params->html))
{
@@ -416,28 +415,28 @@ class block extends control
$this->get->set('blockTitle', $block->title);
$this->get->set('module', $block->module);
$this->get->set('source', $block->source);
$this->get->set('blockid', $block->block);
$this->get->set('blockid', $block->code);
$this->get->set('param', base64_encode(json_encode($block->params)));
$html = $this->fetch('block', 'main', "module={$block->source}&id=$id");
}
elseif($block->block == 'dynamic')
elseif($block->code == 'dynamic')
{
$html = $this->fetch('block', 'dynamic');
}
elseif($block->block == 'guide')
elseif($block->code == 'guide')
{
$html = $this->fetch('block', 'guide', "blockID=$block->id");
}
elseif($block->block == 'assigntome')
elseif($block->code == 'assigntome')
{
$this->get->set('param', base64_encode(json_encode($block->params)));
$html = $this->fetch('block', 'printAssignToMeBlock', 'longBlock=' . $this->block->isLongBlock($block));
}
elseif($block->block == 'welcome')
elseif($block->code == 'welcome')
{
$html = $this->fetch('block', 'welcome', "blockID=$block->id");
}
elseif($block->block == 'contribute')
elseif($block->code == 'contribute')
{
$html = $this->fetch('block', 'contribute');
}
@@ -2233,8 +2232,8 @@ class block extends control
{
$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}");
$this->dao->delete()->from(TABLE_BLOCK)->where('source')->eq($block->source)->andWhere('code')->eq($block->code)->exec();
$this->loadModel('setting')->setItem('system.block.closed', $closedBlock . ",{$block->source}|{$block->code}");
return print(js::reload('parent'));
}
+3 -3
View File
@@ -2,7 +2,7 @@ function getForm(event)
{
const field = $(event.target).attr('id');
const module = $('#module').val();
const block = field == 'module' ? '' : $('#block').val();
const url = $.createLink('block', 'create', 'dashboard='+ dashboard +'&module=' + module + '&block=' + (block ? block : ''));
loadPage(url, '#blockRow, #paramsRow');
const code = field == 'module' ? '' : $('#code').val();
const url = $.createLink('block', 'create', 'dashboard='+ dashboard +'&module=' + module + '&code=' + (code ? code : ''));
loadPage(url, '#codeRow, #paramsRow');
}
+3 -3
View File
@@ -2,7 +2,7 @@ function getForm(event)
{
const field = $(event.target).attr('id');
const module = $('#module').val();
const block = field == 'module' ? '' : $('#block').val();
const url = $.createLink('block', 'edit', 'blockID=' + blockID + '&module=' + module + '&block=' + (block ? block : ''));
loadPage(url, '#blockRow, #paramsRow');
const code = field == 'module' ? '' : $('#code').val();
const url = $.createLink('block', 'edit', 'blockID=' + blockID + '&module=' + module + '&code=' + (code ? code : ''));
loadPage(url, '#codeRow, #paramsRow');
}
+10 -9
View File
@@ -16,13 +16,14 @@ jsVar('dashboard', $dashboard);
$paramsRows = array();
foreach($params as $code => $row)
foreach($params as $key => $row)
{
$paramsRows[] = formGroup
(
set::label($row['name']),
set::name('params'),
set::class('form-row'),
set::value($block->params->{$key}),
set::control(array
(
'type' => $row['control'],
@@ -34,7 +35,7 @@ foreach($params as $code => $row)
form
(
on::change('#module', 'getForm'),
on::change('#block', 'getForm'),
on::change('#code', 'getForm'),
formGroup
(
set::label($lang->block->lblModule),
@@ -47,18 +48,18 @@ form
),
div
(
set::id('blockRow'),
set::id('codeRow'),
set::class('form-row'),
$blocks
$codes
? formGroup
(
set::label($lang->block->lblBlock),
set::name('block'),
set::value($block),
set::name('code'),
set::value($code),
set::control(array
(
'type' => 'select',
'items' => array('') + $blocks
'items' => array('') + $codes
))
) : null
),
@@ -67,7 +68,7 @@ form
set::id('paramsRow'),
set::class('form-grid'),
$paramsRows,
(($module and $block) or ($module and !$blocks))
(($module and $code) or ($module and !$codes))
? formGroup
(
set::label($lang->block->name),
@@ -75,7 +76,7 @@ form
set::class('form-row'),
set::control('input')
) : null,
(($module and $block) or ($module and !$blocks))
(($module and $code) or ($module and !$codes))
? formGroup
(
set::label($lang->block->grid),
+14 -14
View File
@@ -12,18 +12,18 @@ declare(strict_types=1);
namespace zin;
set::title($title);
jsVar('blockID', $blockData->id);
jsVar('blockID', $block->id);
$paramsRows = array();
foreach($params as $code => $row)
foreach($params as $key => $row)
{
$paramsRows[] = formGroup
(
set::label($row['name']),
set::name('params'),
set::class('form-row'),
set::value($blockData->params->{$code}),
set::value($block->params->{$key}),
set::control(array
(
'type' => $row['control'],
@@ -35,12 +35,12 @@ foreach($params as $code => $row)
form
(
on::change('#module', 'getForm'),
on::change('#block', 'getForm'),
on::change('#code', 'getForm'),
formGroup
(
set::label($lang->block->lblModule),
set::name('module'),
set::value($blockData->module),
set::value($block->module),
set::control(array
(
'type' => 'select',
@@ -49,18 +49,18 @@ form
),
div
(
set::id('blockRow'),
set::id('codeRow'),
set::class('form-row'),
$blocks
$codes
? formGroup
(
set::label($lang->block->lblBlock),
set::name('block'),
set::value($block),
set::name('code'),
set::value($code),
set::control(array
(
'type' => 'select',
'items' => array('') + $blocks
'items' => array('') + $codes
))
) : null
),
@@ -69,22 +69,22 @@ form
set::id('paramsRow'),
set::class('form-grid'),
$paramsRows,
(($module and $block) or ($module and !$blocks))
(($module and $code) or ($module and !$codes))
? formGroup
(
set::label($lang->block->name),
set::name('title'),
set::class('form-row'),
set::value($blockData->title),
set::value($block->title),
set::control('input')
) : null,
(($module and $block) or ($module and !$blocks))
(($module and $code) or ($module and !$codes))
? formGroup
(
set::label($lang->block->grid),
set::name("grid"),
set::class('form-row'),
set::value($blockData->grid),
set::value($block->grid),
set::control(array
(
'type' => 'select',