|
|
@@ -3406,7 +3406,7 @@ class TableAjax extends ViewAjax {
|
|
|
}).then(function (response) {
|
|
|
return response.json()
|
|
|
}).then(function (data) {
|
|
|
- if (priv.options.debug) console.log('loadDataAjax:fetch:loadPage: request finished L.<?php echo __LINE__; ?> data:', data);
|
|
|
+ if (priv.options.debug) console.log('loadDataAjax:fetch:loadPage: request finished, data:', data);
|
|
|
// p5UI__notifyAjaxCallback(data);
|
|
|
if ('success' == data.type) {
|
|
|
state = {data: {}};
|
|
|
@@ -3476,186 +3476,19 @@ class TableAjax extends ViewAjax {
|
|
|
$pageSize = $this->_pageSize;
|
|
|
$rowFunctions = $this->_rowFunctions;//$this->_showRowFunctionsJson();
|
|
|
$exportFields = Core_AclHelper::getExportFieldList($acl);
|
|
|
-?>
|
|
|
- <script>
|
|
|
-function TableAjax__HIST_Route(args) {
|
|
|
- var recordID = args;
|
|
|
- if (typeof args == 'object') {
|
|
|
- recordID = args.shift();
|
|
|
- recordID = parseInt(recordID);
|
|
|
- }
|
|
|
- if (typeof recordID !== 'number' || recordID <= 0) {
|
|
|
- // TODO: msg
|
|
|
- return false;
|
|
|
- }
|
|
|
- var cont = jQuery('#<?php echo $this->_htmlID; ?>').parent();
|
|
|
- cont.hide();
|
|
|
-
|
|
|
- // remove previous task content
|
|
|
- var taskCnt = jQuery('#<?php echo $this->_htmlID; ?>_task');
|
|
|
- taskCnt.parent().remove();
|
|
|
- taskCnt.remove();
|
|
|
-
|
|
|
- var taskCont = jQuery('<div class="AjaxTableCont"></div>').insertBefore(cont);
|
|
|
- jQuery('<ul class="breadcrumb">' +
|
|
|
- '<li><a href="#" onclick="return tableAjaxBackToTable();"><?php echo $this->getLabelHtml(); ?></a></li>' +
|
|
|
- '<li class="active">Historia rekordu</li>' +
|
|
|
- '</ul>').appendTo(taskCont);
|
|
|
- var taskCnt = jQuery('<div id="<?php echo $this->_htmlID . '_task'; ?>" class="AjaxTableTaskCnt AjaxTable-loading"></div>').appendTo(taskCont);
|
|
|
- jQuery('<span class="loading-info"> loading ...</span>').appendTo(taskCnt);
|
|
|
-
|
|
|
- $.ajax({
|
|
|
- dataType: 'json',
|
|
|
- type: "GET",
|
|
|
- url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=HIST&ID=' + recordID,
|
|
|
- })
|
|
|
- .done(function(data, textStatus, jqXHR){
|
|
|
- taskCnt.removeClass('AjaxTable-loading');
|
|
|
- <?php if(DBG::isActive() && V::get('DBG', '', $_GET)) : ?>console.log('TODO #L.<?= __LINE__; ?> done loading HIST_AJAX - data:', data);<?php endif; ?>
|
|
|
-
|
|
|
- histAjaxOut = '<fieldset>' +
|
|
|
- '<legend>' + data['label'] +
|
|
|
- '<span class="pull-right valign-btns-bottom">';
|
|
|
- for (i in data['row_functions']) {
|
|
|
- histAjaxOut += data['row_functions'][i];
|
|
|
- // TODO: fetch more row functions
|
|
|
- }
|
|
|
- histAjaxOut += '</span>' +
|
|
|
- '</legend>'
|
|
|
- '</fieldset>';
|
|
|
- if (!data['rows']) {
|
|
|
- histAjaxOut += '<div class="alert alert-info">' +
|
|
|
- '<h4>Brak danych</h4>' +
|
|
|
- '</div>';
|
|
|
- } else {
|
|
|
- histAjaxOut += '<table class="table table-striped table-hover table-bordered table-condensed AjaxTableHist">' +
|
|
|
- '<thead>' +
|
|
|
- '<tr>' +
|
|
|
- '<th>Data</th>' +
|
|
|
- '<th>Autor</th>' +
|
|
|
- '<th>Zmiany</th>' +
|
|
|
- '</tr>' +
|
|
|
- '</thead>' +
|
|
|
- '<tbody>';
|
|
|
- for (i in data['rows']) {
|
|
|
- var row = data['rows'][i];
|
|
|
- histAjaxOut += '<tr data-id_hist="' + row['ID'] + '">' +
|
|
|
- '<td style="white-space:nowrap">' + row['_created'] + '</td>' +
|
|
|
- '<td>' + row['_author'] + '</td>' +
|
|
|
- '<td>';
|
|
|
- for (j in row['changes']) {
|
|
|
- var change = row['changes'][j];
|
|
|
- var fieldName = change['fieldName'];
|
|
|
- if (['ID', 'A_RECORD_UPDATE_DATE', 'A_RECORD_UPDATE_AUTHOR', 'A_RECORD_CREATE_DATE', 'A_RECORD_CREATE_AUTHOR'].indexOf(fieldName) >= 0) continue;
|
|
|
- if ('N/S;' == change['value']) continue;
|
|
|
- histAjaxOut += '<p>' +
|
|
|
- '<em>' + (data['field_label'][fieldName] || fieldName) + '</em>: ';
|
|
|
- histAjaxOut += (change['acl_read'])
|
|
|
- ? change['value']
|
|
|
- : '<span title="Brak uprawnień do odczytu tego pola">*****</span>'
|
|
|
- if (change['revert_function_url']) {
|
|
|
- histAjaxOut += ' <button' +
|
|
|
- ' class="btn btn-xs btn-default"' +
|
|
|
- ' onClick="return p5UI__ajaxLinkClick(this, \''+change['revert_function_url']+'\', \''+change['revert_function_data']+'\')"' +
|
|
|
- ' title="Cofnij dane do tej wartości">' +
|
|
|
- '<i class="glyphicon glyphicon-floppy-disk"></i> cofnij' +
|
|
|
- '</button>';
|
|
|
- }
|
|
|
- histAjaxOut += '</p>';
|
|
|
- }
|
|
|
- histAjaxOut += '</td>' +
|
|
|
- '</tr>';
|
|
|
- }
|
|
|
- histAjaxOut += '</tbody>' +
|
|
|
- '</table>';
|
|
|
- }
|
|
|
-
|
|
|
- {// old view - flat table
|
|
|
- histAjaxOut += '<div style="overflow-x:scroll; overflow-y:visible; padding-bottom:1px; margin:10px 0;">' +
|
|
|
- '<table class="table table-striped table-hover table-bordered table-condensed AjaxTableHist">' +
|
|
|
- '<thead>' +
|
|
|
- '<tr>' + "\n";
|
|
|
- histAjaxOut += '<th>Data</th>';
|
|
|
- histAjaxOut += '<th>Autor</th>';
|
|
|
- for (j in data['fields']) {
|
|
|
- var fieldName = data['fields'][j];
|
|
|
- histAjaxOut += '<th>' + (data['field_label'][fieldName] || fieldName).replace(/_/g, ' ') + '</th>';
|
|
|
- }
|
|
|
- histAjaxOut += '</tr>' +
|
|
|
- '</thead>' +
|
|
|
- '<tbody>';
|
|
|
- for (i in data['rows']) {
|
|
|
- var row = data['rows'][i];
|
|
|
- histAjaxOut += '<tr>';
|
|
|
- histAjaxOut += '<td><nobr>' + row['_created'] + '</nobr></td>';
|
|
|
- histAjaxOut += '<td>' + row['_author'] + '</td>';
|
|
|
- for (j in data['fields']) {
|
|
|
- var fieldName = data['fields'][j];
|
|
|
- histAjaxOut += '<td>';
|
|
|
- ( (!(fieldName in row['changes']) || row['changes'][fieldName]['value'] == 'N/S;')
|
|
|
- ? histAjaxOut += '<em>N/S;</em>'
|
|
|
- : ( (row['changes'][fieldName]['acl_read'])
|
|
|
- ? histAjaxOut += row['changes'][fieldName]['value']
|
|
|
- : histAjaxOut += '<span title="Brak uprawnień do odczytu tego pola">*****</span>'
|
|
|
- )
|
|
|
- );
|
|
|
- histAjaxOut += '</td>';
|
|
|
- }
|
|
|
- histAjaxOut += '</tr>';
|
|
|
- }
|
|
|
- histAjaxOut += '</tbody>' +
|
|
|
- '</table>' +
|
|
|
- '</div>';
|
|
|
- }
|
|
|
- jQuery(histAjaxOut).appendTo(taskCnt);
|
|
|
- })
|
|
|
- .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
|
|
|
- taskCnt.removeClass('AjaxTable-loading');
|
|
|
- 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');
|
|
|
- }
|
|
|
- }
|
|
|
- console.log('TODO #L.<?= __LINE__; ?> fail loading HIST_AJAX - jqXHR.responseText:', jqXHR.responseText);
|
|
|
- });
|
|
|
|
|
|
- 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 = 'OK';
|
|
|
- break;
|
|
|
- case 'info':
|
|
|
- if (!notify.msg) notify.msg = '';
|
|
|
- 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);
|
|
|
- }
|
|
|
- //return false;
|
|
|
-}
|
|
|
- </script>
|
|
|
+ UI::inlineJS(__FILE__ . '.hist.js', [
|
|
|
+ 'TABLE_AJAX_NODE_ID' => $this->_htmlID,
|
|
|
+ 'TABLE_AJAX_LABEL' => $this->getLabelHtml(),
|
|
|
+ 'URL_HIST_BASE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls=" . __CLASS__ . "&_hash={$this->_htmlID}&_task=HIST", // &ID=...
|
|
|
+ 'FUNCTION_HIST_ROUTE' => "TableAjax__HIST_Route",
|
|
|
+ ]);
|
|
|
+?>
|
|
|
<script>
|
|
|
+var TABLE_AJAX_NODE_ID = '<?= $this->_htmlID; ?>';
|
|
|
+var FUNCTION_HIST_ROUTE = window['TableAjax__HIST_Route'];
|
|
|
jQuery(document).ready(function(){
|
|
|
- jQuery('#<?php echo $this->_htmlID; ?>').TableAjax({
|
|
|
+ jQuery('#' + TABLE_AJAX_NODE_ID).TableAjax({
|
|
|
namespace: '<?= $acl->getNamespace(); ?>',
|
|
|
url: '<?= $this->syncUrl; ?>&_hash=<?= $this->_htmlID; ?>&_task=loadDataAjax',// priv.options.url
|
|
|
userTableFilterUrl: '<?= ($this->useUserTableFilter) ? $this->useUserTableFilter : ''; ?>',
|
|
|
@@ -3758,7 +3591,7 @@ jQuery(document).ready(function(){
|
|
|
});
|
|
|
})
|
|
|
},
|
|
|
- HIST: TableAjax__HIST_Route,
|
|
|
+ HIST: FUNCTION_HIST_ROUTE,
|
|
|
FILES: function tableAjaxFiles(args) {
|
|
|
var recordID = args;
|
|
|
if (typeof args == 'object') {
|