@xuda.io/runtime-bundle 1.0.1257 → 1.0.1259

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.
@@ -31998,6 +31998,7 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
31998
31998
  return ret;
31999
31999
  },
32000
32000
  'xu-ref': async function ($elm, val) {
32001
+ if (!val.value) return {};
32001
32002
  let ret = await common_fx['xu-ref']($container, val, $container.data().xuData.xuPanelData.xuData.paramsP.dsSessionP);
32002
32003
  return ret;
32003
32004
  },
@@ -33793,6 +33794,7 @@ func.UI.screen.execute_xu_functions_bad = async function (SESSION_ID, is_skeleto
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
  },
@@ -34527,150 +34529,150 @@ const generate_xu_ui_id = async function (SESSION_ID, nodeP, $container, paramsP
34527
34529
  return await func.common.fastHash(ui_id);
34528
34530
  };
34529
34531
 
34530
- // func.UI.screen.create_container = async function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str, is_placeholder) {
34531
- // // const _paramsP = _.cloneDeep(paramsP);
34532
- // const _paramsP = klona.klona(paramsP);
34533
- // var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
34534
- // var $appendTo = $container;
34535
- // if ($appendToP) $appendTo = $appendToP;
34536
- // if (!$appendTo || !$appendTo.length) return null; // screen closed or not exist abort build
34537
- // var div = 'div';
34538
- // if (div_typeP) div = div_typeP;
34539
- // var items = [];
34540
- // if (nodeP.children)
34541
- // items = nodeP.children.map(function (val) {
34542
- // return val.xu_tree_id || val.id;
34543
- // });
34544
- // var currentRecordId = $container?.data?.()?.xuData?.recordid || (_ds ? _ds.currentRecordId : '');
34545
- // // var xu_id = (glb.screen_num++).toString();
34546
- // // xu_id = xu_id += '_' + currentRecordId;
34532
+ func.UI.screen.create_container = async function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str, is_placeholder) {
34533
+ // const _paramsP = _.cloneDeep(paramsP);
34534
+ const _paramsP = klona.klona(paramsP);
34535
+ var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
34536
+ var $appendTo = $container;
34537
+ if ($appendToP) $appendTo = $appendToP;
34538
+ if (!$appendTo || !$appendTo.length) return null; // screen closed or not exist abort build
34539
+ var div = 'div';
34540
+ if (div_typeP) div = div_typeP;
34541
+ var items = [];
34542
+ if (nodeP.children)
34543
+ items = nodeP.children.map(function (val) {
34544
+ return val.xu_tree_id || val.id;
34545
+ });
34546
+ var currentRecordId = $container?.data?.()?.xuData?.recordid || (_ds ? _ds.currentRecordId : '');
34547
+ // var xu_id = (glb.screen_num++).toString();
34548
+ // xu_id = xu_id += '_' + currentRecordId;
34547
34549
 
34548
- // try {
34549
- // const key_path = `${$container?.data()?.xuData?.key_path || '0'}-${keyP || '0'}`;
34550
- // const elem_key = `${nodeP.xu_tree_id || nodeP.id}-${key_path}-${currentRecordId}`;
34551
- // // let ui_id = `${nodeP.id}-${elem_key}-${_paramsP?.dsSessionP?.toString() || ''}`; //nodeP.xu_tree_id ||
34552
-
34553
- // /////////////////////////////////
34554
-
34555
- // var $div;
34556
-
34557
- // if (div === 'svg') {
34558
- // const draw_svg = function (element) {
34559
- // const get_tag_str = function (element, prop, val) {
34560
- // let class_str = '';
34561
- // let attr_str = '';
34562
- // for (const [key, val] of Object.entries(prop)) {
34563
- // if (key.substr(0, 2) !== 'xu') {
34564
- // attr_str += ` ${key}="${val}" `;
34565
- // }
34566
- // }
34567
- // if (element === 'svg') {
34568
- // return `<${element} ${attr_str} > `;
34569
- // }
34570
- // let ret = '';
34571
- // if (val?.children?.length) {
34572
- // ret = iterate_svg(val);
34573
- // }
34550
+ try {
34551
+ const key_path = `${$container?.data()?.xuData?.key_path || '0'}-${keyP || '0'}`;
34552
+ const elem_key = `${nodeP.xu_tree_id || nodeP.id}-${key_path}-${currentRecordId}`;
34553
+ // let ui_id = `${nodeP.id}-${elem_key}-${_paramsP?.dsSessionP?.toString() || ''}`; //nodeP.xu_tree_id ||
34574
34554
 
34575
- // return `<${element} ${class_str} ${attr_str} > ${ret} </${element}>`;
34576
- // };
34577
- // let svg_str = get_tag_str(element, prop);
34578
- // let inner_str = '';
34579
- // const iterate_svg = function (node) {
34580
- // let ret = '';
34581
- // if (node.children) {
34582
- // for (let val of node.children) {
34583
- // let prop = val.attributes;
34584
- // ret += get_tag_str(val.tagName, prop, val);
34585
- // }
34586
- // }
34587
- // return ret;
34588
- // };
34589
- // inner_str = iterate_svg(nodeP);
34555
+ /////////////////////////////////
34590
34556
 
34591
- // $div = $(svg_str + inner_str + '</svg>').appendTo($appendTo);
34592
- // };
34557
+ var $div;
34593
34558
 
34594
- // draw_svg(div_typeP);
34595
- // } else {
34596
- // $div = $(`<${div} ${attr_str ? attr_str : ''}>`);
34597
- // }
34559
+ if (div === 'svg') {
34560
+ const draw_svg = function (element) {
34561
+ const get_tag_str = function (element, prop, val) {
34562
+ let class_str = '';
34563
+ let attr_str = '';
34564
+ for (const [key, val] of Object.entries(prop)) {
34565
+ if (key.substr(0, 2) !== 'xu') {
34566
+ attr_str += ` ${key}="${val}" `;
34567
+ }
34568
+ }
34569
+ if (element === 'svg') {
34570
+ return `<${element} ${attr_str} > `;
34571
+ }
34572
+ let ret = '';
34573
+ if (val?.children?.length) {
34574
+ ret = iterate_svg(val);
34575
+ }
34598
34576
 
34599
- // // // Returns a 32-bit unsigned integer hash of a string (FNV-1a)
34600
- // // function hash32(str) {
34601
- // // let h = 0x811c9dc5; // FNV offset basis
34602
- // // for (let i = 0; i < str.length; i++) {
34603
- // // h ^= str.charCodeAt(i);
34604
- // // // multiply by FNV prime (2^24 + 2^8 + 0x93) with 32-bit overflow
34605
- // // h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24);
34606
- // // }
34607
- // // // Convert to unsigned 32-bit
34608
- // // return h >>> 0;
34609
- // // }
34577
+ return `<${element} ${class_str} ${attr_str} > ${ret} </${element}>`;
34578
+ };
34579
+ let svg_str = get_tag_str(element, prop);
34580
+ let inner_str = '';
34581
+ const iterate_svg = function (node) {
34582
+ let ret = '';
34583
+ if (node.children) {
34584
+ for (let val of node.children) {
34585
+ let prop = val.attributes;
34586
+ ret += get_tag_str(val.tagName, prop, val);
34587
+ }
34588
+ }
34589
+ return ret;
34590
+ };
34591
+ inner_str = iterate_svg(nodeP);
34610
34592
 
34611
- // // function hash32hex(str) {
34612
- // // return (hash32(str) >>> 0).toString(16).padStart(8, '0');
34613
- // // }
34593
+ $div = $(svg_str + inner_str + '</svg>').appendTo($appendTo);
34594
+ };
34614
34595
 
34615
- // // const new_ui_id = hash32hex(ui_id);
34616
- // // const new_ui_id = await func.common.sha256(ui_id);
34617
- // const new_ui_id = await generate_xu_ui_id(SESSION_ID, nodeP, $container, paramsP, keyP);
34618
-
34619
- // $div
34620
- // .attr('xu-ui-id', new_ui_id)
34621
- // // .attr('xu-node-id', nodeP.id)
34622
- // .data({
34623
- // xuData: {
34624
- // prog_id: _paramsP.prog_id,
34625
- // nodeid: nodeP.id,
34626
- // ui_type: nodeP.tagName,
34627
- // // xu_id,
34628
- // recordid: currentRecordId,
34629
- // paramsP: _paramsP,
34630
- // key: keyP,
34631
- // key_path, //:($container?.data()?.xuData?.key || "0") + "-" + (keyP || "0"),
34632
- // screenId: _paramsP.screenId,
34633
- // parent_container: $container?.attr('id'),
34634
- // elem_key,
34635
- // properties: prop,
34636
- // node: nodeP,
34637
- // node_org: _.cloneDeep(nodeP),
34638
- // is_panelP: _paramsP.is_panelP,
34639
- // ui_id: new_ui_id,
34640
- // elem_prop: elem_propP,
34641
- // debug_info: {
34642
- // id: nodeP.id,
34643
- // parent_id: $container?.data()?.xuData?.ui_id,
34644
- // items: items,
34645
- // },
34646
- // parent_node: parent_nodeP,
34647
- // currentRecordId: currentRecordId,
34648
- // $root_container: $root_container,
34649
- // parent_element_ui_id: $container?.data()?.xuData?.ui_id,
34650
- // },
34651
- // xuAttributes: {},
34652
- // });
34653
- // if (is_placeholder) {
34654
- // $div.addClass('display_none');
34655
- // }
34596
+ draw_svg(div_typeP);
34597
+ } else {
34598
+ $div = $(`<${div} ${attr_str ? attr_str : ''}>`);
34599
+ }
34656
34600
 
34657
- // if (div_typeP !== 'svg') {
34658
- // $div.appendTo($appendTo);
34659
- // }
34660
- // } catch (e) {
34661
- // console.error(e);
34662
- // }
34601
+ // // Returns a 32-bit unsigned integer hash of a string (FNV-1a)
34602
+ // function hash32(str) {
34603
+ // let h = 0x811c9dc5; // FNV offset basis
34604
+ // for (let i = 0; i < str.length; i++) {
34605
+ // h ^= str.charCodeAt(i);
34606
+ // // multiply by FNV prime (2^24 + 2^8 + 0x93) with 32-bit overflow
34607
+ // h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24);
34608
+ // }
34609
+ // // Convert to unsigned 32-bit
34610
+ // return h >>> 0;
34611
+ // }
34663
34612
 
34664
- // if (parent_infoP?.iterate_info) {
34665
- // $div.data().xuData.iterate_info = parent_infoP.iterate_info;
34666
- // }
34613
+ // function hash32hex(str) {
34614
+ // return (hash32(str) >>> 0).toString(16).padStart(8, '0');
34615
+ // }
34667
34616
 
34668
- // if (classP) $div.addClass(classP);
34617
+ // const new_ui_id = hash32hex(ui_id);
34618
+ // const new_ui_id = await func.common.sha256(ui_id);
34619
+ const new_ui_id = await generate_xu_ui_id(SESSION_ID, nodeP, $container, paramsP, keyP);
34669
34620
 
34670
- // return $div;
34671
- // };
34621
+ $div
34622
+ .attr('xu-ui-id', new_ui_id)
34623
+ // .attr('xu-node-id', nodeP.id)
34624
+ .data({
34625
+ xuData: {
34626
+ prog_id: _paramsP.prog_id,
34627
+ nodeid: nodeP.id,
34628
+ ui_type: nodeP.tagName,
34629
+ // xu_id,
34630
+ recordid: currentRecordId,
34631
+ paramsP: _paramsP,
34632
+ key: keyP,
34633
+ key_path, //:($container?.data()?.xuData?.key || "0") + "-" + (keyP || "0"),
34634
+ screenId: _paramsP.screenId,
34635
+ parent_container: $container?.attr('id'),
34636
+ elem_key,
34637
+ properties: prop,
34638
+ node: nodeP,
34639
+ node_org: _.cloneDeep(nodeP),
34640
+ is_panelP: _paramsP.is_panelP,
34641
+ ui_id: new_ui_id,
34642
+ elem_prop: elem_propP,
34643
+ debug_info: {
34644
+ id: nodeP.id,
34645
+ parent_id: $container?.data()?.xuData?.ui_id,
34646
+ items: items,
34647
+ },
34648
+ parent_node: parent_nodeP,
34649
+ currentRecordId: currentRecordId,
34650
+ $root_container: $root_container,
34651
+ parent_element_ui_id: $container?.data()?.xuData?.ui_id,
34652
+ },
34653
+ xuAttributes: {},
34654
+ });
34655
+ if (is_placeholder) {
34656
+ $div.addClass('display_none');
34657
+ }
34672
34658
 
34673
- func.UI.screen.create_container = async function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str, is_placeholder) {
34659
+ if (div_typeP !== 'svg') {
34660
+ $div.appendTo($appendTo);
34661
+ }
34662
+ } catch (e) {
34663
+ console.error(e);
34664
+ }
34665
+
34666
+ if (parent_infoP?.iterate_info) {
34667
+ $div.data().xuData.iterate_info = parent_infoP.iterate_info;
34668
+ }
34669
+
34670
+ if (classP) $div.addClass(classP);
34671
+
34672
+ return $div;
34673
+ };
34674
+
34675
+ func.UI.screen.create_container_bad = async function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str, is_placeholder) {
34674
34676
  const _paramsP = klona.klona(paramsP);
34675
34677
  const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
34676
34678
  const $appendTo = $appendToP || $container;
@@ -34977,1171 +34979,1171 @@ func.UI.screen.screen_loading_done = async function (SESSION_ID, paramsP, $div,
34977
34979
  return $div;
34978
34980
  };
34979
34981
 
34980
- // func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $root_container) {
34981
- // if (!is_skeleton) {
34982
- // var _session = SESSION_OBJ[SESSION_ID];
34983
- // var _ds = _session.DS_GLB[paramsP.dsSessionP];
34984
- // }
34985
- // var prop;
34986
- // try {
34987
- // prop = nodeP.attributes;
34988
- // } catch (error) {
34989
- // // debugger;
34990
- // }
34991
-
34992
- // ///////////
34993
- // var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
34982
+ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $root_container) {
34983
+ if (!is_skeleton) {
34984
+ var _session = SESSION_OBJ[SESSION_ID];
34985
+ var _ds = _session.DS_GLB[paramsP.dsSessionP];
34986
+ }
34987
+ var prop;
34988
+ try {
34989
+ prop = nodeP.attributes;
34990
+ } catch (error) {
34991
+ // debugger;
34992
+ }
34994
34993
 
34995
- // const get_element_info = function () {
34996
- // var ret = {};
34997
- // let currentRecordId = _ds?.currentRecordId || '';
34994
+ ///////////
34995
+ var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
34998
34996
 
34999
- // let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
34997
+ const get_element_info = function () {
34998
+ var ret = {};
34999
+ let currentRecordId = _ds?.currentRecordId || '';
35000
35000
 
35001
- // $.each($div, function (key, val) {
35002
- // if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
35003
- // ret = {
35004
- // div: $div,
35005
- // };
35006
- // }
35007
- // });
35001
+ let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
35008
35002
 
35009
- // return ret;
35010
- // };
35003
+ $.each($div, function (key, val) {
35004
+ if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
35005
+ ret = {
35006
+ div: $div,
35007
+ };
35008
+ }
35009
+ });
35011
35010
 
35012
- // const init = async function () {
35013
- // var ret = true;
35014
- // if (!nodeP) ret = false;
35015
- // return ret;
35016
- // };
35017
- // const debug = function (is_errorP, error_descP) {
35018
- // func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
35019
- // module: 'gui',
35020
- // action: 'init',
35021
- // prop: nodeP.id,
35022
- // details: error_descP,
35023
- // result: null,
35024
- // error: is_errorP,
35025
- // source: _ds?.tree_obj?.menuName || '',
35026
- // fields: null,
35027
- // type: null,
35028
- // prog_id: paramsP.prog_id,
35029
- // dsSession: null,
35030
- // });
35031
- // };
35011
+ return ret;
35012
+ };
35032
35013
 
