|
|
@@ -1158,7 +1158,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
|
|
|
priv.renderRow = function(props) {
|
|
|
var rowNode = $('<tr></tr>'),
|
|
|
- uniqueColName = _state.uniqueCol,
|
|
|
+ uniqueColName = _state.primaryKey,
|
|
|
rowPK = (uniqueColName in props)? props[uniqueColName] : null,
|
|
|
cellNode,
|
|
|
columnName, columnProps, val, cellCnt, format, showTooltip, fldWidgetNode,
|
|
|
@@ -1172,8 +1172,8 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
}
|
|
|
|
|
|
//create checkbox
|
|
|
- if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
- var check = _uniqueCols[props[_state.uniqueCol]] != undefined ? 'checked' : '';
|
|
|
+ if (_state.primaryKey && priv.options.checkboxes) {
|
|
|
+ var check = _uniqueCols[props[_state.primaryKey]] != undefined ? 'checked' : '';
|
|
|
var checkable = props['checkable'] === false ? 'disabled' : '';
|
|
|
cellNode = $('<td></td>').appendTo(rowNode);
|
|
|
$(p5Utils__format('<input class="unique" {0} {1} type="checkbox" />', [check, checkable])).appendTo(cellNode);
|
|
|
@@ -1428,7 +1428,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
$('<td class="text-right stickyCol1"> </td>').appendTo(rowNode);
|
|
|
}
|
|
|
|
|
|
- if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
+ if (_state.primaryKey && priv.options.checkboxes) {
|
|
|
$('<td><input disabled type="checkbox" /></td>').appendTo(rowNode);
|
|
|
}
|
|
|
for (var i = 0; i < _state.colsSorted.length; i++) {
|
|
|
@@ -1448,77 +1448,73 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
};
|
|
|
|
|
|
priv.renderTableTheadSort = function() {
|
|
|
- var nodeClass = 'tblAjax__' + 'head__sort',
|
|
|
- currentNode = _uiNode$Table.find('thead').find('.' + nodeClass),
|
|
|
- node;
|
|
|
- // currentNode.find('i').tooltip('hide');
|
|
|
- node = $('<tr class="sort ' + nodeClass + '"></tr>');
|
|
|
- //create the functions column
|
|
|
+ var nodeClass = 'tblAjax__' + 'head__sort'
|
|
|
+ var currentNode = _uiNode$Table.find('thead').find('.' + nodeClass)
|
|
|
+ var node = $('<tr class="sort ' + nodeClass + '"></tr>')
|
|
|
if (priv.options.tblFunctions || priv.options.filtersClean) {
|
|
|
- var headCell = $('<th class="text-right head-info stickyCol1"></th>').appendTo(node);
|
|
|
- $.map(priv.options.tblFunctions, function(funObj, funName){
|
|
|
- var funHtml = $('<a></a>');
|
|
|
- funHtml.attr('href', funObj.href || '#');
|
|
|
- if (funObj.title) funHtml.attr('title', funObj.title);
|
|
|
- if (funObj.icon) funHtml.html('<span class="glyphicon glyphicon-' + funObj.icon + '"></span> ');
|
|
|
+ var headCell = $('<th class="text-right head-info stickyCol1"></th>').appendTo(node)
|
|
|
+ $.map(priv.options.tblFunctions, function (funObj, funName) {
|
|
|
+ var funHtml = $('<a></a>')
|
|
|
+ funHtml.attr('href', funObj.href || '#')
|
|
|
+ if (funObj.title) funHtml.attr('title', funObj.title)
|
|
|
+ if (funObj.icon) funHtml.html('<span class="glyphicon glyphicon-' + funObj.icon + '"></span> ')
|
|
|
if (funObj.method && priv[funObj.method] && typeof priv[funObj.method] == 'function') {
|
|
|
- funHtml.on('click', priv[funObj.method]);
|
|
|
+ funHtml.on('click', priv[funObj.method])
|
|
|
}
|
|
|
- funHtml.appendTo(headCell);
|
|
|
- });
|
|
|
+ funHtml.appendTo(headCell)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
- //create the checkall toggle
|
|
|
- if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
- var checked = _checkToggleChecked ? 'checked' : '';
|
|
|
- var headCell = $('<th></th>').appendTo(node);
|
|
|
- var elem = $(p5Utils__format('<input {0} class="checkToggle" type="checkbox" />', [checked])).appendTo(headCell);
|
|
|
- elem.on('change', priv.checkToggleChanged);
|
|
|
+ if (_state.primaryKey && priv.options.checkboxes) {
|
|
|
+ var checked = _checkToggleChecked ? 'checked' : ''
|
|
|
+ var headCell = $('<th></th>').appendTo(node)
|
|
|
+ var elem = $(p5Utils__format('<input {0} class="checkToggle" type="checkbox" />', [checked])).appendTo(headCell)
|
|
|
+ elem.on('change', priv.checkToggleChanged)
|
|
|
}
|
|
|
|
|
|
- //create the sortable headers
|
|
|
for (var i = 0; i < _state.colsSorted.length; i++) {
|
|
|
- var column = _state.colsSorted[i];
|
|
|
- var props = _data.cols[column];
|
|
|
- if (!props.hidden) {
|
|
|
- var headCell = $('<th class="ta-ordering"></th>').appendTo(node);
|
|
|
- if (i == 1) headCell.addClass('stickyCol2');
|
|
|
+ var column = _state.colsSorted[i]
|
|
|
+ var props = _data.cols[column]
|
|
|
+ if (props.hidden) continue
|
|
|
|
|
|
- if (props.type != 'special' && props.type != 'geom') { // TODO: props.isSortable
|
|
|
- headCell.on('click', {column: column}, priv.columnClicked);
|
|
|
- }
|
|
|
- var colTitle = column;
|
|
|
- if (props.description && props.description.length > 0) {
|
|
|
- colTitle = props.description;
|
|
|
- colTitle += ' (' + column + ')';
|
|
|
- }
|
|
|
- else if (props._tsRetId > 0) {
|
|
|
- colTitle = 'Kliknij na pole i przejdź do powiązanych rekordów (' + colTitle + ')';
|
|
|
- }
|
|
|
+ var headCell = $('<th class="ta-ordering"></th>').appendTo(node)
|
|
|
+ if (i == 1) headCell.addClass('stickyCol2')
|
|
|
|
|
|
- if (props.friendly) {
|
|
|
- var headCnt = $(p5Utils__format('<span class="pull-left" title="{1}">{0}</span>', [props.friendly, colTitle]));
|
|
|
- } else {
|
|
|
- var headCnt = $(p5Utils__format('<span class="pull-left" title="{1}">{0}</span>', [column, colTitle]));
|
|
|
- }
|
|
|
- headCnt.appendTo(headCell);
|
|
|
+ if (props.type != 'special' && props.type != 'geom') { // TODO: props.isSortable
|
|
|
+ headCell.on('click', {column: column}, priv.columnClicked)
|
|
|
+ }
|
|
|
|
|
|
- //Add sort arrow
|
|
|
- if (column == _state.filters.currSortCol) {
|
|
|
- if (_state.filters.currSortFlip) headCell.addClass('ta-ordering-down');
|
|
|
- else headCell.addClass('ta-ordering-up');
|
|
|
+ var nodeLabel = (props.friendly) ? props.friendly : column
|
|
|
+ var nodeTitle = column
|
|
|
+ if (props.description && props.description.length > 0) {
|
|
|
+ nodeTitle = p5Utils__format("{0} ({1})", [props.description, column])
|
|
|
+ }
|
|
|
+ else if (props._tsRetId > 0) {
|
|
|
+ nodeTitle = p5Utils__format("Kliknij na pole i przejdź do powiązanych rekordów ({0})", [nodeTitle])
|
|
|
+ }
|
|
|
+ if ('ref' === props.type && props.friendly === props.column && props.xsdRefType) {
|
|
|
+ nodeLabel = '<i class="glyphicon glyphicon-export"></i> ' + props.xsdRefType
|
|
|
+ if (props.description && props.description.length > 0 && props.description !== column) {
|
|
|
+ nodeTitle = p5Utils__format("{0} (ref {1})", [props.description, column])
|
|
|
+ } else {
|
|
|
+ nodeTitle = p5Utils__format("(ref {0})", [column])
|
|
|
}
|
|
|
+ }
|
|
|
+ var headCnt = $(p5Utils__format('<span class="pull-left" title="{1}">{0}</span>', [nodeLabel, nodeTitle]))
|
|
|
+ headCnt.appendTo(headCell)
|
|
|
|
|
|
- if (column != 'ID') {
|
|
|
- var hideColBtn = $('<i class="glyphicon glyphicon-remove remove-cell"></i>');
|
|
|
- hideColBtn.on('click', {column: column}, priv.columnHideClicked);
|
|
|
- hideColBtn.appendTo(headCell);
|
|
|
- }
|
|
|
+ if (column == _state.filters.currSortCol) {
|
|
|
+ headCell.addClass((_state.filters.currSortFlip) ? 'ta-ordering-down' : 'ta-ordering-up')
|
|
|
+ }
|
|
|
|
|
|
+ if (column !== _state.primaryKey) {
|
|
|
+ var hideColBtn = $('<i class="glyphicon glyphicon-remove remove-cell"></i>')
|
|
|
+ hideColBtn.on('click', {column: column}, priv.columnHideClicked)
|
|
|
+ hideColBtn.appendTo(headCell)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- currentNode.replaceWith(node);
|
|
|
+ currentNode.replaceWith(node)
|
|
|
};
|
|
|
|
|
|
priv.renderHeadSpecialFilters = function() {
|
|
|
@@ -1580,7 +1576,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
}
|
|
|
|
|
|
//create the filter checkbox
|
|
|
- if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
+ if (_state.primaryKey && priv.options.checkboxes) {
|
|
|
tooltip = priv.options.types.bool.filterTooltip || 'Toggle between:<br/>indeterminate,<br/>checked,<br/>unchecked';
|
|
|
headCell = $('<th></th>').appendTo(node);
|
|
|
elem = $('<input class="filter indeterminate" checked type="checkbox" />').appendTo(headCell);
|
|
|
@@ -1875,7 +1871,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
|
|
|
$('<li class="divider"></li>').appendTo(ul);
|
|
|
$.each(_data.cols, function(col, props) {
|
|
|
- if (props.type != "unique" && col != 'ID') {
|
|
|
+ if (props.type != "unique" && col != _state.primaryKey) {
|
|
|
var li = $('<li></li>').appendTo(ul),
|
|
|
label = (props.friendly || col).replace(/<br\/?>/g, ' '),
|
|
|
input = p5Utils__format('<input {0} type="checkbox" title="{1}" value="{1}" style="margin:0"/> {2}', [(props.hidden) ? '' : 'checked', col, label]),
|
|
|
@@ -2152,11 +2148,11 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
}).then(function (response) {
|
|
|
return response.json()
|
|
|
}).then(function (data) {
|
|
|
- if (priv.options.debug) console.log('loadDataAjax:fetch: request finished L.<?php echo __LINE__; ?> data:', data);
|
|
|
+ if (priv.options.debug) console.log('loadDataAjax:fetch:update: request finished L.<?php echo __LINE__; ?> data:', data);
|
|
|
if ('success' == data.type) {
|
|
|
// p5UI__notifyAjaxCallback(data);
|
|
|
if (data && data.cols) {
|
|
|
- priv.setStateCols(data.cols, data.uniqueCol);
|
|
|
+ priv.setStateCols(data.cols, data.primaryKey);
|
|
|
}
|
|
|
|
|
|
// set initial filters (_state.filters.filterCols)
|
|
|
@@ -2211,7 +2207,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
renderParts = {};
|
|
|
if (state.data) {
|
|
|
if (state.data.cols && state.data.cols.length > 0) {// TODO: never happen, but if happend then rerender all
|
|
|
- priv.setStateCols(state.data.cols, state.data.uniqueCol);
|
|
|
+ priv.setStateCols(state.data.cols, state.data.primaryKey);
|
|
|
priv.setStateData(state.data);
|
|
|
renderParts['head'] = true;
|
|
|
} else {
|
|
|
@@ -2253,9 +2249,9 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- priv.setStateCols = function(cols, uniqueCol) {
|
|
|
+ priv.setStateCols = function(cols, primaryKey) {
|
|
|
_state.cols = cols;
|
|
|
- _state.uniqueCol = uniqueCol;
|
|
|
+ _state.primaryKey = primaryKey;
|
|
|
// fix col name - props.column
|
|
|
$.each(_state.cols, function(col, props) {
|
|
|
props.column = col;
|
|
|
@@ -2268,7 +2264,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
$.each(_state.cols, function(col, props) {
|
|
|
if (props.filter == undefined) props.filter = true;
|
|
|
});
|
|
|
- if (_state.uniqueCol) {
|
|
|
+ if (_state.primaryKey) {
|
|
|
//create a unique column definition
|
|
|
_state.cols["unique"] = {
|
|
|
column: "unique",
|
|
|
@@ -2328,11 +2324,11 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
_uniqueCols[key] = priv.getRow(key);
|
|
|
}
|
|
|
|
|
|
- if (_state.uniqueCol) {
|
|
|
+ if (_state.primaryKey) {
|
|
|
//add rows that needs to be pre-checked
|
|
|
$.each(_data.rows, function(index, row) {
|
|
|
if (row["checked"] === true)
|
|
|
- _uniqueCols[row[_state.uniqueCol]] = row;
|
|
|
+ _uniqueCols[row[_state.primaryKey]] = row;
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
@@ -2353,7 +2349,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
priv.getRow = function(uniqueValue) {
|
|
|
var row;
|
|
|
$.each(_data.rowsOrg, function(i, r) {
|
|
|
- if (r[_state.uniqueCol] == uniqueValue) {
|
|
|
+ if (r[_state.primaryKey] == uniqueValue) {
|
|
|
row = r;
|
|
|
return false;
|
|
|
}
|
|
|
@@ -2789,7 +2785,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
var reqData = {};
|
|
|
|
|
|
$.each(_data.cols, function(col, props) {
|
|
|
- if (props.type != "unique" && col != 'unique' && col != 'ID') {
|
|
|
+ if (props.type != "unique" && col != 'unique' && col != _state.primaryKey) {
|
|
|
reqData[col] = (props.hidden)? 'HIDE' : 'SHOW';
|
|
|
}
|
|
|
});
|
|
|
@@ -3130,7 +3126,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
what: row data and other info is returned to caller
|
|
|
*/
|
|
|
// priv.rowClicked = function(e) {// TODO: not used
|
|
|
-// if (!_state.uniqueCol) {
|
|
|
+// if (!_state.primaryKey) {
|
|
|
// if (priv.options.debug) console.log('no unique column specified');
|
|
|
// return;
|
|
|
// }
|
|
|
@@ -3426,7 +3422,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
|
|
|
}).then(function (response) {
|
|
|
return response.json()
|
|
|
}).then(function (data) {
|
|
|
- if (priv.options.debug) console.log('loadDataAjax:fetch: request finished L.<?php echo __LINE__; ?> data:', data);
|
|
|
+ if (priv.options.debug) console.log('loadDataAjax:fetch:loadPage: request finished L.<?php echo __LINE__; ?> data:', data);
|
|
|
// p5UI__notifyAjaxCallback(data);
|
|
|
if ('success' == data.type) {
|
|
|
state = {data: {}};
|
|
|
@@ -6016,7 +6012,7 @@ jQuery(document).ready(function(){
|
|
|
$jsonData->pageSize = $pageSize;
|
|
|
$jsonData->filters = $filters;
|
|
|
$jsonData->cols = new stdClass();
|
|
|
- $jsonData->uniqueCol = $acl->getPrimaryKeyField();
|
|
|
+ $jsonData->primaryKey = $acl->getPrimaryKeyField();
|
|
|
$ind = 0;
|
|
|
foreach ($visibleCols as $fieldID => $col) {
|
|
|
$ind++;
|