// @require variables: if ('undefined' === typeof TABLE_AJAX_NODE_ID) throw "Missing TABLE_AJAX_NODE_ID"; // $this->_htmlID, if ('undefined' === typeof TABLE_AJAX_LABEL) throw "Missing TABLE_AJAX_LABEL"; // this->getLabelHtml() if ('undefined' === typeof URL_HIST_BASE) throw "Missing URL_HIST_BASE"; // 'index-ajax.php?_zasobID={$this->_zasobID}&_cls={__CLASS__}&_hash={$this->_htmlID}&_task=HIST'; // &ID=... if ('undefined' === typeof FUNCTION_HIST_ROUTE) throw "Missing FUNCTION_HIST_ROUTE"; // '' 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('#' + TABLE_AJAX_NODE_ID).parent(); cont.hide(); // remove previous task content var taskCnt = jQuery('#' + TABLE_AJAX_NODE_ID + '_task'); taskCnt.parent().remove(); taskCnt.remove(); var taskCont = jQuery('
').insertBefore(cont); jQuery('').appendTo(taskCont); var taskCnt = jQuery('').appendTo(taskCont); jQuery(' loading ...').appendTo(taskCnt); window.fetch(URL_HIST_BASE + '&ID=' + recordID, { method: 'GET', credentials: 'same-origin', }).then(function(response) { return response.json() }).then(function __route_hist_payload(payload) { taskCnt.removeClass('AjaxTable-loading'); var data = payload; histAjaxOut = ''; if (!data['rows']) { histAjaxOut += '| Data | ' + 'Autor | ' + 'Zmiany | ' + '
|---|---|---|
| ' + row['_created'] + ' | ' + '' + row['_author'] + ' | ' + '';
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 += ' ' + '' + (data['field_label'][fieldName] || fieldName) + ': '; histAjaxOut += (change['acl_read']) ? change['value'] : '*****' if (change['revert_function_url']) { histAjaxOut += ' '; } histAjaxOut += ' '; } histAjaxOut += ' | ' +
'
| Data | '; histAjaxOut += 'Autor | '; for (j in data['fields']) { var fieldName = data['fields'][j]; histAjaxOut += '' + (data['field_label'][fieldName] || fieldName).replace(/_/g, ' ') + ' | '; } histAjaxOut += '
|---|---|---|
| ' + row['_author'] + ' | '; for (j in data['fields']) { var fieldName = data['fields'][j]; histAjaxOut += ''; ( (!(fieldName in row['changes']) || row['changes'][fieldName]['value'] == 'N/S;') ? histAjaxOut += 'N/S;' : ( (row['changes'][fieldName]['acl_read']) ? histAjaxOut += row['changes'][fieldName]['value'] : histAjaxOut += '*****' ) ); histAjaxOut += ' | '; } histAjaxOut += '