35033
- // const open_modal = async function ($div) {
35034
- // const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35035
- // var xu_modal_controller = document.querySelector('xu-modal-controller');
35036
- // if (!xu_modal_controller) {
35037
- // func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35038
- // xu_modal_controller = document.querySelector('xu-modal-controller');
35039
- // }
35014
+ const init = async function () {
35015
+ var ret = true;
35016
+ if (!nodeP) ret = false;
35017
+ return ret;
35018
+ };
35019
+ const debug = function (is_errorP, error_descP) {
35020
+ func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
35021
+ module: 'gui',
35022
+ action: 'init',
35023
+ prop: nodeP.id,
35024
+ details: error_descP,
35025
+ result: null,
35026
+ error: is_errorP,
35027
+ source: _ds?.tree_obj?.menuName || '',
35028
+ fields: null,
35029
+ type: null,
35030
+ prog_id: paramsP.prog_id,
35031
+ dsSession: null,
35032
+ });
35033
+ };
35040
35034
 
35041
- // var controller_params = $(xu_modal_controller).data('xuControllerParams');
35035
+ const open_modal = async function ($div) {
35036
+ const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35037
+ var xu_modal_controller = document.querySelector('xu-modal-controller');
35038
+ if (!xu_modal_controller) {
35039
+ func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35040
+ xu_modal_controller = document.querySelector('xu-modal-controller');
35041
+ }
35042
35042
 
35043
- // if (!controller_params) {
35044
- // controller_params = {};
35045
- // }
35043
+ var controller_params = $(xu_modal_controller).data('xuControllerParams');
35046
35044
 
35047
- // var params = {
35048
- // menuTitle: paramsP.screenInfo.properties?.menuTitle,
35049
- // screenId: paramsP.screenId,
35050
- // $dialogDiv: $div.children(),
35051
- // $container: $container,
35052
- // dsSession: paramsP.dsSessionP,
35053
- // };
35045
+ if (!controller_params) {
35046
+ controller_params = {};
35047
+ }
35054
35048
 
35055
- // controller_params[modal_id] = params;
35049
+ var params = {
35050
+ menuTitle: paramsP.screenInfo.properties?.menuTitle,
35051
+ screenId: paramsP.screenId,
35052
+ $dialogDiv: $div.children(),
35053
+ $container: $container,
35054
+ dsSession: paramsP.dsSessionP,
35055
+ };
35056
35056
 
35057
- // $(xu_modal_controller).data('xuControllerParams', controller_params);
35058
- // const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35057
+ controller_params[modal_id] = params;
35059
35058
 
35060
- // if (!APP_MODAL_OBJ[modal_id]) {
35061
- // const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
35062
- // APP_MODAL_OBJ[modal_id] = modal;
35063
- // } else {
35064
- // $(modal_id).empty();
35065
- // }
35066
- // await modalController.init(SESSION_ID, modal_id);
35059
+ $(xu_modal_controller).data('xuControllerParams', controller_params);
35060
+ const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35067
35061
 
35068
- // return $div;
35069
- // };
35062
+ if (!APP_MODAL_OBJ[modal_id]) {
35063
+ const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
35064
+ APP_MODAL_OBJ[modal_id] = modal;
35065
+ } else {
35066
+ $(modal_id).empty();
35067
+ }
35068
+ await modalController.init(SESSION_ID, modal_id);
35070
35069
 
35071
- // const close_modal = async function (modal_id) {
35072
- // delete APP_MODAL_OBJ[modal_id];
35073
- // const xu_modal_controller = document.querySelector('xu-modal-controller');
35074
- // var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
35075
- // if (params && params.$container) {
35076
- // await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
35077
- // func.datasource.clean_all(SESSION_ID, params.dsSession);
35078
- // }
35079
- // };
35070
+ return $div;
35071
+ };
35080
35072
 
35081
- // const close_all_modals = function () {
35082
- // $.each(APP_MODAL_OBJ, function (key, val) {
35083
- // if (val) {
35084
- // // close_modal(key);
35085
- // UI_FRAMEWORK_PLUGIN.modal.close(key);
35086
- // }
35087
- // });
35088
- // };
35073
+ const close_modal = async function (modal_id) {
35074
+ delete APP_MODAL_OBJ[modal_id];
35075
+ const xu_modal_controller = document.querySelector('xu-modal-controller');
35076
+ var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
35077
+ if (params && params.$container) {
35078
+ await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
35079
+ func.datasource.clean_all(SESSION_ID, params.dsSession);
35080
+ }
35081
+ };
35089
35082
 
35090
- // const open_popover = async function ($div) {
35091
- // const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35083
+ const close_all_modals = function () {
35084
+ $.each(APP_MODAL_OBJ, function (key, val) {
35085
+ if (val) {
35086
+ // close_modal(key);
35087
+ UI_FRAMEWORK_PLUGIN.modal.close(key);
35088
+ }
35089
+ });
35090
+ };
35092
35091
 
