// @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 = '
' + '' + data['label'] + ''; for (i in data['row_functions']) { histAjaxOut += data['row_functions'][i]; // TODO: fetch more row functions } histAjaxOut += '' + '' '
'; if (!data['rows']) { histAjaxOut += '
' + '

Brak danych

' + '
'; } else { histAjaxOut += '' + '' + '' + '' + '' + '' + '' + '' + ''; for (i in data['rows']) { var row = data['rows'][i]; histAjaxOut += '' + '' + '' + '' + ''; } histAjaxOut += '' + '
DataAutorZmiany
' + 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 += ' ' + ' cofnij' + ''; } histAjaxOut += '

'; } histAjaxOut += '
'; } {// old view - flat table histAjaxOut += '
' + '' + '' + '' + "\n"; histAjaxOut += ''; histAjaxOut += ''; for (j in data['fields']) { var fieldName = data['fields'][j]; histAjaxOut += ''; } histAjaxOut += '' + '' + ''; for (i in data['rows']) { var row = data['rows'][i]; histAjaxOut += ''; histAjaxOut += ''; histAjaxOut += ''; for (j in data['fields']) { var fieldName = data['fields'][j]; histAjaxOut += ''; } histAjaxOut += ''; } histAjaxOut += '' + '
DataAutor' + (data['field_label'][fieldName] || fieldName).replace(/_/g, ' ') + '
' + row['_created'] + '' + row['_author'] + ''; ( (!(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 += '
' + '
'; } jQuery(histAjaxOut).appendTo(taskCnt); }).catch(function __route_hist_catch(e) { taskCnt.removeClass('AjaxTable-loading'); p5UI__notifyAjaxCallback({ type: 'error', msg: 'Request error ' + e }); }) } global[FUNCTION_HIST_ROUTE] = TableAjax__HIST_Route