// @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 FUNCTION_EDIT_ROUTE) throw "Missing FUNCTION_EDIT_ROUTE"; if ('undefined' === typeof URL_EDIT_FORM_AJAX) throw "Missing URL_EDIT_FORM_AJAX"; function TableAjax__EDIT_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); taskCnt = jQuery('').appendTo(taskCont); jQuery(' loading ...').appendTo(taskCnt); window.fetch(URL_EDIT_FORM_AJAX + recordID, { method: 'GET', credentials: 'same-origin', }).then(function(response) { return response.json() }).then(function __route_edit_payload(payload) { taskCnt.removeClass('AjaxTable-loading'); // console.log('editFormJson :: payload', payload) if ('success' == payload.type) { var node = document.createElement('div') taskCnt.get(0).appendChild(node) p5UI__buildDom(payload.body.reactNode, node) initDateTimePicker(jQuery(node)); // console.log('editFormJson :: dom loaded - TODO: add action on save - P5UI__FeatureEditForm') } else { console.log('editFormJson :: ERROR payload', payload) } }).catch(function __route_edit_catch(e) { taskCnt.removeClass('AjaxTable-loading'); console.log('editFormJson :: ERROR', e) p5UI__notifyAjaxCallback({ type: 'error', msg: 'Request error ' + e }); }) } global[FUNCTION_EDIT_ROUTE] = TableAjax__EDIT_Route