35093
- // $(xu_popover_controller).data('xuControllerParams', {
35094
- // menuTitle: paramsP.screenInfo.properties?.menuTitle,
35095
- // screenId: paramsP.screenId,
35096
- // $dialogDiv: $div.children(),
35097
- // $container: $container,
35098
- // });
35099
- // const popover = new UI_FRAMEWORK_PLUGIN.popover(
35100
- // SESSION_ID,
35101
- // // ELEMENT_CLICK_EVENT,
35102
- // // props
35103
- // );
35104
- // await popover.open(SESSION_ID);
35105
- // CURRENT_APP_POPOVER = popover;
35106
-
35107
- // return;
35108
- // popoverController
35109
- // .create({
35110
- // component: 'xu-popover-content-' + SESSION_ID,
35111
- // event: ELEMENT_CLICK_EVENT,
35112
- // translucent: true,
35113
- // })
35114
- // .then((modal) => {
35115
- // modal.present().then(() => {
35116
- // CURRENT_APP_POPOVER = modal;
35092
+ const open_popover = async function ($div) {
35093
+ const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35117
35094
 
35118
- // if (callbackP) callbackP($div);
35119
- // });
35120
- // });
35121
- // };
35122
- // const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35123
- // if (!is_mobile && nodeP.busy) return;
35124
- // nodeP.busy = true;
35125
- // const done = async function ($divP) {
35126
- // setTimeout(function () {
35127
- // nodeP.busy = false;
35128
- // }, 1000);
35129
-
35130
- // return $divP;
35131
- // };
35132
- // if (!nodeP || !nodeP.children) {
35133
- // return await done($divP);
35134
- // }
35095
+ $(xu_popover_controller).data('xuControllerParams', {
35096
+ menuTitle: paramsP.screenInfo.properties?.menuTitle,
35097
+ screenId: paramsP.screenId,
35098
+ $dialogDiv: $div.children(),
35099
+ $container: $container,
35100
+ });
35101
+ const popover = new UI_FRAMEWORK_PLUGIN.popover(
35102
+ SESSION_ID,
35103
+ // ELEMENT_CLICK_EVENT,
35104
+ // props
35105
+ );
35106
+ await popover.open(SESSION_ID);
35107
+ CURRENT_APP_POPOVER = popover;
35135
35108
 
35136
- // if (before_record_function) {
35137
- // await before_record_function();
35138
- // }
35139
- // if (nodeP?.children?.length) {
35140
- // let node_promises = [];
35141
- // for (const [key, val] of Object.entries(nodeP.children)) {
35142
- // node_promises.push(
35143
- // new Promise(async (resolve, reject) => {
35144
- // const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $divP, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
35145
-
35146
- // resolve();
35147
- // }),
35148
- // );
35149
- // }
35150
- // await Promise.all(node_promises);
35151
- // }
35152
- // return await done($divP);
35153
- // };
35109
+ return;
35110
+ popoverController
35111
+ .create({
35112
+ component: 'xu-popover-content-' + SESSION_ID,
35113
+ event: ELEMENT_CLICK_EVENT,
35114
+ translucent: true,
35115
+ })
35116
+ .then((modal) => {
35117
+ modal.present().then(() => {
35118
+ CURRENT_APP_POPOVER = modal;
35154
35119
 
35155
- // // const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35156
- // // if (!is_mobile && nodeP.busy) return;
35157
- // // nodeP.busy = true;
35158
- // // const done = async function ($divP) {
35159
- // // setTimeout(function () {
35160
- // // nodeP.busy = false;
35161
- // // }, 1000);
35120
+ if (callbackP) callbackP($div);
35121
+ });
35122
+ });
35123
+ };
35124
+ const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35125
+ if (!is_mobile && nodeP.busy) return;
35126
+ nodeP.busy = true;
35127
+ const done = async function ($divP) {
35128
+ setTimeout(function () {
35129
+ nodeP.busy = false;
35130
+ }, 1000);
35162
35131
 
35163
- // // return $divP;
35164
- // // };
35165
- // // if (!nodeP || !nodeP.children) {
35166
- // // return await done($divP);
35167
- // // }
35168
-
35169
- // // if (before_record_function) {
35170
- // // await before_record_function();
35171
- // // }
35172
- // // if (nodeP?.children?.length) {
35173
- // // for await (const [key, val] of Object.entries(nodeP.children)) {
35174
- // // const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $divP, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
35175
- // // }
35176
- // // }
35177
- // // return await done($divP);
35178
- // // };
35132
+ return $divP;
35133
+ };
35134
+ if (!nodeP || !nodeP.children) {
35135
+ return await done($divP);
35136
+ }
35179
35137
 
35180
- // const _$ = function ($elm) {
35181
- // try {
35182
- // const id = $elm.attr('xu-ui-id');
35183
- // if (!id || !glb.DEBUG_MODE) return $elm;
35184
- // const $el = $(`[xu-ui-id="${id}"]`);
35138
+ if (before_record_function) {
35139
+ await before_record_function();
35140
+ }
35141
+ if (nodeP?.children?.length) {
35142
+ let node_promises = [];
35143
+ for (const [key, val] of Object.entries(nodeP.children)) {
35144
+ node_promises.push(
35145
+ new Promise(async (resolve, reject) => {
35146
+ const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $divP, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
35185
35147
 
35186
- // if ($el.length > 1) {
35187
- // console.warn('Multiple elements for xu-ui-id: ' + id, $el);
35188
- // }
35148
+ resolve();
35149
+ }),
35150
+ );
35151
+ }
35152
+ await Promise.all(node_promises);
35153
+ }
35154
+ return await done($divP);
35155
+ };
35189
35156
 
35190
- // return $($el[0]);
35191
- // } catch (e) {
35192
- // console.error(e);
35193
- // }
35194
- // };
35157
+ // const iterate_child = async function ($divP, nodeP, parent_infoP, $root_container, before_record_function) {
35158
+ // if (!is_mobile && nodeP.busy) return;
35159
+ // nodeP.busy = true;
35160
+ // const done = async function ($divP) {
35161
+ // setTimeout(function () {
35162
+ // nodeP.busy = false;
35163
+ // }, 1000);
35164
+
35165
+ // return $divP;
35166
+ // };
35167
+ // if (!nodeP || !nodeP.children) {
35168
+ // return await done($divP);
35169
+ // }
35195
35170
 
35196
- // const hover_in = function ($div, e) {
35197
- // if (is_skeleton || (e && (EXP_BUSY || UI_WORKER_OBJ.jobs.length))) return;
35198
- // CLIENT_ACTIVITY_TS = Date.now();
35199
- // if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
35200
- // if (!_ds) return;
35201
- // ///////// SET Attributes///////////
35202
- // let attributes = {};
35203
- // $.each($div[0].attributes, function (index, attr) {
35204
- // attributes[attr.name] = attr.value;
35205
- // });
35171
+ // if (before_record_function) {
35172
+ // await before_record_function();
35173
+ // }
35174
+ // if (nodeP?.children?.length) {
35175
+ // for await (const [key, val] of Object.entries(nodeP.children)) {
35176
+ // const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $divP, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
35177
+ // }
35178
+ // }
35179
+ // return await done($divP);
35180
+ // };
35206
35181
 
35207
- // _session.DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
35208
- // //////////////////////////////////
35209
- // if (!$div.data()?.xuData) return;
35210
- // const _iterate_info = $div.data().xuData.iterate_info;
35211
- // if (_iterate_info) {
35212
- // if (_iterate_info.is_key_dynamic_field) {
35213
- // _ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
35214
- // } else {
35215
- // try {
35216
- // const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35217
- // _ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
35218
- // } catch (err) {
35219
- // console.error(err);
35220
- // }
35221
- // }
35182
+ const _$ = function ($elm) {
35183
+ try {
35184
+ const id = $elm.attr('xu-ui-id');
35185
+ if (!id || !glb.DEBUG_MODE) return $elm;
35186
+ const $el = $(`[xu-ui-id="${id}"]`);
35222
35187
 
35223
- // if (_iterate_info.is_val_dynamic_field) {
35224
- // _ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
35225
- // } else {
35226
- // try {
35227
- // const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35228
- // _ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
35229
- // } catch (err) {
35230
- // console.error(err);
35231
- // }
35232
- // }
35233
- // }
35188
+ if ($el.length > 1) {
35189
+ console.warn('Multiple elements for xu-ui-id: ' + id, $el);
35190
+ }
35234
35191
 
35235
- // if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
35236
- // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
35237
- // }
35192
+ return $($el[0]);
35193
+ } catch (e) {
35194
+ console.error(e);
35195
+ }
35196
+ };
35238
35197
 
35239
- // const set_value = function (field_id, value) {
35240
- // var currentRecordId = _$($div).data().xuData.currentRecordId;
35198
+ const hover_in = function ($div, e) {
35199
+ if (is_skeleton || (e && (EXP_BUSY || UI_WORKER_OBJ.jobs.length))) return;
35200
+ CLIENT_ACTIVITY_TS = Date.now();
35201
+ if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
35202
+ if (!_ds) return;
35203
+ ///////// SET Attributes///////////
35204
+ let attributes = {};
35205
+ $.each($div[0].attributes, function (index, attr) {
35206
+ attributes[attr.name] = attr.value;
35207
+ });
35241
35208
 
35242
- // func.UI.worker.add_to_queue(
35243
- // SESSION_ID,
35244
- // 'gui event',
35245
- // 'update_datasource',
35246
- // {
35247
- // currentRecordId,
35248
- // field_id,
35249
- // field_value: value,
35250
- // },
35251
- // null,
35252
- // null,
35253
- // paramsP.dsSessionP,
35254
- // );
35255
- // };
35209
+ _session.DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
35210
+ //////////////////////////////////
35211
+ if (!$div.data()?.xuData) return;
35212
+ const _iterate_info = $div.data().xuData.iterate_info;
35213
+ if (_iterate_info) {
35214
+ if (_iterate_info.is_key_dynamic_field) {
35215
+ _ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
35216
+ } else {
35217
+ try {
35218
+ const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35219
+ _ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
35220
+ } catch (err) {
35221
+ console.error(err);
35222
+ }
35223
+ }
35256
35224
 
35257
- // if ($div?.data()?.iterate_info) {
35258
- // var data = $div.data().xuData.iterate_info;
35259
- // if (data.iterator_key) {
35260
- // set_value(data.iterator_key, data._key);
35261
- // }
35262
- // if (data.iterator_val) {
35263
- // set_value(data.iterator_val, data._val);
35264
- // }
35265
- // }
35266
- // };
35267
- // const hover_out = function () {
35268
- // if (is_skeleton) return;
35225
+ if (_iterate_info.is_val_dynamic_field) {
35226
+ _ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
35227
+ } else {
35228
+ try {
35229
+ const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
35230
+ _ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
35231
+ } catch (err) {
35232
+ console.error(err);
35233
+ }
35234
+ }
35235
+ }
35269
35236
 
35270
- // CLIENT_ACTIVITY_TS = Date.now();
35271
- // if (_$($container)?.data()?.xuData?.debug_info) {
35272
- // _$($container).data().xuData.debug_info.hover_item = null;
35273
- // }
35274
- // if (_ds?.data_system) {
35275
- // SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
35276
- // }
35277
- // };
35278
- // const render_screen_type = async function ($div) {
35279
- // const set_call_screen_properties_values = async function (ui_framework) {
35280
- // params.properties = {};
35281
- // const get_values = async function (property) {
35282
- // var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
35283
- // if (paramsP?.call_screen_propertiesP) {
35284
- // if (paramsP.call_screen_propertiesP?.[property]) {
35285
- // property_value = paramsP.call_screen_propertiesP[property];
35286
- // }
35287
- // if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
35288
- // property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
35289
- // }
35290
- // }
35291
- // return property_value;
35292
- // };
35293
- // params.properties['name'] = await get_values('menuTitle');
35294
- // if (await ui_framework?.properties()) {
35295
- // for await (const [key, val] of Object.entries(await ui_framework.properties())) {
35296
- // params.properties[key] = await get_values(key);
35297
- // }
35298
- // }
35299
- // };
35237
+ if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
35238
+ func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
35239
+ }
35300
35240
 
35301
- // var $div_content = $div.children();
35241
+ const set_value = function (field_id, value) {
35242
+ var currentRecordId = _$($div).data().xuData.currentRecordId;
35302
35243
 
35303
- // $.each($div_content, function (key, val) {
35304
- // if (!$(val)?.data()?.xuData?.parent_container) {
35305
- // return true;
35306
- // }
35307
- // $(val).data().xuData.parent_container = $div.data().xuData.parent_container;
35308
- // });
35244
+ func.UI.worker.add_to_queue(
35245
+ SESSION_ID,
35246
+ 'gui event',
35247
+ 'update_datasource',
35248
+ {
35249
+ currentRecordId,
35250
+ field_id,
35251
+ field_value: value,
35252
+ },
35253
+ null,
35254
+ null,
35255
+ paramsP.dsSessionP,
35256
+ );
35257
+ };
35309
35258
 
