|
@@ -406,23 +406,23 @@ class TableAjax extends ViewAjax {
|
|
|
UI::showMessagesForTable($this->_tbl);
|
|
UI::showMessagesForTable($this->_tbl);
|
|
|
UI::endContainer();
|
|
UI::endContainer();
|
|
|
$namespace = $acl->getNamespace();
|
|
$namespace = $acl->getNamespace();
|
|
|
- ?>
|
|
|
|
|
- <div class="AjaxTableCont">
|
|
|
|
|
- <ul class="breadcrumb">
|
|
|
|
|
- <?php
|
|
|
|
|
- echo UI::h('li', [], [
|
|
|
|
|
|
|
+ echo UI::h('div', [ 'class' => "AjaxTableCont" ], [
|
|
|
|
|
+ UI::h('ul', [ 'class' => "breadcrumb" ], [
|
|
|
|
|
+ UI::h('li', [], [
|
|
|
UI::h('a', [ 'href' => "#", 'onclick' => "return tableAjaxBackToTable();" ], $this->getLabelHtml() ),
|
|
UI::h('a', [ 'href' => "#", 'onclick' => "return tableAjaxBackToTable();" ], $this->getLabelHtml() ),
|
|
|
- ]);
|
|
|
|
|
- if ($hasPermCreate) {
|
|
|
|
|
- echo UI::h('li', [], [
|
|
|
|
|
|
|
+ ]),
|
|
|
|
|
+
|
|
|
|
|
+ ($hasPermCreate)
|
|
|
|
|
+ ? UI::h('li', [], [
|
|
|
UI::h('a', [ 'title' => "Dodaj nowy rekord", 'class' => "", 'href' => "#CREATE" ], [
|
|
UI::h('a', [ 'title' => "Dodaj nowy rekord", 'class' => "", 'href' => "#CREATE" ], [
|
|
|
UI::h('span', [ 'class' => "glyphicon glyphicon-plus" ]),
|
|
UI::h('span', [ 'class' => "glyphicon glyphicon-plus" ]),
|
|
|
" Dodaj nowy rekord",
|
|
" Dodaj nowy rekord",
|
|
|
]),
|
|
]),
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
- if ($this->showProcesInitFiltr) {
|
|
|
|
|
- echo UI::h('div', [ 'class' => "btn-group pull-right" ], [
|
|
|
|
|
|
|
+ ])
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ ($this->showProcesInitFiltr)
|
|
|
|
|
+ ? UI::h('div', [ 'class' => "btn-group pull-right" ], [
|
|
|
UI::h('a', [ 'class' => "btn btn-xs btn-info dropdown-toggle",
|
|
UI::h('a', [ 'class' => "btn btn-xs btn-info dropdown-toggle",
|
|
|
'data-toggle' => "dropdown",
|
|
'data-toggle' => "dropdown",
|
|
|
'href' => "#",
|
|
'href' => "#",
|
|
@@ -434,10 +434,11 @@ class TableAjax extends ViewAjax {
|
|
|
UI::h('a', [ 'href' => "#", 'onclick' => "return false;" ], " loading ... "),
|
|
UI::h('a', [ 'href' => "#", 'onclick' => "return false;" ], " loading ... "),
|
|
|
]),
|
|
]),
|
|
|
]),
|
|
]),
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
- if ($this->showTableTools) {
|
|
|
|
|
- echo UI::h('div', [ 'class' => "btn-group pull-right" ], [
|
|
|
|
|
|
|
+ ])
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ ($this->showTableTools)
|
|
|
|
|
+ ? UI::h('div', [ 'class' => "btn-group pull-right" ], [
|
|
|
UI::h('a', [ 'class' => "btn btn-xs btn-default dropdown-toggle",
|
|
UI::h('a', [ 'class' => "btn btn-xs btn-default dropdown-toggle",
|
|
|
'style' => "margin-right:16px",
|
|
'style' => "margin-right:16px",
|
|
|
'data-toggle' => "dropdown",
|
|
'data-toggle' => "dropdown",
|
|
@@ -450,55 +451,56 @@ class TableAjax extends ViewAjax {
|
|
|
UI::h('a', [ 'href' => "#", 'onclick' => "return false;" ], " loading ... "),
|
|
UI::h('a', [ 'href' => "#", 'onclick' => "return false;" ], " loading ... "),
|
|
|
]),
|
|
]),
|
|
|
]),
|
|
]),
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- <?php if ($this->_tbl == 'IN7_MK_BAZA_DYSTRYBUCJI') : ?>
|
|
|
|
|
- <a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?MENU_INIT=TREEJS&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
|
|
|
|
|
- <?php elseif ($this->allowTreeView()) : ?>
|
|
|
|
|
- <a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?MENU_INIT=VIEWTREE_AJAX&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
- <?php if ($this->_tbl == 'WMS_MAP_GEOREFERENCES') : ?>
|
|
|
|
|
- <a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?_route=GeoreferencesManager"; ?>"><i class="glyphicon glyphicon glyphicon-wrench"></i> Zarządzaj punktami</a>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
- </ul>
|
|
|
|
|
- <?php
|
|
|
|
|
- if ($this->_backRefFilter) {
|
|
|
|
|
- echo UI::h('div', [ 'class' => "container" ], [
|
|
|
|
|
- UI::h('div', [ 'class' => "alert alert-info" ], [
|
|
|
|
|
- "Rekordy powiązane z rekordem {$this->_backRefFilter['primaryKey']} z ",
|
|
|
|
|
- UI::h('a', [
|
|
|
|
|
- 'href' => "index.php?_route=ViewTableAjax&namespace={$this->_backRefFilter['namespace']}",
|
|
|
|
|
- ], $this->_backRefFilter['namespace']),
|
|
|
|
|
- " - ",
|
|
|
|
|
- UI::h('a', [
|
|
|
|
|
- 'href' => $this->rootUrl,
|
|
|
|
|
- 'style' => "color:red",
|
|
|
|
|
- ], "usuń filtr"),
|
|
|
|
|
- ]),
|
|
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- <?php
|
|
|
|
|
- if ($this->_childRefFilter) {
|
|
|
|
|
- echo UI::h('div', [ 'class' => "container" ], [
|
|
|
|
|
- UI::h('div', [ 'class' => "alert alert-info" ], [
|
|
|
|
|
- "Rekordy powiązane z rekordem {$this->_childRefFilter['primaryKey']} z ",
|
|
|
|
|
- UI::h('a', [
|
|
|
|
|
- 'href' => "index.php?_route=ViewTableAjax&namespace={$this->_childRefFilter['namespace']}",
|
|
|
|
|
- ], $this->_childRefFilter['namespace']),
|
|
|
|
|
- " - ",
|
|
|
|
|
- UI::h('a', [
|
|
|
|
|
- 'href' => $this->rootUrl,
|
|
|
|
|
- 'style' => "color:red",
|
|
|
|
|
- ], "usuń filtr"),
|
|
|
|
|
- ]),
|
|
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- <div id="<?= $this->_htmlID; ?>"></div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php
|
|
|
|
|
|
|
+ ])
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ ($this->_tbl == 'IN7_MK_BAZA_DYSTRYBUCJI')
|
|
|
|
|
+ ? UI::h('a', [ 'class' => "pull-right", 'style' => "padding:0 20px 0 0", 'href' => "index.php?MENU_INIT=TREEJS&ZASOB_ID={$this->_zasobID}" ], "<i class=\"glyphicon glyphicon-eye-open\"></i> Drzewo")
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ ($this->_tbl !== 'IN7_MK_BAZA_DYSTRYBUCJI' && $this->allowTreeView())
|
|
|
|
|
+ ? UI::h('a', [ 'class' => "pull-right", 'style' => "padding:0 20px 0 0", 'href' => "index.php?MENU_INIT=VIEWTREE_AJAX&ZASOB_ID={$this->_zasobID}" ], "<i class=\"glyphicon glyphicon-eye-open\"></i> Drzewo")
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ ($this->_tbl == 'WMS_MAP_GEOREFERENCES')
|
|
|
|
|
+ ? UI::h('a', [ 'class' => "pull-right", 'style' => "padding:0 20px 0 0", 'href' => "index.php?_route=GeoreferencesManager" ], "<i class=\"glyphicon glyphicon glyphicon-wrench\"></i> Zarządzaj punktami")
|
|
|
|
|
+ : '',
|
|
|
|
|
+ ]),
|
|
|
|
|
+
|
|
|
|
|
+ ($this->_backRefFilter)
|
|
|
|
|
+ ? UI::h('div', [ 'class' => "container" ], [
|
|
|
|
|
+ UI::h('div', [ 'class' => "alert alert-info" ], [
|
|
|
|
|
+ "Rekordy powiązane z rekordem {$this->_backRefFilter['primaryKey']} z ",
|
|
|
|
|
+ UI::h('a', [
|
|
|
|
|
+ 'href' => "index.php?_route=ViewTableAjax&namespace={$this->_backRefFilter['namespace']}",
|
|
|
|
|
+ ], $this->_backRefFilter['namespace']),
|
|
|
|
|
+ " - ",
|
|
|
|
|
+ UI::h('a', [
|
|
|
|
|
+ 'href' => $this->rootUrl,
|
|
|
|
|
+ 'style' => "color:red",
|
|
|
|
|
+ ], "usuń filtr"),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ ])
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ ($this->_childRefFilter)
|
|
|
|
|
+ ? UI::h('div', [ 'class' => "container" ], [
|
|
|
|
|
+ UI::h('div', [ 'class' => "alert alert-info" ], [
|
|
|
|
|
+ "Rekordy powiązane z rekordem {$this->_childRefFilter['primaryKey']} z ",
|
|
|
|
|
+ UI::h('a', [
|
|
|
|
|
+ 'href' => "index.php?_route=ViewTableAjax&namespace={$this->_childRefFilter['namespace']}",
|
|
|
|
|
+ ], $this->_childRefFilter['namespace']),
|
|
|
|
|
+ " - ",
|
|
|
|
|
+ UI::h('a', [
|
|
|
|
|
+ 'href' => $this->rootUrl,
|
|
|
|
|
+ 'style' => "color:red",
|
|
|
|
|
+ ], "usuń filtr"),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ ])
|
|
|
|
|
+ : '',
|
|
|
|
|
+
|
|
|
|
|
+ UI::h('div', [ 'id' => $this->_htmlID ]),
|
|
|
|
|
+ ]);
|
|
|
UI::inlineJS(__FILE__ . '.generateFunctionNode.js');
|
|
UI::inlineJS(__FILE__ . '.generateFunctionNode.js');
|
|
|
UI::inlineJS(__FILE__ . '.GeomField.js');
|
|
UI::inlineJS(__FILE__ . '.GeomField.js');
|
|
|
if ($this->showProcesInitFiltr) {
|
|
if ($this->showProcesInitFiltr) {
|
|
@@ -618,8 +620,11 @@ class TableAjax extends ViewAjax {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //try call webservice for data
|
|
|
|
|
- priv.update(priv.options.router);
|
|
|
|
|
|
|
+ if (location.hash) {
|
|
|
|
|
+ priv.options.router()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ priv.update(priv.options.router)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (typeof priv.options.router == "function") {
|
|
if (typeof priv.options.router == "function") {
|
|
|
$(window).bind('hashchange', function() {
|
|
$(window).bind('hashchange', function() {
|
|
@@ -709,65 +714,37 @@ class TableAjax extends ViewAjax {
|
|
|
priv.renderInlineEditBox();// .tblAjax__inlineEditBox
|
|
priv.renderInlineEditBox();// .tblAjax__inlineEditBox
|
|
|
|
|
|
|
|
_foot = _head = _body = _headSort = _headFilter = undefined;// TODO: refactor
|
|
_foot = _head = _body = _headSort = _headFilter = undefined;// TODO: refactor
|
|
|
- /// console.log('L.<?php echo __LINE__; ?> priv.initialRender, _uiNode$Table: ', _uiNode$Table.html())
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- creates the table with all its parts and handlers.
|
|
|
|
|
- note that only the parts we need is created.
|
|
|
|
|
- (yeah, the function is huge)
|
|
|
|
|
- */
|
|
|
|
|
priv.renderTable = function() {
|
|
priv.renderTable = function() {
|
|
|
- //create table itself
|
|
|
|
|
- // console.log('renderTable:: _data', _data);//TODO:DBG:RMME
|
|
|
|
|
- /// console.log('renderTable:: _uiNode$Table', _uiNode$Table);//TODO:DBG:RMME
|
|
|
|
|
-
|
|
|
|
|
- //create the header which will later hold both sorting and filtering
|
|
|
|
|
- /// console.log('renderTable:: _head', _head);//TODO:DBG:RMME
|
|
|
|
|
|
|
+ if (!_state.colsSorted) return;
|
|
|
if (!_head) {
|
|
if (!_head) {
|
|
|
_headSort = _headFilter = _headSpecialFilter = undefined;
|
|
_headSort = _headFilter = _headSpecialFilter = undefined;
|
|
|
- //_head = $('<thead></thead>');
|
|
|
|
|
- // $('<tr class="sort"></tr>').prependTo(_head);
|
|
|
|
|
- //_uiNode$Table.find('thead').replaceWith(_head);
|
|
|
|
|
_head = _uiNode$Table.find('thead');
|
|
_head = _uiNode$Table.find('thead');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //create the header sorting row
|
|
|
|
|
- if (!_headSort) {
|
|
|
|
|
- /// console.log('renderTable::renderTableTheadSort...');//TODO:DBG:RMME
|
|
|
|
|
- priv.renderTableTheadSort();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //create the header filtering row
|
|
|
|
|
|
|
+ if (!_headSort) priv.renderTableTheadSort();
|
|
|
if (!_headFilter && priv.options.filter) {
|
|
if (!_headFilter && priv.options.filter) {
|
|
|
- /// console.log('renderTable::renderTableTheadFilter...');//TODO:DBG:RMME
|
|
|
|
|
priv.renderTableTheadFilter();
|
|
priv.renderTableTheadFilter();
|
|
|
_headFilter = true;
|
|
_headFilter = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //create the header special filters row
|
|
|
|
|
if (!_headSpecialFilter && priv.options.specialFilterFunctions) {
|
|
if (!_headSpecialFilter && priv.options.specialFilterFunctions) {
|
|
|
priv.renderHeadSpecialFilters();
|
|
priv.renderHeadSpecialFilters();
|
|
|
_headSpecialFilter = true;
|
|
_headSpecialFilter = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //create the body
|
|
|
|
|
if (!_body) {
|
|
if (!_body) {
|
|
|
_uiNode$Table.find('tbody').remove();
|
|
_uiNode$Table.find('tbody').remove();
|
|
|
_bodyNode = $('<tbody></tbody>').insertAfter(_head);
|
|
_bodyNode = $('<tbody></tbody>').insertAfter(_head);
|
|
|
//_bodyNode.on('change', '.unique', priv.rowChecked);
|
|
//_bodyNode.on('change', '.unique', priv.rowChecked);
|
|
|
|
|
|
|
|
- //find out what rows to show next...
|
|
|
|
|
|
|
+ // find out what rows to show next...
|
|
|
var rowsAdded = 0;
|
|
var rowsAdded = 0;
|
|
|
|
|
|
|
|
- //slice out the chunk of data we need and create rows
|
|
|
|
|
|
|
+ // slice out the chunk of data we need and create rows
|
|
|
$.each(_data.rows, function(index, props) {
|
|
$.each(_data.rows, function(index, props) {
|
|
|
var rowNode = priv.renderRow(props);
|
|
var rowNode = priv.renderRow(props);
|
|
|
if (rowNode) rowNode.appendTo(_bodyNode);
|
|
if (rowNode) rowNode.appendTo(_bodyNode);
|
|
|
rowsAdded++;
|
|
rowsAdded++;
|
|
|
-
|
|
|
|
|
- //enough rows created?
|
|
|
|
|
- if (rowsAdded >= priv.options.pageSize) {
|
|
|
|
|
|
|
+ if (rowsAdded >= priv.options.pageSize) { // enough rows created
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -776,8 +753,7 @@ class TableAjax extends ViewAjax {
|
|
|
_totalPages = Math.ceil(_data.total / priv.options.pageSize);
|
|
_totalPages = Math.ceil(_data.total / priv.options.pageSize);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //pad with empty rows if we're at last page.
|
|
|
|
|
- if (_state.page == _totalPages) {
|
|
|
|
|
|
|
+ if (_state.page == _totalPages) { // pad with empty rows if we're at last page.
|
|
|
while (rowsAdded < priv.options.pageSize) {
|
|
while (rowsAdded < priv.options.pageSize) {
|
|
|
var rowNode = priv.renderRowEmptyNode();
|
|
var rowNode = priv.renderRowEmptyNode();
|
|
|
if (rowNode) rowNode.appendTo(_bodyNode);
|
|
if (rowNode) rowNode.appendTo(_bodyNode);
|
|
@@ -786,7 +762,6 @@ class TableAjax extends ViewAjax {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //create the footer
|
|
|
|
|
if (!_foot) {
|
|
if (!_foot) {
|
|
|
priv.renderTableTfoot();
|
|
priv.renderTableTfoot();
|
|
|
priv.renderFooter();
|
|
priv.renderFooter();
|
|
@@ -805,19 +780,21 @@ class TableAjax extends ViewAjax {
|
|
|
var colsW = stickyCol1Width + stickyCol2Width;
|
|
var colsW = stickyCol1Width + stickyCol2Width;
|
|
|
jQuery(_uiNodeCont).css({width:'' + (contW - colsW) + 'px', marginLeft:'' + colsW + 'px', overflowX:'scroll', overflowY:'visible', paddingBottom:'1px'});
|
|
jQuery(_uiNodeCont).css({width:'' + (contW - colsW) + 'px', marginLeft:'' + colsW + 'px', overflowX:'scroll', overflowY:'visible', paddingBottom:'1px'});
|
|
|
}
|
|
}
|
|
|
- _uiNode$Table.find('.stickyCol1').css({position:'absolute',
|
|
|
|
|
- left:'0',
|
|
|
|
|
- top:'auto',
|
|
|
|
|
- width:'' + stickyCol1Width + 'px',
|
|
|
|
|
|
|
+ _uiNode$Table.find('.stickyCol1').css({
|
|
|
|
|
+ position: 'absolute',
|
|
|
|
|
+ left: '0',
|
|
|
|
|
+ top: 'auto',
|
|
|
|
|
+ width: '' + stickyCol1Width + 'px',
|
|
|
});
|
|
});
|
|
|
//_uiNode$Table.find('.filter').find('.stickyCol1').css({height:'34px'});
|
|
//_uiNode$Table.find('.filter').find('.stickyCol1').css({height:'34px'});
|
|
|
var sortStickyColHeight = _uiNode$Table.find('.sort').find('th:last').outerHeight();
|
|
var sortStickyColHeight = _uiNode$Table.find('.sort').find('th:last').outerHeight();
|
|
|
_uiNode$Table.find('.sort').find('.stickyCol1').css({height: sortStickyColHeight + 'px'});
|
|
_uiNode$Table.find('.sort').find('.stickyCol1').css({height: sortStickyColHeight + 'px'});
|
|
|
_uiNode$Table.find('.sort').find('.stickyCol2').css({height: sortStickyColHeight + 'px'});
|
|
_uiNode$Table.find('.sort').find('.stickyCol2').css({height: sortStickyColHeight + 'px'});
|
|
|
- _uiNode$Table.find('.stickyCol2').css({position:'absolute',
|
|
|
|
|
- left:'' + (stickyCol1Width) + 'px',
|
|
|
|
|
- top:'auto',
|
|
|
|
|
- width:'' + stickyCol2Width + 'px',
|
|
|
|
|
|
|
+ _uiNode$Table.find('.stickyCol2').css({
|
|
|
|
|
+ position: 'absolute',
|
|
|
|
|
+ left: '' + (stickyCol1Width) + 'px',
|
|
|
|
|
+ top: 'auto',
|
|
|
|
|
+ width: '' + stickyCol2Width + 'px',
|
|
|
borderRight: '1px solid silver',
|
|
borderRight: '1px solid silver',
|
|
|
overflow: 'hidden'
|
|
overflow: 'hidden'
|
|
|
});
|
|
});
|
|
@@ -977,13 +954,24 @@ class TableAjax extends ViewAjax {
|
|
|
break;
|
|
break;
|
|
|
case "special":
|
|
case "special":
|
|
|
fieldWidget = (function(fldName, fieldProps) {
|
|
fieldWidget = (function(fldName, fieldProps) {
|
|
|
- var _fieldName = fldName,
|
|
|
|
|
- _fieldProps = fieldProps,
|
|
|
|
|
- _format = _.get(_fieldProps, 'format', '{0}');
|
|
|
|
|
|
|
+ var _fieldName = fldName;
|
|
|
|
|
+ var _fieldProps = fieldProps;
|
|
|
|
|
+ var _format = _.get(_fieldProps, 'format', '{0}');
|
|
|
|
|
+ var _aliasMap = _.get(_fieldProps, 'aliasMap', null);
|
|
|
// console.log('FieldWidget: generate function to render field('+_fieldName+') ', fieldProps);
|
|
// console.log('FieldWidget: generate function to render field('+_fieldName+') ', fieldProps);
|
|
|
return function(val, fieldPK, row) {
|
|
return function(val, fieldPK, row) {
|
|
|
- // console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value('+val+') ', fieldProps);
|
|
|
|
|
- return p5Utils__format(_format, [val]);
|
|
|
|
|
|
|
+ // console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value('+val+') ', fieldProps, 'row', row);
|
|
|
|
|
+ var format = _format;
|
|
|
|
|
+ if (_aliasMap) {
|
|
|
|
|
+ Object.keys(_aliasMap).map(function (mapKey) {
|
|
|
|
|
+ var mapField = _aliasMap[mapKey]
|
|
|
|
|
+ if (undefined !== row[mapField]) {
|
|
|
|
|
+ format = format.replace(new RegExp('\{' + mapKey + '\}', 'g'), row[mapField]);
|
|
|
|
|
+ }
|
|
|
|
|
+ // console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value('+val+') _aliasMap:', _aliasMap, 'row['+mapField+']', row[mapField], 'converted val:', val);
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ return p5Utils__format(format, [val]);
|
|
|
}
|
|
}
|
|
|
}(fldName, fieldProps));
|
|
}(fldName, fieldProps));
|
|
|
break;
|
|
break;
|
|
@@ -2091,14 +2079,14 @@ class TableAjax extends ViewAjax {
|
|
|
priv.update = function(callback) {
|
|
priv.update = function(callback) {
|
|
|
var skipCols, resetChecked;// undefined
|
|
var skipCols, resetChecked;// undefined
|
|
|
if (!priv.options.url) {
|
|
if (!priv.options.url) {
|
|
|
- if (priv.options.debug) console.log('no url found L.<?php echo __LINE__; ?>');
|
|
|
|
|
|
|
+ if (priv.options.debug) console.log('no url found');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (priv.options.debug) console.log(p5Utils__format('requesting data from url:{0} data:{1} L.<?php echo __LINE__; ?>', [priv.options.url, JSON.stringify(priv.options.urlData) || '']));
|
|
|
|
|
|
|
+ if (priv.options.debug) console.log(p5Utils__format('requesting data from url:{0} data:{1}', [priv.options.url, JSON.stringify(priv.options.urlData) || '']));
|
|
|
|
|
|
|
|
- var initUrlAdd = '',
|
|
|
|
|
- filtersInitSet = false;
|
|
|
|
|
|
|
+ var initUrlAdd = '';
|
|
|
|
|
+ var filtersInitSet = false;
|
|
|
initUrlAdd += '&currSortCol=' + _state.filters.currSortCol;
|
|
initUrlAdd += '&currSortCol=' + _state.filters.currSortCol;
|
|
|
initUrlAdd += '&currSortFlip=' + ((_state.filters.currSortCol)? "desc" : "asc");
|
|
initUrlAdd += '&currSortFlip=' + ((_state.filters.currSortCol)? "desc" : "asc");
|
|
|
if (Object.keys(_state.filters.filterCols).length > 0) {
|
|
if (Object.keys(_state.filters.filterCols).length > 0) {
|
|
@@ -2130,52 +2118,58 @@ class TableAjax extends ViewAjax {
|
|
|
}).then(function (response) {
|
|
}).then(function (response) {
|
|
|
return response.json()
|
|
return response.json()
|
|
|
}).then(function (data) {
|
|
}).then(function (data) {
|
|
|
- if (priv.options.debug) console.log('loadDataAjax:fetch:update: request finished L.<?php echo __LINE__; ?> data:', data);
|
|
|
|
|
|
|
+ if (priv.options.debug) console.log('loadDataAjax:fetch:update: request finished response data:', data);
|
|
|
if ('success' == data.type) {
|
|
if ('success' == data.type) {
|
|
|
// p5UI__notifyAjaxCallback(data);
|
|
// p5UI__notifyAjaxCallback(data);
|
|
|
- if (data && data.cols) {
|
|
|
|
|
- priv.setStateCols(data.cols, data.primaryKey);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // set initial filters (_state.filters.filterCols)
|
|
|
|
|
- if (filtersInitSet && _data && _data.cols) {
|
|
|
|
|
- $.map(reqData, function(fltrValue, fltr){
|
|
|
|
|
- var colName = null;
|
|
|
|
|
- if (fltr.substr(0, 3) == 'sf_') {
|
|
|
|
|
- colName = fltr.substr(3);
|
|
|
|
|
- }
|
|
|
|
|
- else if (fltr.substr(0, 2) == 'f_') {
|
|
|
|
|
- colName = fltr.substr(2);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (colName && _data.cols[colName]) {
|
|
|
|
|
- //add the filter to the filter array
|
|
|
|
|
- _state.filters.filterCols[colName] = {
|
|
|
|
|
- filter: fltrValue,
|
|
|
|
|
- colName: colName
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // assign the new state (data)
|
|
|
|
|
- state = {data: {}};
|
|
|
|
|
- if (!skipCols) state.data.cols = data.cols || {};
|
|
|
|
|
- state.data.rows = data.rows || [];
|
|
|
|
|
- state.data.total = data.total || 0;
|
|
|
|
|
- state.page = data.page || 0;
|
|
|
|
|
- state.pageSize = data.pageSize || priv.options.pageSize;
|
|
|
|
|
- state.filters = data.filters || {};
|
|
|
|
|
- priv.setState(state);
|
|
|
|
|
-
|
|
|
|
|
- if (typeof callback == "function") {
|
|
|
|
|
- callback.call(this);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return data;
|
|
|
} else if ('error' == data.type) {
|
|
} else if ('error' == data.type) {
|
|
|
p5UI__notifyAjaxCallback(data);
|
|
p5UI__notifyAjaxCallback(data);
|
|
|
} else {
|
|
} else {
|
|
|
p5UI__notifyAjaxCallback(data);
|
|
p5UI__notifyAjaxCallback(data);
|
|
|
}
|
|
}
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }).then(function (data) {
|
|
|
|
|
+ if (priv.options.debug) console.log('loadDataAjax:fetch:update: request finished data:', data);
|
|
|
|
|
+ if (!data) return;
|
|
|
|
|
+ if (data && data.cols) {
|
|
|
|
|
+ priv.setStateCols(data.cols, data.primaryKey);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // set initial filters (_state.filters.filterCols)
|
|
|
|
|
+ if (filtersInitSet && _data && _data.cols) {
|
|
|
|
|
+ $.map(reqData, function(fltrValue, fltr){
|
|
|
|
|
+ var colName = null;
|
|
|
|
|
+ if (fltr.substr(0, 3) == 'sf_') {
|
|
|
|
|
+ colName = fltr.substr(3);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (fltr.substr(0, 2) == 'f_') {
|
|
|
|
|
+ colName = fltr.substr(2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (colName && _data.cols[colName]) {
|
|
|
|
|
+ //add the filter to the filter array
|
|
|
|
|
+ _state.filters.filterCols[colName] = {
|
|
|
|
|
+ filter: fltrValue,
|
|
|
|
|
+ colName: colName
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // assign the new state (data)
|
|
|
|
|
+ state = {data: {}};
|
|
|
|
|
+ if (!skipCols) state.data.cols = data.cols || {};
|
|
|
|
|
+ state.data.rows = data.rows || [];
|
|
|
|
|
+ state.data.total = data.total || 0;
|
|
|
|
|
+ state.data.primaryKey = data.primaryKey || 'ID';
|
|
|
|
|
+ state.page = data.page || 0;
|
|
|
|
|
+ state.pageSize = data.pageSize || priv.options.pageSize;
|
|
|
|
|
+ state.filters = data.filters || {};
|
|
|
|
|
+ priv.setState(state);
|
|
|
|
|
+
|
|
|
|
|
+ if (typeof callback == "function") {
|
|
|
|
|
+ callback.call(this);
|
|
|
|
|
+ }
|
|
|
}).catch(function (e) {
|
|
}).catch(function (e) {
|
|
|
console.log('loadDataAjax:fetch: ERR:', e);
|
|
console.log('loadDataAjax:fetch: ERR:', e);
|
|
|
});
|
|
});
|
|
@@ -2185,15 +2179,15 @@ class TableAjax extends ViewAjax {
|
|
|
assigns the new data.
|
|
assigns the new data.
|
|
|
*/
|
|
*/
|
|
|
priv.setState = function(state) {
|
|
priv.setState = function(state) {
|
|
|
- var oldState = _state,// TODO: use to check what really changed (use extend!)
|
|
|
|
|
- renderParts = {};
|
|
|
|
|
|
|
+ var oldState = _state; // TODO: use to check what really changed (use extend!)
|
|
|
|
|
+ var renderParts = {};
|
|
|
if (state.data) {
|
|
if (state.data) {
|
|
|
- if (state.data.cols && state.data.cols.length > 0) {// TODO: never happen, but if happend then rerender all
|
|
|
|
|
|
|
+ if (state.data.cols && Object.keys(state.data.cols).length > 0) {// TODO: never happen, but if happend then rerender all
|
|
|
priv.setStateCols(state.data.cols, state.data.primaryKey);
|
|
priv.setStateCols(state.data.cols, state.data.primaryKey);
|
|
|
priv.setStateData(state.data);
|
|
priv.setStateData(state.data);
|
|
|
renderParts['head'] = true;
|
|
renderParts['head'] = true;
|
|
|
} else {
|
|
} else {
|
|
|
- priv.setStateData(state.data, true);
|
|
|
|
|
|
|
+ priv.setStateData(state.data);
|
|
|
}
|
|
}
|
|
|
renderParts['body'] = true;
|
|
renderParts['body'] = true;
|
|
|
renderParts['foot_pagination'] = true;
|
|
renderParts['foot_pagination'] = true;
|
|
@@ -2215,9 +2209,7 @@ class TableAjax extends ViewAjax {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (state.hasOwnProperty('filters')) {
|
|
if (state.hasOwnProperty('filters')) {
|
|
|
-/// console.log('L.<?php echo __LINE__; ?> setState::state.filters: ', state.filters);//TODO:DBG:RMME
|
|
|
|
|
priv.setStateFilters(state.filters);
|
|
priv.setStateFilters(state.filters);
|
|
|
- // TODO: if state diff's
|
|
|
|
|
renderParts['head__specialFilters'] = true;
|
|
renderParts['head__specialFilters'] = true;
|
|
|
renderParts['foot_pagination'] = true;
|
|
renderParts['foot_pagination'] = true;
|
|
|
}
|
|
}
|
|
@@ -2225,15 +2217,15 @@ class TableAjax extends ViewAjax {
|
|
|
renderParts = Object.keys(renderParts);
|
|
renderParts = Object.keys(renderParts);
|
|
|
|
|
|
|
|
if (priv.options.debug) console.log('setState::renderParts: ', renderParts);//TODO:DBG:RMME
|
|
if (priv.options.debug) console.log('setState::renderParts: ', renderParts);//TODO:DBG:RMME
|
|
|
-///console.log('L.<?php echo __LINE__; ?> setState::renderParts: ', renderParts);//TODO:DBG:RMME
|
|
|
|
|
if (renderParts.length > 0) {
|
|
if (renderParts.length > 0) {
|
|
|
jQuery(_uiNodeCont).trigger('TableAjax:render', renderParts);
|
|
jQuery(_uiNodeCont).trigger('TableAjax:render', renderParts);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
priv.setStateCols = function(cols, primaryKey) {
|
|
priv.setStateCols = function(cols, primaryKey) {
|
|
|
|
|
+ if (priv.options.debug) console.log('priv.setStateCols: ', {primaryKey: primaryKey, cols: cols});
|
|
|
_state.cols = cols;
|
|
_state.cols = cols;
|
|
|
- _state.primaryKey = primaryKey;
|
|
|
|
|
|
|
+ _state.primaryKey = primaryKey || _state.primaryKey;
|
|
|
// fix col name - props.column
|
|
// fix col name - props.column
|
|
|
$.each(_state.cols, function(col, props) {
|
|
$.each(_state.cols, function(col, props) {
|
|
|
props.column = col;
|
|
props.column = col;
|
|
@@ -3367,8 +3359,7 @@ class TableAjax extends ViewAjax {
|
|
|
priv.loadPage(page, pageSize);
|
|
priv.loadPage(page, pageSize);
|
|
|
}
|
|
}
|
|
|
priv.loadPage = function(page, pageSize) {
|
|
priv.loadPage = function(page, pageSize) {
|
|
|
- var skipCols = true, // skipCols = true - prevent columns delete
|
|
|
|
|
- resetChecked = false;
|
|
|
|
|
|
|
+ var resetChecked = false;
|
|
|
var reqData = {
|
|
var reqData = {
|
|
|
page: page,
|
|
page: page,
|
|
|
pageSize: (pageSize || priv.options.pageSize),
|
|
pageSize: (pageSize || priv.options.pageSize),
|
|
@@ -3387,7 +3378,6 @@ class TableAjax extends ViewAjax {
|
|
|
urlAdd += '&f_' + col + '=' + encodeURIComponent(colProps.filter);
|
|
urlAdd += '&f_' + col + '=' + encodeURIComponent(colProps.filter);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- skipCols = true;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// specialFilters
|
|
// specialFilters
|
|
@@ -3417,9 +3407,10 @@ class TableAjax extends ViewAjax {
|
|
|
// p5UI__notifyAjaxCallback(data);
|
|
// p5UI__notifyAjaxCallback(data);
|
|
|
if ('success' == data.type) {
|
|
if ('success' == data.type) {
|
|
|
state = {data: {}};
|
|
state = {data: {}};
|
|
|
- if (!skipCols) state.data.cols = data.cols || {};
|
|
|
|
|
|
|
+ state.data.cols = data.cols || {};
|
|
|
state.data.rows = data.rows || [];
|
|
state.data.rows = data.rows || [];
|
|
|
state.data.total = data.total || 0;
|
|
state.data.total = data.total || 0;
|
|
|
|
|
+ state.data.primaryKey = data.primaryKey || 'ID';
|
|
|
state.page = data.page || 0;
|
|
state.page = data.page || 0;
|
|
|
state.pageSize = data.pageSize || priv.options.pageSize;
|
|
state.pageSize = data.pageSize || priv.options.pageSize;
|
|
|
state.filters = data.filters || {};
|
|
state.filters = data.filters || {};
|
|
@@ -4826,7 +4817,12 @@ jQuery(document).ready(function(){
|
|
|
if (!$record) throw new HttpException("404: No item ID({$id})", 404);
|
|
if (!$record) throw new HttpException("404: No item ID({$id})", 404);
|
|
|
|
|
|
|
|
$visibleCols = $acl->getRealFieldList();
|
|
$visibleCols = $acl->getRealFieldList();
|
|
|
- $rowsHist = $acl->getHistItems($id);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ $rowsHist = $acl->getHistItems($id);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ DBG::log($e);
|
|
|
|
|
+ $rowsHist = [];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$jsonResponse['row_functions'] = $this->_parseRowFunctions($record['ID'], array('hist', 'cp'), $showLabel = true);
|
|
$jsonResponse['row_functions'] = $this->_parseRowFunctions($record['ID'], array('hist', 'cp'), $showLabel = true);
|
|
|
|
|
|
|
@@ -5653,8 +5649,8 @@ jQuery(document).ready(function(){
|
|
|
switch ($typeName) {
|
|
switch ($typeName) {
|
|
|
case 'enum': $columnConfig->type = 'string'; break;
|
|
case 'enum': $columnConfig->type = 'string'; break;
|
|
|
case 'alias': {
|
|
case 'alias': {
|
|
|
- $format = $acl->getXsdFieldParam($col, 'format');
|
|
|
|
|
- if ($format) $columnConfig->format = $format;
|
|
|
|
|
|
|
+ if ($format = $acl->getXsdFieldParam($col, 'format')) $columnConfig->format = $format;
|
|
|
|
|
+ if ($aliasMap = $acl->getXsdFieldParam($col, 'aliasMap')) $columnConfig->aliasMap = $aliasMap;
|
|
|
} break;
|
|
} break;
|
|
|
case 'string': {
|
|
case 'string': {
|
|
|
$columnConfig->type = 'p5:string';
|
|
$columnConfig->type = 'p5:string';
|
|
@@ -5823,11 +5819,16 @@ jQuery(document).ready(function(){
|
|
|
$sqlRemoteValueFieldName = V::get('remote_column_value', '', $conf);
|
|
$sqlRemoteValueFieldName = V::get('remote_column_value', '', $conf);
|
|
|
$sqlRemoteKeyName = V::get('remote_join_key', '', $conf);
|
|
$sqlRemoteKeyName = V::get('remote_join_key', '', $conf);
|
|
|
$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
|
|
$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
|
|
|
- $aliasValuesRaw = DB::getPDO()->fetchAllByKey("
|
|
|
|
|
- select r.{$sqlRemoteKeyName} as {$sqlLocalKeyName}, r.{$sqlRemoteValueFieldName} as remote_value
|
|
|
|
|
- from {$sqlRemoteTable} r
|
|
|
|
|
- where r.{$sqlRemoteKeyName} in(" . implode(",", $localKeys[$localKeyName]) . ")
|
|
|
|
|
- ", $sqlLocalKeyName);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ $aliasValuesRaw = DB::getPDO()->fetchAllByKey("
|
|
|
|
|
+ select r.{$sqlRemoteKeyName} as {$sqlLocalKeyName}, r.{$sqlRemoteValueFieldName} as remote_value
|
|
|
|
|
+ from {$sqlRemoteTable} r
|
|
|
|
|
+ where r.{$sqlRemoteKeyName} in(" . implode(",", $localKeys[$localKeyName]) . ")
|
|
|
|
|
+ ", $sqlLocalKeyName);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ // TODO: error msg for GUI
|
|
|
|
|
+ DBG::log($e);
|
|
|
|
|
+ }
|
|
|
if(V::get('DBG', '', $_GET)){$jsonData->__DBG__['$aliasValuesRaw'][$fieldName] = $aliasValuesRaw;}
|
|
if(V::get('DBG', '', $_GET)){$jsonData->__DBG__['$aliasValuesRaw'][$fieldName] = $aliasValuesRaw;}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -5847,7 +5848,12 @@ jQuery(document).ready(function(){
|
|
|
if (!empty($localKeys[$localKeyName])) {
|
|
if (!empty($localKeys[$localKeyName])) {
|
|
|
$sql = str_replace('{sql_in_local_join_key}', implode(",", $localKeys[$localKeyName]), $sqlFormat);
|
|
$sql = str_replace('{sql_in_local_join_key}', implode(",", $localKeys[$localKeyName]), $sqlFormat);
|
|
|
$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
|
|
$sqlLocalKeyName = $acl->getSqlFieldName($localKeyName);
|
|
|
- $aliasValuesRaw = DB::getPDO()->fetchAllByKey($sql, $sqlLocalKeyName);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ $aliasValuesRaw = DB::getPDO()->fetchAllByKey($sql, $sqlLocalKeyName);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ // TODO: error msg for GUI
|
|
|
|
|
+ DBG::log($e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
DBG::log($aliasValuesRaw, 'array', '$aliasValuesRaw');
|
|
DBG::log($aliasValuesRaw, 'array', '$aliasValuesRaw');
|