@xuda.io/runtime-bundle 1.0.1258 → 1.0.1260

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