35310
- // let $ret = $div;
35311
- // var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
35312
- // var params;
35313
- // switch (paramsP.screen_type) {
35314
- // case 'modal':
35315
- // const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35316
- // var xu_modal_controller = document.querySelector('xu-modal-controller');
35317
- // if (!xu_modal_controller) {
35318
- // func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35319
- // xu_modal_controller = document.querySelector('xu-modal-controller');
35320
- // }
35259
+ if ($div?.data()?.iterate_info) {
35260
+ var data = $div.data().xuData.iterate_info;
35261
+ if (data.iterator_key) {
35262
+ set_value(data.iterator_key, data._key);
35263
+ }
35264
+ if (data.iterator_val) {
35265
+ set_value(data.iterator_val, data._val);
35266
+ }
35267
+ }
35268
+ };
35269
+ const hover_out = function () {
35270
+ if (is_skeleton) return;
35321
35271
 
35322
- // var controller_params = $(xu_modal_controller).data('xuControllerParams');
35272
+ CLIENT_ACTIVITY_TS = Date.now();
35273
+ if (_$($container)?.data()?.xuData?.debug_info) {
35274
+ _$($container).data().xuData.debug_info.hover_item = null;
35275
+ }
35276
+ if (_ds?.data_system) {
35277
+ SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
35278
+ }
35279
+ };
35280
+ const render_screen_type = async function ($div) {
35281
+ const set_call_screen_properties_values = async function (ui_framework) {
35282
+ params.properties = {};
35283
+ const get_values = async function (property) {
35284
+ var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
35285
+ if (paramsP?.call_screen_propertiesP) {
35286
+ if (paramsP.call_screen_propertiesP?.[property]) {
35287
+ property_value = paramsP.call_screen_propertiesP[property];
35288
+ }
35289
+ if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
35290
+ property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
35291
+ }
35292
+ }
35293
+ return property_value;
35294
+ };
35295
+ params.properties['name'] = await get_values('menuTitle');
35296
+ if (await ui_framework?.properties()) {
35297
+ for await (const [key, val] of Object.entries(await ui_framework.properties())) {
35298
+ params.properties[key] = await get_values(key);
35299
+ }
35300
+ }
35301
+ };
35323
35302
 
35324
- // if (!controller_params) {
35325
- // controller_params = {};
35326
- // }
35303
+ var $div_content = $div.children();
35327
35304
 
35328
- // params = {
35329
- // screenId: paramsP.screenId,
35330
- // $dialogDiv: $div.children(),
35331
- // $container: $container,
35332
- // dsSession: paramsP.dsSessionP,
35333
- // modal_id,
35334
- // screenInfo: paramsP.screenInfo,
35335
- // close_callback: close_modal,
35336
- // paramsP,
35337
- // };
35305
+ $.each($div_content, function (key, val) {
35306
+ if (!$(val)?.data()?.xuData?.parent_container) {
35307
+ return true;
35308
+ }
35309
+ $(val).data().xuData.parent_container = $div.data().xuData.parent_container;
35310
+ });
35338
35311
 
35339
- // controller_params[modal_id] = params;
35312
+ let $ret = $div;
35313
+ var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
35314
+ var params;
35315
+ switch (paramsP.screen_type) {
35316
+ case 'modal':
35317
+ const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
35318
+ var xu_modal_controller = document.querySelector('xu-modal-controller');
35319
+ if (!xu_modal_controller) {
35320
+ func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
35321
+ xu_modal_controller = document.querySelector('xu-modal-controller');
35322
+ }
35340
35323
 
35341
- // $(xu_modal_controller).data('xuControllerParams', controller_params);
35342
- // const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35343
- // await set_call_screen_properties_values(modalController);
35344
- // if (!APP_MODAL_OBJ[modal_id]) {
35345
- // const modal = await modalController.create(params);
35324
+ var controller_params = $(xu_modal_controller).data('xuControllerParams');
35346
35325
 
35347
- // APP_MODAL_OBJ[modal_id] = modal;
35348
- // } else {
35349
- // $(modal_id).empty();
35350
- // }
35326
+ if (!controller_params) {
35327
+ controller_params = {};
35328
+ }
35351
35329
 
35352
- // await modalController.init(params);
35330
+ params = {
35331
+ screenId: paramsP.screenId,
35332
+ $dialogDiv: $div.children(),
35333
+ $container: $container,
35334
+ dsSession: paramsP.dsSessionP,
35335
+ modal_id,
35336
+ screenInfo: paramsP.screenInfo,
35337
+ close_callback: close_modal,
35338
+ paramsP,
35339
+ };
35353
35340
 
35354
- // break;
35341
+ controller_params[modal_id] = params;
35355
35342
 
35356
- // case 'popover':
35357
- // // open_popover($div);
35343
+ $(xu_modal_controller).data('xuControllerParams', controller_params);
35344
+ const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
35345
+ await set_call_screen_properties_values(modalController);
35346
+ if (!APP_MODAL_OBJ[modal_id]) {
35347
+ const modal = await modalController.create(params);
35358
35348
 
35359
- // const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35360
- // params = {
35361
- // menuTitle: paramsP.screenInfo.properties?.menuTitle,
35362
- // screenId: paramsP.screenId,
35363
- // $dialogDiv: $div.children(),
35364
- // $container: $container,
35365
- // };
35349
+ APP_MODAL_OBJ[modal_id] = modal;
35350
+ } else {
35351
+ $(modal_id).empty();
35352
+ }
35366
35353
 
35367
- // $(xu_popover_controller).data('xuControllerParams', params);
35368
- // const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
35369
- // await set_call_screen_properties_values(popover);
35370
- // await popover.open(params);
35371
- // CURRENT_APP_POPOVER = popover;
35354
+ await modalController.init(params);
35372
35355
 
35373
- // func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
35374
- // break;
35356
+ break;
35375
35357
 
35376
- // case 'page':
35377
- // const nav = $nav[0];
35358
+ case 'popover':
35359
+ // open_popover($div);
35378
35360
 
35379
- // params = {
35380
- // div: $div_content,
35381
- // name: paramsP.screenInfo.properties?.menuTitle,
35382
- // screenId: paramsP.screenId,
35383
- // $container: $container,
35384
- // dsSession: paramsP.dsSessionP,
35385
- // SESSION_ID,
35386
- // nav,
35387
- // paramsP,
35388
- // };
35361
+ const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
35362
+ params = {
35363
+ menuTitle: paramsP.screenInfo.properties?.menuTitle,
35364
+ screenId: paramsP.screenId,
35365
+ $dialogDiv: $div.children(),
35366
+ $container: $container,
35367
+ };
35389
35368
 
35390
- // var component_name = 'xu-page-component-' + paramsP.dsSessionP;
35391
- // if (!$(nav).data().xuData.nav_params) {
35392
- // $(nav).data().xuData.nav_params = {};
35393
- // }
35369
+ $(xu_popover_controller).data('xuControllerParams', params);
35370
+ const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
35371
+ await set_call_screen_properties_values(popover);
35372
+ await popover.open(params);
35373
+ CURRENT_APP_POPOVER = popover;
35394
35374
 
35395
- // //restore validate
35396
- // if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
35397
- // params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
35398
- // }
35375
+ func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
35376
+ break;
35399
35377
 
35400
- // if (!$(nav)?.data()?.xuData) return;
35401
- // $(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
35402
- // if (!$(component_name).length) {
35403
- // await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
35404
- // const page = new UI_FRAMEWORK_PLUGIN.page();
35405
- // await set_call_screen_properties_values(page);
35406
- // await page.create(params);
35407
- // await page.init(params);
35408
- // nav.push(component_name, { params });
35409
- // } else {
35410
- // debugger;
35411
- // $(component_name).empty();
35412
-
35413
- // await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
35414
- // }
35415
- // $div.data().xuData.paramsP = $container.data().xuData.paramsP;
35416
- // break;
35417
-
35418
- // case 'panel':
35419
- // $container.append($div_content);
35420
- // $ret = $container;
35421
- // break;
35422
-
35423
- // default: // set data to nav to use in the component
35424
- // if ($nav && $nav.length) {
35425
- // // refresh made
35426
- // } else {
35427
- // $nav = $('<xu-nav>'); //.attr('xu-ui-id', SESSION_ID);
35428
- // $container.append($nav);
35429
- // func.UI.component.init_xu_nav($container, $nav);
35430
- // }
35378
+ case 'page':
35379
+ const nav = $nav[0];
35431
35380
 
35432
- // $nav.data().xuData.$div = $div_content;
35381
+ params = {
35382
+ div: $div_content,
35383
+ name: paramsP.screenInfo.properties?.menuTitle,
35384
+ screenId: paramsP.screenId,
35385
+ $container: $container,
35386
+ dsSession: paramsP.dsSessionP,
35387
+ SESSION_ID,
35388
+ nav,
35389
+ paramsP,
35390
+ };
35433
35391
 
35434
- // await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
35435
- // $ret = $container;
35436
- // break;
35437
- // }
35438
- // return $ret;
35439
- // };
35392
+ var component_name = 'xu-page-component-' + paramsP.dsSessionP;
35393
+ if (!$(nav).data().xuData.nav_params) {
35394
+ $(nav).data().xuData.nav_params = {};
35395
+ }
35440
35396
 
35441
- // if (!(await init())) return;
35442
- // debug();
35443
- // const fx = {
35444
- // widget: async function () {
35445
- // var _session = SESSION_OBJ[SESSION_ID];
35446
-
35447
- // var exist_elm_obj = get_element_info();
35448
- // var $div = exist_elm_obj.div;
35449
- // if (!exist_elm_obj.div) {
35450
- // $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, 'widget_wrapper', null, null, null, null);
35451
-
35452
- // //////////////////////////
35453
-
35454
- // let plugin_name = prop['xu-widget'],
35455
- // method = prop['xu-method'],
35456
- // dsP = paramsP.dsSessionP,
35457
- // propsP = prop,
35458
- // sourceP = 'widgets';
35459
-
35460
- // // const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
35461
- // // var obj = _.clone(docP);
35462
- // // obj.date = await func.utils.get_dateTime(
35463
- // // SESSION_ID,
35464
- // // "SYS_DATE",
35465
- // // docP.date
35466
- // // );
35467
- // // obj.time = await func.utils.get_dateTime(
35468
- // // SESSION_ID,
35469
- // // "SYS_TIME",
35470
- // // docP.date
35471
- // // );
35472
-
35473
- // // var datasource_changes = {
35474
- // // [0]: {
35475
- // // ["data_system"]: {
35476
- // // ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
35477
- // // },
35478
- // // },
35479
- // // };
35480
- // // await func.datasource.update(SESSION_ID, datasource_changes);
35481
- // // };
35482
- // const call_plugin_api = async function (plugin_nameP, dataP) {
35483
- // return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
35484
- // };
35485
- // const report_error = function (descP, warn) {
35486
- // func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35487
- // module: 'widgets',
35488
- // action: 'Init',
35489
- // source: sourceP,
35490
- // prop: descP,
35491
- // details: descP,
35492
- // result: null,
35493
- // error: warn ? false : true,
35494
- // fields: null,
35495
- // type: 'widgets',
35496
- // prog_id: _session.DS_GLB[dsP].prog_id,
35497
- // });
35498
- // };
35499
- // const get_fields_data = async function (fields, props) {
35500
- // const report_error = function (descP, warn) {
35501
- // func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35502
- // module: 'widgets',
35503
- // action: 'Init',
35504
- // source: sourceP,
35505
- // prop: descP,
35506
- // details: descP,
35507
- // result: null,
35508
- // error: warn ? false : true,
35509
- // fields: null,
35510
- // type: 'widgets',
35511
- // prog_id: _session.DS_GLB[dsP].prog_id,
35512
- // });
35513
- // };
35514
- // const get_property_value = async function (fieldIdP, val) {
35515
- // if (!val) return;
35516
- // var value = fieldIdP in props ? props[fieldIdP] : typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue;
35517
- // if (val.render === 'eventId') {
35518
- // value = props?.[fieldIdP]?.event;
35519
- // }
35397
+ //restore validate
35398
+ if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
35399
+ params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
35400
+ }
35520
35401
 
