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