|
|
@@ -558,7 +558,8 @@ class TableAjax extends ViewAjax {
|
|
|
var _headSort; // table header sorting row
|
|
|
var _headFilter; // table header columns filter row
|
|
|
var _headSpecialFilter; // table header special filter row
|
|
|
- var _body; // table body
|
|
|
+ var _bodyNode; // table body
|
|
|
+ var _body; // TODO: table body need render?
|
|
|
var _foot; // table footer
|
|
|
var _inlineEditBox; // inline edit box with form
|
|
|
var _popoverCell; // inline popover cell
|
|
|
@@ -655,8 +656,8 @@ class TableAjax extends ViewAjax {
|
|
|
_head = $('<thead></thead>').prependTo(_uiNode$Table);
|
|
|
_headSort = $('<tr class="sort tblAjax__head__sort"></tr>').prependTo(_head);
|
|
|
_headFilter = $('<tr class="filter tblAjax__head__filter"></tr>').appendTo(_head);
|
|
|
- _body = $('<tbody></tbody>').insertAfter(_head);
|
|
|
- $('<tfoot></tfoot>').insertAfter(_body);
|
|
|
+ _bodyNode = $('<tbody></tbody>').insertAfter(_head);
|
|
|
+ $('<tfoot></tfoot>').insertAfter(_bodyNode);
|
|
|
_foot = $('<div class="foot tblAjax__footer"></div>').insertAfter(_uiNodeCont);
|
|
|
var footToolbar = $('<div class="btn-toolbar tblAjax__footer__toolbar"></div>').appendTo(_foot);
|
|
|
$('<span class="tblAjax__footer__toolbar__info"></span>').appendTo(footToolbar);
|
|
|
@@ -719,199 +720,16 @@ class TableAjax extends ViewAjax {
|
|
|
//create the body
|
|
|
if (!_body) {
|
|
|
_uiNode$Table.find('tbody').remove();
|
|
|
- _body = $('<tbody></tbody>').insertAfter(_head);
|
|
|
- //_body.on('change', '.unique', priv.rowChecked);
|
|
|
+ _bodyNode = $('<tbody></tbody>').insertAfter(_head);
|
|
|
+ //_bodyNode.on('change', '.unique', priv.rowChecked);
|
|
|
|
|
|
//find out what rows to show next...
|
|
|
var rowsAdded = 0;
|
|
|
|
|
|
//slice out the chunk of data we need and create rows
|
|
|
$.each(_data.rows, function (index, props) {
|
|
|
- var row = $('<tr></tr>').appendTo(_body);
|
|
|
-
|
|
|
- if (priv.options.rowFunctions || priv.options.filtersClean) {
|
|
|
- var cell = $('<td class="text-right stickyCol1"></td>').appendTo(row);
|
|
|
- var cellID = _state.uniqueCol || 'ID';
|
|
|
- cellID = (cellID in props)? props[cellID] : null;
|
|
|
- $.map(priv.options.rowFunctions, function(funObj, funName){
|
|
|
- $(funObj.f(cellID)).appendTo(cell);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- //create checkbox
|
|
|
- if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
- var check = _uniqueCols[props[_state.uniqueCol]] != undefined ? 'checked' : '';
|
|
|
- var checkable = props['checkable'] === false ? 'disabled' : '';
|
|
|
- var cell = $('<td></td>').appendTo(row);
|
|
|
- $('<input class="unique" {0} {1} type="checkbox" />'.f(check, checkable)).appendTo(cell);
|
|
|
- }
|
|
|
-
|
|
|
- //create cells
|
|
|
- var primaryKeyField = '';
|
|
|
- for (var i = 0; i < _state.colsSorted.length; i++) {
|
|
|
- var key = _state.colsSorted[i];
|
|
|
- var val = props[key];
|
|
|
- if (!_data.cols[key]) return;
|
|
|
- if (_data.cols[key].unique) row.data('unique', val);
|
|
|
-
|
|
|
- primaryKeyField = _state.uniqueCol || 'ID';
|
|
|
- cellID = (primaryKeyField in props)? props[primaryKeyField] : null;
|
|
|
-
|
|
|
- if (!_data.cols[key].hidden) {
|
|
|
- var cell = $('<td></td>').appendTo(row);
|
|
|
- if (key !== primaryKeyField) {
|
|
|
- cell.on('dblclick', {id:cellID, col:key}, priv.rowDblClicked);
|
|
|
- }
|
|
|
- var cellCnt;
|
|
|
- if (i == 1) {// primaryKey(ID)
|
|
|
- cellCnt = $('<div></div>').appendTo(cell);// fix dblclick for copy
|
|
|
- cell.addClass('stickyCol2');
|
|
|
- } else {
|
|
|
- cellCnt = $('<span></span>').appendTo(cell);
|
|
|
- }
|
|
|
- cell.data('column', key);
|
|
|
- if (val === undefined) continue;
|
|
|
-
|
|
|
- var format = props[key + 'Format'] || _data.cols[key].format || '{0}';
|
|
|
- var showTooltip = true;
|
|
|
-
|
|
|
- switch (_data.cols[key].type) {
|
|
|
- case "string":
|
|
|
- cellCnt.html(format.f(val));
|
|
|
- break;
|
|
|
- case "number":
|
|
|
- val = Number(val);
|
|
|
- var forceDecimals = !isNaN(_data.cols[key].decimals);
|
|
|
- if (forceDecimals) cellCnt.html(format.f(val.toFixed(_data.cols[key].decimals)));
|
|
|
- else {
|
|
|
- (val || 0) % 1 === 0
|
|
|
- ? cellCnt.html(format.f(val))
|
|
|
- : cellCnt.html(format.f(val.toFixed(priv.options.types.number.decimals || 2)));
|
|
|
- }
|
|
|
- break;
|
|
|
- case "date":
|
|
|
- cellCnt.html(format.f(val));
|
|
|
- break;
|
|
|
- case "bool":
|
|
|
- $('<input type="checkbox" {0} disabled />'.f(val ? "checked" : "")).appendTo(cellCnt);
|
|
|
- break;
|
|
|
- case "special":
|
|
|
- cellCnt.html(format.f(val));
|
|
|
- break;
|
|
|
- case "simpleLink":
|
|
|
- var valLink = String(val);
|
|
|
- if (undefined !== _data.cols[key]._tsRetId
|
|
|
- && (0 === _data.cols[key]._tsRetId || '0' === _data.cols[key]._tsRetId)
|
|
|
- && undefined !== _data.cols[key]._tsSimpleLink) {
|
|
|
- valLink = _data.cols[key]._tsSimpleLink.format;
|
|
|
- $.each(_data.cols[key]._tsSimpleLink.aliasMap, function (i, v) {
|
|
|
- //console.log('simpleLink aliasMap key:', key, 'i:', i, 'v:', v, 'props['+v+']', props[v], 'val', val, 'typeof val', typeof val);
|
|
|
- if (undefined !== props[v]) {
|
|
|
- valLink = valLink.replace(new RegExp('\{' + i + '\}', 'g'), props[v]);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- cellCnt.html(format.f(valLink));
|
|
|
- break;
|
|
|
- case "geom":
|
|
|
- cellCnt.TableAjaxGeomField({
|
|
|
- recordID: cellID,
|
|
|
- fieldValue: val,
|
|
|
- hasValueClassName: 'cell-mapfld-hasValue',
|
|
|
- //removeUrl: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=THE_GEOM_REMOVE&ID=' + cellID,
|
|
|
- linkClassNamePrefix: 'cell-mapfld',
|
|
|
- linkSelectClassName: 'select',
|
|
|
- linkSelectAddClassNames: 'glyphicon glyphicon-map-marker',
|
|
|
- linkRemoveClassName: 'remove',
|
|
|
- linkRemoveAddClassNames: 'glyphicon glyphicon-remove',
|
|
|
- onSelect: function(recordID, geomShape) {
|
|
|
- if (priv.options.debug) console.log('recordID:', recordID, 'geomShape:', geomShape);
|
|
|
- priv.mapEditorShow();
|
|
|
- _mapEditor.TableAjaxMapSelectRecord(recordID, geomShape);
|
|
|
- },
|
|
|
- onRemove: function(geomField, recordID, geomShape) {
|
|
|
- if (confirm('Czy usunąć obiekt z mapy dla rekordu ' + recordID + '?')) {
|
|
|
- if (!recordID) return;
|
|
|
-
|
|
|
- var selectedRecordId = recordID;
|
|
|
- function notifyAjaxCallback(data) {
|
|
|
- var notify = {};
|
|
|
- notify.type = (data && data.type)? data.type : '';
|
|
|
- notify.msg = (data && data.msg)? data.msg : '';
|
|
|
- switch (notify.type) {
|
|
|
- case 'success':
|
|
|
- if (!notify.msg) notify.msg = 'Usunięto obiekt z mapy dla rekordu ' + selectedRecordId;
|
|
|
- break;
|
|
|
- case 'info':
|
|
|
- if (!notify.msg) notify.msg = 'Rekord nie był powiązany z żadnym obiektem na mapie';
|
|
|
- break;
|
|
|
- case 'error':
|
|
|
- if (!notify.msg) notify.msg = 'Wystąpiły błędy';
|
|
|
- break;
|
|
|
- case 'warning':
|
|
|
- notify.type = 'warn';
|
|
|
- if (!notify.msg) notify.msg = 'Wystąpiły błędy';
|
|
|
- break;
|
|
|
- default:
|
|
|
- notify.msg = 'Nieznany błąd';
|
|
|
- if (data && data.errorCode) notify.msg += ' ' + data.errorCode;
|
|
|
- notify.type = '';
|
|
|
- }
|
|
|
- jQuery.notify(notify.msg, notify.type);
|
|
|
- }
|
|
|
- $.ajax({
|
|
|
- data: {},
|
|
|
- dataType: 'json',
|
|
|
- type: "POST",
|
|
|
- url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=THE_GEOM_REMOVE&ID=' + recordID
|
|
|
- })
|
|
|
- .done(function(data, textStatus, jqXHR){
|
|
|
- notifyAjaxCallback(data);
|
|
|
- if (priv.options.debug) console.log('data.record.the_geom:', data.record.the_geom);
|
|
|
- if (data && data.record && data.record.the_geom) {
|
|
|
- if (priv.options.debug) console.log('data.record.the_geom:2:', data.record.the_geom);
|
|
|
- geomField.setValue(data.record.the_geom);
|
|
|
- }
|
|
|
- else if (data && data.record) {
|
|
|
- if (priv.options.debug) console.log('data.record.the_geom:2:', data.record.the_geom);
|
|
|
- geomField.setValue(data.record.the_geom);
|
|
|
- }
|
|
|
- _mapEditor.TableAjaxMapRefresh();
|
|
|
- })
|
|
|
- .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
|
|
|
- if (jqXHR.responseJSON) {
|
|
|
- notifyAjaxCallback(jqXHR.responseJSON);
|
|
|
- }
|
|
|
- else {
|
|
|
- var txt = jqXHR.responseText || 'Wystąpiły błędy';
|
|
|
- if (jqXHR.status == 404) {
|
|
|
- jQuery.notify(jqXHR.responseText, 'error');
|
|
|
- } else {
|
|
|
- jQuery.notify(jqXHR.responseText, 'warn');
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (_data.cols[key]._tsRetId) {
|
|
|
- showTooltip = false;
|
|
|
- if (_data.cols[key]._tsRetId > 0) {
|
|
|
- cellCnt.on('click', {id:cellID, col:key, friendly:_data.cols[key].friendly, value:format.f(val)}, priv.popoverCell);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (i > 1 && priv.options.longDesc) {
|
|
|
- cell.addClass('tbl-short-txt');
|
|
|
- if (showTooltip) {
|
|
|
- cellCnt.tooltip({title: cellCnt.text(), placement: 'left'});
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ var rowNode = priv.renderRow(props);
|
|
|
+ if (rowNode) rowNode.appendTo(_bodyNode);
|
|
|
rowsAdded++;
|
|
|
|
|
|
//enough rows created?
|
|
|
@@ -928,7 +746,7 @@ class TableAjax extends ViewAjax {
|
|
|
if (_state.page == _totalPages) {
|
|
|
while (rowsAdded < priv.options.pageSize) {
|
|
|
var rowNode = priv.renderRowEmptyNode();
|
|
|
- if (rowNode) rowNode.appendTo(_body);
|
|
|
+ if (rowNode) rowNode.appendTo(_bodyNode);
|
|
|
rowsAdded++;
|
|
|
}
|
|
|
}
|
|
|
@@ -978,30 +796,222 @@ class TableAjax extends ViewAjax {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- priv.renderRowEmptyNode = function() {
|
|
|
- var row = $('<tr></tr>');
|
|
|
+ priv.renderRow = function (props) {
|
|
|
+ var rowNode = $('<tr></tr>'),
|
|
|
+ uniqueColName = _state.uniqueCol,
|
|
|
+ rowPK = (uniqueColName in props)? props[uniqueColName] : null,
|
|
|
+ cellNode
|
|
|
+ ;
|
|
|
+
|
|
|
+ if (priv.options.rowFunctions || priv.options.filtersClean) {
|
|
|
+ cellNode = $('<td class="text-right stickyCol1"></td>').appendTo(rowNode);
|
|
|
+ $.map(priv.options.rowFunctions, function(funObj, funName){
|
|
|
+ $(funObj.f(rowPK)).appendTo(cellNode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //create checkbox
|
|
|
if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
- var cell = $('<td></td>').appendTo(row);
|
|
|
- $('<input disabled type="checkbox" />').appendTo(cell);
|
|
|
+ var check = _uniqueCols[props[_state.uniqueCol]] != undefined ? 'checked' : '';
|
|
|
+ var checkable = props['checkable'] === false ? 'disabled' : '';
|
|
|
+ cellNode = $('<td></td>').appendTo(rowNode);
|
|
|
+ $('<input class="unique" {0} {1} type="checkbox" />'.f(check, checkable)).appendTo(cellNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (uniqueColName) rowNode.data('unique', rowPK);
|
|
|
+
|
|
|
+ //create cells
|
|
|
+ for (var i = 0; i < _state.colsSorted.length; i++) {
|
|
|
+ var columnName = _state.colsSorted[i],
|
|
|
+ columnProps = _data.cols[columnName],
|
|
|
+ val = '',
|
|
|
+ cellNode,
|
|
|
+ cellCnt,
|
|
|
+ format,
|
|
|
+ showTooltip
|
|
|
+ ;
|
|
|
+ if (!columnProps) continue;
|
|
|
+ if (columnProps.hidden) continue;// TODO: "unique" is hidden
|
|
|
+
|
|
|
+ val = props[columnName];
|
|
|
+ cellNode = $('<td></td>').appendTo(rowNode);
|
|
|
+ if (columnName !== uniqueColName) {
|
|
|
+ cellNode.on('dblclick', {id:rowPK, col:columnName}, priv.rowDblClicked);
|
|
|
+ }
|
|
|
+ if (i == 1) {// primaryKey(ID)
|
|
|
+ cellCnt = $('<div></div>').appendTo(cellNode);// fix dblclick for copy
|
|
|
+ cellNode.addClass('stickyCol2');
|
|
|
+ } else {
|
|
|
+ cellCnt = $('<span></span>').appendTo(cellNode);
|
|
|
+ }
|
|
|
+ cellNode.data('column', columnName);
|
|
|
+ if (val === undefined) continue;
|
|
|
+
|
|
|
+ format = props[columnName + 'Format'] || columnProps.format || '{0}';
|
|
|
+ showTooltip = true;
|
|
|
+ switch (columnProps.type) {
|
|
|
+ case "string":
|
|
|
+ cellCnt.html(format.f(val));
|
|
|
+ break;
|
|
|
+ case "number":
|
|
|
+ val = Number(val);
|
|
|
+ var forceDecimals = !isNaN(columnProps.decimals);
|
|
|
+ if (forceDecimals) cellCnt.html(format.f(val.toFixed(columnProps.decimals)));
|
|
|
+ else {
|
|
|
+ (val || 0) % 1 === 0
|
|
|
+ ? cellCnt.html(format.f(val))
|
|
|
+ : cellCnt.html(format.f(val.toFixed(priv.options.types.number.decimals || 2)));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "date":
|
|
|
+ cellCnt.html(format.f(val));
|
|
|
+ break;
|
|
|
+ case "bool":
|
|
|
+ $('<input type="checkbox" {0} disabled />'.f(val ? "checked" : "")).appendTo(cellCnt);
|
|
|
+ break;
|
|
|
+ case "special":
|
|
|
+ cellCnt.html(format.f(val));
|
|
|
+ break;
|
|
|
+ case "simpleLink":
|
|
|
+ var valLink = String(val);
|
|
|
+ if (undefined !== columnProps._tsRetId
|
|
|
+ && (0 === columnProps._tsRetId || '0' === columnProps._tsRetId)
|
|
|
+ && undefined !== columnProps._tsSimpleLink) {
|
|
|
+ valLink = columnProps._tsSimpleLink.format;
|
|
|
+ $.each(columnProps._tsSimpleLink.aliasMap, function (i, v) {
|
|
|
+ //console.log('simpleLink aliasMap columnName:', columnName, 'i:', i, 'v:', v, 'props['+v+']', props[v], 'val', val, 'typeof val', typeof val);
|
|
|
+ if (undefined !== props[v]) {
|
|
|
+ valLink = valLink.replace(new RegExp('\{' + i + '\}', 'g'), props[v]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ cellCnt.html(format.f(valLink));
|
|
|
+ break;
|
|
|
+ case "geom":
|
|
|
+ cellCnt.TableAjaxGeomField({
|
|
|
+ recordID: rowPK,
|
|
|
+ fieldValue: val,
|
|
|
+ hasValueClassName: 'cell-mapfld-hasValue',
|
|
|
+ //removeUrl: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=THE_GEOM_REMOVE&ID=' + rowPK,
|
|
|
+ linkClassNamePrefix: 'cell-mapfld',
|
|
|
+ linkSelectClassName: 'select',
|
|
|
+ linkSelectAddClassNames: 'glyphicon glyphicon-map-marker',
|
|
|
+ linkRemoveClassName: 'remove',
|
|
|
+ linkRemoveAddClassNames: 'glyphicon glyphicon-remove',
|
|
|
+ onSelect: function(recordID, geomShape) {
|
|
|
+ if (priv.options.debug) console.log('recordID:', recordID, 'geomShape:', geomShape);
|
|
|
+ priv.mapEditorShow();
|
|
|
+ _mapEditor.TableAjaxMapSelectRecord(recordID, geomShape);
|
|
|
+ },
|
|
|
+ onRemove: function(geomField, recordID, geomShape) {
|
|
|
+ if (confirm('Czy usunąć obiekt z mapy dla rekordu ' + recordID + '?')) {
|
|
|
+ if (!recordID) return;
|
|
|
+
|
|
|
+ var selectedRecordId = recordID;
|
|
|
+ function notifyAjaxCallback(data) {
|
|
|
+ var notify = {};
|
|
|
+ notify.type = (data && data.type)? data.type : '';
|
|
|
+ notify.msg = (data && data.msg)? data.msg : '';
|
|
|
+ switch (notify.type) {
|
|
|
+ case 'success':
|
|
|
+ if (!notify.msg) notify.msg = 'Usunięto obiekt z mapy dla rekordu ' + selectedRecordId;
|
|
|
+ break;
|
|
|
+ case 'info':
|
|
|
+ if (!notify.msg) notify.msg = 'Rekord nie był powiązany z żadnym obiektem na mapie';
|
|
|
+ break;
|
|
|
+ case 'error':
|
|
|
+ if (!notify.msg) notify.msg = 'Wystąpiły błędy';
|
|
|
+ break;
|
|
|
+ case 'warning':
|
|
|
+ notify.type = 'warn';
|
|
|
+ if (!notify.msg) notify.msg = 'Wystąpiły błędy';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ notify.msg = 'Nieznany błąd';
|
|
|
+ if (data && data.errorCode) notify.msg += ' ' + data.errorCode;
|
|
|
+ notify.type = '';
|
|
|
+ }
|
|
|
+ jQuery.notify(notify.msg, notify.type);
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ data: {},
|
|
|
+ dataType: 'json',
|
|
|
+ type: "POST",
|
|
|
+ url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=THE_GEOM_REMOVE&ID=' + recordID
|
|
|
+ })
|
|
|
+ .done(function(data, textStatus, jqXHR){
|
|
|
+ notifyAjaxCallback(data);
|
|
|
+ if (priv.options.debug) console.log('data.record.the_geom:', data.record.the_geom);
|
|
|
+ if (data && data.record && data.record.the_geom) {
|
|
|
+ if (priv.options.debug) console.log('data.record.the_geom:2:', data.record.the_geom);
|
|
|
+ geomField.setValue(data.record.the_geom);
|
|
|
+ }
|
|
|
+ else if (data && data.record) {
|
|
|
+ if (priv.options.debug) console.log('data.record.the_geom:2:', data.record.the_geom);
|
|
|
+ geomField.setValue(data.record.the_geom);
|
|
|
+ }
|
|
|
+ _mapEditor.TableAjaxMapRefresh();
|
|
|
+ })
|
|
|
+ .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
|
|
|
+ if (jqXHR.responseJSON) {
|
|
|
+ notifyAjaxCallback(jqXHR.responseJSON);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var txt = jqXHR.responseText || 'Wystąpiły błędy';
|
|
|
+ if (jqXHR.status == 404) {
|
|
|
+ jQuery.notify(jqXHR.responseText, 'error');
|
|
|
+ } else {
|
|
|
+ jQuery.notify(jqXHR.responseText, 'warn');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (columnProps._tsRetId) {
|
|
|
+ showTooltip = false;
|
|
|
+ if (columnProps._tsRetId > 0) {
|
|
|
+ cellCnt.on('click', {id:rowPK, col:columnName, friendly:columnProps.friendly, value:format.f(val)}, priv.popoverCell);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (i > 1 && priv.options.longDesc) {// TODO: use better check for columns: functions and pk
|
|
|
+ cellNode.addClass('tbl-short-txt');
|
|
|
+ if (showTooltip) {
|
|
|
+ cellCnt.tooltip({title: cellCnt.text(), placement: 'left'});
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return rowNode;
|
|
|
+ };
|
|
|
+
|
|
|
+ priv.renderRowEmptyNode = function() {
|
|
|
+ var rowNode = $('<tr></tr>');
|
|
|
|
|
|
if (priv.options.rowFunctions || priv.options.filtersClean) {
|
|
|
- $('<td class="text-right stickyCol1"> </td>').appendTo(row);
|
|
|
+ $('<td class="text-right stickyCol1"> </td>').appendTo(rowNode);
|
|
|
}
|
|
|
|
|
|
+ if (_state.uniqueCol && priv.options.checkboxes) {
|
|
|
+ $('<td><input disabled type="checkbox" /></td>').appendTo(rowNode);
|
|
|
+ }
|
|
|
for (var i = 0; i < _state.colsSorted.length; i++) {
|
|
|
- var key = _state.colsSorted[i];
|
|
|
- if (!_data.cols[key]) return;
|
|
|
- var props = _data.cols[key];
|
|
|
- if (props.hidden) continue;
|
|
|
-
|
|
|
- if (i == 1) {
|
|
|
- $('<td class="stickyCol2"> </td>').appendTo(row);
|
|
|
+ var columnName = _state.colsSorted[i],
|
|
|
+ columnProps = _data.cols[columnName]
|
|
|
+ ;
|
|
|
+ if (!columnProps) return;
|
|
|
+ if (columnProps.hidden) continue;// "unique" is hidden - TODO: rm "unique" from _state.colsSorted ?
|
|
|
+
|
|
|
+ if (i == 1) {// TODO: 1 is pk - use better check
|
|
|
+ $('<td class="stickyCol2"> </td>').appendTo(rowNode);
|
|
|
} else {
|
|
|
- $('<td> </td>').appendTo(row);
|
|
|
+ $('<td> </td>').appendTo(rowNode);
|
|
|
}
|
|
|
}
|
|
|
- return row;
|
|
|
+ return rowNode;
|
|
|
};
|
|
|
|
|
|
priv.renderTableTheadSort = function() {
|
|
|
@@ -1310,7 +1320,7 @@ class TableAjax extends ViewAjax {
|
|
|
|
|
|
priv.renderTableTfoot = function() {
|
|
|
_uiNode$Table.find('tfoot').remove();
|
|
|
- _foot = $('<tfoot></tfoot>').insertAfter(_body);
|
|
|
+ _foot = $('<tfoot></tfoot>').insertAfter(_bodyNode);
|
|
|
//$(_uiNodeCont).next('.foot').replaceWith(_foot);
|
|
|
};
|
|
|
|
|
|
@@ -1709,7 +1719,7 @@ class TableAjax extends ViewAjax {
|
|
|
|
|
|
// assign the new data
|
|
|
if (data && data.cols) {
|
|
|
- priv.setStateCols(data.cols);
|
|
|
+ priv.setStateCols(data.cols, data.uniqueCol);
|
|
|
}
|
|
|
|
|
|
// set initial filters (_state.filters.filterCols)
|
|
|
@@ -1761,8 +1771,8 @@ class TableAjax extends ViewAjax {
|
|
|
var oldState = _state,// TODO: use to check what really changed (use extend!)
|
|
|
renderParts = {};
|
|
|
if (state.data) {
|
|
|
- if (state.data.cols && state.data.cols.length > 0) {
|
|
|
- priv.setStateCols(state.data.cols);
|
|
|
+ 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.setStateData(state.data);
|
|
|
renderParts['head'] = true;
|
|
|
} else {
|
|
|
@@ -1804,9 +1814,9 @@ class TableAjax extends ViewAjax {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- priv.setStateCols = function (cols) {
|
|
|
+ priv.setStateCols = function (cols, uniqueCol) {
|
|
|
_state.cols = cols;
|
|
|
- _state.uniqueCol = undefined;
|
|
|
+ _state.uniqueCol = uniqueCol;
|
|
|
// fix col name - props.column
|
|
|
$.each(_state.cols, function (col, props) {
|
|
|
props.column = col;
|
|
|
@@ -1815,15 +1825,6 @@ class TableAjax extends ViewAjax {
|
|
|
$.each(_state.cols, function (col, props) {
|
|
|
if (!props.type) cols[col].type = "string";
|
|
|
});
|
|
|
- // fix props.unique - set false if not set
|
|
|
- // set _state.uniqueCol - first column defined as unique
|
|
|
- $.each(_state.cols, function (col, props) {
|
|
|
- //if several unique columns is defined, use the first.
|
|
|
- if (props.unique) {
|
|
|
- if (!_state.uniqueCol) _state.uniqueCol = col;
|
|
|
- else props.unique = false;
|
|
|
- }
|
|
|
- });
|
|
|
// fix props.filter - set true if not set - TODO: allow filter this col?
|
|
|
$.each(_state.cols, function (col, props) {
|
|
|
if (props.filter == undefined) props.filter = true;
|
|
|
@@ -2032,7 +2033,7 @@ class TableAjax extends ViewAjax {
|
|
|
|
|
|
priv.longTextChanged = function(e) {
|
|
|
priv.options.longDesc = !priv.options.longDesc;
|
|
|
- _body.find('td').each(function(ind, el){
|
|
|
+ _bodyNode.find('td').each(function(ind, el){
|
|
|
var $el = jQuery(el);
|
|
|
if (!$el.attr('class') || $el.attr('class') == 'tbl-short-txt') {
|
|
|
//console.log(el.attr('class') + ': ' + el.text());
|
|
|
@@ -2429,29 +2430,29 @@ class TableAjax extends ViewAjax {
|
|
|
when: clicking anywhere on a row
|
|
|
what: row data and other info is returned to caller
|
|
|
*/
|
|
|
- priv.rowClicked = function (e) {
|
|
|
- if (!_state.uniqueCol) {
|
|
|
- if (priv.options.debug) console.log('no unique column specified');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //gather callback data
|
|
|
- var elem = $(this);
|
|
|
- var column = _data.cols[elem.data('column')];
|
|
|
- var unique = elem.closest('tr').data('unique');
|
|
|
- var row = priv.getRow(unique);
|
|
|
- var isChecked = elem.closest('tr').find('.unique').is(':checked');
|
|
|
-
|
|
|
- //trigger callback
|
|
|
- if (typeof priv.options.rowClicked == 'function') {
|
|
|
- priv.options.rowClicked.call(e.target, {
|
|
|
- event: e,
|
|
|
- row: row,
|
|
|
- column: column,
|
|
|
- checked: isChecked
|
|
|
- });
|
|
|
- }
|
|
|
- };
|
|
|
+// priv.rowClicked = function (e) {// TODO: not used
|
|
|
+// if (!_state.uniqueCol) {
|
|
|
+// if (priv.options.debug) console.log('no unique column specified');
|
|
|
+// return;
|
|
|
+// }
|
|
|
+
|
|
|
+// //gather callback data
|
|
|
+// var elem = $(this);
|
|
|
+// var column = _data.cols[elem.data('column')];
|
|
|
+// var unique = elem.closest('tr').data('unique');
|
|
|
+// var row = priv.getRow(unique);
|
|
|
+// var isChecked = elem.closest('tr').find('.unique').is(':checked');
|
|
|
+
|
|
|
+// //trigger callback
|
|
|
+// if (typeof priv.options.rowClicked == 'function') {
|
|
|
+// priv.options.rowClicked.call(e.target, {
|
|
|
+// event: e,
|
|
|
+// row: row,
|
|
|
+// column: column,
|
|
|
+// checked: isChecked
|
|
|
+// });
|
|
|
+// }
|
|
|
+// };
|
|
|
|
|
|
/**
|
|
|
* Inline edit.
|
|
|
@@ -5290,14 +5291,12 @@ jQuery(document).ready(function(){
|
|
|
$jsonData->pageSize = $pageSize;
|
|
|
$jsonData->filters = $filters;
|
|
|
$jsonData->cols = new stdClass();
|
|
|
+ $jsonData->uniqueCol = $this->_acl->getPrimaryKeyField();
|
|
|
$ind = 0;
|
|
|
foreach ($visibleCols as $fieldID => $col) {
|
|
|
$ind++;
|
|
|
$columnConfig = (object)array('index'=>$ind);
|
|
|
- if ($col == 'ID') {
|
|
|
- $columnConfig->unique = true;
|
|
|
- }
|
|
|
- else if (in_array($col, array('A_STATUS','A_STATUS_CURRENT','A_SERVICES_STATUS_CURRENT'))) {
|
|
|
+ if (in_array($col, array('A_STATUS','A_STATUS_CURRENT','A_SERVICES_STATUS_CURRENT'))) {
|
|
|
$columnConfig->format = '<div class="cell-A_STATUS-{0}">{0}</div>';
|
|
|
}
|
|
|
else if (in_array($col, array('Status'))) {
|