35521
- // if (props[`xu-exp:${fieldIdP}`]) {
35522
- // value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
35523
- // }
35402
+ if (!$(nav)?.data()?.xuData) return;
35403
+ $(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
35404
+ if (!$(component_name).length) {
35405
+ await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
35406
+ const page = new UI_FRAMEWORK_PLUGIN.page();
35407
+ await set_call_screen_properties_values(page);
35408
+ await page.create(params);
35409
+ await page.init(params);
35410
+ nav.push(component_name, { params });
35411
+ } else {
35412
+ debugger;
35413
+ $(component_name).empty();
35524
35414
 
35525
- // return func.common.get_cast_val(
35526
- // SESSION_ID,
35527
- // 'widgets',
35528
- // fieldIdP,
35529
- // val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
35530
- // value,
35531
- // null,
35532
- // );
35533
- // };
35534
- // var data_obj = {};
35535
- // var return_code = 1;
35536
- // // $.each(fields, function (key, val) {
35537
- // for await (const [key, val] of Object.entries(fields)) {
35538
- // data_obj[key] = await get_property_value(key, val);
35539
- // if (!data_obj[key] && val.mandatory) {
35540
- // return_code = -1;
35541
- // report_error(`${key} is a mandatory field.`);
35542
- // break;
35543
- // }
35544
- // // console.log(val);
35545
- // }
35546
- // for await (const key of ['xu-bind']) {
35547
- // data_obj[key] = await get_property_value(key, props[key]);
35548
- // }
35415
+ await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
35416
+ }
35417
+ $div.data().xuData.paramsP = $container.data().xuData.paramsP;
35418
+ break;
35549
35419
 
35550
- // return { code: return_code, data: data_obj };
35551
- // };
35420
+ case 'panel':
35421
+ $container.append($div_content);
35422
+ $ret = $container;
35423
+ break;
35552
35424
 
35553
- // const load_css_style = function () {
35554
- // const get_css_path = function (resource) {
35555
- // if (_session.worker_type === 'Dev') {
35556
- // return `../../plugins/${plugin_name}/${resource}`;
35557
- // }
35558
- // return `https://${_session.domain}/plugins/${plugin_name}/${APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest[resource].dist ? 'dist/' : ''}${resource}?gtp_token=${_session.gtp_token}&app_id=${_session.app_id}`;
35559
- // };
35560
- // let path = get_css_path('style.css');
35561
- // func.utils.load_css_on_demand(path);
35562
- // };
35425
+ default: // set data to nav to use in the component
35426
+ if ($nav && $nav.length) {
35427
+ // refresh made
35428
+ } else {
35429
+ $nav = $('<xu-nav>'); //.attr('xu-ui-id', SESSION_ID);
35430
+ $container.append($nav);
35431
+ func.UI.component.init_xu_nav($container, $nav);
35432
+ }
35563
35433
 
35564
- // const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
35565
- // const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
35566
- // const methods = index.methods;
35567
- // if (methods && !methods[method]) {
35568
- // return report_error('method not found');
35569
- // }
35434
+ $nav.data().xuData.$div = $div_content;
35570
35435
 
35571
- // const fields_ret = await get_fields_data(methods[method].fields, propsP);
35572
- // if (fields_ret.code < 0) {
35573
- // return report_error(fields_ret.data);
35574
- // }
35575
- // const fields = fields_ret.data;
35436
+ await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
35437
+ $ret = $container;
35438
+ break;
35439
+ }
35440
+ return $ret;
35441
+ };
35576
35442
 
35577
- // let exclude_attributes = [];
35578
- // for await (const [key, val] of Object.entries(propsP)) {
35579
- // if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
35580
- // exclude_attributes.push(key);
35581
- // }
35582
- // }
35443
+ if (!(await init())) return;
35444
+ debug();
35445
+ const fx = {
35446
+ widget: async function () {
35447
+ var _session = SESSION_OBJ[SESSION_ID];
35583
35448
 
35584
- // let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true, exclude_attributes);
35449
+ var exist_elm_obj = get_element_info();
35450
+ var $div = exist_elm_obj.div;
35451
+ if (!exist_elm_obj.div) {
35452
+ $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, 'widget_wrapper', null, null, null, null);
35585
35453
 
35586
- // $div.addClass('widget_wrapper'); // class get override in set_attributes_new
35454
+ //////////////////////////
35455
+
35456
+ let plugin_name = prop['xu-widget'],
35457
+ method = prop['xu-method'],
35458
+ dsP = paramsP.dsSessionP,
35459
+ propsP = prop,
35460
+ sourceP = 'widgets';
35461
+
35462
+ // const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
35463
+ // var obj = _.clone(docP);
35464
+ // obj.date = await func.utils.get_dateTime(
35465
+ // SESSION_ID,
35466
+ // "SYS_DATE",
35467
+ // docP.date
35468
+ // );
35469
+ // obj.time = await func.utils.get_dateTime(
35470
+ // SESSION_ID,
35471
+ // "SYS_TIME",
35472
+ // docP.date
35473
+ // );
35474
+
35475
+ // var datasource_changes = {
35476
+ // [0]: {
35477
+ // ["data_system"]: {
35478
+ // ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
35479
+ // },
35480
+ // },
35481
+ // };
35482
+ // await func.datasource.update(SESSION_ID, datasource_changes);
35483
+ // };
35484
+ const call_plugin_api = async function (plugin_nameP, dataP) {
35485
+ return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
35486
+ };
35487
+ const report_error = function (descP, warn) {
35488
+ func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35489
+ module: 'widgets',
35490
+ action: 'Init',
35491
+ source: sourceP,
35492
+ prop: descP,
35493
+ details: descP,
35494
+ result: null,
35495
+ error: warn ? false : true,
35496
+ fields: null,
35497
+ type: 'widgets',
35498
+ prog_id: _session.DS_GLB[dsP].prog_id,
35499
+ });
35500
+ };
35501
+ const get_fields_data = async function (fields, props) {
35502
+ const report_error = function (descP, warn) {
35503
+ func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
35504
+ module: 'widgets',
35505
+ action: 'Init',
35506
+ source: sourceP,
35507
+ prop: descP,
35508
+ details: descP,
35509
+ result: null,
35510
+ error: warn ? false : true,
35511
+ fields: null,
35512
+ type: 'widgets',
35513
+ prog_id: _session.DS_GLB[dsP].prog_id,
35514
+ });
35515
+ };
35516
+ const get_property_value = async function (fieldIdP, val) {
35517
+ if (!val) return;
35518
+ var value = fieldIdP in props ? props[fieldIdP] : typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue;
35519
+ if (val.render === 'eventId') {
35520
+ value = props?.[fieldIdP]?.event;
35521
+ }
35587
35522
 
35588
- // if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
35589
- // return report_error(`plugin ${plugin_name} not found`);
35590
- // }
35523
+ if (props[`xu-exp:${fieldIdP}`]) {
35524
+ value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
35525
+ }
35591
35526
 
35592
- // if (APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest['style.css'].exist) {
35593
- // load_css_style();
35594
- // }
35527
+ return func.common.get_cast_val(
35528
+ SESSION_ID,
35529
+ 'widgets',
35530
+ fieldIdP,
35531
+ val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
35532
+ value,
35533
+ null,
35534
+ );
35535
+ };
35536
+ var data_obj = {};
35537
+ var return_code = 1;
35538
+ // $.each(fields, function (key, val) {
35539
+ for await (const [key, val] of Object.entries(fields)) {
35540
+ data_obj[key] = await get_property_value(key, val);
35541
+ if (!data_obj[key] && val.mandatory) {
35542
+ return_code = -1;
35543
+ report_error(`${key} is a mandatory field.`);
35544
+ break;
35545
+ }
35546
+ // console.log(val);
35547
+ }
35548
+ for await (const key of ['xu-bind']) {
35549
+ data_obj[key] = await get_property_value(key, props[key]);
35550
+ }
35595
35551
 
35596
- // const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
35597
- // if (plugin_setup_ret.code < 0) {
35598
- // return report_error(plugin_setup_ret);
35599
- // }
35552
+ return { code: return_code, data: data_obj };
35553
+ };
35600
35554
 
35601
- // const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
35602
- // func,
35603
- // glb,
35604
- // SESSION_OBJ,
35605
- // SESSION_ID,
35606
- // APP_OBJ,
35607
- // dsSession: paramsP.dsSessionP,
35608
- // job_id: jobNoP,
35609
- // });
35555
+ const load_css_style = function () {
35556
+ const get_css_path = function (resource) {
35557
+ if (_session.worker_type === 'Dev') {
35558
+ return `../../plugins/${plugin_name}/${resource}`;
35559
+ }
35560
+ return `https://${_session.domain}/plugins/${plugin_name}/${APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest[resource].dist ? 'dist/' : ''}${resource}?gtp_token=${_session.gtp_token}&app_id=${_session.app_id}`;
35561
+ };
35562
+ let path = get_css_path('style.css');
35563
+ func.utils.load_css_on_demand(path);
35564
+ };
35610
35565
 
35611
- // const params = {
35612
- // SESSION_ID,
35613
- // method,
35614
- // _session,
35615
- // dsP,
35616
- // sourceP,
35617
- // propsP,
35618
- // plugin_name,
35619
- // $containerP: $div,
35620
- // plugin_setup: plugin_setup_ret.data,
35621
-
35622
- // report_error,
35623
- // call_plugin_api,
35624
- // // set_SYS_GLOBAL_OBJ_WIDGET_INFO,
35625
- // api_utils,
35626
- // };
35566
+ const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
35567
+ const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
35568
+ const methods = index.methods;
35569
+ if (methods && !methods[method]) {
35570
+ return report_error('method not found');
35571
+ }
35627
35572
 
35628
- // const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
35573
+ const fields_ret = await get_fields_data(methods[method].fields, propsP);
35574
+ if (fields_ret.code < 0) {
35575
+ return report_error(fields_ret.data);
35576
+ }
35577
+ const fields = fields_ret.data;
35629
35578
 
35630
- // if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
35631
- // const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
35632
- // func.utils.load_css_on_demand(plugin_runtime_css_url);
35633
- // }
35579
+ let exclude_attributes = [];
35580
+ for await (const [key, val] of Object.entries(propsP)) {
35581
+ if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
35582
+ exclude_attributes.push(key);
35583
+ }
35584
+ }
35634
35585
 
35635
- // if (!fx[method]) {
35636
- // throw `Method: ${method} does not exist`;
35637
- // }
35638
- // try {
35639
- // await fx[method](fields, params);
35640
- // } catch (err) {
35641
- // func.utils.debug_report(SESSION_ID, `${plugin_name} widget`, err.message, 'E');
35642
- // }
35643
- // }
35644
- // return $div;
35645
- // },
35646
- // [`xu-single-view`]: async function () {
35647
- // var exist_elm_obj = get_element_info();
35648
- // var $div = exist_elm_obj.div;
35586
+ let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true, exclude_attributes);
35649
35587
 
35650
- // if (!exist_elm_obj.div) {
35651
- // var $wrapper = $('<div>');
35652
- // $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, 'div', $wrapper, '');
35588
+ $div.addClass('widget_wrapper'); // class get override in set_attributes_new
35653
35589
 
35654
- // if (!$div) return;
35590
+ if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
35591
+ return report_error(`plugin ${plugin_name} not found`);
35592
+ }
35655
35593
 
35656
- // if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
35657
- // close_all_modals();
35658
- // }
35594
+ if (APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest['style.css'].exist) {
35595
+ load_css_style();
35596
+ }
35659
35597
 
