* [misc] fix bug.
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
window.builderUpdate = function(action, type = 'page')
|
||||
{
|
||||
let {url, data, selectors} = getSqlBuilderPost(action, type);
|
||||
const formData = zui.createFormData({action, sqlBuilder: JSON.stringify(data)});
|
||||
selectors = `${selectors},pageJS/.zin-page-js,pageCSS/.zin-page-css>*,#configJS`;
|
||||
postAndLoadPage(url, formData, selectors);
|
||||
data = {sqlbuilder: data};
|
||||
const formData = zui.createFormData({action, data: JSON.stringify(data)});
|
||||
const defaultSelectors = ['#sqlBuilder', 'pageJS/.zin-page-js', 'pageCSS/.zin-page-css>*', '#configJS'];
|
||||
if(selectors?.length) defaultSelectors.push(selectors);
|
||||
postAndLoadPage(url, formData, defaultSelectors.join(','));
|
||||
}
|
||||
|
||||
window.getSqlBuilderPost = function(action, type = 'page')
|
||||
{
|
||||
const sqlBuilder = $('#builderPanel').data('sqlbuilder');
|
||||
const sqlBuilder = $('#sqlBuilder').data('sqlbuilder');
|
||||
const url = $('#builderPanel').data('url');
|
||||
const selectors = type == 'page' ? '#builderPanel' : '';
|
||||
|
||||
@@ -33,14 +35,19 @@ window.changeBuilderTable = function(event)
|
||||
const from = getSqlBuilder('from');
|
||||
const joins = getSqlBuilder('joins');
|
||||
|
||||
if(name == 'from') from.table = value;
|
||||
if(name == 'from')
|
||||
{
|
||||
from.table = value;
|
||||
from.select = [];
|
||||
}
|
||||
if(name.startsWith('left'))
|
||||
{
|
||||
const [key, alias] = name.split('_');
|
||||
const index = joins.findIndex(join => join.alias == alias);
|
||||
if(index < 0) return;
|
||||
|
||||
joins[index].table = value;
|
||||
joins[index].table = value;
|
||||
joins[index].select = [];
|
||||
}
|
||||
if(name.startsWith('join'))
|
||||
{
|
||||
@@ -355,9 +362,9 @@ window.switchGroupFieldType = function(event)
|
||||
|
||||
window.setSqlBuilder = function(key, value)
|
||||
{
|
||||
const sqlBuilder = $('#builderPanel').data('sqlbuilder');
|
||||
const sqlBuilder = $('#sqlBuilder').data('sqlbuilder');
|
||||
sqlBuilder[key] = value;
|
||||
$('#builderPanel').attr('data-sqlbuilder', JSON.stringify(sqlBuilder));
|
||||
$('#sqlBuilder').attr('data-sqlbuilder', JSON.stringify(sqlBuilder));
|
||||
}
|
||||
|
||||
window.getSqlBuilder = function(key)
|
||||
@@ -365,7 +372,7 @@ window.getSqlBuilder = function(key)
|
||||
const onUpdate = $('#builderPanel').data('onupdate');
|
||||
if(onUpdate?.length) window.builderUpdate = window[onUpdate];
|
||||
|
||||
const sqlBuilder = $('#builderPanel').data('sqlbuilder');
|
||||
const sqlBuilder = $('#sqlBuilder').data('sqlbuilder');
|
||||
|
||||
return sqlBuilder[key];
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ class sqlBuilder extends wg
|
||||
'data?: object',
|
||||
'tableList?: array',
|
||||
'url?: string',
|
||||
'onUpdate?: function'
|
||||
'onUpdate?: function',
|
||||
'afterUpdate?: function'
|
||||
);
|
||||
|
||||
protected static array $tablesDesc = array();
|
||||
@@ -425,16 +426,26 @@ class sqlBuilder extends wg
|
||||
global $lang;
|
||||
$this->setSteps();
|
||||
|
||||
list($class, $data, $url, $onUpdate) = $this->prop(array('class', 'data', 'url', 'onUpdate'));
|
||||
list($class, $data, $url, $onUpdate, $afterUpdate) = $this->prop(array('class', 'data', 'url', 'onUpdate', 'afterUpdate'));
|
||||
|
||||
return panel
|
||||
(
|
||||
setID('builderPanel'),
|
||||
set('data-sqlbuilder', $data),
|
||||
set('data-url', $url),
|
||||
set('data-onupdate', $onUpdate),
|
||||
setClass('h-96 min-w-1200', $class),
|
||||
set::bodyClass('flex h-96'),
|
||||
div
|
||||
(
|
||||
setID('sqlBuilder'),
|
||||
setClass('hidden'),
|
||||
set('data-sqlbuilder', $data),
|
||||
set('data-afterupdate', $afterUpdate),
|
||||
div
|
||||
(
|
||||
on::init()->do($afterUpdate)
|
||||
)
|
||||
),
|
||||
$this->buildStepBar(),
|
||||
$this->buildStepContent()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user