|
|
@@ -3486,7 +3486,15 @@ class TableAjax extends ViewAjax {
|
|
|
'URL_HIST_BASE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls=" . __CLASS__ . "&_hash={$this->_htmlID}&_task=HIST", // &ID=...
|
|
|
'FUNCTION_HIST_ROUTE' => "TableAjax__HIST_Route",
|
|
|
]);
|
|
|
-
|
|
|
+ UI::inlineJS(__FILE__ . '.create.js', [
|
|
|
+ 'TABLE_AJAX_NODE_ID' => $this->_htmlID,
|
|
|
+ 'TABLE_AJAX_LABEL' => $this->getLabelHtml(),
|
|
|
+ 'NAMESPACE' => $acl->getNamespace(),
|
|
|
+ 'FIRCE_FILER_INIT' => $forceFilterInit,
|
|
|
+ 'FUNCTION_CREATE_ROUTE' => "TableAjax__CREATE_Route",
|
|
|
+ 'URL_CREATE_FORM_AJAX' => "{$this->syncUrl}&_hash={$this->_htmlID}&_task=createFormJson",
|
|
|
+ 'URL_CREATE_FORM_LEGACY_HTML' => "index.php?_route=ViewTableAjax&_task=createForm&namespace=" . $acl->getNamespace() . "&_hash={$this->_htmlID}",
|
|
|
+ ]);
|
|
|
|
|
|
$fltrs = (method_exists($acl, 'getSpecialFilters')) ? $acl->getSpecialFilters() : null;
|
|
|
$jsonSpecialFilters = (!empty($fltrs)) ? json_encode($fltrs) : 'false';
|
|
|
@@ -3649,78 +3657,7 @@ jQuery(document).ready(function(){
|
|
|
});
|
|
|
//return false;
|
|
|
},
|
|
|
- CREATE: function tableAjaxCreate() {
|
|
|
- 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">Dodaj nowy rekord</li>' +
|
|
|
- '</ul>').appendTo(taskCont);
|
|
|
- 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);
|
|
|
-
|
|
|
- var reqData = {};
|
|
|
- var forceFilterInit = <?php echo json_encode($forceFilterInit);// TODO: read from TableAjax ?>;
|
|
|
- if (forceFilterInit) {
|
|
|
- $.map(forceFilterInit, function(fltrProps, fltr) {
|
|
|
- reqData['ff_' + fltr] = fltrProps;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // TODO: replace jQuery.ajax
|
|
|
- // window.fetch('<?= $this->syncUrl; ?>&_hash=<?= $this->_htmlID; ?>&_task=createFormJson', {
|
|
|
- // 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
|
|
|
- // });
|
|
|
- // });
|
|
|
-
|
|
|
- jQuery.ajax({
|
|
|
- url: 'index.php?_route=ViewTableAjax&_task=createForm&namespace=<?= $acl->getNamespace(); ?>&_hash=<?php echo $this->_htmlID; ?>',
|
|
|
- type: 'GET',
|
|
|
- dataType: 'text',
|
|
|
- data: reqData,
|
|
|
- async: true,
|
|
|
- success: function(data) {
|
|
|
- taskCnt.removeClass('AjaxTable-loading');
|
|
|
- // console.log('request finished L.<?php echo __LINE__; ?>', data);
|
|
|
- jQuery(data).appendTo(taskCnt);
|
|
|
-
|
|
|
- initDateTimePicker(taskCnt);
|
|
|
- },
|
|
|
- error: function(err) {
|
|
|
- taskCnt.removeClass('AjaxTable-loading');
|
|
|
- //console.log(p5Utils__format('request error: {0}', [err]));
|
|
|
- }
|
|
|
- });
|
|
|
- //return false;
|
|
|
- }
|
|
|
+ CREATE: TableAjax__CREATE_Route,
|
|
|
};
|
|
|
var routePath = location.hash;
|
|
|
//console.log('location.hash: ' + routePath);
|