35660
- // $div.hover(
35661
- // function (e) {
35662
- // hover_in();
35663
- // // func.UI.screen.hover_in(SESSION_ID, null, $container, paramsP, is_skeleton);
35664
- // },
35665
- // function (e) {
35666
- // // func.UI.screen.hover_out(SESSION_ID, $container, is_skeleton, paramsP);
35667
- // hover_out();
35668
- // },
35669
- // );
35670
- // }
35598
+ const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
35599
+ if (plugin_setup_ret.code < 0) {
35600
+ return report_error(plugin_setup_ret);
35601
+ }
35671
35602
 
35672
- // const ret = await iterate_child($div, nodeP, null, $div);
35673
- // if (_.isEmpty($container.data().xuAttributes)) {
35674
- // await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35675
- // }
35603
+ const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
35604
+ func,
35605
+ glb,
35606
+ SESSION_OBJ,
35607
+ SESSION_ID,
35608
+ APP_OBJ,
35609
+ dsSession: paramsP.dsSessionP,
35610
+ job_id: jobNoP,
35611
+ });
35676
35612
 
35677
- // $.each($div.data().xuData, function (key, val) {
35678
- // $container.data().xuData[key] = _.cloneDeep(val);
35679
- // });
35680
- // $.each($div.data().xuAttributes, function (key, val) {
35681
- // // $container.data().xuAttributes[key] = _.cloneDeep(val);
35682
- // $container.data().xuAttributes[key] = klona.klona(val);
35683
- // });
35613
+ const params = {
35614
+ SESSION_ID,
35615
+ method,
35616
+ _session,
35617
+ dsP,
35618
+ sourceP,
35619
+ propsP,
35620
+ plugin_name,
35621
+ $containerP: $div,
35622
+ plugin_setup: plugin_setup_ret.data,
35684
35623
 
35685
- // return await render_screen_type($div);
35686
- // },
35687
- // [`xu-multi-view`]: async function () {
35688
- // var $div = $container;
35624
+ report_error,
35625
+ call_plugin_api,
35626
+ // set_SYS_GLOBAL_OBJ_WIDGET_INFO,
35627
+ api_utils,
35628
+ };
35689
35629
 
35690
- // if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
35691
- // $div.data().xuData.node = nodeP;
35692
- // }
35630
+ const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
35693
35631
 
35694
- // if (!$div.data().xuData.debug_info) {
35695
- // $div.data().xuData.debug_info = {
35696
- // id: nodeP.id,
35697
- // parent_id: $container.data().xuData.ui_id,
35698
- // };
35699
- // }
35632
+ if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
35633
+ const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
35634
+ func.utils.load_css_on_demand(plugin_runtime_css_url);
35635
+ }
35700
35636
 
35701
- // const done = async function (continuous_idx) {
35702
- // // const do_callback = async function ($div) {
35703
- // // // if ($root_container.data().xuData.progress_bar_circle) {
35704
- // // // setTimeout(function () {
35705
- // // // $.each(
35706
- // // // $root_container.data().xuData.progress_bar_circle,
35707
- // // // function (key, val) {
35708
- // // // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
35709
- // // // }
35710
- // // // );
35711
- // // // }, 2000);
35712
- // // // }
35713
-
35714
- // // if (paramsP.screenInfo.properties?.rtl) {
35715
- // // $div_content.attr('dir', 'rtl');
35716
- // // }
35717
-
35718
- // // return $div;
35719
- // // };
35720
- // await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35721
-
35722
- // return await render_screen_type($div);
35723
- // };
35637
+ if (!fx[method]) {
35638
+ throw `Method: ${method} does not exist`;
35639
+ }
35640
+ try {
35641
+ await fx[method](fields, params);
35642
+ } catch (err) {
35643
+ func.utils.debug_report(SESSION_ID, `${plugin_name} widget`, err.message, 'E');
35644
+ }
35645
+ }
35646
+ return $div;
35647
+ },
35648
+ [`xu-single-view`]: async function () {
35649
+ var exist_elm_obj = get_element_info();
35650
+ var $div = exist_elm_obj.div;
35724
35651
 
35725
- // if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
35726
- // close_all_modals();
35727
- // }
35652
+ if (!exist_elm_obj.div) {
35653
+ var $wrapper = $('<div>');
35654
+ $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, 'div', $wrapper, '');
35728
35655
 
35729
- // const empty_result = async function () {
35730
- // // var content = prop.empty_result_content || '';
35731
-
35732
- // // var res = await func.expression.get(
35733
- // // SESSION_ID,
35734
- // // content, // prop["xu-exp:empty_result_content"],
35735
- // // paramsP.dsSessionP,
35736
- // // 'empty_result_content_EXP',
35737
- // // _ds.currentRecordId,
35738
- // // );
35739
- // // content = res.result;
35740
-
35741
- // // let empty_result_node = {
35742
- // // type: 'element',
35743
- // // id: crypto.randomUUID(),
35744
- // // content,
35745
- // // // : content || (typeof content === "undefined" && "Empty results"),
35746
- // // tagName: 'div',
35747
- // // attributes: {},
35748
- // // children: [],
35749
- // // };
35750
-
35751
- // // const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $container, empty_result_node, parent_infoP, paramsP, jobNoP, null, 0, null, nodeP, null, $root_container);
35752
- // await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
35753
- // return await done(null);
35754
- // };
35755
- // var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
35656
+ if (!$div) return;
35756
35657
 
35757
- // var continuous_idx = null;
35658
+ if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
35659
+ close_all_modals();
35660
+ }
35758
35661
 
35759
- // if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
35760
- // return await empty_result();
35761
- // }
35662
+ $div.hover(
35663
+ function (e) {
35664
+ hover_in();
35665
+ // func.UI.screen.hover_in(SESSION_ID, null, $container, paramsP, is_skeleton);
35666
+ },
35667
+ function (e) {
35668
+ // func.UI.screen.hover_out(SESSION_ID, $container, is_skeleton, paramsP);
35669
+ hover_out();
35670
+ },
35671
+ );
35672
+ }
35762
35673
 
35763
- // var i = 0;
35764
- // for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
35765
- // var node = JSON.parse(JSON.stringify(nodeP));
35674
+ const ret = await iterate_child($div, nodeP, null, $div);
35675
+ if (_.isEmpty($container.data().xuAttributes)) {
35676
+ await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35677
+ }
35766
35678
 
35767
- // _ds.currentRecordId = val._ROWID;
35768
- // const ret = await iterate_child($div, node, { continuous_idx }, $root_container);
35679
+ $.each($div.data().xuData, function (key, val) {
35680
+ $container.data().xuData[key] = _.cloneDeep(val);
35681
+ });
35682
+ $.each($div.data().xuAttributes, function (key, val) {
35683
+ // $container.data().xuAttributes[key] = _.cloneDeep(val);
35684
+ $container.data().xuAttributes[key] = klona.klona(val);
35685
+ });
35769
35686
 
35770
- // if (_.isEmpty($container.data().xuAttributes)) {
35771
- // await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35772
- // }
35773
- // }
35687
+ return await render_screen_type($div);
35688
+ },
35689
+ [`xu-multi-view`]: async function () {
35690
+ var $div = $container;
35774
35691
 
35775
- // return await done(continuous_idx);
35776
- // },
35777
- // [`xu-panel`]: async function () {
35778
- // const done = async function ($new_div) {
35779
- // if (!$container.data()?.xuData?.paramsP) {
35780
- // return $container;
35781
- // }
35782
- // var $div_items = $div.data().xuData.node.children;
35692
+ if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
35693
+ $div.data().xuData.node = nodeP;
35694
+ }
35783
35695
 
35784
- // await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
35696
+ if (!$div.data().xuData.debug_info) {
35697
+ $div.data().xuData.debug_info = {
35698
+ id: nodeP.id,
35699
+ parent_id: $container.data().xuData.ui_id,
35700
+ };
35701
+ }
35785
35702
 
35786
- // // TO FIX should be timeout
35787
- // $container.data().xuData.node.children = $div_items;
35703
+ const done = async function (continuous_idx) {
35704
+ // const do_callback = async function ($div) {
35705
+ // // if ($root_container.data().xuData.progress_bar_circle) {
35706
+ // // setTimeout(function () {
35707
+ // // $.each(
35708
+ // // $root_container.data().xuData.progress_bar_circle,
35709
+ // // function (key, val) {
35710
+ // // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
35711
+ // // }
35712
+ // // );
35713
+ // // }, 2000);
35714
+ // // }
35715
+
35716
+ // if (paramsP.screenInfo.properties?.rtl) {
35717
+ // $div_content.attr('dir', 'rtl');
35718
+ // }
35788
35719
 
35789
- // return $container;
35790
- // };
35720
+ // return $div;
35721
+ // };
35722
+ await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35791
35723
 
35792
- // var $wrapper = $('<div>');
35793
- // $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, null, $wrapper, '');
35724
+ return await render_screen_type($div);
35725
+ };
35794
35726
 
35795
- // let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div.clone(true), true, undefined, refreshed_ds);
35796
- // if (ret.abort) {
35797
- // // render N
35798
- // return (ret.$new_div = $('<template>').append($div));
35799
- // }
35727
+ if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
35728
+ close_all_modals();
35729
+ }
35800
35730
 
35801
- // let $ret_panel_div = ret.$new_div;
35731
+ const empty_result = async function () {
35732
+ // var content = prop.empty_result_content || '';
35733
+
35734
+ // var res = await func.expression.get(
35735
+ // SESSION_ID,
35736
+ // content, // prop["xu-exp:empty_result_content"],
35737
+ // paramsP.dsSessionP,
35738
+ // 'empty_result_content_EXP',
35739
+ // _ds.currentRecordId,
35740
+ // );
35741
+ // content = res.result;
35742
+
35743
+ // let empty_result_node = {
35744
+ // type: 'element',
35745
+ // id: crypto.randomUUID(),
35746
+ // content,
35747
+ // // : content || (typeof content === "undefined" && "Empty results"),
35748
+ // tagName: 'div',
35749
+ // attributes: {},
35750
+ // children: [],
35751
+ // };
35802
35752
 
35803
- // if (!$ret_panel_div?.children()?.length) {
35804
- // ////// render default children tree
35805
- // if (nodeP.children.length) {
35806
- // $ret_panel_div = await func.UI.screen.render_ui_tree(SESSION_ID, $container, nodeP.children[0], parent_infoP, paramsP, jobNoP, null, 0, null, nodeP, null, $root_container);
35807
- // }
35808
- // }
35753
+ // const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $container, empty_result_node, parent_infoP, paramsP, jobNoP, null, 0, null, nodeP, null, $root_container);
35754
+ await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
35755
+ return await done(null);
35756
+ };
35757
+ var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
35809
35758
 
35810
- // let ret_done = await done($ret_panel_div);
35759
+ var continuous_idx = null;
35811
35760
 
35812
- // return ret_done;
35813
- // },
35814
- // };
35761
+ if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
35762
+ return await empty_result();
35763
+ }
35815
35764
 
35816
- // const draw_html_element_org = async function (element) {
35817
- // const done = async function (ret = {}) {
35818
- // return $div;
35819
- // };
35820
- // if (!element || element === 'script') return await done();
35821
- // let str = '';
35765
+ var i = 0;
35766
+ for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
35767
+ var node = JSON.parse(JSON.stringify(nodeP));
35822
35768
 
35823
- // var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
35769
+ _ds.currentRecordId = val._ROWID;
35770
+ const ret = await iterate_child($div, node, { continuous_idx }, $root_container);
35824
35771
 
