@xuda.io/runtime-bundle 1.0.1256 → 1.0.1257
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/xuda-runtime-bundle.js +1296 -1296
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +1303 -1303
- package/js/xuda-runtime-slim.min.es.js +1303 -1303
- package/js/xuda-runtime-slim.min.js +1 -1
- package/package.json +1 -1
|
@@ -31903,1137 +31903,1137 @@ const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession
|
|
|
31903
31903
|
return { params_res, params_raw };
|
|
31904
31904
|
};
|
|
31905
31905
|
|
|
31906
|
-
|
|
31907
|
-
|
|
31908
|
-
|
|
31909
|
-
// // console.log(nodeP.id, xu_func, val);
|
|
31910
|
-
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
31911
|
-
// const tag_fx = {
|
|
31912
|
-
// [`xu-panel`]: {
|
|
31913
|
-
// program: async function ($elm, val) {
|
|
31914
|
-
// var ret = {};
|
|
31915
|
-
// var _session = SESSION_OBJ[SESSION_ID];
|
|
31916
|
-
// var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
31917
|
-
// const init_program = async function () {
|
|
31918
|
-
// async function render_panel() {
|
|
31919
|
-
// const prog_id = val.value?.prog || val.value;
|
|
31920
|
-
// const params_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
|
|
31921
|
-
// let ret_panel = await func.UI.screen.init(SESSION_ID, prog_id, paramsP.screenId, _ds, $elm, null, _ds.currentRecordId, null, true, params_obj.params_res, 'initXu_panel', undefined, prog_id !== _ds.prog_id ? null : refreshed_ds, params_obj.params_raw);
|
|
31922
|
-
// ret = { $new_div: ret_panel };
|
|
31923
|
-
// if ($container.data().xuData) {
|
|
31924
|
-
// $container.data().xuData.xuPanelProps = $elm.data().xuAttributes;
|
|
31925
|
-
// $container.data().xuData.xuPanelData = ret_panel.data();
|
|
31926
|
-
// }
|
|
31927
|
-
// return ret;
|
|
31928
|
-
// }
|
|
31906
|
+
func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, xu_func, $elm, val, is_init, refreshed_ds) {
|
|
31907
|
+
if (is_skeleton) return;
|
|
31929
31908
|
|
|
31930
|
-
//
|
|
31931
|
-
|
|
31932
|
-
|
|
31909
|
+
// console.log(nodeP.id, xu_func, val);
|
|
31910
|
+
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
31911
|
+
const tag_fx = {
|
|
31912
|
+
[`xu-panel`]: {
|
|
31913
|
+
program: async function ($elm, val) {
|
|
31914
|
+
var ret = {};
|
|
31915
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
31916
|
+
var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
31917
|
+
const init_program = async function () {
|
|
31918
|
+
async function render_panel() {
|
|
31919
|
+
const prog_id = val.value?.prog || val.value;
|
|
31920
|
+
const params_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
|
|
31921
|
+
let ret_panel = await func.UI.screen.init(SESSION_ID, prog_id, paramsP.screenId, _ds, $elm, null, _ds.currentRecordId, null, true, params_obj.params_res, 'initXu_panel', undefined, prog_id !== _ds.prog_id ? null : refreshed_ds, params_obj.params_raw);
|
|
31922
|
+
ret = { $new_div: ret_panel };
|
|
31923
|
+
if ($container.data().xuData) {
|
|
31924
|
+
$container.data().xuData.xuPanelProps = $elm.data().xuAttributes;
|
|
31925
|
+
$container.data().xuData.xuPanelData = ret_panel.data();
|
|
31926
|
+
}
|
|
31927
|
+
return ret;
|
|
31928
|
+
}
|
|
31933
31929
|
|
|
31934
|
-
|
|
31930
|
+
if (!val.value) {
|
|
31931
|
+
val.value = '_empty_panel_program';
|
|
31932
|
+
}
|
|
31935
31933
|
|
|
31936
|
-
|
|
31937
|
-
// };
|
|
31938
|
-
// const alter_program = async function () {
|
|
31939
|
-
// var _session = SESSION_OBJ[SESSION_ID];
|
|
31940
|
-
// var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
31941
|
-
|
|
31942
|
-
// /////////////////
|
|
31943
|
-
// async function render_panel() {
|
|
31944
|
-
// // // if (!cache_str) {
|
|
31945
|
-
// // // await update_container(screen_ready_function);
|
|
31946
|
-
// // // }
|
|
31947
|
-
// // // if (cache_str && !CACHE_PROG_UI[cache_str]) {
|
|
31948
|
-
// // // await update_container(screen_ready_function);
|
|
31949
|
-
// // // save_cache();
|
|
31950
|
-
// // // }
|
|
31951
|
-
// // // if (callback) callback($div);
|
|
31952
|
-
// // // $container.data().xuData.node.children =
|
|
31953
|
-
// // // $div.data().xuData.node.children;
|
|
31954
|
-
// // // //swiper-wrapper
|
|
31955
|
-
// // // var restore_slides_elements = async function () {
|
|
31956
|
-
// // // if ($tmp_div.children().length) {
|
|
31957
|
-
// // // $tmp_div
|
|
31958
|
-
// // // .find(".swiper-wrapper")
|
|
31959
|
-
// // // .empty()
|
|
31960
|
-
// // // .append($new_div.children());
|
|
31961
|
-
// // // $new_div.append($tmp_div.children());
|
|
31962
|
-
// // // }
|
|
31963
|
-
// // // };
|
|
31964
|
-
// // // // console.log($tmp_div);
|
|
31965
|
-
// // // await restore_slides_elements();
|
|
31966
|
-
// // // // CHANGE_PANEL_BUSY = false;
|
|
31967
|
-
// // // func.events.delete_job(SESSION_ID, jobNo);
|
|
31968
|
-
// // };
|
|
31969
|
-
// const program = val.value?.prog || val.value;
|
|
31970
|
-
// var $wrapper = $('<div>');
|
|
31971
|
-
// var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, nodeP.attributes, null, null, null, $wrapper, '');
|
|
31972
|
-
// const params_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
|
|
31973
|
-
// let ret_init = await func.UI.screen.init(SESSION_ID, program, paramsP.screenId, _ds, $div, null, _ds.currentRecordId, jobNoP, true, params_obj.params_res, 'alterXu_panel', undefined, undefined, params_obj.params_raw);
|
|
31974
|
-
// ret = {
|
|
31975
|
-
// $new_div: ret_init,
|
|
31976
|
-
// abort: true,
|
|
31977
|
-
// };
|
|
31978
|
-
// await func.UI.screen.panel_post_render_handler(SESSION_ID, $elm, $new_div, nodeP, $div.clone(true), jobNoP);
|
|
31979
|
-
|
|
31980
|
-
// return ret;
|
|
31981
|
-
// }
|
|
31982
|
-
// if (!val.value) {
|
|
31983
|
-
// return { abort: true };
|
|
31984
|
-
// }
|
|
31985
|
-
// await render_panel();
|
|
31986
|
-
// return ret;
|
|
31987
|
-
// };
|
|
31934
|
+
ret = await render_panel();
|
|
31988
31935
|
|
|
31989
|
-
|
|
31990
|
-
|
|
31991
|
-
|
|
31992
|
-
|
|
31993
|
-
|
|
31994
|
-
// },
|
|
31936
|
+
return ret;
|
|
31937
|
+
};
|
|
31938
|
+
const alter_program = async function () {
|
|
31939
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
31940
|
+
var _ds = _session.DS_GLB[paramsP.dsSessionP];
|
|
31995
31941
|
|
|
31996
|
-
|
|
31997
|
-
|
|
31998
|
-
//
|
|
31999
|
-
//
|
|
32000
|
-
//
|
|
32001
|
-
//
|
|
32002
|
-
//
|
|
32003
|
-
//
|
|
32004
|
-
//
|
|
32005
|
-
//
|
|
32006
|
-
//
|
|
32007
|
-
//
|
|
32008
|
-
//
|
|
32009
|
-
//
|
|
32010
|
-
//
|
|
32011
|
-
//
|
|
32012
|
-
//
|
|
32013
|
-
//
|
|
32014
|
-
|
|
32015
|
-
//
|
|
32016
|
-
//
|
|
32017
|
-
//
|
|
32018
|
-
//
|
|
32019
|
-
//
|
|
32020
|
-
//
|
|
32021
|
-
//
|
|
32022
|
-
//
|
|
32023
|
-
|
|
32024
|
-
|
|
32025
|
-
|
|
32026
|
-
|
|
31942
|
+
/////////////////
|
|
31943
|
+
async function render_panel() {
|
|
31944
|
+
// // if (!cache_str) {
|
|
31945
|
+
// // await update_container(screen_ready_function);
|
|
31946
|
+
// // }
|
|
31947
|
+
// // if (cache_str && !CACHE_PROG_UI[cache_str]) {
|
|
31948
|
+
// // await update_container(screen_ready_function);
|
|
31949
|
+
// // save_cache();
|
|
31950
|
+
// // }
|
|
31951
|
+
// // if (callback) callback($div);
|
|
31952
|
+
// // $container.data().xuData.node.children =
|
|
31953
|
+
// // $div.data().xuData.node.children;
|
|
31954
|
+
// // //swiper-wrapper
|
|
31955
|
+
// // var restore_slides_elements = async function () {
|
|
31956
|
+
// // if ($tmp_div.children().length) {
|
|
31957
|
+
// // $tmp_div
|
|
31958
|
+
// // .find(".swiper-wrapper")
|
|
31959
|
+
// // .empty()
|
|
31960
|
+
// // .append($new_div.children());
|
|
31961
|
+
// // $new_div.append($tmp_div.children());
|
|
31962
|
+
// // }
|
|
31963
|
+
// // };
|
|
31964
|
+
// // // console.log($tmp_div);
|
|
31965
|
+
// // await restore_slides_elements();
|
|
31966
|
+
// // // CHANGE_PANEL_BUSY = false;
|
|
31967
|
+
// // func.events.delete_job(SESSION_ID, jobNo);
|
|
31968
|
+
// };
|
|
31969
|
+
const program = val.value?.prog || val.value;
|
|
31970
|
+
var $wrapper = $('<div>');
|
|
31971
|
+
var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, nodeP.attributes, null, null, null, $wrapper, '');
|
|
31972
|
+
const params_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
|
|
31973
|
+
let ret_init = await func.UI.screen.init(SESSION_ID, program, paramsP.screenId, _ds, $div, null, _ds.currentRecordId, jobNoP, true, params_obj.params_res, 'alterXu_panel', undefined, undefined, params_obj.params_raw);
|
|
31974
|
+
ret = {
|
|
31975
|
+
$new_div: ret_init,
|
|
31976
|
+
abort: true,
|
|
31977
|
+
};
|
|
31978
|
+
await func.UI.screen.panel_post_render_handler(SESSION_ID, $elm, $new_div, nodeP, $div.clone(true), jobNoP);
|
|
32027
31979
|
|
|
32028
|
-
|
|
32029
|
-
|
|
32030
|
-
|
|
32031
|
-
|
|
32032
|
-
|
|
32033
|
-
|
|
32034
|
-
|
|
31980
|
+
return ret;
|
|
31981
|
+
}
|
|
31982
|
+
if (!val.value) {
|
|
31983
|
+
return { abort: true };
|
|
31984
|
+
}
|
|
31985
|
+
await render_panel();
|
|
31986
|
+
return ret;
|
|
31987
|
+
};
|
|
32035
31988
|
|
|
32036
|
-
|
|
32037
|
-
|
|
32038
|
-
|
|
32039
|
-
|
|
32040
|
-
|
|
32041
|
-
|
|
32042
|
-
// // $elm.parent().data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
32043
|
-
// // $teleport_elm.attr('xu-teleport-parent-id', $elm.parent().attr('xu-ui-id'));
|
|
32044
|
-
// // }
|
|
32045
|
-
// // $elm.remove();
|
|
32046
|
-
// // } else {
|
|
32047
|
-
// // $elm.data('xuTeleportData', []).attr('hidden', true);
|
|
32048
|
-
// // for (const [key, node] of Object.entries(nodeP.children)) {
|
|
32049
|
-
// // const $to_container = $(val.value);
|
|
32050
|
-
// // if (!$to_container?.length) {
|
|
32051
|
-
// // return console.error(`container ${val.value} for xuTeleportData not found`);
|
|
32052
|
-
// // }
|
|
32053
|
-
// // const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $to_container, node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
32054
|
-
// // $elm.data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
32055
|
-
// // $teleport_elm.attr('xu-teleport-parent-id', $elm.attr('xu-ui-id'));
|
|
32056
|
-
// // }
|
|
32057
|
-
// // }
|
|
32058
|
-
// }
|
|
32059
|
-
// return {};
|
|
32060
|
-
// },
|
|
32061
|
-
// 'xu-render': async function ($elm, val) {
|
|
32062
|
-
// let ret = await common_fx['xu-render']($elm, val, true);
|
|
32063
|
-
// return ret;
|
|
32064
|
-
// },
|
|
32065
|
-
// 'xu-show': async function ($elm, val) {
|
|
32066
|
-
// let ret = await common_fx['xu-show']($elm, val, true);
|
|
32067
|
-
// return ret;
|
|
32068
|
-
// },
|
|
32069
|
-
// },
|
|
32070
|
-
// };
|
|
31989
|
+
if (is_init) {
|
|
31990
|
+
let ret = await init_program();
|
|
31991
|
+
return ret;
|
|
31992
|
+
}
|
|
31993
|
+
return alter_program();
|
|
31994
|
+
},
|
|
32071
31995
|
|
|
32072
|
-
|
|
32073
|
-
|
|
32074
|
-
|
|
32075
|
-
|
|
32076
|
-
|
|
32077
|
-
|
|
32078
|
-
|
|
32079
|
-
|
|
32080
|
-
|
|
32081
|
-
|
|
32082
|
-
|
|
32083
|
-
|
|
32084
|
-
|
|
32085
|
-
//
|
|
32086
|
-
|
|
32087
|
-
|
|
32088
|
-
|
|
32089
|
-
|
|
32090
|
-
|
|
32091
|
-
|
|
32092
|
-
|
|
32093
|
-
|
|
32094
|
-
|
|
32095
|
-
|
|
32096
|
-
|
|
32097
|
-
|
|
32098
|
-
|
|
32099
|
-
|
|
32100
|
-
|
|
32101
|
-
|
|
31996
|
+
'xu-render': async function ($elm, val) {
|
|
31997
|
+
let ret = await common_fx['xu-render']($elm, val, true);
|
|
31998
|
+
return ret;
|
|
31999
|
+
},
|
|
32000
|
+
'xu-ref': async function ($elm, val) {
|
|
32001
|
+
let ret = await common_fx['xu-ref']($container, val, $container.data().xuData.xuPanelData.xuData.paramsP.dsSessionP);
|
|
32002
|
+
return ret;
|
|
32003
|
+
},
|
|
32004
|
+
},
|
|
32005
|
+
[`xu-teleport`]: {
|
|
32006
|
+
to: async function ($elm, val) {
|
|
32007
|
+
if (!glb.new_xu_render) {
|
|
32008
|
+
if (val.value) {
|
|
32009
|
+
// parent_infoP.is_xu_teleport;
|
|
32010
|
+
if ($elm?.parent()?.data()?.xuData?.length) {
|
|
32011
|
+
$elm.parent().data('xuTeleportData', []);
|
|
32012
|
+
for (const [key, node] of Object.entries(nodeP.children)) {
|
|
32013
|
+
const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $(val.value), node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
32014
|
+
|
|
32015
|
+
$elm.parent().data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
32016
|
+
$teleport_elm.attr('xu-teleport-parent-id', $elm.parent().attr('xu-ui-id'));
|
|
32017
|
+
}
|
|
32018
|
+
$elm.remove();
|
|
32019
|
+
} else {
|
|
32020
|
+
$elm.data('xuTeleportData', []).attr('hidden', true);
|
|
32021
|
+
for (const [key, node] of Object.entries(nodeP.children)) {
|
|
32022
|
+
const $to_container = $(val.value);
|
|
32023
|
+
if (!$to_container?.length) {
|
|
32024
|
+
return console.error(`container ${val.value} for xuTeleportData not found`);
|
|
32025
|
+
}
|
|
32026
|
+
const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $to_container, node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
32102
32027
|
|
|
32103
|
-
|
|
32104
|
-
|
|
32105
|
-
|
|
32106
|
-
|
|
32107
|
-
|
|
32108
|
-
|
|
32109
|
-
|
|
32110
|
-
// // }
|
|
32111
|
-
// // if (resource.type === "module") {
|
|
32112
|
-
// // func.utils.load_js_on_demand(resource.src, "module");
|
|
32113
|
-
// // return resolve();
|
|
32114
|
-
// // }
|
|
32115
|
-
// // func.utils.debug_report(
|
|
32116
|
-
// // SESSION_ID,
|
|
32117
|
-
// // "xu-cdn",
|
|
32118
|
-
// // "Fail to load: " + resource,
|
|
32119
|
-
// // "W"
|
|
32120
|
-
// // );
|
|
32121
|
-
// // return resolve();
|
|
32122
|
-
// });
|
|
32123
|
-
// };
|
|
32028
|
+
$elm.data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
32029
|
+
$teleport_elm.attr('xu-teleport-parent-id', $elm.attr('xu-ui-id'));
|
|
32030
|
+
}
|
|
32031
|
+
}
|
|
32032
|
+
}
|
|
32033
|
+
return { abort: true };
|
|
32034
|
+
}
|
|
32124
32035
|
|
|
32125
|
-
|
|
32126
|
-
//
|
|
32127
|
-
//
|
|
32128
|
-
//
|
|
32129
|
-
//
|
|
32130
|
-
//
|
|
32131
|
-
//
|
|
32036
|
+
if (val.value) {
|
|
32037
|
+
// // parent_infoP.is_xu_teleport;
|
|
32038
|
+
// if ($elm?.parent()?.data()?.xuData?.length) {
|
|
32039
|
+
// $elm.parent().data('xuTeleportData', []);
|
|
32040
|
+
// for (const [key, node] of Object.entries(nodeP.children)) {
|
|
32041
|
+
// const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $(val.value), node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
32042
|
+
// $elm.parent().data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
32043
|
+
// $teleport_elm.attr('xu-teleport-parent-id', $elm.parent().attr('xu-ui-id'));
|
|
32044
|
+
// }
|
|
32045
|
+
// $elm.remove();
|
|
32046
|
+
// } else {
|
|
32047
|
+
// $elm.data('xuTeleportData', []).attr('hidden', true);
|
|
32048
|
+
// for (const [key, node] of Object.entries(nodeP.children)) {
|
|
32049
|
+
// const $to_container = $(val.value);
|
|
32050
|
+
// if (!$to_container?.length) {
|
|
32051
|
+
// return console.error(`container ${val.value} for xuTeleportData not found`);
|
|
32052
|
+
// }
|
|
32053
|
+
// const $teleport_elm = await func.UI.screen.render_ui_tree(SESSION_ID, $to_container, node, parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, node, null, $root_container);
|
|
32054
|
+
// $elm.data().xuTeleportData.push($teleport_elm.attr('xu-ui-id'));
|
|
32055
|
+
// $teleport_elm.attr('xu-teleport-parent-id', $elm.attr('xu-ui-id'));
|
|
32056
|
+
// }
|
|
32057
|
+
// }
|
|
32058
|
+
}
|
|
32059
|
+
return {};
|
|
32060
|
+
},
|
|
32061
|
+
'xu-render': async function ($elm, val) {
|
|
32062
|
+
let ret = await common_fx['xu-render']($elm, val, true);
|
|
32063
|
+
return ret;
|
|
32064
|
+
},
|
|
32065
|
+
'xu-show': async function ($elm, val) {
|
|
32066
|
+
let ret = await common_fx['xu-show']($elm, val, true);
|
|
32067
|
+
return ret;
|
|
32068
|
+
},
|
|
32069
|
+
},
|
|
32070
|
+
};
|
|
32132
32071
|
|
|
32133
|
-
|
|
32134
|
-
//
|
|
32135
|
-
|
|
32136
|
-
|
|
32072
|
+
const load_cdn = async function (resource) {
|
|
32073
|
+
// console.log("loading cdn", resource);
|
|
32074
|
+
if (!_.isObject(resource) && _.isString(resource)) {
|
|
32075
|
+
resource = { src: resource, type: 'js' };
|
|
32076
|
+
}
|
|
32077
|
+
if (!_.isObject(resource)) {
|
|
32078
|
+
throw new Error('cdn resource in wrong format');
|
|
32079
|
+
}
|
|
32080
|
+
return new Promise(async (resolve) => {
|
|
32081
|
+
try {
|
|
32082
|
+
switch (resource.type) {
|
|
32083
|
+
case 'js':
|
|
32084
|
+
await func.utils.load_js_on_demand(resource.src);
|
|
32085
|
+
break;
|
|
32086
|
+
case 'css':
|
|
32087
|
+
await func.utils.load_js_on_demand(resource.src);
|
|
32088
|
+
break;
|
|
32089
|
+
case 'module':
|
|
32090
|
+
func.utils.load_js_on_demand(resource.src, 'module');
|
|
32091
|
+
break;
|
|
32137
32092
|
|
|
32138
|
-
|
|
32093
|
+
default:
|
|
32094
|
+
await func.utils.load_js_on_demand(resource.src);
|
|
32095
|
+
break;
|
|
32096
|
+
}
|
|
32097
|
+
resolve();
|
|
32098
|
+
} catch (error) {
|
|
32099
|
+
func.utils.debug_report(SESSION_ID, 'xu-cdn', 'Fail to load: ' + resource, 'W');
|
|
32100
|
+
resolve();
|
|
32101
|
+
}
|
|
32139
32102
|
|
|
32140
|
-
//
|
|
32141
|
-
//
|
|
32103
|
+
// if (resource.type === "js" || !resource.type) {
|
|
32104
|
+
// await func.utils.load_js_on_demand(resource.src);
|
|
32105
|
+
// return resolve();
|
|
32106
|
+
// }
|
|
32107
|
+
// if (resource.type === "css") {
|
|
32108
|
+
// func.utils.load_css_on_demand(resource.src);
|
|
32109
|
+
// return resolve();
|
|
32110
|
+
// }
|
|
32111
|
+
// if (resource.type === "module") {
|
|
32112
|
+
// func.utils.load_js_on_demand(resource.src, "module");
|
|
32113
|
+
// return resolve();
|
|
32114
|
+
// }
|
|
32115
|
+
// func.utils.debug_report(
|
|
32116
|
+
// SESSION_ID,
|
|
32117
|
+
// "xu-cdn",
|
|
32118
|
+
// "Fail to load: " + resource,
|
|
32119
|
+
// "W"
|
|
32120
|
+
// );
|
|
32121
|
+
// return resolve();
|
|
32122
|
+
});
|
|
32123
|
+
};
|
|
32142
32124
|
|
|
32143
|
-
|
|
32125
|
+
const common_fx = {
|
|
32126
|
+
'xu-attrs': async function ($elm, val) {
|
|
32127
|
+
if (!val.value) return {};
|
|
32128
|
+
if (!_.isObject(val.value)) throw 'xu-attrs value us not an object';
|
|
32129
|
+
for (const [attr_key, attr_val] of Object.entries(val.value)) {
|
|
32130
|
+
nodeP.attributes[attr_key] = attr_val;
|
|
32131
|
+
}
|
|
32144
32132
|
|
|
32145
|
-
|
|
32146
|
-
|
|
32133
|
+
return {};
|
|
32134
|
+
},
|
|
32135
|
+
'xu-ref': async function ($elm, val, dsSession) {
|
|
32136
|
+
if (!val.value) return {};
|
|
32147
32137
|
|
|
32148
|
-
|
|
32149
|
-
// const callback = (mutationList, observer) => {
|
|
32150
|
-
// func.UI.screen.refresh_xu_attributes(SESSION_ID, [val.value]);
|
|
32151
|
-
// };
|
|
32138
|
+
func.UI.update_xu_ref(SESSION_ID, dsSession || paramsP.dsSessionP, val.value, $elm);
|
|
32152
32139
|
|
|
32153
|
-
//
|
|
32154
|
-
|
|
32140
|
+
// Select the node that will be observed for mutations
|
|
32141
|
+
const targetNode = $elm[0];
|
|
32155
32142
|
|
|
32156
|
-
|
|
32157
|
-
// observer.observe(targetNode, config);
|
|
32143
|
+
if (!targetNode) return;
|
|
32158
32144
|
|
|
32159
|
-
//
|
|
32160
|
-
|
|
32145
|
+
// Options for the observer (which mutations to observe)
|
|
32146
|
+
const config = { attributes: true, childList: true, subtree: true };
|
|
32161
32147
|
|
|
32162
|
-
//
|
|
32163
|
-
|
|
32164
|
-
|
|
32165
|
-
|
|
32148
|
+
// Callback function to execute when mutations are observed
|
|
32149
|
+
const callback = (mutationList, observer) => {
|
|
32150
|
+
func.UI.screen.refresh_xu_attributes(SESSION_ID, [val.value]);
|
|
32151
|
+
};
|
|
32166
32152
|
|
|
32167
|
-
//
|
|
32153
|
+
// Create an observer instance linked to the callback function
|
|
32154
|
+
const observer = new MutationObserver(callback);
|
|
32168
32155
|
|
|
32169
|
-
//
|
|
32170
|
-
|
|
32171
|
-
// const view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _prog_id);
|
|
32172
|
-
// if (!view_ret) return {};
|
|
32156
|
+
// Start observing the target node for configured mutations
|
|
32157
|
+
observer.observe(targetNode, config);
|
|
32173
32158
|
|
|
32174
|
-
//
|
|
32175
|
-
//
|
|
32176
|
-
// let bind_field_id;
|
|
32159
|
+
// Later, you can stop observing
|
|
32160
|
+
// observer.disconnect();
|
|
32177
32161
|
|
|
32178
|
-
|
|
32162
|
+
return {};
|
|
32163
|
+
},
|
|
32164
|
+
'xu-bind': async function ($elm, val) {
|
|
32165
|
+
if (is_skeleton) return;
|
|
32179
32166
|
|
|
32180
|
-
|
|
32181
|
-
// if (['_FOR_VAL', '_FOR_KEY'].includes(field_id)) {
|
|
32182
|
-
// is_dynamic_field = true;
|
|
32183
|
-
// field_prop = _ds.dynamic_fields[field_id];
|
|
32184
|
-
// } else {
|
|
32185
|
-
// field_prop = func.common.find_item_by_key(view_ret.progFields, 'field_id', field_id);
|
|
32186
|
-
// if (!field_prop) {
|
|
32187
|
-
// /// find the field everywhere in the chain Aug 30 2024
|
|
32188
|
-
// const ret_get_value = await func.datasource.get_value(SESSION_ID, field_id, _dsP);
|
|
32189
|
-
|
|
32190
|
-
// if (ret_get_value.found) {
|
|
32191
|
-
// _dsP = ret_get_value.dsSessionP;
|
|
32192
|
-
// let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
|
|
32193
|
-
// _prog_id = _ds.prog_id;
|
|
32194
|
-
// const view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _prog_id);
|
|
32195
|
-
// if (!view_ret) return {};
|
|
32196
|
-
// field_prop = func.common.find_item_by_key(view_ret.progFields, 'field_id', field_id);
|
|
32197
|
-
// }
|
|
32198
|
-
// if (!field_prop) {
|
|
32199
|
-
// throw `field ${field_id} not found in the program scope`;
|
|
32200
|
-
// }
|
|
32201
|
-
// }
|
|
32202
|
-
// }
|
|
32203
|
-
// return field_id;
|
|
32204
|
-
// };
|
|
32167
|
+
let val_is_reference_field = false;
|
|
32205
32168
|
|
|
32206
|
-
|
|
32207
|
-
|
|
32208
|
-
|
|
32209
|
-
|
|
32210
|
-
// console.error(err?.message || err);
|
|
32211
|
-
// return {};
|
|
32212
|
-
// }
|
|
32169
|
+
let _prog_id = $elm.data().xuData.paramsP.prog_id;
|
|
32170
|
+
let _dsP = $elm.data().xuData.paramsP.dsSessionP;
|
|
32171
|
+
const view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _prog_id);
|
|
32172
|
+
if (!view_ret) return {};
|
|
32213
32173
|
|
|
32214
|
-
|
|
32215
|
-
|
|
32174
|
+
let is_dynamic_field = false;
|
|
32175
|
+
let field_prop;
|
|
32176
|
+
let bind_field_id;
|
|
32216
32177
|
|
|
32217
|
-
|
|
32218
|
-
// if (field_prop.props.fieldType === 'array' && input_field_type === 'checkbox' && val_is_reference_field) {
|
|
32219
|
-
// let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
|
|
32220
|
-
// let value_from_getter = bind.getter($elm[0]);
|
|
32221
|
-
// let value;
|
|
32222
|
-
// if (arr_value_before_cast.includes(value_from_getter)) {
|
|
32223
|
-
// value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
|
|
32224
|
-
// } else {
|
|
32225
|
-
// arr_value_before_cast.push(value_from_getter);
|
|
32226
|
-
// value = arr_value_before_cast;
|
|
32227
|
-
// }
|
|
32178
|
+
const input_field_type = $elm.attr('type');
|
|
32228
32179
|
|
|
32229
|
-
|
|
32230
|
-
|
|
32231
|
-
|
|
32232
|
-
|
|
32233
|
-
|
|
32234
|
-
|
|
32235
|
-
|
|
32180
|
+
const get_bind_field = async function (field_id) {
|
|
32181
|
+
if (['_FOR_VAL', '_FOR_KEY'].includes(field_id)) {
|
|
32182
|
+
is_dynamic_field = true;
|
|
32183
|
+
field_prop = _ds.dynamic_fields[field_id];
|
|
32184
|
+
} else {
|
|
32185
|
+
field_prop = func.common.find_item_by_key(view_ret.progFields, 'field_id', field_id);
|
|
32186
|
+
if (!field_prop) {
|
|
32187
|
+
/// find the field everywhere in the chain Aug 30 2024
|
|
32188
|
+
const ret_get_value = await func.datasource.get_value(SESSION_ID, field_id, _dsP);
|
|
32236
32189
|
|
|
32237
|
-
|
|
32238
|
-
|
|
32190
|
+
if (ret_get_value.found) {
|
|
32191
|
+
_dsP = ret_get_value.dsSessionP;
|
|
32192
|
+
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
|
|
32193
|
+
_prog_id = _ds.prog_id;
|
|
32194
|
+
const view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _prog_id);
|
|
32195
|
+
if (!view_ret) return {};
|
|
32196
|
+
field_prop = func.common.find_item_by_key(view_ret.progFields, 'field_id', field_id);
|
|
32197
|
+
}
|
|
32198
|
+
if (!field_prop) {
|
|
32199
|
+
throw `field ${field_id} not found in the program scope`;
|
|
32200
|
+
}
|
|
32201
|
+
}
|
|
32202
|
+
}
|
|
32203
|
+
return field_id;
|
|
32204
|
+
};
|
|
32239
32205
|
|
|
32240
|
-
|
|
32241
|
-
|
|
32242
|
-
|
|
32206
|
+
try {
|
|
32207
|
+
bind_field_id = await get_bind_field(val.value.split('.')[0]);
|
|
32208
|
+
val_is_reference_field = true;
|
|
32209
|
+
} catch (err) {
|
|
32210
|
+
console.error(err?.message || err);
|
|
32211
|
+
return {};
|
|
32212
|
+
}
|
|
32243
32213
|
|
|
32244
|
-
|
|
32245
|
-
|
|
32246
|
-
// [_ds.currentRecordId]: {
|
|
32247
|
-
// [bind_field_id]: [value_from_getter],
|
|
32248
|
-
// },
|
|
32249
|
-
// },
|
|
32250
|
-
// };
|
|
32214
|
+
const field_changed = async function (e) {
|
|
32215
|
+
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
|
|
32251
32216
|
|
|
32252
|
-
//
|
|
32253
|
-
|
|
32217
|
+
// update array for checkbox that not in xu-for
|
|
32218
|
+
if (field_prop.props.fieldType === 'array' && input_field_type === 'checkbox' && val_is_reference_field) {
|
|
32219
|
+
let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
|
|
32220
|
+
let value_from_getter = bind.getter($elm[0]);
|
|
32221
|
+
let value;
|
|
32222
|
+
if (arr_value_before_cast.includes(value_from_getter)) {
|
|
32223
|
+
value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
|
|
32224
|
+
} else {
|
|
32225
|
+
arr_value_before_cast.push(value_from_getter);
|
|
32226
|
+
value = arr_value_before_cast;
|
|
32227
|
+
}
|
|
32254
32228
|
|
|
32255
|
-
|
|
32229
|
+
let datasource_changes = {
|
|
32230
|
+
[_dsP]: {
|
|
32231
|
+
[_ds.currentRecordId]: {
|
|
32232
|
+
[bind_field_id]: value,
|
|
32233
|
+
},
|
|
32234
|
+
},
|
|
32235
|
+
};
|
|
32256
32236
|
|
|
32257
|
-
|
|
32258
|
-
|
|
32259
|
-
// }
|
|
32237
|
+
return await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32238
|
+
}
|
|
32260
32239
|
|
|
32261
|
-
//
|
|
32240
|
+
// update array for radio that not in xu-for
|
|
32241
|
+
if (field_prop.props.fieldType === 'array' && input_field_type === 'radio' && val_is_reference_field) {
|
|
32242
|
+
let value_from_getter = bind.getter($elm[0]);
|
|
32262
32243
|
|
|
32263
|
-
|
|
32264
|
-
|
|
32265
|
-
|
|
32266
|
-
|
|
32267
|
-
|
|
32268
|
-
|
|
32269
|
-
|
|
32244
|
+
let datasource_changes = {
|
|
32245
|
+
[_dsP]: {
|
|
32246
|
+
[_ds.currentRecordId]: {
|
|
32247
|
+
[bind_field_id]: [value_from_getter],
|
|
32248
|
+
},
|
|
32249
|
+
},
|
|
32250
|
+
};
|
|
32270
32251
|
|
|
32271
|
-
|
|
32272
|
-
|
|
32273
|
-
// const reference_source_obj = iterate_info?.reference_source_obj;
|
|
32274
|
-
// if (reference_source_obj) {
|
|
32275
|
-
// if (reference_source_obj.ret.type === 'array') {
|
|
32276
|
-
// if (iterate_info.iterator_val === bind_field_id) {
|
|
32277
|
-
// const arr_idx = Number($elm?.data()?.xuData?.iterate_info._key);
|
|
32252
|
+
return await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32253
|
+
}
|
|
32278
32254
|
|
|
32279
|
-
|
|
32280
|
-
// let new_arr = _.cloneDeep(dataset_arr.ret.value);
|
|
32255
|
+
var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_prop.props.fieldType, bind.getter($elm[0]));
|
|
32281
32256
|
|
|
32282
|
-
|
|
32283
|
-
|
|
32257
|
+
if (field_prop.props.fieldType === 'object') {
|
|
32258
|
+
value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, bind.getter($elm[0]));
|
|
32259
|
+
}
|
|
32284
32260
|
|
|
32285
|
-
|
|
32261
|
+
if (!_ds.currentRecordId) return;
|
|
32286
32262
|
|
|
32287
|
-
|
|
32263
|
+
let datasource_changes = {
|
|
32264
|
+
[_dsP]: {
|
|
32265
|
+
[_ds.currentRecordId]: {
|
|
32266
|
+
[bind_field_id]: value,
|
|
32267
|
+
},
|
|
32268
|
+
},
|
|
32269
|
+
};
|
|
32288
32270
|
|
|
32289
|
-
|
|
32290
|
-
|
|
32291
|
-
|
|
32292
|
-
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
// [_dsP]: {
|
|
32297
|
-
// [_ds.currentRecordId]: {
|
|
32298
|
-
// [reference_source_obj.fieldIdP]: new_arr,
|
|
32299
|
-
// },
|
|
32300
|
-
// },
|
|
32301
|
-
// };
|
|
32271
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32272
|
+
const iterate_info = $elm?.data()?.xuData?.iterate_info;
|
|
32273
|
+
const reference_source_obj = iterate_info?.reference_source_obj;
|
|
32274
|
+
if (reference_source_obj) {
|
|
32275
|
+
if (reference_source_obj.ret.type === 'array') {
|
|
32276
|
+
if (iterate_info.iterator_val === bind_field_id) {
|
|
32277
|
+
const arr_idx = Number($elm?.data()?.xuData?.iterate_info._key);
|
|
32302
32278
|
|
|
32303
|
-
|
|
32304
|
-
|
|
32305
|
-
// }
|
|
32306
|
-
// }
|
|
32279
|
+
const dataset_arr = await func.datasource.get_value(SESSION_ID, reference_source_obj.fieldIdP, _dsP, reference_source_obj.currentRecordId);
|
|
32280
|
+
let new_arr = _.cloneDeep(dataset_arr.ret.value);
|
|
32307
32281
|
|
|
32308
|
-
|
|
32309
|
-
|
|
32282
|
+
if (field_prop.props.fieldType === 'object' && val_is_reference_field) {
|
|
32283
|
+
let obj_item = new_arr[arr_idx];
|
|
32310
32284
|
|
|
32311
|
-
|
|
32285
|
+
let e_exp = val.value.replace(bind_field_id, 'obj_item');
|
|
32312
32286
|
|
|
32313
|
-
|
|
32287
|
+
let new_val = eval(e_exp + (input_field_type === 'string' ? `="${value}"` : `=${value}`));
|
|
32314
32288
|
|
|
32315
|
-
|
|
32316
|
-
|
|
32317
|
-
|
|
32318
|
-
|
|
32319
|
-
//
|
|
32320
|
-
// if (val_is_reference_field) {
|
|
32321
|
-
// if (is_dynamic_field) {
|
|
32322
|
-
// value = _ds.dynamic_fields[bind_field_id].value;
|
|
32323
|
-
// } else {
|
|
32324
|
-
// const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
32325
|
-
// value = _ds.data_feed.rows?.[row_idx]?.[bind_field_id];
|
|
32326
|
-
// }
|
|
32327
|
-
// if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && $elm.attr('value')) {
|
|
32328
|
-
// if (value.includes($elm.attr('value'))) {
|
|
32329
|
-
// value = true;
|
|
32330
|
-
// } else {
|
|
32331
|
-
// value = false;
|
|
32332
|
-
// }
|
|
32333
|
-
// } else if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && $elm.attr('value')) {
|
|
32334
|
-
// if (value.includes($elm.attr('value'))) {
|
|
32335
|
-
// value = $elm.attr('value');
|
|
32336
|
-
// } else {
|
|
32337
|
-
// value = false;
|
|
32338
|
-
// }
|
|
32339
|
-
// } else if (field_prop.props.fieldType === 'object' && val.value.split('.').length > 1) {
|
|
32340
|
-
// let str = val.value.replace(bind_field_id, '(' + JSON.stringify(value) + ')');
|
|
32341
|
-
// value = eval(str);
|
|
32342
|
-
// }
|
|
32343
|
-
// } else {
|
|
32344
|
-
// value = val.value;
|
|
32345
|
-
// }
|
|
32346
|
-
// if (typeof value === 'undefined') return;
|
|
32347
|
-
// bind.setter($elm[0], value);
|
|
32348
|
-
// } catch (err) {
|
|
32349
|
-
// console.error(err);
|
|
32350
|
-
// }
|
|
32351
|
-
// };
|
|
32352
|
-
// /// init value from ds
|
|
32353
|
-
// $('body').on('xu-bind-refresh.' + _ds.dsSession.toString(), () => {
|
|
32354
|
-
// set_value();
|
|
32355
|
-
// });
|
|
32289
|
+
new_arr[arr_idx] = obj_item;
|
|
32290
|
+
} else {
|
|
32291
|
+
new_arr[arr_idx] = value;
|
|
32292
|
+
}
|
|
32293
|
+
// datasource_changes[_dsP][_ds.currentRecordId][reference_source_obj.fieldIdP] = new_arr;
|
|
32356
32294
|
|
|
32357
|
-
|
|
32358
|
-
|
|
32359
|
-
|
|
32360
|
-
|
|
32361
|
-
|
|
32362
|
-
|
|
32363
|
-
|
|
32364
|
-
// if (!value) {
|
|
32365
|
-
// var cloned_$div = $elm.clone(true);
|
|
32366
|
-
|
|
32367
|
-
// let $xurender = $('<xurender>').attr('xu-ui-id', $elm.attr('xu-ui-id')).attr('hidden', true).appendTo($container); //.hide();
|
|
32368
|
-
// let original_data_obj = {
|
|
32369
|
-
// $container: cloned_$div,
|
|
32370
|
-
// nodeP: _.cloneDeep(nodeP),
|
|
32371
|
-
// parent_infoP,
|
|
32372
|
-
// paramsP,
|
|
32373
|
-
// keyP,
|
|
32374
|
-
// parent_nodeP,
|
|
32375
|
-
// $root_container,
|
|
32376
|
-
// };
|
|
32377
|
-
// $xurender.data('xuData', cloned_$div.data().xuData);
|
|
32378
|
-
// $xurender.data().xuData.original_data_obj = original_data_obj;
|
|
32379
|
-
// $xurender.data().xuData.xurender_node = cloned_$div;
|
|
32380
|
-
// $xurender.data().xuAttributes = nodeP.attributes || {};
|
|
32381
|
-
// // $xurender.hide();
|
|
32382
|
-
|
|
32383
|
-
// $elm.remove();
|
|
32384
|
-
// return { abort: true };
|
|
32385
|
-
// }
|
|
32386
|
-
// return {};
|
|
32387
|
-
// };
|
|
32295
|
+
let datasource_changes = {
|
|
32296
|
+
[_dsP]: {
|
|
32297
|
+
[_ds.currentRecordId]: {
|
|
32298
|
+
[reference_source_obj.fieldIdP]: new_arr,
|
|
32299
|
+
},
|
|
32300
|
+
},
|
|
32301
|
+
};
|
|
32388
32302
|
|
|
32389
|
-
|
|
32390
|
-
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
// if ($elm[0].tagName !== 'XURENDER' && $elm?.length) {
|
|
32394
|
-
// return func.events.delete_job(SESSION_ID, jobNoP);
|
|
32395
|
-
// }
|
|
32303
|
+
await func.datasource.update(SESSION_ID, datasource_changes, null, true);
|
|
32304
|
+
}
|
|
32305
|
+
}
|
|
32306
|
+
}
|
|
32396
32307
|
|
|
32397
|
-
|
|
32308
|
+
await func.datasource.update_changes_for_out_parameter(SESSION_ID, _dsP, _ds.parentDataSourceNo);
|
|
32309
|
+
};
|
|
32398
32310
|
|
|
32399
|
-
|
|
32400
|
-
// func.events.delete_job(SESSION_ID, jobNoP);
|
|
32401
|
-
// return { delete_job: jobNoP };
|
|
32402
|
-
// }
|
|
32311
|
+
const bind = new UI_FRAMEWORK_PLUGIN.bind();
|
|
32403
32312
|
|
|
32404
|
-
|
|
32405
|
-
// SESSION_ID,
|
|
32406
|
-
// $elm, //original_data_obj.$container,
|
|
32407
|
-
// _.cloneDeep(original_data_obj.nodeP),
|
|
32408
|
-
// original_data_obj.parent_infoP,
|
|
32409
|
-
// original_data_obj.paramsP,
|
|
32410
|
-
// jobNoP,
|
|
32411
|
-
// null,
|
|
32412
|
-
// original_data_obj.keyP,
|
|
32413
|
-
// null,
|
|
32414
|
-
// original_data_obj.parent_nodeP,
|
|
32415
|
-
// null,
|
|
32416
|
-
// original_data_obj.$root_container,
|
|
32417
|
-
// );
|
|
32313
|
+
bind.listener($elm[0], field_changed);
|
|
32418
32314
|
|
|
32419
|
-
|
|
32420
|
-
|
|
32421
|
-
|
|
32315
|
+
const set_value = function () {
|
|
32316
|
+
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
32317
|
+
if (!_ds.currentRecordId) return;
|
|
32318
|
+
let value;
|
|
32319
|
+
try {
|
|
32320
|
+
if (val_is_reference_field) {
|
|
32321
|
+
if (is_dynamic_field) {
|
|
32322
|
+
value = _ds.dynamic_fields[bind_field_id].value;
|
|
32323
|
+
} else {
|
|
32324
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
32325
|
+
value = _ds.data_feed.rows?.[row_idx]?.[bind_field_id];
|
|
32326
|
+
}
|
|
32327
|
+
if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && $elm.attr('value')) {
|
|
32328
|
+
if (value.includes($elm.attr('value'))) {
|
|
32329
|
+
value = true;
|
|
32330
|
+
} else {
|
|
32331
|
+
value = false;
|
|
32332
|
+
}
|
|
32333
|
+
} else if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && $elm.attr('value')) {
|
|
32334
|
+
if (value.includes($elm.attr('value'))) {
|
|
32335
|
+
value = $elm.attr('value');
|
|
32336
|
+
} else {
|
|
32337
|
+
value = false;
|
|
32338
|
+
}
|
|
32339
|
+
} else if (field_prop.props.fieldType === 'object' && val.value.split('.').length > 1) {
|
|
32340
|
+
let str = val.value.replace(bind_field_id, '(' + JSON.stringify(value) + ')');
|
|
32341
|
+
value = eval(str);
|
|
32342
|
+
}
|
|
32343
|
+
} else {
|
|
32344
|
+
value = val.value;
|
|
32345
|
+
}
|
|
32346
|
+
if (typeof value === 'undefined') return;
|
|
32347
|
+
bind.setter($elm[0], value);
|
|
32348
|
+
} catch (err) {
|
|
32349
|
+
console.error(err);
|
|
32350
|
+
}
|
|
32351
|
+
};
|
|
32352
|
+
/// init value from ds
|
|
32353
|
+
$('body').on('xu-bind-refresh.' + _ds.dsSession.toString(), () => {
|
|
32354
|
+
set_value();
|
|
32355
|
+
});
|
|
32422
32356
|
|
|
32423
|
-
|
|
32424
|
-
|
|
32425
|
-
|
|
32426
|
-
|
|
32427
|
-
|
|
32428
|
-
|
|
32429
|
-
|
|
32357
|
+
set_value();
|
|
32358
|
+
return {};
|
|
32359
|
+
},
|
|
32360
|
+
'xu-render': async function ($elm, val, from_panel) {
|
|
32361
|
+
const old_render = async function () {
|
|
32362
|
+
var value = await func.common.get_cast_val(SESSION_ID, 'common fx', 'xu-render', 'bool', val.value);
|
|
32363
|
+
const init_render = function () {
|
|
32364
|
+
if (!value) {
|
|
32365
|
+
var cloned_$div = $elm.clone(true);
|
|
32430
32366
|
|
|
32431
|
-
|
|
32432
|
-
|
|
32433
|
-
|
|
32434
|
-
|
|
32435
|
-
|
|
32436
|
-
|
|
32437
|
-
|
|
32438
|
-
|
|
32439
|
-
|
|
32440
|
-
|
|
32367
|
+
let $xurender = $('<xurender>').attr('xu-ui-id', $elm.attr('xu-ui-id')).attr('hidden', true).appendTo($container); //.hide();
|
|
32368
|
+
let original_data_obj = {
|
|
32369
|
+
$container: cloned_$div,
|
|
32370
|
+
nodeP: _.cloneDeep(nodeP),
|
|
32371
|
+
parent_infoP,
|
|
32372
|
+
paramsP,
|
|
32373
|
+
keyP,
|
|
32374
|
+
parent_nodeP,
|
|
32375
|
+
$root_container,
|
|
32376
|
+
};
|
|
32377
|
+
$xurender.data('xuData', cloned_$div.data().xuData);
|
|
32378
|
+
$xurender.data().xuData.original_data_obj = original_data_obj;
|
|
32379
|
+
$xurender.data().xuData.xurender_node = cloned_$div;
|
|
32380
|
+
$xurender.data().xuAttributes = nodeP.attributes || {};
|
|
32381
|
+
// $xurender.hide();
|
|
32441
32382
|
|
|
32442
|
-
|
|
32443
|
-
|
|
32444
|
-
|
|
32445
|
-
|
|
32446
|
-
|
|
32447
|
-
// return;
|
|
32448
|
-
// }
|
|
32449
|
-
// // if (!value) {
|
|
32450
|
-
// if ($elm.prop('tagName') === 'XURENDER') {
|
|
32451
|
-
// func.events.delete_job(SESSION_ID, jobNoP);
|
|
32452
|
-
// return;
|
|
32453
|
-
// }
|
|
32383
|
+
$elm.remove();
|
|
32384
|
+
return { abort: true };
|
|
32385
|
+
}
|
|
32386
|
+
return {};
|
|
32387
|
+
};
|
|
32454
32388
|
|
|
32455
|
-
|
|
32389
|
+
const post_render = async function () {
|
|
32390
|
+
if (value) {
|
|
32391
|
+
try {
|
|
32392
|
+
// abort if already rended
|
|
32393
|
+
if ($elm[0].tagName !== 'XURENDER' && $elm?.length) {
|
|
32394
|
+
return func.events.delete_job(SESSION_ID, jobNoP);
|
|
32395
|
+
}
|
|
32456
32396
|
|
|
32457
|
-
|
|
32458
|
-
// // was true before
|
|
32459
|
-
// if ($elm.data().xuData.xurender_node) {
|
|
32460
|
-
// $xurender.data({
|
|
32461
|
-
// xuAttributes: $elm.data().xuData.xurender_node.data().xuAttributes || {},
|
|
32462
|
-
// xuData: $elm.data().xuData.xurender_node.data().xuData || {},
|
|
32463
|
-
// });
|
|
32464
|
-
// } else {
|
|
32465
|
-
// // default new state
|
|
32397
|
+
let original_data_obj = $elm.data().xuData.original_data_obj;
|
|
32466
32398
|
|
|
32467
|
-
|
|
32468
|
-
|
|
32469
|
-
|
|
32470
|
-
|
|
32471
|
-
// const original_data_obj = {
|
|
32472
|
-
// nodeP: _.cloneDeep($elm.data().xuData.node_org),
|
|
32473
|
-
// paramsP: $elm.data().xuData.paramsP,
|
|
32474
|
-
// $container: $elm.clone(true),
|
|
32475
|
-
// parent_infoP: parent_infoP,
|
|
32476
|
-
// };
|
|
32477
|
-
|
|
32478
|
-
// $xurender.data().xuData.original_data_obj = original_data_obj;
|
|
32479
|
-
// }
|
|
32399
|
+
if (!original_data_obj) {
|
|
32400
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32401
|
+
return { delete_job: jobNoP };
|
|
32402
|
+
}
|
|
32480
32403
|
|
|
32481
|
-
|
|
32482
|
-
|
|
32483
|
-
|
|
32484
|
-
|
|
32485
|
-
|
|
32486
|
-
|
|
32487
|
-
|
|
32404
|
+
const new_$div = await func.UI.screen.render_ui_tree(
|
|
32405
|
+
SESSION_ID,
|
|
32406
|
+
$elm, //original_data_obj.$container,
|
|
32407
|
+
_.cloneDeep(original_data_obj.nodeP),
|
|
32408
|
+
original_data_obj.parent_infoP,
|
|
32409
|
+
original_data_obj.paramsP,
|
|
32410
|
+
jobNoP,
|
|
32411
|
+
null,
|
|
32412
|
+
original_data_obj.keyP,
|
|
32413
|
+
null,
|
|
32414
|
+
original_data_obj.parent_nodeP,
|
|
32415
|
+
null,
|
|
32416
|
+
original_data_obj.$root_container,
|
|
32417
|
+
);
|
|
32488
32418
|
|
|
32489
|
-
|
|
32490
|
-
|
|
32491
|
-
|
|
32492
|
-
// };
|
|
32493
|
-
// if (is_init) {
|
|
32494
|
-
// return init_render();
|
|
32495
|
-
// }
|
|
32496
|
-
// return await post_render();
|
|
32497
|
-
// };
|
|
32419
|
+
new_$div.data().xuData.original_data_obj = original_data_obj;
|
|
32420
|
+
new_$div.data().xuData.xurender_node = $elm.clone(true);
|
|
32421
|
+
new_$div.data().xuAttributes = $elm.data().xuAttributes || {};
|
|
32498
32422
|
|
|
32499
|
-
|
|
32500
|
-
|
|
32501
|
-
|
|
32502
|
-
|
|
32503
|
-
|
|
32504
|
-
|
|
32505
|
-
|
|
32506
|
-
// if (has_xu_exp_render_attribute) {
|
|
32507
|
-
// return { has_xu_exp_render_attribute, has_xu_render_attribute, xu_render_background_processing: true };
|
|
32508
|
-
// }
|
|
32509
|
-
// return { has_xu_render_attribute, abort: true };
|
|
32510
|
-
// }
|
|
32511
|
-
// return { has_xu_exp_render_attribute, has_xu_render_attribute };
|
|
32512
|
-
// };
|
|
32423
|
+
const replace = async function () {
|
|
32424
|
+
$elm.replaceWith(new_$div);
|
|
32425
|
+
if (from_panel) {
|
|
32426
|
+
const xuPanelWrapper = _.clone(new_$div.data().xuPanelWrapper);
|
|
32427
|
+
$elm.parent().data().xuPanelWrapper = xuPanelWrapper;
|
|
32428
|
+
$elm.replaceWith(new_$div.children());
|
|
32429
|
+
}
|
|
32513
32430
|
|
|
32514
|
-
|
|
32515
|
-
|
|
32516
|
-
|
|
32517
|
-
|
|
32518
|
-
|
|
32519
|
-
//
|
|
32520
|
-
|
|
32521
|
-
|
|
32522
|
-
|
|
32523
|
-
|
|
32524
|
-
// if (new_$div) {
|
|
32525
|
-
// // validate if $div contains fields from parent ds
|
|
32526
|
-
// const parent_data = get_parent_ds_fields(SESSION_ID, paramsP.dsSessionP);
|
|
32527
|
-
// const parent_fields = Object.keys(parent_data);
|
|
32528
|
-
|
|
32529
|
-
// $.each(new_$div.find('*'), (key, val) => {
|
|
32530
|
-
// const _xuAttributes = $(val)?.data()?.xuAttributes;
|
|
32531
|
-
// if (found_parent_vars || !_xuAttributes) return;
|
|
32532
|
-
// for (const [attr_key, attr_val] of Object.entries(_xuAttributes)) {
|
|
32533
|
-
// if (found_parent_vars) break;
|
|
32534
|
-
// for (const [key, val] of Object.entries(parent_fields)) {
|
|
32535
|
-
// if (attr_val.includes('@' + key)) {
|
|
32536
|
-
// found_parent_vars = true;
|
|
32537
|
-
// break;
|
|
32538
|
-
// }
|
|
32539
|
-
// }
|
|
32540
|
-
// }
|
|
32541
|
-
// });
|
|
32542
|
-
// }
|
|
32431
|
+
if (val.fields_arr) {
|
|
32432
|
+
return await func.UI.screen.refresh_xu_attributes(SESSION_ID, val.fields_arr, val.jobNoP, new_$div);
|
|
32433
|
+
}
|
|
32434
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32435
|
+
};
|
|
32436
|
+
// if ($elm && func.UI.utils.find_in_element_data('xuData', $(SESSION_OBJ[SESSION_ID].root_element), 'xu_id', $elm.data().xuData.xu_id).length) {
|
|
32437
|
+
if ($elm && $(`[xu-ui-id="${$elm.attr('xu-ui-id')}"]`).length) {
|
|
32438
|
+
if (new_$div.data().xuData.paramsP) {
|
|
32439
|
+
return await replace();
|
|
32440
|
+
}
|
|
32543
32441
|
|
|
32544
|
-
|
|
32545
|
-
|
|
32546
|
-
|
|
32547
|
-
|
|
32548
|
-
|
|
32549
|
-
|
|
32550
|
-
|
|
32551
|
-
//
|
|
32552
|
-
|
|
32553
|
-
|
|
32442
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32443
|
+
}
|
|
32444
|
+
} catch (error) {
|
|
32445
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32446
|
+
}
|
|
32447
|
+
return;
|
|
32448
|
+
}
|
|
32449
|
+
// if (!value) {
|
|
32450
|
+
if ($elm.prop('tagName') === 'XURENDER') {
|
|
32451
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32452
|
+
return;
|
|
32453
|
+
}
|
|
32554
32454
|
|
|
32555
|
-
|
|
32556
|
-
// new_$div.appendTo($container);
|
|
32557
|
-
// } else {
|
|
32558
|
-
// // iterate the container node
|
|
32559
|
-
// let $last_elm_found = [];
|
|
32560
|
-
// $.each($container.data().xuData.node.children, (item_key, item_val) => {
|
|
32561
|
-
// // const $elm = $(`[xu-node-id="${item_val.id}"]`);
|
|
32562
|
-
// const $elm = func.UI.utils.find_in_element_data('xuData', $(SESSION_OBJ[SESSION_ID].root_element), 'nodeid', item_val.id);
|
|
32563
|
-
// if ($elm.length) {
|
|
32564
|
-
// $last_elm_found = $elm;
|
|
32565
|
-
// }
|
|
32566
|
-
// if (keyP == item_key) {
|
|
32567
|
-
// if ($last_elm_found.length) {
|
|
32568
|
-
// new_$div.after($last_elm_found);
|
|
32569
|
-
// } else {
|
|
32570
|
-
// $container.prepend(new_$div);
|
|
32571
|
-
// }
|
|
32572
|
-
// }
|
|
32573
|
-
// });
|
|
32574
|
-
// }
|
|
32575
|
-
// } catch (error) {
|
|
32576
|
-
// func.events.delete_job(SESSION_ID, jobNoP);
|
|
32577
|
-
// }
|
|
32578
|
-
// return;
|
|
32579
|
-
// }
|
|
32455
|
+
let tmp_$div = $('<div>');
|
|
32580
32456
|
|
|
32581
|
-
|
|
32457
|
+
let $xurender = $('<xurender>').attr('xu-ui-id', $elm.attr('xu-ui-id')).appendTo(tmp_$div); //.hide();
|
|
32458
|
+
// was true before
|
|
32459
|
+
if ($elm.data().xuData.xurender_node) {
|
|
32460
|
+
$xurender.data({
|
|
32461
|
+
xuAttributes: $elm.data().xuData.xurender_node.data().xuAttributes || {},
|
|
32462
|
+
xuData: $elm.data().xuData.xurender_node.data().xuData || {},
|
|
32463
|
+
});
|
|
32464
|
+
} else {
|
|
32465
|
+
// default new state
|
|
32582
32466
|
|
|
32583
|
-
|
|
32467
|
+
$xurender.data({
|
|
32468
|
+
xuAttributes: $elm.data().xuAttributes || {},
|
|
32469
|
+
xuData: $elm.data().xuData || {},
|
|
32470
|
+
});
|
|
32471
|
+
const original_data_obj = {
|
|
32472
|
+
nodeP: _.cloneDeep($elm.data().xuData.node_org),
|
|
32473
|
+
paramsP: $elm.data().xuData.paramsP,
|
|
32474
|
+
$container: $elm.clone(true),
|
|
32475
|
+
parent_infoP: parent_infoP,
|
|
32476
|
+
};
|
|
32584
32477
|
|
|
32585
|
-
|
|
32586
|
-
|
|
32587
|
-
// UI_WORKER_OBJ.xu_render_cache[xu_ui_id + cache_str] = { $div: _$div, data: _$div.data(), paramsP };
|
|
32588
|
-
// $elm.remove();
|
|
32589
|
-
// func.events.delete_job(SESSION_ID, jobNoP);
|
|
32590
|
-
// };
|
|
32591
|
-
// if (is_init) {
|
|
32592
|
-
// return await init_render();
|
|
32593
|
-
// }
|
|
32594
|
-
// return await post_render();
|
|
32595
|
-
// };
|
|
32478
|
+
$xurender.data().xuData.original_data_obj = original_data_obj;
|
|
32479
|
+
}
|
|
32596
32480
|
|
|
32597
|
-
//
|
|
32598
|
-
|
|
32599
|
-
|
|
32600
|
-
|
|
32601
|
-
|
|
32602
|
-
|
|
32603
|
-
|
|
32604
|
-
// if (value) {
|
|
32605
|
-
// $elm.show();
|
|
32606
|
-
// }
|
|
32607
|
-
// if (!value) {
|
|
32608
|
-
// $elm.hide();
|
|
32609
|
-
// }
|
|
32610
|
-
// return {};
|
|
32611
|
-
// },
|
|
32612
|
-
// 'xu-content': async function ($elm, val) {
|
|
32613
|
-
// try {
|
|
32614
|
-
// $elm.html(val.value);
|
|
32615
|
-
// } catch (error) {
|
|
32616
|
-
// console.warn(e);
|
|
32617
|
-
// }
|
|
32618
|
-
// return;
|
|
32619
|
-
// },
|
|
32620
|
-
// 'xu-text': async function ($elm, val) {
|
|
32621
|
-
// try {
|
|
32622
|
-
// $elm.text(val.value);
|
|
32623
|
-
// } catch (error) {
|
|
32624
|
-
// console.warn(e);
|
|
32625
|
-
// }
|
|
32626
|
-
// return;
|
|
32627
|
-
// },
|
|
32628
|
-
// 'xu-html': async function ($elm, val) {
|
|
32629
|
-
// try {
|
|
32630
|
-
// $elm.html(val.value);
|
|
32631
|
-
// } catch (error) {
|
|
32632
|
-
// console.warn(e);
|
|
32633
|
-
// }
|
|
32634
|
-
// return;
|
|
32635
|
-
// },
|
|
32636
|
-
// 'xu-for': async function ($elm, data) {
|
|
32637
|
-
// // exit if call from rendered xu-for item to prevent infante loop (parent_infoP?.iterate_info indicate call from rendered item)
|
|
32638
|
-
// if (parent_infoP?.iterate_info) return {};
|
|
32639
|
-
// if (!data.value) return {};
|
|
32640
|
-
// try {
|
|
32641
|
-
// // data.value (xu-for) can store actual values such as an array, a CSV, or a field_id that references a specific field within the dataset, initialized with values for the iteration.
|
|
32642
|
-
// let arr = data.value;
|
|
32481
|
+
//remove xu-teleport trace
|
|
32482
|
+
$.each($elm.find('xu-teleport'), (key, val) => {
|
|
32483
|
+
const xuTeleportData = $(val).data().xuTeleportData || [];
|
|
32484
|
+
for (const teleported_elm_id of xuTeleportData) {
|
|
32485
|
+
$(`[xu-ui-id="${teleported_elm_id}"]`).remove();
|
|
32486
|
+
}
|
|
32487
|
+
});
|
|
32643
32488
|
|
|
32644
|
-
|
|
32645
|
-
|
|
32489
|
+
$elm.replaceWith(tmp_$div.children());
|
|
32490
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32491
|
+
// }
|
|
32492
|
+
};
|
|
32493
|
+
if (is_init) {
|
|
32494
|
+
return init_render();
|
|
32495
|
+
}
|
|
32496
|
+
return await post_render();
|
|
32497
|
+
};
|
|
32646
32498
|
|
|
32647
|
-
|
|
32499
|
+
const new_render = async function () {
|
|
32500
|
+
var value = await func.common.get_cast_val(SESSION_ID, 'common fx', 'xu-render', 'bool', val.value);
|
|
32501
|
+
const has_xu_render_attribute = true;
|
|
32502
|
+
const has_xu_exp_render_attribute = $elm.data()?.xuData?.attr_exp_info?.['xu-render'] ? true : false;
|
|
32503
|
+
const init_render = async function () {
|
|
32504
|
+
nodeP.xu_render_made = value;
|
|
32505
|
+
if (!value) {
|
|
32506
|
+
if (has_xu_exp_render_attribute) {
|
|
32507
|
+
return { has_xu_exp_render_attribute, has_xu_render_attribute, xu_render_background_processing: true };
|
|
32508
|
+
}
|
|
32509
|
+
return { has_xu_render_attribute, abort: true };
|
|
32510
|
+
}
|
|
32511
|
+
return { has_xu_exp_render_attribute, has_xu_render_attribute };
|
|
32512
|
+
};
|
|
32648
32513
|
|
|
32649
|
-
|
|
32650
|
-
//
|
|
32651
|
-
|
|
32652
|
-
|
|
32653
|
-
|
|
32654
|
-
|
|
32655
|
-
|
|
32656
|
-
|
|
32657
|
-
|
|
32658
|
-
|
|
32659
|
-
|
|
32660
|
-
//
|
|
32661
|
-
|
|
32662
|
-
|
|
32663
|
-
|
|
32514
|
+
const post_render = async function () {
|
|
32515
|
+
// always come from refresh
|
|
32516
|
+
let nodeP = $container.data().xuData.node.children[keyP];
|
|
32517
|
+
nodeP.xu_render_made = value;
|
|
32518
|
+
if (value) {
|
|
32519
|
+
try {
|
|
32520
|
+
const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($elm.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
|
|
32521
|
+
const xu_ui_id = $elm.attr('xu-ui-id');
|
|
32522
|
+
let new_$div = UI_WORKER_OBJ?.xu_render_cache?.[xu_ui_id + xu_render_cache_id]?.$div.clone(true);
|
|
32523
|
+
let found_parent_vars = false;
|
|
32524
|
+
if (new_$div) {
|
|
32525
|
+
// validate if $div contains fields from parent ds
|
|
32526
|
+
const parent_data = get_parent_ds_fields(SESSION_ID, paramsP.dsSessionP);
|
|
32527
|
+
const parent_fields = Object.keys(parent_data);
|
|
32528
|
+
|
|
32529
|
+
$.each(new_$div.find('*'), (key, val) => {
|
|
32530
|
+
const _xuAttributes = $(val)?.data()?.xuAttributes;
|
|
32531
|
+
if (found_parent_vars || !_xuAttributes) return;
|
|
32532
|
+
for (const [attr_key, attr_val] of Object.entries(_xuAttributes)) {
|
|
32533
|
+
if (found_parent_vars) break;
|
|
32534
|
+
for (const [key, val] of Object.entries(parent_fields)) {
|
|
32535
|
+
if (attr_val.includes('@' + key)) {
|
|
32536
|
+
found_parent_vars = true;
|
|
32537
|
+
break;
|
|
32538
|
+
}
|
|
32539
|
+
}
|
|
32540
|
+
}
|
|
32541
|
+
});
|
|
32542
|
+
}
|
|
32664
32543
|
|
|
32665
|
-
|
|
32666
|
-
|
|
32544
|
+
if (!new_$div || found_parent_vars) {
|
|
32545
|
+
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { paramsP };
|
|
32546
|
+
nodeP.xu_render_xu_ui_id = xu_ui_id;
|
|
32547
|
+
nodeP.xu_render_cache_id = xu_render_cache_id;
|
|
32548
|
+
new_$div = await func.UI.screen.render_ui_tree(SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, null, keyP, null, parent_nodeP, null, $root_container);
|
|
32549
|
+
const _$div = new_$div.clone(true);
|
|
32550
|
+
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id].$div = _$div;
|
|
32551
|
+
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id].data = _$div.data();
|
|
32552
|
+
}
|
|
32553
|
+
// append order handling
|
|
32667
32554
|
|
|
32668
|
-
|
|
32669
|
-
|
|
32670
|
-
|
|
32555
|
+
if (!$container.children().length) {
|
|
32556
|
+
new_$div.appendTo($container);
|
|
32557
|
+
} else {
|
|
32558
|
+
// iterate the container node
|
|
32559
|
+
let $last_elm_found = [];
|
|
32560
|
+
$.each($container.data().xuData.node.children, (item_key, item_val) => {
|
|
32561
|
+
// const $elm = $(`[xu-node-id="${item_val.id}"]`);
|
|
32562
|
+
const $elm = func.UI.utils.find_in_element_data('xuData', $(SESSION_OBJ[SESSION_ID].root_element), 'nodeid', item_val.id);
|
|
32563
|
+
if ($elm.length) {
|
|
32564
|
+
$last_elm_found = $elm;
|
|
32565
|
+
}
|
|
32566
|
+
if (keyP == item_key) {
|
|
32567
|
+
if ($last_elm_found.length) {
|
|
32568
|
+
new_$div.after($last_elm_found);
|
|
32569
|
+
} else {
|
|
32570
|
+
$container.prepend(new_$div);
|
|
32571
|
+
}
|
|
32572
|
+
}
|
|
32573
|
+
});
|
|
32574
|
+
}
|
|
32575
|
+
} catch (error) {
|
|
32576
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32577
|
+
}
|
|
32578
|
+
return;
|
|
32579
|
+
}
|
|
32671
32580
|
|
|
32672
|
-
|
|
32673
|
-
// if (!custom_iterator_key) {
|
|
32674
|
-
// is_key_dynamic_field = true;
|
|
32581
|
+
/////////// !value ///////////
|
|
32675
32582
|
|
|
32676
|
-
|
|
32677
|
-
// }
|
|
32583
|
+
const xu_ui_id = $elm.attr('xu-ui-id');
|
|
32678
32584
|
|
|
32679
|
-
|
|
32680
|
-
|
|
32585
|
+
const cache_str = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($elm.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
|
|
32586
|
+
const _$div = $elm.clone(true);
|
|
32587
|
+
UI_WORKER_OBJ.xu_render_cache[xu_ui_id + cache_str] = { $div: _$div, data: _$div.data(), paramsP };
|
|
32588
|
+
$elm.remove();
|
|
32589
|
+
func.events.delete_job(SESSION_ID, jobNoP);
|
|
32590
|
+
};
|
|
32591
|
+
if (is_init) {
|
|
32592
|
+
return await init_render();
|
|
32593
|
+
}
|
|
32594
|
+
return await post_render();
|
|
32595
|
+
};
|
|
32681
32596
|
|
|
32682
|
-
|
|
32683
|
-
|
|
32597
|
+
if (glb.new_xu_render) {
|
|
32598
|
+
return new_render();
|
|
32599
|
+
}
|
|
32600
|
+
return old_render();
|
|
32601
|
+
},
|
|
32602
|
+
'xu-show': async function ($elm, val) {
|
|
32603
|
+
var value = await func.common.get_cast_val(SESSION_ID, 'common fx', 'xu-show', 'bool', val.value);
|
|
32604
|
+
if (value) {
|
|
32605
|
+
$elm.show();
|
|
32606
|
+
}
|
|
32607
|
+
if (!value) {
|
|
32608
|
+
$elm.hide();
|
|
32609
|
+
}
|
|
32610
|
+
return {};
|
|
32611
|
+
},
|
|
32612
|
+
'xu-content': async function ($elm, val) {
|
|
32613
|
+
try {
|
|
32614
|
+
$elm.html(val.value);
|
|
32615
|
+
} catch (error) {
|
|
32616
|
+
console.warn(e);
|
|
32617
|
+
}
|
|
32618
|
+
return;
|
|
32619
|
+
},
|
|
32620
|
+
'xu-text': async function ($elm, val) {
|
|
32621
|
+
try {
|
|
32622
|
+
$elm.text(val.value);
|
|
32623
|
+
} catch (error) {
|
|
32624
|
+
console.warn(e);
|
|
32625
|
+
}
|
|
32626
|
+
return;
|
|
32627
|
+
},
|
|
32628
|
+
'xu-html': async function ($elm, val) {
|
|
32629
|
+
try {
|
|
32630
|
+
$elm.html(val.value);
|
|
32631
|
+
} catch (error) {
|
|
32632
|
+
console.warn(e);
|
|
32633
|
+
}
|
|
32634
|
+
return;
|
|
32635
|
+
},
|
|
32636
|
+
'xu-for': async function ($elm, data) {
|
|
32637
|
+
// exit if call from rendered xu-for item to prevent infante loop (parent_infoP?.iterate_info indicate call from rendered item)
|
|
32638
|
+
if (parent_infoP?.iterate_info) return {};
|
|
32639
|
+
if (!data.value) return {};
|
|
32640
|
+
try {
|
|
32641
|
+
// data.value (xu-for) can store actual values such as an array, a CSV, or a field_id that references a specific field within the dataset, initialized with values for the iteration.
|
|
32642
|
+
let arr = data.value;
|
|
32684
32643
|
|
|
32685
|
-
//
|
|
32686
|
-
|
|
32687
|
-
// if (_.isArray(arr)) {
|
|
32688
|
-
// _key = Number(_key);
|
|
32689
|
-
// }
|
|
32644
|
+
// find reference source field
|
|
32645
|
+
let reference_source_obj;
|
|
32690
32646
|
|
|
32691
|
-
|
|
32692
|
-
// if (is_dynamic_field) {
|
|
32693
|
-
// func.datasource.add_dynamic_field_to_ds(SESSION_ID, paramsP.dsSessionP, field_id, value);
|
|
32694
|
-
// } else {
|
|
32695
|
-
// const _progFields = await func.datasource.get_progFields(SESSION_ID, paramsP.dsSessionP);
|
|
32696
|
-
|
|
32697
|
-
// let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
32698
|
-
// if (view_field_obj) {
|
|
32699
|
-
// let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
32700
|
-
// try {
|
|
32701
|
-
// const row_idx = func.common.find_ROWID_idx(_ds, currentRecordId);
|
|
32702
|
-
// _ds.data_feed.rows[row_idx][field_id] = value;
|
|
32703
|
-
// } catch (err) {
|
|
32704
|
-
// console.error(err);
|
|
32705
|
-
// }
|
|
32706
|
-
// } else {
|
|
32707
|
-
// console.error('field not exist in dataset for xu-for method');
|
|
32708
|
-
// }
|
|
32709
|
-
// }
|
|
32710
|
-
// };
|
|
32647
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, paramsP.dsSessionP);
|
|
32711
32648
|
|
|
32712
|
-
|
|
32649
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', data.value);
|
|
32650
|
+
// detect if data.value (xu-for) is reference field_id by checking if exist in the dataset
|
|
32651
|
+
if (view_field_obj) {
|
|
32652
|
+
// xu-for is reference field_id
|
|
32653
|
+
reference_source_obj = await func.datasource.get_value(SESSION_ID, data.value, paramsP.dsSessionP);
|
|
32654
|
+
arr = reference_source_obj?.ret?.value;
|
|
32655
|
+
} else {
|
|
32656
|
+
// xu-for is actual data
|
|
32657
|
+
if (typeof data.value === 'string') {
|
|
32658
|
+
arr = eval(data.value.replaceAll('\\', ''));
|
|
32659
|
+
}
|
|
32660
|
+
if (typeof arr === 'number') {
|
|
32661
|
+
arr = Array.from(Array(arr).keys());
|
|
32662
|
+
}
|
|
32663
|
+
}
|
|
32713
32664
|
|
|
32714
|
-
|
|
32715
|
-
|
|
32665
|
+
const custom_iterator_key = $elm.data().xuData.iterator_key;
|
|
32666
|
+
const custom_iterator_val = $elm.data().xuData.iterator_val;
|
|
32716
32667
|
|
|
32717
|
-
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
// iterator_key,
|
|
32721
|
-
// iterator_val,
|
|
32722
|
-
// is_key_dynamic_field,
|
|
32723
|
-
// is_val_dynamic_field,
|
|
32724
|
-
// reference_source_obj,
|
|
32725
|
-
// };
|
|
32726
|
-
// // let _parent_info = _.cloneDeep(parent_infoP) || {};
|
|
32727
|
-
// let _parent_info = klona.klona(parent_infoP) || {};
|
|
32728
|
-
// _parent_info.iterate_info = iterate_info;
|
|
32668
|
+
let iterator_key = custom_iterator_key;
|
|
32669
|
+
let iterator_val = custom_iterator_val;
|
|
32670
|
+
let is_key_dynamic_field, is_val_dynamic_field;
|
|
32729
32671
|
|
|
32730
|
-
//
|
|
32731
|
-
|
|
32732
|
-
|
|
32733
|
-
// nodeP,
|
|
32734
|
-
// _parent_info, //parent_infoP ? _.cloneDeep(_parent_info) : null,
|
|
32735
|
-
// paramsP,
|
|
32736
|
-
// jobNoP,
|
|
32737
|
-
// null,
|
|
32738
|
-
// i,
|
|
32739
|
-
// null,
|
|
32740
|
-
// nodeP,
|
|
32741
|
-
// null,
|
|
32742
|
-
// $root_container,
|
|
32743
|
-
// );
|
|
32672
|
+
// custom FOR_VAL name or namespaced default name
|
|
32673
|
+
if (!custom_iterator_key) {
|
|
32674
|
+
is_key_dynamic_field = true;
|
|
32744
32675
|
|
|
32745
|
-
|
|
32746
|
-
|
|
32747
|
-
// $(val).data().xuData.iterate_info = iterate_info;
|
|
32748
|
-
// }
|
|
32749
|
-
// });
|
|
32676
|
+
iterator_key = '_FOR_KEY';
|
|
32677
|
+
}
|
|
32750
32678
|
|
|
32751
|
-
|
|
32752
|
-
|
|
32753
|
-
// $elm.remove();
|
|
32754
|
-
// return { abort: true };
|
|
32755
|
-
// } catch (e) {
|
|
32756
|
-
// console.error(' Iterator Arr parse error');
|
|
32757
|
-
// return { abort: true };
|
|
32758
|
-
// }
|
|
32759
|
-
// },
|
|
32760
|
-
// 'xu-for-key': async function ($elm, val) {
|
|
32761
|
-
// $elm.data().xuData.iterator_key = val.value;
|
|
32762
|
-
// return {};
|
|
32763
|
-
// },
|
|
32764
|
-
// 'xu-for-val': async function ($elm, val) {
|
|
32765
|
-
// $elm.data().xuData.iterator_val = val.value;
|
|
32766
|
-
// return {};
|
|
32767
|
-
// },
|
|
32768
|
-
// 'xu-class': async function ($elm, val) {
|
|
32769
|
-
// try {
|
|
32770
|
-
// const classes_string = val.value;
|
|
32771
|
-
// // let obj = _.isString(classes_string) ? JSON.parse(classes_string) : _.defaults(classes_string, {});
|
|
32679
|
+
if (!custom_iterator_val) {
|
|
32680
|
+
is_val_dynamic_field = true;
|
|
32772
32681
|
|
|
32773
|
-
|
|
32774
|
-
|
|
32775
|
-
// let res = await func.expression.get(
|
|
32776
|
-
// SESSION_ID,
|
|
32777
|
-
// cond,
|
|
32778
|
-
// paramsP.dsSessionP,
|
|
32779
|
-
// 'UI Attr EXP',
|
|
32780
|
-
// $elm.data().xuData.currentRecordId, // SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId
|
|
32781
|
-
// null,
|
|
32782
|
-
// null,
|
|
32783
|
-
// null,
|
|
32784
|
-
// null,
|
|
32785
|
-
// null,
|
|
32786
|
-
// $elm.data().xuData.iterate_info,
|
|
32787
|
-
// );
|
|
32682
|
+
iterator_val = '_FOR_VAL';
|
|
32683
|
+
}
|
|
32788
32684
|
|
|
32789
|
-
|
|
32790
|
-
|
|
32791
|
-
|
|
32792
|
-
|
|
32793
|
-
|
|
32685
|
+
var i = 0;
|
|
32686
|
+
for await (let [_key, _val] of Object.entries(arr)) {
|
|
32687
|
+
if (_.isArray(arr)) {
|
|
32688
|
+
_key = Number(_key);
|
|
32689
|
+
}
|
|
32794
32690
|
|
|
32795
|
-
|
|
32796
|
-
|
|
32797
|
-
|
|
32798
|
-
|
|
32799
|
-
|
|
32800
|
-
// return { abort: true };
|
|
32801
|
-
// }
|
|
32802
|
-
// },
|
|
32803
|
-
// 'xu-exp': async function ($elm, val) {
|
|
32804
|
-
// let exp = val.value === null ? true : val.value;
|
|
32691
|
+
const set_value = async function (is_dynamic_field, currentRecordId, field_id, value) {
|
|
32692
|
+
if (is_dynamic_field) {
|
|
32693
|
+
func.datasource.add_dynamic_field_to_ds(SESSION_ID, paramsP.dsSessionP, field_id, value);
|
|
32694
|
+
} else {
|
|
32695
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, paramsP.dsSessionP);
|
|
32805
32696
|
|
|
32806
|
-
|
|
32697
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
32698
|
+
if (view_field_obj) {
|
|
32699
|
+
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
32700
|
+
try {
|
|
32701
|
+
const row_idx = func.common.find_ROWID_idx(_ds, currentRecordId);
|
|
32702
|
+
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
32703
|
+
} catch (err) {
|
|
32704
|
+
console.error(err);
|
|
32705
|
+
}
|
|
32706
|
+
} else {
|
|
32707
|
+
console.error('field not exist in dataset for xu-for method');
|
|
32708
|
+
}
|
|
32709
|
+
}
|
|
32710
|
+
};
|
|
32807
32711
|
|
|
32808
|
-
|
|
32712
|
+
var currentRecordId = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId.toString();
|
|
32809
32713
|
|
|
32810
|
-
|
|
32811
|
-
|
|
32812
|
-
// value,
|
|
32813
|
-
// };
|
|
32714
|
+
await set_value(is_key_dynamic_field, currentRecordId, iterator_key, _key);
|
|
32715
|
+
await set_value(is_val_dynamic_field, currentRecordId, iterator_val, _val);
|
|
32814
32716
|
|
|
32815
|
-
|
|
32816
|
-
|
|
32817
|
-
|
|
32818
|
-
|
|
32819
|
-
|
|
32820
|
-
|
|
32821
|
-
|
|
32822
|
-
|
|
32717
|
+
var iterate_info = {
|
|
32718
|
+
_val,
|
|
32719
|
+
_key,
|
|
32720
|
+
iterator_key,
|
|
32721
|
+
iterator_val,
|
|
32722
|
+
is_key_dynamic_field,
|
|
32723
|
+
is_val_dynamic_field,
|
|
32724
|
+
reference_source_obj,
|
|
32725
|
+
};
|
|
32726
|
+
// let _parent_info = _.cloneDeep(parent_infoP) || {};
|
|
32727
|
+
let _parent_info = klona.klona(parent_infoP) || {};
|
|
32728
|
+
_parent_info.iterate_info = iterate_info;
|
|
32823
32729
|
|
|
32824
|
-
|
|
32730
|
+
const $divP = await func.UI.screen.render_ui_tree(
|
|
32731
|
+
SESSION_ID,
|
|
32732
|
+
$container,
|
|
32733
|
+
nodeP,
|
|
32734
|
+
_parent_info, //parent_infoP ? _.cloneDeep(_parent_info) : null,
|
|
32735
|
+
paramsP,
|
|
32736
|
+
jobNoP,
|
|
32737
|
+
null,
|
|
32738
|
+
i,
|
|
32739
|
+
null,
|
|
32740
|
+
nodeP,
|
|
32741
|
+
null,
|
|
32742
|
+
$root_container,
|
|
32743
|
+
);
|
|
32825
32744
|
|
|
32826
|
-
|
|
32827
|
-
|
|
32828
|
-
|
|
32829
|
-
|
|
32745
|
+
$.each($divP.children(), function (key, val) {
|
|
32746
|
+
if ($(val)?.data()?.xuData) {
|
|
32747
|
+
$(val).data().xuData.iterate_info = iterate_info;
|
|
32748
|
+
}
|
|
32749
|
+
});
|
|
32830
32750
|
|
|
32831
|
-
|
|
32832
|
-
|
|
32833
|
-
|
|
32834
|
-
|
|
32751
|
+
i++;
|
|
32752
|
+
}
|
|
32753
|
+
$elm.remove();
|
|
32754
|
+
return { abort: true };
|
|
32755
|
+
} catch (e) {
|
|
32756
|
+
console.error(' Iterator Arr parse error');
|
|
32757
|
+
return { abort: true };
|
|
32758
|
+
}
|
|
32759
|
+
},
|
|
32760
|
+
'xu-for-key': async function ($elm, val) {
|
|
32761
|
+
$elm.data().xuData.iterator_key = val.value;
|
|
32762
|
+
return {};
|
|
32763
|
+
},
|
|
32764
|
+
'xu-for-val': async function ($elm, val) {
|
|
32765
|
+
$elm.data().xuData.iterator_val = val.value;
|
|
32766
|
+
return {};
|
|
32767
|
+
},
|
|
32768
|
+
'xu-class': async function ($elm, val) {
|
|
32769
|
+
try {
|
|
32770
|
+
const classes_string = val.value;
|
|
32771
|
+
// let obj = _.isString(classes_string) ? JSON.parse(classes_string) : _.defaults(classes_string, {});
|
|
32835
32772
|
|
|
32836
|
-
|
|
32837
|
-
|
|
32838
|
-
|
|
32773
|
+
const classes_obj = _.isString(classes_string) ? JSON.parse(classes_string) : _.defaults(classes_string, {});
|
|
32774
|
+
for await (const [cla, cond] of Object.entries(classes_obj)) {
|
|
32775
|
+
let res = await func.expression.get(
|
|
32776
|
+
SESSION_ID,
|
|
32777
|
+
cond,
|
|
32778
|
+
paramsP.dsSessionP,
|
|
32779
|
+
'UI Attr EXP',
|
|
32780
|
+
$elm.data().xuData.currentRecordId, // SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId
|
|
32781
|
+
null,
|
|
32782
|
+
null,
|
|
32783
|
+
null,
|
|
32784
|
+
null,
|
|
32785
|
+
null,
|
|
32786
|
+
$elm.data().xuData.iterate_info,
|
|
32787
|
+
);
|
|
32839
32788
|
|
|
32840
|
-
|
|
32841
|
-
|
|
32842
|
-
|
|
32843
|
-
|
|
32844
|
-
|
|
32845
|
-
// const trigger = val.key.split('xu-on:')[1].toLowerCase();
|
|
32846
|
-
// $elm.on(trigger, async function (evt) {
|
|
32847
|
-
// const _$elm = $(evt.currentTarget);
|
|
32848
|
-
// if (_.isEmpty(_$elm.data().xuAttributes)) return;
|
|
32849
|
-
|
|
32850
|
-
// for await (const [key, val] of Object.entries(_$elm.data().xuAttributes['xu-on:' + evt.type])) {
|
|
32851
|
-
// if (!_.isEmpty(val.props.condition)) {
|
|
32852
|
-
// const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
|
|
32853
|
-
// if (!expCond.result) continue;
|
|
32854
|
-
// }
|
|
32789
|
+
if (res.result) {
|
|
32790
|
+
$elm.addClass(cla);
|
|
32791
|
+
} else {
|
|
32792
|
+
$elm.removeClass(cla);
|
|
32793
|
+
}
|
|
32855
32794
|
|
|
32856
|
-
|
|
32857
|
-
|
|
32858
|
-
|
|
32795
|
+
$elm.data().xuData.debug_info.attribute_stat['xu-class'] = $elm.attr('class');
|
|
32796
|
+
}
|
|
32797
|
+
return {};
|
|
32798
|
+
} catch (e) {
|
|
32799
|
+
console.warn('parse error:' + val.value);
|
|
32800
|
+
return { abort: true };
|
|
32801
|
+
}
|
|
32802
|
+
},
|
|
32803
|
+
'xu-exp': async function ($elm, val) {
|
|
32804
|
+
let exp = val.value === null ? true : val.value;
|
|
32859
32805
|
|
|
32860
|
-
|
|
32861
|
-
// if (val.workflow) {
|
|
32862
|
-
// // do BL
|
|
32863
|
-
// for await (const [key2, val2] of Object.entries(val.workflow)) {
|
|
32864
|
-
// // var cond = val2.data.enabled;
|
|
32865
|
-
// // if (val2.data.enabled && val2.props.condition) {
|
|
32866
|
-
// // expCond = await func.expression.get(SESSION_ID, val2.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
|
|
32867
|
-
// // cond = expCond.result;
|
|
32868
|
-
// // }
|
|
32869
|
-
// // if (!cond) continue;
|
|
32806
|
+
let exp_ret = await func.expression.get(SESSION_ID, exp, paramsP.dsSessionP, 'UI Attr EXP', SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP].currentRecordId, null, null, null, null, null, $elm.data().xuData.iterate_info);
|
|
32870
32807
|
|
|
32871
|
-
|
|
32808
|
+
let value = func.UI.screen.fix_val_defaults(val.key, exp_ret.result);
|
|
32872
32809
|
|
|
32873
|
-
|
|
32874
|
-
|
|
32875
|
-
|
|
32876
|
-
|
|
32877
|
-
// });
|
|
32878
|
-
// return {};
|
|
32879
|
-
// },
|
|
32880
|
-
// 'xu-script': async function ($elm, val) {
|
|
32881
|
-
// var checkExist = setInterval(async function () {
|
|
32882
|
-
// if ($elm.is(':visible')) {
|
|
32883
|
-
// try {
|
|
32884
|
-
// // var res = eval('(' + val.value + ')');
|
|
32885
|
-
// // const fn = `(function(el) {
|
|
32886
|
-
// // ${val.value}
|
|
32887
|
-
// // })(document.querySelector(\`[xu-ui-id="${$elm.attr('xu-ui-id')}"]\`));`;
|
|
32888
|
-
|
|
32889
|
-
// const fn = `async (el)=>{${val.value} };`;
|
|
32890
|
-
|
|
32891
|
-
// var res = eval(fn);
|
|
32892
|
-
// await res($elm[0]);
|
|
32893
|
-
// // if (typeof res === 'function') {
|
|
32894
|
-
// // res($elm[0]);
|
|
32895
|
-
// // }
|
|
32896
|
-
// } catch (e) {
|
|
32897
|
-
// eval(val.value);
|
|
32898
|
-
// }
|
|
32810
|
+
var new_val = {
|
|
32811
|
+
key: val.key,
|
|
32812
|
+
value,
|
|
32813
|
+
};
|
|
32899
32814
|
|
|
32900
|
-
|
|
32901
|
-
|
|
32902
|
-
|
|
32815
|
+
if (nodeP.tagName.substr(0, 3) === 'xu-') {
|
|
32816
|
+
if (tag_fx[nodeP.tagName][new_val.key]) {
|
|
32817
|
+
return await tag_fx[nodeP.tagName][new_val.key]($elm, new_val);
|
|
32818
|
+
}
|
|
32819
|
+
console.warn(`attribute ${new_val.key} not found for ${nodeP.tagName}`);
|
|
32820
|
+
return {};
|
|
32821
|
+
}
|
|
32822
|
+
if (!$elm.data().xuData) return;
|
|
32903
32823
|
|
|
32904
|
-
|
|
32905
|
-
// },
|
|
32906
|
-
// 'xu-style-global': async function ($elm, val) {
|
|
32907
|
-
// $('head').append(`<style>${val.value}</style>`);
|
|
32908
|
-
// return {};
|
|
32909
|
-
// },
|
|
32910
|
-
// 'xu-style': async function ($elm, val) {
|
|
32911
|
-
// var cssString = val.value;
|
|
32824
|
+
$elm.data().xuData.debug_info.attribute_stat[new_val.key] = new_val.value;
|
|
32912
32825
|
|
|
32913
|
-
//
|
|
32826
|
+
// IGNORE UNDEFINED or NULL ATTRIBUTES
|
|
32827
|
+
if (typeof new_val.value === 'undefined' || new_val.value === null) {
|
|
32828
|
+
return {};
|
|
32829
|
+
}
|
|
32914
32830
|
|
|
32915
|
-
//
|
|
32916
|
-
|
|
32831
|
+
// IGNORE ATTRIBUTES WITH EMPTY VALUES
|
|
32832
|
+
if (glb.solid_attributes.includes(new_val.key) && !new_val.value) {
|
|
32833
|
+
return {};
|
|
32834
|
+
}
|
|
32917
32835
|
|
|
32918
|
-
|
|
32919
|
-
|
|
32836
|
+
if (new_val.key.substr(0, 2) === 'xu') {
|
|
32837
|
+
return await common_fx[new_val.key]($elm, new_val);
|
|
32838
|
+
}
|
|
32920
32839
|
|
|
32921
|
-
|
|
32922
|
-
|
|
32923
|
-
|
|
32924
|
-
|
|
32840
|
+
$elm.attr(new_val.key, ($elm.attr(new_val.key) || '') + new_val.value);
|
|
32841
|
+
return {};
|
|
32842
|
+
},
|
|
32843
|
+
'xu-on': async function ($elm, val) {
|
|
32844
|
+
CLIENT_ACTIVITY_TS = Date.now();
|
|
32845
|
+
const trigger = val.key.split('xu-on:')[1].toLowerCase();
|
|
32846
|
+
$elm.on(trigger, async function (evt) {
|
|
32847
|
+
const _$elm = $(evt.currentTarget);
|
|
32848
|
+
if (_.isEmpty(_$elm.data().xuAttributes)) return;
|
|
32925
32849
|
|
|
32926
|
-
|
|
32927
|
-
|
|
32928
|
-
|
|
32850
|
+
for await (const [key, val] of Object.entries(_$elm.data().xuAttributes['xu-on:' + evt.type])) {
|
|
32851
|
+
if (!_.isEmpty(val.props.condition)) {
|
|
32852
|
+
const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
|
|
32853
|
+
if (!expCond.result) continue;
|
|
32854
|
+
}
|
|
32929
32855
|
|
|
32930
|
-
|
|
32856
|
+
if (val.event_modifiers && evt[val.event_modifiers]) {
|
|
32857
|
+
evt[val.event_modifiers]();
|
|
32858
|
+
}
|
|
32931
32859
|
|
|
32932
|
-
//
|
|
32933
|
-
|
|
32934
|
-
//
|
|
32935
|
-
|
|
32936
|
-
//
|
|
32937
|
-
//
|
|
32938
|
-
//
|
|
32860
|
+
// if (val.handler === 'custom') {
|
|
32861
|
+
if (val.workflow) {
|
|
32862
|
+
// do BL
|
|
32863
|
+
for await (const [key2, val2] of Object.entries(val.workflow)) {
|
|
32864
|
+
// var cond = val2.data.enabled;
|
|
32865
|
+
// if (val2.data.enabled && val2.props.condition) {
|
|
32866
|
+
// expCond = await func.expression.get(SESSION_ID, val2.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
|
|
32867
|
+
// cond = expCond.result;
|
|
32868
|
+
// }
|
|
32869
|
+
// if (!cond) continue;
|
|
32939
32870
|
|
|
32940
|
-
//
|
|
32941
|
-
// },
|
|
32942
|
-
// 'xu-ui-plugin': async function ($elm, val) {
|
|
32943
|
-
// var _session = SESSION_OBJ[SESSION_ID];
|
|
32871
|
+
if (!val2.data.enabled) continue; // added Jul 3, 25 - condition validate on execution
|
|
32944
32872
|
|
|
32945
|
-
|
|
32946
|
-
|
|
32947
|
-
|
|
32948
|
-
|
|
32949
|
-
|
|
32950
|
-
|
|
32951
|
-
|
|
32873
|
+
func.events.add_to_queue(SESSION_ID, 'element event', val2.id, evt.type, val2.data.action, val2.data.name, null, _$elm.attr('xu-ui-id'), null, evt, null, null, null, paramsP.dsSessionP, null, null, null, evt.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
|
|
32874
|
+
}
|
|
32875
|
+
}
|
|
32876
|
+
}
|
|
32877
|
+
});
|
|
32878
|
+
return {};
|
|
32879
|
+
},
|
|
32880
|
+
'xu-script': async function ($elm, val) {
|
|
32881
|
+
var checkExist = setInterval(async function () {
|
|
32882
|
+
if ($elm.is(':visible')) {
|
|
32883
|
+
try {
|
|
32884
|
+
// var res = eval('(' + val.value + ')');
|
|
32885
|
+
// const fn = `(function(el) {
|
|
32886
|
+
// ${val.value}
|
|
32887
|
+
// })(document.querySelector(\`[xu-ui-id="${$elm.attr('xu-ui-id')}"]\`));`;
|
|
32952
32888
|
|
|
32953
|
-
|
|
32889
|
+
const fn = `async (el)=>{${val.value} };`;
|
|
32954
32890
|
|
|
32955
|
-
|
|
32891
|
+
var res = eval(fn);
|
|
32892
|
+
await res($elm[0]);
|
|
32893
|
+
// if (typeof res === 'function') {
|
|
32894
|
+
// res($elm[0]);
|
|
32895
|
+
// }
|
|
32896
|
+
} catch (e) {
|
|
32897
|
+
eval(val.value);
|
|
32898
|
+
}
|
|
32956
32899
|
|
|
32957
|
-
|
|
32958
|
-
|
|
32959
|
-
//
|
|
32960
|
-
|
|
32961
|
-
|
|
32962
|
-
|
|
32963
|
-
|
|
32964
|
-
|
|
32965
|
-
|
|
32966
|
-
|
|
32900
|
+
clearInterval(checkExist);
|
|
32901
|
+
}
|
|
32902
|
+
}, 100); // check every 100ms
|
|
32903
|
+
|
|
32904
|
+
return {};
|
|
32905
|
+
},
|
|
32906
|
+
'xu-style-global': async function ($elm, val) {
|
|
32907
|
+
$('head').append(`<style>${val.value}</style>`);
|
|
32908
|
+
return {};
|
|
32909
|
+
},
|
|
32910
|
+
'xu-style': async function ($elm, val) {
|
|
32911
|
+
var cssString = val.value;
|
|
32912
|
+
|
|
32913
|
+
var parser = new cssjs();
|
|
32914
|
+
|
|
32915
|
+
var parsed = parser.parseCSS(cssString);
|
|
32916
|
+
var xuUiId = `[xu-ui-id="${$elm.attr('xu-ui-id')}"]`;
|
|
32917
|
+
|
|
32918
|
+
$.each(parsed, function (key, val) {
|
|
32919
|
+
var selectors_arr = val.selector.split(',');
|
|
32920
|
+
|
|
32921
|
+
$.each(selectors_arr, function (key2, val2) {
|
|
32922
|
+
selectors_arr[key2] = `${xuUiId} ${val2}, ${xuUiId}${val2}`;
|
|
32923
|
+
// console.log(new_selector);
|
|
32924
|
+
});
|
|
32925
|
+
|
|
32926
|
+
val.selector = selectors_arr.join(',');
|
|
32927
|
+
// console.log(parsed);
|
|
32928
|
+
});
|
|
32929
|
+
|
|
32930
|
+
var newCSSString = parser.getCSSForEditor(parsed);
|
|
32931
|
+
|
|
32932
|
+
$('head').append(`<style>${newCSSString}</style>`);
|
|
32933
|
+
return {};
|
|
32934
|
+
},
|
|
32935
|
+
'xu-cdn': async function ($elm, val) {
|
|
32936
|
+
for await (const [key, resource] of Object.entries(val.value)) {
|
|
32937
|
+
await load_cdn(resource);
|
|
32938
|
+
}
|
|
32939
|
+
|
|
32940
|
+
return {};
|
|
32941
|
+
},
|
|
32942
|
+
'xu-ui-plugin': async function ($elm, val) {
|
|
32943
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
32944
|
+
|
|
32945
|
+
for await (const [plugin_name, value] of Object.entries(val.value)) {
|
|
32946
|
+
const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
|
|
32947
|
+
if (_plugin?.installed && _plugin?.manifest?.['runtime.mjs']?.exist && _plugin?.manifest?.['index.mjs']?.exist && value.enabled) {
|
|
32948
|
+
if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
|
|
32949
|
+
const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
|
|
32950
|
+
func.utils.load_css_on_demand(plugin_runtime_css_url);
|
|
32951
|
+
}
|
|
32952
|
+
|
|
32953
|
+
const plugin_index_src = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
|
|
32954
|
+
|
|
32955
|
+
const plugin_index_resources = await import(plugin_index_src);
|
|
32956
|
+
|
|
32957
|
+
let properties = _.cloneDeep(plugin_index_resources.properties);
|
|
32958
|
+
for await (let [prop_name, prop_val] of Object.entries(properties)) {
|
|
32959
|
+
prop_val.value = value?.attributes?.[prop_name];
|
|
32960
|
+
if (value?.attributes?.[`xu-exp:${prop_name}`]) {
|
|
32961
|
+
const res = await func.expression.get(SESSION_ID, value?.attributes?.[`xu-exp:${prop_name}`], paramsP.dsSessionP, 'UI Attr EXP');
|
|
32962
|
+
prop_val.value = res.result;
|
|
32963
|
+
}
|
|
32964
|
+
}
|
|
32965
|
+
// $elm.data().xu_ui_plugin = { properties };
|
|
32966
|
+
const plugin_runtime_src = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
|
|
32967
32967
|
|
|
32968
|
-
|
|
32968
|
+
const plugin_runtime_resources = await import(plugin_runtime_src);
|
|
32969
32969
|
|
|
32970
|
-
|
|
32971
|
-
|
|
32972
|
-
|
|
32973
|
-
|
|
32974
|
-
|
|
32970
|
+
if (plugin_runtime_resources.cdn && typeof _.isArray(plugin_runtime_resources.cdn)) {
|
|
32971
|
+
for await (const resource of plugin_runtime_resources.cdn) {
|
|
32972
|
+
await load_cdn(resource);
|
|
32973
|
+
}
|
|
32974
|
+
}
|
|
32975
32975
|
|
|
32976
|
-
|
|
32977
|
-
|
|
32978
|
-
//
|
|
32979
|
-
|
|
32980
|
-
|
|
32981
|
-
|
|
32976
|
+
if (plugin_runtime_resources.fn) {
|
|
32977
|
+
await plugin_runtime_resources.fn(plugin_name, $elm?.[0], properties);
|
|
32978
|
+
// await plugin_runtime_resources.fn(plugin_name, $elm?.[0], $elm.data().xu_ui_plugin.properties);
|
|
32979
|
+
}
|
|
32980
|
+
}
|
|
32981
|
+
}
|
|
32982
32982
|
|
|
32983
|
-
|
|
32984
|
-
|
|
32985
|
-
|
|
32986
|
-
|
|
32987
|
-
|
|
32988
|
-
|
|
32989
|
-
|
|
32990
|
-
|
|
32991
|
-
|
|
32992
|
-
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
|
|
32997
|
-
//
|
|
32998
|
-
|
|
32999
|
-
|
|
33000
|
-
|
|
32983
|
+
return {};
|
|
32984
|
+
},
|
|
32985
|
+
'xu-store': async function ($elm, val) {
|
|
32986
|
+
try {
|
|
32987
|
+
const fields_obj = JSON5.parse(val.value);
|
|
32988
|
+
for (const [field_id, value] of Object.entries(fields_obj)) {
|
|
32989
|
+
func.datasource.add_dynamic_field_to_ds(SESSION_ID, paramsP.dsSessionP, field_id, value);
|
|
32990
|
+
}
|
|
32991
|
+
} catch (err) {
|
|
32992
|
+
console.error(err);
|
|
32993
|
+
}
|
|
32994
|
+
return {};
|
|
32995
|
+
},
|
|
32996
|
+
'xu-viewport': async function ($elm, val) {
|
|
32997
|
+
// functionality in draw_html_element
|
|
32998
|
+
return {};
|
|
32999
|
+
},
|
|
33000
|
+
};
|
|
33001
33001
|
|
|
33002
|
-
|
|
33003
|
-
|
|
33004
|
-
|
|
33005
|
-
|
|
33002
|
+
if (nodeP.tagName.substr(0, 3) === 'xu-') {
|
|
33003
|
+
if (xu_func === 'xu-exp') {
|
|
33004
|
+
return common_fx[xu_func]($elm, val);
|
|
33005
|
+
}
|
|
33006
33006
|
|
|
33007
|
-
|
|
33008
|
-
|
|
33009
|
-
|
|
33010
|
-
|
|
33011
|
-
//
|
|
33012
|
-
|
|
33013
|
-
|
|
33014
|
-
|
|
33015
|
-
|
|
33016
|
-
|
|
33017
|
-
|
|
33018
|
-
|
|
33019
|
-
|
|
33020
|
-
|
|
33021
|
-
|
|
33022
|
-
|
|
33023
|
-
|
|
33024
|
-
|
|
33025
|
-
|
|
33026
|
-
|
|
33027
|
-
|
|
33028
|
-
|
|
33007
|
+
if (tag_fx?.[nodeP.tagName]?.[xu_func]) {
|
|
33008
|
+
let ret = await tag_fx[nodeP.tagName][xu_func]($elm, val);
|
|
33009
|
+
return ret;
|
|
33010
|
+
}
|
|
33011
|
+
// if (xu_func !== "tree_id")
|
|
33012
|
+
console.warn(`attribute ${xu_func} not found for ${nodeP.tagName}`);
|
|
33013
|
+
return {};
|
|
33014
|
+
}
|
|
33015
|
+
if (_.isEmpty($elm.data())) {
|
|
33016
|
+
return {};
|
|
33017
|
+
}
|
|
33018
|
+
if (!$elm.data().xuData.debug_info.attribute_stat) {
|
|
33019
|
+
$elm.data().xuData.debug_info.attribute_stat = {};
|
|
33020
|
+
}
|
|
33021
|
+
if (xu_func !== 'xu-exp') {
|
|
33022
|
+
$elm.data().xuData.debug_info.attribute_stat[xu_func] = val.value;
|
|
33023
|
+
}
|
|
33024
|
+
try {
|
|
33025
|
+
if (!common_fx[xu_func]) {
|
|
33026
|
+
console.warn('invalid xu-tag', xu_func, error);
|
|
33027
|
+
return {};
|
|
33028
|
+
}
|
|
33029
33029
|
|
|
33030
|
-
|
|
33031
|
-
|
|
33032
|
-
|
|
33033
|
-
|
|
33034
|
-
|
|
33030
|
+
return await common_fx[xu_func]($elm, val);
|
|
33031
|
+
} catch (error) {
|
|
33032
|
+
debugger;
|
|
33033
|
+
}
|
|
33034
|
+
};
|
|
33035
33035
|
|
|
33036
|
-
func.UI.screen.
|
|
33036
|
+
func.UI.screen.execute_xu_functions_bad = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, xu_func, $elm, val, is_init, refreshed_ds) {
|
|
33037
33037
|
if (is_skeleton) return;
|
|
33038
33038
|
|
|
33039
33039
|
// Cache frequently accessed values
|
|
@@ -33890,335 +33890,335 @@ func.UI.screen.fix_val_defaults = function (key, val) {
|
|
|
33890
33890
|
return ret;
|
|
33891
33891
|
};
|
|
33892
33892
|
|
|
33893
|
-
|
|
33894
|
-
|
|
33893
|
+
func.UI.screen.set_attributes_new = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $elm, is_init, execute_attributes = [], refreshed_ds) {
|
|
33894
|
+
var done_exp = [];
|
|
33895
33895
|
|
|
33896
|
-
|
|
33897
|
-
|
|
33896
|
+
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|
|
33897
|
+
if (!_ds) return { abort: true };
|
|
33898
33898
|
|
|
33899
|
-
|
|
33900
|
-
|
|
33901
|
-
|
|
33902
|
-
|
|
33903
|
-
|
|
33904
|
-
|
|
33905
|
-
|
|
33899
|
+
const get_attr_value = async function (key) {
|
|
33900
|
+
let ret = func.UI.screen.fix_val_defaults(key, nodeP.attributes[key]);
|
|
33901
|
+
if (nodeP?.attributes?.hasOwnProperty(`xu-exp:${key}`)) {
|
|
33902
|
+
ret = await get_xuExp(key);
|
|
33903
|
+
}
|
|
33904
|
+
return ret;
|
|
33905
|
+
};
|
|
33906
33906
|
|
|
33907
|
-
|
|
33908
|
-
|
|
33909
|
-
|
|
33910
|
-
|
|
33911
|
-
|
|
33912
|
-
|
|
33913
|
-
|
|
33914
|
-
|
|
33915
|
-
|
|
33907
|
+
const get_xuExp = async function (attrib) {
|
|
33908
|
+
if (is_skeleton) return;
|
|
33909
|
+
if (glb.new_xu_render) {
|
|
33910
|
+
let _xuData = $elm.data().xuData;
|
|
33911
|
+
if (!_xuData.attr_exp_info) {
|
|
33912
|
+
_xuData.attr_exp_info = {};
|
|
33913
|
+
}
|
|
33914
|
+
}
|
|
33915
|
+
const attr = `xu-exp:${attrib}`;
|
|
33916
33916
|
|
|
33917
|
-
|
|
33918
|
-
//
|
|
33919
|
-
|
|
33920
|
-
//
|
|
33917
|
+
if (!nodeP?.attributes?.hasOwnProperty(attr)) return;
|
|
33918
|
+
// const attr = `xu-exp-${attrib}`;
|
|
33919
|
+
var exp = nodeP.attributes[attr];
|
|
33920
|
+
// if (!value) return func.UI.screen.fix_val_defaults(attrib, exp || nodeP.attributes[attrib]);
|
|
33921
33921
|
|
|
33922
|
-
|
|
33923
|
-
|
|
33924
|
-
|
|
33925
|
-
|
|
33926
|
-
//
|
|
33927
|
-
|
|
33928
|
-
|
|
33929
|
-
|
|
33922
|
+
var res = await func.expression.get(SESSION_ID, exp, paramsP.dsSessionP, 'UI Attr EXP', _ds.currentRecordId);
|
|
33923
|
+
if (glb.new_xu_render) {
|
|
33924
|
+
_xuData.attr_exp_info[attrib] = res;
|
|
33925
|
+
}
|
|
33926
|
+
// nodeP.attributes[attr] = value; //{ value: value, res: res };
|
|
33927
|
+
done_exp.push(attr);
|
|
33928
|
+
return res.result; //func.UI.screen.fix_val_defaults(attrib, res.result);
|
|
33929
|
+
};
|
|
33930
33930
|
|
|
33931
|
-
|
|
33932
|
-
|
|
33931
|
+
var _ret = {};
|
|
33932
|
+
if (nodeP.type !== 'element' || !nodeP.attributes) return _ret;
|
|
33933
33933
|
|
|
33934
|
-
|
|
33935
|
-
//
|
|
33936
|
-
|
|
33937
|
-
|
|
33938
|
-
|
|
33939
|
-
|
|
33940
|
-
|
|
33941
|
-
|
|
33942
|
-
|
|
33943
|
-
|
|
33944
|
-
|
|
33945
|
-
|
|
33946
|
-
//
|
|
33947
|
-
|
|
33948
|
-
|
|
33949
|
-
|
|
33950
|
-
|
|
33951
|
-
|
|
33952
|
-
|
|
33953
|
-
|
|
33954
|
-
|
|
33955
|
-
|
|
33956
|
-
|
|
33957
|
-
|
|
33958
|
-
|
|
33959
|
-
|
|
33960
|
-
|
|
33961
|
-
|
|
33962
|
-
|
|
33963
|
-
|
|
33964
|
-
|
|
33965
|
-
|
|
33966
|
-
|
|
33967
|
-
|
|
33934
|
+
for (let [key, val] of Object.entries(nodeP.attributes)) {
|
|
33935
|
+
// REMOVE STATIC ATTRIBUTES IF EXP EXISTS to avoid dup
|
|
33936
|
+
if (key.substring(0, 6) === 'xu-exp') {
|
|
33937
|
+
if (_.isEmpty(val)) {
|
|
33938
|
+
delete nodeP.attributes[key];
|
|
33939
|
+
continue;
|
|
33940
|
+
}
|
|
33941
|
+
const clean_key = key.split(':')[1];
|
|
33942
|
+
if (typeof nodeP.attributes[clean_key] !== 'undefined') {
|
|
33943
|
+
delete nodeP.attributes[clean_key];
|
|
33944
|
+
}
|
|
33945
|
+
}
|
|
33946
|
+
// FIX abbreviations
|
|
33947
|
+
if (glb.attr_abbreviations_arr.includes(key)) {
|
|
33948
|
+
nodeP.attributes[`xu-on:${key.substring(3)}`] = [
|
|
33949
|
+
{
|
|
33950
|
+
handler: 'custom',
|
|
33951
|
+
props: {},
|
|
33952
|
+
event: [
|
|
33953
|
+
{
|
|
33954
|
+
id: Date.now(),
|
|
33955
|
+
data: {
|
|
33956
|
+
action: 'update',
|
|
33957
|
+
name: { value: val },
|
|
33958
|
+
enabled: true,
|
|
33959
|
+
},
|
|
33960
|
+
props: {},
|
|
33961
|
+
},
|
|
33962
|
+
],
|
|
33963
|
+
},
|
|
33964
|
+
];
|
|
33965
|
+
delete nodeP.attributes[key];
|
|
33966
|
+
}
|
|
33967
|
+
}
|
|
33968
33968
|
|
|
33969
|
-
|
|
33970
|
-
//
|
|
33971
|
-
|
|
33969
|
+
for (let [key, val] of Object.entries(nodeP.attributes)) {
|
|
33970
|
+
// FIX STATIC DEFAULTS
|
|
33971
|
+
val = func.UI.screen.fix_val_defaults(key, val);
|
|
33972
33972
|
|
|
33973
|
-
//
|
|
33974
|
-
|
|
33975
|
-
|
|
33976
|
-
|
|
33973
|
+
// REMOVE UNDEFINED or NULL ATTRIBUTES
|
|
33974
|
+
if (typeof val === 'undefined' || val === null) {
|
|
33975
|
+
delete nodeP.attributes[key];
|
|
33976
|
+
}
|
|
33977
33977
|
|
|
33978
|
-
//
|
|
33979
|
-
|
|
33980
|
-
|
|
33981
|
-
|
|
33982
|
-
|
|
33978
|
+
// REMOVE ATTRIBUTES WITH EMPTY VALUES
|
|
33979
|
+
if (glb.solid_attributes.includes(key) && !val) {
|
|
33980
|
+
delete nodeP.attributes[key];
|
|
33981
|
+
}
|
|
33982
|
+
}
|
|
33983
33983
|
|
|
33984
|
-
//
|
|
33985
|
-
|
|
33986
|
-
|
|
33987
|
-
|
|
33988
|
-
|
|
33989
|
-
|
|
33990
|
-
|
|
33991
|
-
|
|
33992
|
-
|
|
33993
|
-
|
|
33994
|
-
|
|
33995
|
-
|
|
33996
|
-
|
|
33997
|
-
|
|
33998
|
-
|
|
33999
|
-
|
|
34000
|
-
|
|
34001
|
-
|
|
34002
|
-
|
|
34003
|
-
|
|
34004
|
-
|
|
34005
|
-
|
|
34006
|
-
|
|
33984
|
+
// XU-ATTRS
|
|
33985
|
+
if (nodeP?.attributes?.['xu-attrs'] || nodeP?.attributes?.['xu-exp:xu-attrs']) {
|
|
33986
|
+
const attr = 'xu-attrs';
|
|
33987
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
33988
|
+
SESSION_ID,
|
|
33989
|
+
is_skeleton,
|
|
33990
|
+
$root_container,
|
|
33991
|
+
nodeP,
|
|
33992
|
+
$container,
|
|
33993
|
+
paramsP,
|
|
33994
|
+
parent_infoP,
|
|
33995
|
+
jobNoP,
|
|
33996
|
+
keyP,
|
|
33997
|
+
parent_nodeP,
|
|
33998
|
+
attr,
|
|
33999
|
+
$elm,
|
|
34000
|
+
{
|
|
34001
|
+
key: attr,
|
|
34002
|
+
value: await get_attr_value(attr),
|
|
34003
|
+
},
|
|
34004
|
+
is_init,
|
|
34005
|
+
);
|
|
34006
|
+
}
|
|
34007
34007
|
|
|
34008
|
-
//
|
|
34009
|
-
|
|
34010
|
-
|
|
34011
|
-
|
|
34012
|
-
|
|
34013
|
-
|
|
34014
|
-
|
|
34008
|
+
// BEFORE
|
|
34009
|
+
if (!_.isEmpty(nodeP.attributes)) {
|
|
34010
|
+
for await (const [key, attr] of Object.entries(glb.run_xu_before)) {
|
|
34011
|
+
if (_ret.abort || $container?.data()?.xuData?.pending_to_delete) break;
|
|
34012
|
+
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) {
|
|
34013
|
+
continue;
|
|
34014
|
+
}
|
|
34015
34015
|
|
|
34016
|
-
|
|
34017
|
-
|
|
34018
|
-
|
|
34016
|
+
if (!nodeP?.attributes?.hasOwnProperty(attr) && !nodeP?.attributes?.hasOwnProperty(`xu-exp:${attr}`)) {
|
|
34017
|
+
continue;
|
|
34018
|
+
}
|
|
34019
34019
|
|
|
34020
|
-
|
|
34021
|
-
|
|
34022
|
-
|
|
34020
|
+
if (!nodeP.attributes[`xu-exp:${attr}`] && nodeP?.attributes?.hasOwnProperty(attr) && typeof func.UI.screen.fix_val_defaults(attr, nodeP.attributes[attr]) === 'undefined') {
|
|
34021
|
+
continue;
|
|
34022
|
+
}
|
|
34023
34023
|
|
|
34024
|
-
|
|
34025
|
-
|
|
34026
|
-
|
|
34027
|
-
|
|
34028
|
-
|
|
34029
|
-
|
|
34030
|
-
|
|
34031
|
-
|
|
34032
|
-
|
|
34033
|
-
|
|
34034
|
-
|
|
34035
|
-
|
|
34036
|
-
|
|
34037
|
-
|
|
34038
|
-
|
|
34024
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
34025
|
+
SESSION_ID,
|
|
34026
|
+
is_skeleton,
|
|
34027
|
+
$root_container,
|
|
34028
|
+
nodeP,
|
|
34029
|
+
$container,
|
|
34030
|
+
paramsP,
|
|
34031
|
+
parent_infoP,
|
|
34032
|
+
jobNoP,
|
|
34033
|
+
keyP,
|
|
34034
|
+
parent_nodeP,
|
|
34035
|
+
attr,
|
|
34036
|
+
$elm,
|
|
34037
|
+
{
|
|
34038
|
+
key: attr,
|
|
34039
34039
|
|
|
34040
|
-
|
|
34041
|
-
|
|
34042
|
-
|
|
34043
|
-
|
|
34044
|
-
|
|
34045
|
-
|
|
34046
|
-
|
|
34040
|
+
value: await get_attr_value(attr),
|
|
34041
|
+
},
|
|
34042
|
+
is_init,
|
|
34043
|
+
);
|
|
34044
|
+
_ret = _.assignIn(_ret, ret);
|
|
34045
|
+
}
|
|
34046
|
+
}
|
|
34047
34047
|
|
|
34048
|
-
//
|
|
34048
|
+
// ALL
|
|
34049
34049
|
|
|
34050
|
-
|
|
34051
|
-
|
|
34052
|
-
|
|
34053
|
-
|
|
34054
|
-
|
|
34050
|
+
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
34051
|
+
if (_ret.abort || $container?.data()?.xuData?.pending_to_delete) break;
|
|
34052
|
+
if (glb.html5_events_handler.includes(key) || execute_attributes.includes(key)) {
|
|
34053
|
+
continue;
|
|
34054
|
+
}
|
|
34055
34055
|
|
|
34056
|
-
|
|
34057
|
-
|
|
34058
|
-
|
|
34059
|
-
|
|
34060
|
-
|
|
34061
|
-
|
|
34062
|
-
//
|
|
34063
|
-
|
|
34064
|
-
|
|
34065
|
-
|
|
34066
|
-
|
|
34067
|
-
|
|
34056
|
+
const new_key = key.split(':')[0]; // break expression
|
|
34057
|
+
if (
|
|
34058
|
+
nodeP.tagName !== 'xu-panel' &&
|
|
34059
|
+
nodeP.tagName !== 'xu-teleport' && // nodeP.tagName.substr(0, 3) !== "xu-" &&
|
|
34060
|
+
(new_key.substr(0, 2) !== 'xu' || new_key.substr(2, 1) !== '-')
|
|
34061
|
+
) {
|
|
34062
|
+
// handle common html attributes
|
|
34063
|
+
try {
|
|
34064
|
+
$elm.get(0).setAttribute(key, val);
|
|
34065
|
+
} catch (err) {
|
|
34066
|
+
console.error(err.message);
|
|
34067
|
+
}
|
|
34068
34068
|
|
|
34069
|
-
|
|
34070
|
-
|
|
34071
|
-
//
|
|
34072
|
-
|
|
34073
|
-
|
|
34074
|
-
//
|
|
34075
|
-
|
|
34076
|
-
|
|
34077
|
-
|
|
34078
|
-
|
|
34079
|
-
|
|
34080
|
-
|
|
34069
|
+
continue;
|
|
34070
|
+
}
|
|
34071
|
+
// handle xu attributes
|
|
34072
|
+
try {
|
|
34073
|
+
if ($elm?.data()?.xuAttributes) {
|
|
34074
|
+
// in some cases xu data delete in purpose when refreshing the screen
|
|
34075
|
+
$elm.data().xuAttributes[key] = val;
|
|
34076
|
+
}
|
|
34077
|
+
} catch (error) {
|
|
34078
|
+
debugger;
|
|
34079
|
+
console.error(error);
|
|
34080
|
+
}
|
|
34081
34081
|
|
|
34082
|
-
|
|
34083
|
-
|
|
34084
|
-
|
|
34082
|
+
if (new_key === 'xu-exp' || nodeP.attributes['xu-exp:' + new_key] || glb.run_xu_before.includes(new_key) || glb.run_xu_after.includes(new_key)) {
|
|
34083
|
+
continue;
|
|
34084
|
+
}
|
|
34085
34085
|
|
|
34086
|
-
|
|
34087
|
-
|
|
34088
|
-
|
|
34089
|
-
|
|
34090
|
-
|
|
34091
|
-
|
|
34092
|
-
|
|
34093
|
-
|
|
34094
|
-
|
|
34095
|
-
|
|
34096
|
-
|
|
34097
|
-
|
|
34098
|
-
|
|
34099
|
-
|
|
34100
|
-
|
|
34101
|
-
|
|
34102
|
-
//
|
|
34103
|
-
|
|
34104
|
-
|
|
34105
|
-
|
|
34106
|
-
|
|
34107
|
-
|
|
34108
|
-
|
|
34109
|
-
|
|
34110
|
-
|
|
34086
|
+
if (new_key === 'xu-on') {
|
|
34087
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
34088
|
+
SESSION_ID,
|
|
34089
|
+
is_skeleton,
|
|
34090
|
+
$root_container,
|
|
34091
|
+
nodeP,
|
|
34092
|
+
$container,
|
|
34093
|
+
paramsP,
|
|
34094
|
+
parent_infoP,
|
|
34095
|
+
jobNoP,
|
|
34096
|
+
keyP,
|
|
34097
|
+
parent_nodeP,
|
|
34098
|
+
'xu-on',
|
|
34099
|
+
$elm,
|
|
34100
|
+
{
|
|
34101
|
+
key: key,
|
|
34102
|
+
// value: (await get_xuExp(new_key)) || func.UI.screen.fix_val_defaults(key, val),
|
|
34103
|
+
value: await get_attr_value(key),
|
|
34104
|
+
},
|
|
34105
|
+
is_init,
|
|
34106
|
+
refreshed_ds,
|
|
34107
|
+
);
|
|
34108
|
+
_ret = _.assignIn(_ret, ret);
|
|
34109
|
+
continue;
|
|
34110
|
+
}
|
|
34111
34111
|
|
|
34112
|
-
|
|
34113
|
-
|
|
34114
|
-
|
|
34115
|
-
|
|
34116
|
-
|
|
34117
|
-
|
|
34118
|
-
|
|
34119
|
-
|
|
34120
|
-
|
|
34121
|
-
|
|
34122
|
-
|
|
34123
|
-
|
|
34124
|
-
|
|
34125
|
-
|
|
34126
|
-
|
|
34127
|
-
//
|
|
34128
|
-
|
|
34129
|
-
|
|
34130
|
-
|
|
34131
|
-
|
|
34132
|
-
|
|
34112
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
34113
|
+
SESSION_ID,
|
|
34114
|
+
is_skeleton,
|
|
34115
|
+
$root_container,
|
|
34116
|
+
nodeP,
|
|
34117
|
+
$container,
|
|
34118
|
+
paramsP,
|
|
34119
|
+
parent_infoP,
|
|
34120
|
+
jobNoP,
|
|
34121
|
+
keyP,
|
|
34122
|
+
parent_nodeP,
|
|
34123
|
+
new_key,
|
|
34124
|
+
$elm,
|
|
34125
|
+
{
|
|
34126
|
+
key: key,
|
|
34127
|
+
// value: (await get_xuExp(new_key)) || func.UI.screen.fix_val_defaults(key, val),
|
|
34128
|
+
value: await get_attr_value(key),
|
|
34129
|
+
},
|
|
34130
|
+
is_init,
|
|
34131
|
+
refreshed_ds,
|
|
34132
|
+
);
|
|
34133
34133
|
|
|
34134
|
-
|
|
34135
|
-
|
|
34134
|
+
_ret = _.assignIn(_ret, ret);
|
|
34135
|
+
}
|
|
34136
34136
|
|
|
34137
|
-
//
|
|
34137
|
+
// EXP for
|
|
34138
34138
|
|
|
34139
|
-
|
|
34140
|
-
|
|
34139
|
+
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
34140
|
+
if (_ret.abort || $container?.data()?.xuData?.pending_to_delete) break;
|
|
34141
34141
|
|
|
34142
|
-
|
|
34142
|
+
const attr = key.split('xu-exp:')[1];
|
|
34143
34143
|
|
|
34144
|
-
|
|
34145
|
-
|
|
34146
|
-
|
|
34144
|
+
if (!attr) {
|
|
34145
|
+
continue;
|
|
34146
|
+
}
|
|
34147
34147
|
|
|
34148
|
-
|
|
34148
|
+
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
|
|
34149
34149
|
|
|
34150
|
-
|
|
34151
|
-
|
|
34152
|
-
|
|
34153
|
-
|
|
34154
|
-
|
|
34155
|
-
|
|
34156
|
-
|
|
34157
|
-
|
|
34158
|
-
|
|
34159
|
-
|
|
34160
|
-
|
|
34161
|
-
|
|
34162
|
-
|
|
34163
|
-
|
|
34164
|
-
|
|
34165
|
-
|
|
34166
|
-
|
|
34167
|
-
|
|
34168
|
-
|
|
34169
|
-
|
|
34170
|
-
|
|
34171
|
-
|
|
34172
|
-
|
|
34173
|
-
|
|
34174
|
-
|
|
34150
|
+
if (done_exp.includes(key)) {
|
|
34151
|
+
continue;
|
|
34152
|
+
}
|
|
34153
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
34154
|
+
SESSION_ID,
|
|
34155
|
+
is_skeleton,
|
|
34156
|
+
$root_container,
|
|
34157
|
+
nodeP,
|
|
34158
|
+
$container,
|
|
34159
|
+
paramsP,
|
|
34160
|
+
parent_infoP,
|
|
34161
|
+
jobNoP,
|
|
34162
|
+
keyP,
|
|
34163
|
+
parent_nodeP,
|
|
34164
|
+
'xu-exp',
|
|
34165
|
+
$elm,
|
|
34166
|
+
{
|
|
34167
|
+
key: attr,
|
|
34168
|
+
value: val,
|
|
34169
|
+
},
|
|
34170
|
+
true,
|
|
34171
|
+
refreshed_ds,
|
|
34172
|
+
);
|
|
34173
|
+
_ret = _.assignIn(_ret, ret);
|
|
34174
|
+
}
|
|
34175
34175
|
|
|
34176
|
-
//
|
|
34176
|
+
// AFTER
|
|
34177
34177
|
|
|
34178
|
-
|
|
34179
|
-
|
|
34178
|
+
for await (const [key, attr] of Object.entries(glb.run_xu_after)) {
|
|
34179
|
+
if ($container?.data()?.xuData?.pending_to_delete) break;
|
|
34180
34180
|
|
|
34181
|
-
|
|
34181
|
+
if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
|
|
34182
34182
|
|
|
34183
|
-
|
|
34183
|
+
if (!nodeP.attributes || !nodeP.attributes[attr] & !nodeP.attributes[`xu-exp:${attr}`]) continue;
|
|
34184
34184
|
|
|
34185
|
-
|
|
34186
|
-
|
|
34187
|
-
|
|
34188
|
-
|
|
34189
|
-
|
|
34190
|
-
|
|
34191
|
-
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
-
//
|
|
34201
|
-
|
|
34202
|
-
|
|
34203
|
-
|
|
34204
|
-
|
|
34205
|
-
|
|
34206
|
-
|
|
34207
|
-
|
|
34185
|
+
let ret = await func.UI.screen.execute_xu_functions(
|
|
34186
|
+
SESSION_ID,
|
|
34187
|
+
is_skeleton,
|
|
34188
|
+
$root_container,
|
|
34189
|
+
nodeP,
|
|
34190
|
+
$container,
|
|
34191
|
+
paramsP,
|
|
34192
|
+
parent_infoP,
|
|
34193
|
+
jobNoP,
|
|
34194
|
+
keyP,
|
|
34195
|
+
parent_nodeP,
|
|
34196
|
+
attr,
|
|
34197
|
+
$elm,
|
|
34198
|
+
{
|
|
34199
|
+
key: attr,
|
|
34200
|
+
// value: (await get_xuExp(attr)) || func.UI.screen.fix_val_defaults(attr, nodeP.attributes[attr]),
|
|
34201
|
+
value: await get_attr_value(attr),
|
|
34202
|
+
},
|
|
34203
|
+
is_init,
|
|
34204
|
+
refreshed_ds,
|
|
34205
|
+
);
|
|
34206
|
+
_ret = _.assignIn(_ret, ret);
|
|
34207
|
+
}
|
|
34208
34208
|
|
|
34209
|
-
//
|
|
34209
|
+
// REGISTER EVENTS ATTRIBUTES
|
|
34210
34210
|
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
//
|
|
34215
|
-
|
|
34216
|
-
|
|
34211
|
+
for await (const [key, val] of Object.entries(nodeP.attributes)) {
|
|
34212
|
+
if ($container?.data()?.xuData?.pending_to_delete) break;
|
|
34213
|
+
if (!glb.html5_events_handler.includes(key)) break;
|
|
34214
|
+
// $elm.attr(key, await get_xuExp(key)) || val;
|
|
34215
|
+
$elm.attr(key, await get_xuExp(key)) || val;
|
|
34216
|
+
}
|
|
34217
34217
|
|
|
34218
|
-
|
|
34219
|
-
|
|
34218
|
+
return _ret;
|
|
34219
|
+
};
|
|
34220
34220
|
|
|
34221
|
-
func.UI.screen.
|
|
34221
|
+
func.UI.screen.set_attributes_new_bad = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $elm, is_init, execute_attributes = [], refreshed_ds) {
|
|
34222
34222
|
const done_exp = new Set(); // Use Set for O(1) lookups instead of array
|
|
34223
34223
|
|
|
34224
34224
|
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
|