35825
- // $div.hover(
35826
- // function (e) {
35827
- // hover_in($div, e);
35828
- // },
35829
- // function (e) {
35830
- // hover_out();
35831
- // },
35832
- // );
35833
- // if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35834
- // $div.on('click contextmenu', function (e) {
35835
- // hover_in($div, e);
35836
- // });
35837
- // }
35772
+ if (_.isEmpty($container.data().xuAttributes)) {
35773
+ await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
35774
+ }
35775
+ }
35838
35776
 
35839
- // // let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $container, nodeP, $div, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
35840
- // let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
35841
- // if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
35842
- // return await done(ret);
35843
- // }
35844
- // // check if iterator made to prevent children render
35845
-
35846
- // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
35847
- // // const xu_viewport = async function () {
35848
- // // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
35849
- // // const container_id = $container.attr('xu-ui-id');
35850
- // // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
35851
- // // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
35852
- // // await iterate_child($div, nodeP, parent_infoP, $root_container);
35853
- // // } else {
35854
- // // $div.remove();
35855
- // // }
35856
- // // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
35857
-
35858
- // // // if (!$div.children().length) {
35859
- // // // // render the first element to determine height
35860
- // // // await iterate_child($div, nodeP, parent_infoP, $root_container);
35861
- // // // // hover_in($div);
35862
- // // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
35863
- // // // } else {
35864
- // // // }
35865
- // // };
35866
- // const xu_viewport = function () {
35867
- // const observer_inViewport = new IntersectionObserver(
35868
- // function (entries) {
35869
- // entries.forEach((entry) => {
35870
- // if (entry.isIntersecting) {
35871
- // $(entry.target).trigger('inViewport');
35872
-
35873
- // // Optional: stop observing once triggered
35874
- // observer_inViewport.unobserve(entry.target);
35875
- // }
35876
- // });
35877
- // },
35878
- // {
35879
- // threshold: 0.1, // Trigger when 10% of element is visible
35880
- // },
35881
- // );
35777
+ return await done(continuous_idx);
35778
+ },
35779
+ [`xu-panel`]: async function () {
35780
+ const done = async function ($new_div) {
35781
+ if (!$container.data()?.xuData?.paramsP) {
35782
+ return $container;
35783
+ }
35784
+ var $div_items = $div.data().xuData.node.children;
35882
35785
 
35883
- // const observer_outViewport = new IntersectionObserver(
35884
- // function (entries) {
35885
- // entries.forEach((entry) => {
35886
- // if (!entry.isIntersecting) {
35887
- // // Element is OUT of viewport - trigger custom event
35888
- // $(entry.target).trigger('outViewport');
35786
+ await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
35889
35787
 
35890
- // // Optional: stop observing once triggered
35891
- // // observer_outViewport.unobserve(entry.target);
35892
- // }
35893
- // });
35894
- // },
35895
- // {
35896
- // threshold: 0, // Trigger when element is completely out of view
35897
- // },
35898
- // );
35788
+ // TO FIX should be timeout
35789
+ $container.data().xuData.node.children = $div_items;
35899
35790
 
35900
- // let ui_job_id;
35901
- // $div.on('inViewport', function () {
35902
- // if ($div.children().length) {
35903
- // $div.removeClass('skeleton');
35904
- // return;
35905
- // }
35791
+ return $container;
35792
+ };
35906
35793
 
35907
- // // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
35908
- // // $div[0].style.removeProperty('height');
35909
- // // $div.removeClass('skeleton');
35910
- // // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
35911
- // // } else {
35912
- // hover_in($div);
35913
- // ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container }, null, null, paramsP.dsSessionP);
35914
- // // }
35915
- // observer_outViewport.observe($div[0]);
35916
- // });
35794
+ var $wrapper = $('<div>');
35795
+ $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, null, $wrapper, '');
35917
35796
 
35918
- // $div.on('outViewport', function () {
35919
- // func.UI.worker.delete_job(SESSION_ID, ui_job_id);
35797
+ let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div.clone(true), true, undefined, refreshed_ds);
35798
+ if (ret.abort) {
35799
+ // render N
35800
+ return (ret.$new_div = $('<template>').append($div));
35801
+ }
35920
35802
 
35921
- // if ($div.children().length) {
35922
- // // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
35923
- // $div.empty();
35924
- // const height = $div?.data()?.xuData?.viewport_height || 10;
35925
- // if (typeof height !== 'undefined') {
35926
- // $div.css('height', height);
35927
- // }
35928
- // }
35929
- // // $div.addClass('skeleton');
35930
- // observer_inViewport.observe($div[0]);
35931
- // });
35932
- // $div.addClass('skeleton');
35933
- // observer_inViewport.observe($div[0]);
35934
- // };
35935
- // xu_viewport();
35936
- // } else {
35937
- // await iterate_child($div, nodeP, parent_infoP, $root_container);
35938
- // }
35803
+ let $ret_panel_div = ret.$new_div;
35939
35804
 
35940
- // // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
35941
- // return await done(ret);
35942
- // };
35805
+ if (!$ret_panel_div?.children()?.length) {
35806
+ ////// render default children tree
35807
+ if (nodeP.children.length) {
35808
+ $ret_panel_div = await func.UI.screen.render_ui_tree(SESSION_ID, $container, nodeP.children[0], parent_infoP, paramsP, jobNoP, null, 0, null, nodeP, null, $root_container);
35809
+ }
35810
+ }
35943
35811
 
35944
- // const draw_html_element = async function (element) {
35945
- // const done = async function (ret = {}) {
35946
- // const xu_ui_id = $div.attr('xu-ui-id');
35947
- // $div.removeClass('display_none');
35948
- // if (ret.has_xu_exp_render_attribute) {
35949
- // // $div.css('display', 'unset');
35950
-
35951
- // const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($div.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
35952
- // const _$div = $div.clone(true);
35953
- // UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: _$div, paramsP, data: _$div.data() };
35954
- // nodeP.xu_render_xu_ui_id = xu_ui_id;
35955
- // nodeP.xu_render_cache_id = xu_render_cache_id;
35956
-
35957
- // if (ret.xu_render_background_processing) {
35958
- // temp_$div.remove();
35959
- // // $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
35960
- // return $div;
35961
- // } else {
35962
- // // $div.css('display', 'unset');
35963
- // temp_$div.replaceWith($div);
35964
- // return $div;
35965
- // }
35966
- // } else {
35967
- // if (ret.has_xu_render_attribute) {
35968
- // temp_$div.remove();
35969
- // return $div;
35970
- // }
35971
- // // $div.css('display', 'unset');
35972
- // temp_$div.replaceWith($div);
35973
- // return $div;
35974
- // }
35975
- // };
35976
- // if (!element || element === 'script') return await done();
35977
- // let str = '';
35812
+ let ret_done = await done($ret_panel_div);
35978
35813
 
35979
- // var temp_$div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str, true);
35814
+ return ret_done;
35815
+ },
35816
+ };
35980
35817
 
35981
- // let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
35982
- // let $div = temp_$div.clone(true);
35818
+ const draw_html_element_org = async function (element) {
35819
+ const done = async function (ret = {}) {
35820
+ return $div;
35821
+ };
35822
+ if (!element || element === 'script') return await done();
35823
+ let str = '';
35983
35824
 
35984
- // // $div.css('display', 'none');
35825
+ var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
35985
35826
 
35986
- // $div.hover(
35987
- // function (e) {
35988
- // hover_in($div, e);
35989
- // },
35990
- // function (e) {
35991
- // hover_out();
35992
- // },
35993
- // );
35994
- // if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35995
- // $div.on('click contextmenu', function (e) {
35996
- // hover_in($div, e);
35997
- // });
35998
- // }
35827
+ $div.hover(
35828
+ function (e) {
35829
+ hover_in($div, e);
35830
+ },
35831
+ function (e) {
35832
+ hover_out();
35833
+ },
35834
+ );
35835
+ if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35836
+ $div.on('click contextmenu', function (e) {
35837
+ hover_in($div, e);
35838
+ });
35839
+ }
35999
35840
 
36000
- // let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, temp_$container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
36001
- // if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
36002
- // return await done(ret);
36003
- // }
36004
- // // check if iterator made to prevent children render
36005
-
36006
- // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36007
- // // const xu_viewport = async function () {
36008
- // // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36009
- // // const container_id = $container.attr('xu-ui-id');
36010
- // // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36011
- // // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36012
- // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36013
- // // } else {
36014
- // // $div.remove();
36015
- // // }
36016
- // // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36017
-
36018
- // // // if (!$div.children().length) {
36019
- // // // // render the first element to determine height
36020
- // // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36021
- // // // // hover_in($div);
36022
- // // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
36023
- // // // } else {
36024
- // // // }
36025
- // // };
36026
- // const xu_viewport = function () {
36027
- // const observer_inViewport = new IntersectionObserver(
36028
- // function (entries) {
36029
- // entries.forEach((entry) => {
36030
- // if (entry.isIntersecting) {
36031
- // $(entry.target).trigger('inViewport');
36032
-
36033
- // // Optional: stop observing once triggered
36034
- // observer_inViewport.unobserve(entry.target);
36035
- // }
36036
- // });
36037
- // },
36038
- // {
36039
- // threshold: 0.1, // Trigger when 10% of element is visible
36040
- // },
36041
- // );
35841
+ // let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $container, nodeP, $div, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
35842
+ let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
35843
+ if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
35844
+ return await done(ret);
35845
+ }
35846
+ // check if iterator made to prevent children render
35847
+
35848
+ if (nodeP?.attributes?.['xu-viewport'] == 'true') {
35849
+ // const xu_viewport = async function () {
35850
+ // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
35851
+ // const container_id = $container.attr('xu-ui-id');
35852
+ // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
35853
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
35854
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
35855
+ // } else {
35856
+ // $div.remove();
35857
+ // }
35858
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
35859
+
35860
+ // // if (!$div.children().length) {
35861
+ // // // render the first element to determine height
35862
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
35863
+ // // // hover_in($div);
35864
+ // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
35865
+ // // } else {
35866
+ // // }
35867
+ // };
35868
+ const xu_viewport = function () {
35869
+ const observer_inViewport = new IntersectionObserver(
35870
+ function (entries) {
35871
+ entries.forEach((entry) => {
35872
+ if (entry.isIntersecting) {
35873
+ $(entry.target).trigger('inViewport');
36042
35874
 
36043
- // const observer_outViewport = new IntersectionObserver(
36044
- // function (entries) {
36045
- // entries.forEach((entry) => {
36046
- // if (!entry.isIntersecting) {
36047
- // // Element is OUT of viewport - trigger custom event
36048
- // $(entry.target).trigger('outViewport');
35875
+ // Optional: stop observing once triggered
35876
+ observer_inViewport.unobserve(entry.target);
35877
+ }
35878
+ });
35879
+ },
35880
+ {
35881
+ threshold: 0.1, // Trigger when 10% of element is visible
35882
+ },
35883
+ );
36049
35884
 
36050
- // // Optional: stop observing once triggered
36051
- // // observer_outViewport.unobserve(entry.target);
36052
- // }
36053
- // });
36054
- // },
36055
- // {
36056
- // threshold: 0, // Trigger when element is completely out of view
36057
- // },
36058
- // );
35885
+ const observer_outViewport = new IntersectionObserver(
35886
+ function (entries) {
35887
+ entries.forEach((entry) => {
35888
+ if (!entry.isIntersecting) {
35889
+ // Element is OUT of viewport - trigger custom event
35890
+ $(entry.target).trigger('outViewport');
36059
35891
 
36060
- // let ui_job_id;
36061
- // $div.on('inViewport', function () {
36062
- // if ($div.children().length) {
36063
- // $div.removeClass('skeleton');
36064
- // return;
36065
- // }
35892
+ // Optional: stop observing once triggered
35893
+ // observer_outViewport.unobserve(entry.target);
35894
+ }
35895
+ });
35896
+ },
35897
+ {
35898
+ threshold: 0, // Trigger when element is completely out of view
35899
+ },
35900
+ );
36066
35901
 
36067
- // // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
36068
- // // $div[0].style.removeProperty('height');
36069
- // // $div.removeClass('skeleton');
36070
- // // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
36071
- // // } else {
36072
- // hover_in($div);
36073
- // ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, temp_$container }, null, null, paramsP.dsSessionP);
36074
- // // }
36075
- // observer_outViewport.observe($div[0]);
36076
- // });
35902
+ let ui_job_id;
35903
+ $div.on('inViewport', function () {
35904
+ if ($div.children().length) {
35905
+ $div.removeClass('skeleton');
35906
+ return;
35907
+ }
36077
35908
 
36078
- // $div.on('outViewport', function () {
36079
- // func.UI.worker.delete_job(SESSION_ID, ui_job_id);
35909
+ // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
35910
+ // $div[0].style.removeProperty('height');
35911
+ // $div.removeClass('skeleton');
35912
+ // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
35913
+ // } else {
35914
+ hover_in($div);
35915
+ ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container }, null, null, paramsP.dsSessionP);
35916
+ // }
35917
+ observer_outViewport.observe($div[0]);
35918
+ });
36080
35919
 
36081
- // if ($div.children().length) {
36082
- // // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
36083
- // $div.empty();
36084
- // const height = $div?.data()?.xuData?.viewport_height || 10;
36085
- // if (typeof height !== 'undefined') {
36086
- // $div.css('height', height);
36087
- // }
36088
- // }
36089
- // // $div.addClass('skeleton');
36090
- // observer_inViewport.observe($div[0]);
36091
- // });
36092
- // $div.addClass('skeleton');
36093
- // observer_inViewport.observe($div[0]);
36094
- // };
36095
- // xu_viewport();
36096
- // } else {
36097
- // // if (ret.xu_render_background_processing) {
36098
- // // // let temp_$div = $div.clone(true);
36099
- // // iterate_child($div, nodeP, parent_infoP, $root_container);
36100
- // // } else {
36101
- // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36102
- // // }
36103
- // if (!ret.xu_render_background_processing) {
36104
- // iterate_child($div, nodeP, parent_infoP, $root_container);
36105
- // }
36106
- // }
35920
+ $div.on('outViewport', function () {
35921
+ func.UI.worker.delete_job(SESSION_ID, ui_job_id);
36107
35922
 
36108
- // // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
36109
- // return await done(ret);
36110
- // };
35923
+ if ($div.children().length) {
35924
+ // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
35925
+ $div.empty();
35926
+ const height = $div?.data()?.xuData?.viewport_height || 10;
35927
+ if (typeof height !== 'undefined') {
35928
+ $div.css('height', height);
35929
+ }
35930
+ }
35931
+ // $div.addClass('skeleton');
35932
+ observer_inViewport.observe($div[0]);
35933
+ });
35934
+ $div.addClass('skeleton');
35935
+ observer_inViewport.observe($div[0]);
35936
+ };
35937
+ xu_viewport();
35938
+ } else {
35939
+ await iterate_child($div, nodeP, parent_infoP, $root_container);
35940
+ }
36111
35941
 
36112
- // if (nodeP.content && nodeP.attributes) {
36113
- // nodeP.attributes['xu-content'] = nodeP.content;
36114
- // }
35942
+ // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
35943
+ return await done(ret);
35944
+ };
36115
35945
 
36116
- // if (nodeP.tagName === 'xu-widget') {
36117
- // if (is_skeleton) return;
36118
- // return await fx['widget']();
36119
- // }
36120
- // if (fx[nodeP.tagName]) {
36121
- // return await fx[nodeP.tagName]();
36122
- // }
36123
- // // const xu_viewport = async function () {
36124
- // // const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36125
- // // const container_id = $container.attr('xu-ui-id');
36126
- // // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36127
- // // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36128
- // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36129
- // // }
36130
- // // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36131
- // // };
35946
+ const draw_html_element = async function (element) {
35947
+ const done = async function (ret = {}) {
35948
+ const xu_ui_id = $div.attr('xu-ui-id');
35949
+ $div.removeClass('display_none');
35950
+ if (ret.has_xu_exp_render_attribute) {
35951
+ // $div.css('display', 'unset');
36132
35952
 
36133
- // // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36134
- // // return await xu_viewport();
36135
- // // } else {
36136
- // if (!glb.new_xu_render) {
36137
- // return await draw_html_element_org(nodeP.tagName);
36138
- // }
36139
- // return await draw_html_element(nodeP.tagName);
35953
+ const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($div.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
35954
+ const _$div = $div.clone(true);
35955
+ UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: _$div, paramsP, data: _$div.data() };
35956
+ nodeP.xu_render_xu_ui_id = xu_ui_id;
35957
+ nodeP.xu_render_cache_id = xu_render_cache_id;
36140
35958
 
36141
- // // }
36142
- // };
35959
+ if (ret.xu_render_background_processing) {
35960
+ temp_$div.remove();
35961
+ // $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
35962
+ return $div;
35963
+ } else {
35964
+ // $div.css('display', 'unset');
35965
+ temp_$div.replaceWith($div);
35966
+ return $div;
35967
+ }
35968
+ } else {
35969
+ if (ret.has_xu_render_attribute) {
35970
+ temp_$div.remove();
35971
+ return $div;
35972
+ }
35973
+ // $div.css('display', 'unset');
35974
+ temp_$div.replaceWith($div);
35975
+ return $div;
35976
+ }
35977
+ };
35978
+ if (!element || element === 'script') return await done();
35979
+ let str = '';
36143
35980
 
36144
- func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $root_container) {
35981
+ var temp_$div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str, true);
35982
+
35983
+ let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
35984
+ let $div = temp_$div.clone(true);
35985
+
35986
+ // $div.css('display', 'none');
35987
+
35988
+ $div.hover(
35989
+ function (e) {
35990
+ hover_in($div, e);
35991
+ },
35992
+ function (e) {
35993
+ hover_out();
35994
+ },
35995
+ );
35996
+ if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
35997
+ $div.on('click contextmenu', function (e) {
35998
+ hover_in($div, e);
35999
+ });
36000
+ }
36001
+
36002
+ let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, temp_$container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
36003
+ if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
36004
+ return await done(ret);
36005
+ }
36006
+ // check if iterator made to prevent children render
36007
+
36008
+ if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36009
+ // const xu_viewport = async function () {
36010
+ // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36011
+ // const container_id = $container.attr('xu-ui-id');
36012
+ // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36013
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36014
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
36015
+ // } else {
36016
+ // $div.remove();
36017
+ // }
36018
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36019
+
36020
+ // // if (!$div.children().length) {
36021
+ // // // render the first element to determine height
36022
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
36023
+ // // // hover_in($div);
36024
+ // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
36025
+ // // } else {
36026
+ // // }
36027
+ // };
36028
+ const xu_viewport = function () {
36029
+ const observer_inViewport = new IntersectionObserver(
36030
+ function (entries) {
36031
+ entries.forEach((entry) => {
36032
+ if (entry.isIntersecting) {
36033
+ $(entry.target).trigger('inViewport');
36034
+
36035
+ // Optional: stop observing once triggered
36036
+ observer_inViewport.unobserve(entry.target);
36037
+ }
36038
+ });
36039
+ },
36040
+ {
36041
+ threshold: 0.1, // Trigger when 10% of element is visible
36042
+ },
36043
+ );
36044
+
36045
+ const observer_outViewport = new IntersectionObserver(
36046
+ function (entries) {
36047
+ entries.forEach((entry) => {
36048
+ if (!entry.isIntersecting) {
36049
+ // Element is OUT of viewport - trigger custom event
36050
+ $(entry.target).trigger('outViewport');
36051
+
36052
+ // Optional: stop observing once triggered
36053
+ // observer_outViewport.unobserve(entry.target);
36054
+ }
36055
+ });
36056
+ },
36057
+ {
36058
+ threshold: 0, // Trigger when element is completely out of view
36059
+ },
36060
+ );
36061
+
36062
+ let ui_job_id;
36063
+ $div.on('inViewport', function () {
36064
+ if ($div.children().length) {
36065
+ $div.removeClass('skeleton');
36066
+ return;
36067
+ }
36068
+
36069
+ // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
36070
+ // $div[0].style.removeProperty('height');
36071
+ // $div.removeClass('skeleton');
36072
+ // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
36073
+ // } else {
36074
+ hover_in($div);
36075
+ ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, temp_$container }, null, null, paramsP.dsSessionP);
36076
+ // }
36077
+ observer_outViewport.observe($div[0]);
36078
+ });
36079
+
36080
+ $div.on('outViewport', function () {
36081
+ func.UI.worker.delete_job(SESSION_ID, ui_job_id);
36082
+
36083
+ if ($div.children().length) {
36084
+ // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
36085
+ $div.empty();
36086
+ const height = $div?.data()?.xuData?.viewport_height || 10;
36087
+ if (typeof height !== 'undefined') {
36088
+ $div.css('height', height);
36089
+ }
36090
+ }
36091
+ // $div.addClass('skeleton');
36092
+ observer_inViewport.observe($div[0]);
36093
+ });
36094
+ $div.addClass('skeleton');
36095
+ observer_inViewport.observe($div[0]);
36096
+ };
36097
+ xu_viewport();
36098
+ } else {
36099
+ // if (ret.xu_render_background_processing) {
36100
+ // // let temp_$div = $div.clone(true);
36101
+ // iterate_child($div, nodeP, parent_infoP, $root_container);
36102
+ // } else {
36103
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
36104
+ // }
36105
+ if (!ret.xu_render_background_processing) {
36106
+ iterate_child($div, nodeP, parent_infoP, $root_container);
36107
+ }
36108
+ }
36109
+
36110
+ // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
36111
+ return await done(ret);
36112
+ };
36113
+
36114
+ if (nodeP.content && nodeP.attributes) {
36115
+ nodeP.attributes['xu-content'] = nodeP.content;
36116
+ }
36117
+
36118
+ if (nodeP.tagName === 'xu-widget') {
36119
+ if (is_skeleton) return;
36120
+ return await fx['widget']();
36121
+ }
36122
+ if (fx[nodeP.tagName]) {
36123
+ return await fx[nodeP.tagName]();
36124
+ }
36125
+ // const xu_viewport = async function () {
36126
+ // const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
36127
+ // const container_id = $container.attr('xu-ui-id');
36128
+ // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
36129
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
36130
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
36131
+ // }
36132
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
36133
+ // };
36134
+
36135
+ // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
36136
+ // return await xu_viewport();
36137
+ // } else {
36138
+ if (!glb.new_xu_render) {
36139
+ return await draw_html_element_org(nodeP.tagName);
36140
+ }
36141
+ return await draw_html_element(nodeP.tagName);
36142
+
36143
+ // }
36144
+ };
36145
+
36146
+ func.UI.screen.render_ui_tree_bad = async function (SESSION_ID, $container, nodeP, parent_infoP, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $root_container) {
36145
36147
  // Early cache session and datasource
36146
36148
  let _session, _ds;
36147
36149
  if (!is_skeleton) {