@xuda.io/runtime-bundle 1.0.607 → 1.0.609

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.
@@ -27425,40 +27425,40 @@ func.UI.utils.init_ui_framework = async function (SESSION_ID, prog_id) {
27425
27425
  }
27426
27426
  };
27427
27427
  // old
27428
- func.UI.utils.get_panels_from_dom = function (SESSION_ID, ignore_disableAutoRefresh) {
27429
- const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
27430
- var panels_obj = {};
27428
+ // func.UI.utils.get_panels_from_dom = function (SESSION_ID, ignore_disableAutoRefresh) {
27429
+ // const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
27430
+ // var panels_obj = {};
27431
27431
 
27432
- // set panels_obj
27433
- for (const [elem_key, elem_val] of Object.entries($elm)) {
27434
- if (elem_key === 'length') break;
27435
- var $div = $(elem_val);
27436
- let xuData = $div.data().xuData;
27432
+ // // set panels_obj
27433
+ // for (const [elem_key, elem_val] of Object.entries($elm)) {
27434
+ // if (elem_key === 'length') break;
27435
+ // var $div = $(elem_val);
27436
+ // let xuData = $div.data().xuData;
27437
27437
 
27438
- if (!$div.data().xuPanelData) continue;
27438
+ // if (!$div.data().xuPanelData) continue;
27439
27439
 
27440
- let dsSession = xuData.paramsP.dsSessionP;
27441
- var _session = SESSION_OBJ[SESSION_ID];
27442
- let _ds = _session?.DS_GLB[dsSession];
27443
- if (!_ds) continue;
27440
+ // let dsSession = xuData.paramsP.dsSessionP;
27441
+ // var _session = SESSION_OBJ[SESSION_ID];
27442
+ // let _ds = _session?.DS_GLB[dsSession];
27443
+ // if (!_ds) continue;
27444
27444
 
27445
- if (!ignore_disableAutoRefresh && _ds.tree_obj.disableAutoRefresh) {
27446
- continue;
27447
- }
27445
+ // if (!ignore_disableAutoRefresh && _ds.tree_obj.disableAutoRefresh) {
27446
+ // continue;
27447
+ // }
27448
27448
 
27449
- const parent_element_ui_id = $div.data().xuPanelData.parent_element_ui_id;
27450
- if (!panels_obj[parent_element_ui_id]) {
27451
- panels_obj[parent_element_ui_id] = {
27452
- _ds,
27453
- $div,
27454
- ids: [],
27455
- };
27456
- }
27457
- panels_obj[parent_element_ui_id].ids.push($div.attr('xu-ui-id'));
27458
- }
27449
+ // const parent_element_ui_id = $div.data().xuPanelData.parent_element_ui_id;
27450
+ // if (!panels_obj[parent_element_ui_id]) {
27451
+ // panels_obj[parent_element_ui_id] = {
27452
+ // _ds,
27453
+ // $div,
27454
+ // ids: [],
27455
+ // };
27456
+ // }
27457
+ // panels_obj[parent_element_ui_id].ids.push($div.attr('xu-ui-id'));
27458
+ // }
27459
27459
 
27460
- return panels_obj;
27461
- };
27460
+ // return panels_obj;
27461
+ // };
27462
27462
 
27463
27463
  func.UI.utils.get_panels_wrapper_from_dom = async function (SESSION_ID, $xu_embed_container, ignore_disableAutoRefresh) {
27464
27464
  const $elm = func.UI.utils.find_in_element_data('xuPanelWrapper', $(SESSION_OBJ[SESSION_ID].root_element), 'isWrapper');
@@ -31571,7 +31571,7 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31571
31571
  elem_key: _elem_key,
31572
31572
  elem_val: _elem_val,
31573
31573
  fields_arr,
31574
- xu_for_item_id: elem_val?.$elm?.data().nodeid,
31574
+ xu_for_item_id: elem_val?.$elm?.data().xuData.nodeid,
31575
31575
  };
31576
31576
  await func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'execute_xu_for', obj, new_job, _elem_val.$elm, _elem_val.$elm.data().xuData.paramsP.dsSessionP);
31577
31577
 
@@ -31600,31 +31600,6 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31600
31600
  const _elem_val = { attributes: [], $elm: _$elem };
31601
31601
  if (!_$elem?.length) continue;
31602
31602
 
31603
- // if (!_$elem?.length) {
31604
- // // xu-for may exist in the panel root
31605
- // if (!panel_wrapper_element_ui_id) continue;
31606
-
31607
- // $.each(item.attributes, function (key, val) {
31608
- // _elem_val.attributes.push(key);
31609
- // });
31610
- // // _$elem = $(`[xu-ui-id="${panel_wrapper_element}"]`);
31611
- // await func.UI.worker.add_to_queue(
31612
- // SESSION_ID,
31613
- // 'gui event',
31614
- // 'execute_xu_for',
31615
- // {
31616
- // ui_type: _elem_val.$elm.data().xuData.ui_type,
31617
- // SESSION_ID,
31618
- // elem_key: _elem_key,
31619
- // elem_val: _elem_val,
31620
- // fields_arr,
31621
- // },
31622
- // new_job,
31623
- // _elem_val.$elm,
31624
- // _elem_val.$elm.data().xuData.paramsP.dsSessionP,
31625
- // );
31626
- // }
31627
-
31628
31603
  if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
31629
31604
 
31630
31605
  $.each(_$elem.data()?.xuAttributes, function (key, val) {
@@ -31662,7 +31637,6 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31662
31637
 
31663
31638
  const $xu_embed_container = $('.xu_embed_container');
31664
31639
  const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $xu_embed_container, true);
31665
- // let inviable_panels_obj = {};
31666
31640
 
31667
31641
  for await (const field_id of fields_arr) {
31668
31642
  // run root
@@ -31670,29 +31644,12 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31670
31644
  const progUi = $xu_embed_container?.data()?.xuData?.screenInfo?.progUi;
31671
31645
  if (progUi) {
31672
31646
  await iterate_field_in_progUi(progUi, field_id);
31673
- // // find invisible panels
31674
- // const inviable_panels_arr = func.UI.find_field_in_progUi_attributes(progUi, field_id, null, 'xu-panel');
31675
- // console.log('inviable_panels_arr', inviable_panels_arr);
31676
- // let prog_id = elm_node?.attributes?.program;
31677
- // const exp = elm_node?.attributes?.['xu-exp:program'];
31678
- // if (exp) {
31679
- // let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
31680
- // prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
31681
- // inviable_panels_obj[elm_node.id] = { prog_id };
31682
- // }
31683
31647
  }
31684
31648
  }
31685
31649
  // run panels
31686
31650
  for await (const [panel_wrapper_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31687
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val.prog_id);
31688
31651
  await iterate_field_in_progUi(panel_val.progUi, field_id);
31689
31652
  }
31690
-
31691
- // // run invisible panels
31692
- // for await (const [parent_element_ui_id, panel_val] of Object.entries(inviable_panels_obj)) {
31693
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val.prog_id);
31694
- // await iterate_field_in_progUi(prog_doc.progUi, field_id);
31695
- // }
31696
31653
  }
31697
31654
 
31698
31655
  func.events.delete_job(SESSION_ID, jobNoP);
@@ -31710,9 +31667,6 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31710
31667
 
31711
31668
  var found, refresh_reason, refresh_details;
31712
31669
  if (fields_changed_arr) {
31713
- // if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
31714
- // continue;
31715
- // }
31716
31670
  if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
31717
31671
  continue;
31718
31672
  }
@@ -31813,43 +31767,43 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31813
31767
  if (_.isEmpty(wrapper_data)) continue;
31814
31768
 
31815
31769
  try {
31816
- // const panelDivData = panel_val.$panel_div.data().xuPanelWrapper.panelDivData;
31817
31770
  const ts = Date.now();
31818
31771
  // remove old panel content
31819
31772
  $.each(panel_val.ids, async function (key, val) {
31820
31773
  $("[xu-ui-id='" + val + "']")
31821
31774
  .attr('xu-ui-id', val + ts)
31822
31775
  .removeData();
31823
- // .css('filter', 'blur(1px)');
31824
31776
  });
31825
31777
 
31826
31778
  let refreshed_ds;
31827
31779
  // check if ds exist and deleted by garbage collector
31828
31780
 
31829
- // const _session = SESSION_OBJ[SESSION_ID];
31830
31781
  if (_session.DS_GLB[panel_val._ds.dsSession]) {
31831
31782
  refreshed_ds = panel_val._ds.dsSession;
31832
31783
  }
31784
+ for await (item of wrapper_data.xuData.node_org.children) {
31785
+ if (item.tagName !== 'xu-render') continue;
31833
31786
 
31834
- const new_$div = await func.UI.screen.render_ui_tree(
31835
- SESSION_ID,
31836
- $div_elm, // the wrapper
31837
- _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
31838
- {},
31839
- wrapper_data.xuData.paramsP, // the wrapper params
31840
- null,
31841
- null,
31842
- wrapper_data.xuData.key, // the wrapper key
31843
- refreshed_ds, // the refreshed_ds
31844
- wrapper_data.xuData.parent_node, // the wrapper parent node
31845
- null,
31846
- wrapper_data.xuData.$root_container, // the wrapper root container
31847
- );
31787
+ const new_$div = await func.UI.screen.render_ui_tree(
31788
+ SESSION_ID,
31789
+ $div_elm, // the wrapper
31790
+ _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
31791
+ {},
31792
+ wrapper_data.xuData.paramsP, // the wrapper params
31793
+ null,
31794
+ null,
31795
+ wrapper_data.xuData.key, // the wrapper key
31796
+ refreshed_ds, // the refreshed_ds
31797
+ wrapper_data.xuData.parent_node, // the wrapper parent node
31798
+ null,
31799
+ wrapper_data.xuData.$root_container, // the wrapper root container
31800
+ );
31848
31801
 
31849
- // remove old panel content
31850
- $.each(panel_val.ids, async function (key, val) {
31851
- $("[xu-ui-id='" + val + ts + "']").remove();
31852
- });
31802
+ // remove old panel content
31803
+ $.each(panel_val.ids, async function (key, val) {
31804
+ $("[xu-ui-id='" + val + ts + "']").remove();
31805
+ });
31806
+ }
31853
31807
  } catch (error) {
31854
31808
  debugger;
31855
31809
  }
@@ -31858,86 +31812,86 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31858
31812
  }
31859
31813
  };
31860
31814
 
31861
- func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31862
- const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);
31863
-
31864
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31865
- const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val._ds.prog_id);
31866
- const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31867
-
31868
- var found;
31869
- if (fields_changed_arr) {
31870
- if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
31871
- continue;
31872
- }
31873
- for (const field_id of fields_changed_arr) {
31874
- // get panel attributes
31875
- const _attributes = panel_val?.$div?.data()?.xuPanelData?.node?.attributes || {};
31876
-
31877
- // detect if program changed
31878
- found = _attributes['xu-exp:program']?.includes('@' + field_id);
31879
- if (found) break;
31880
-
31881
- // _attributes holds also info of parameters in code_in: @code
31882
- // search field changed in panel call send parameters exp
31883
- for (const [attr, value] of Object.entries(_attributes)) {
31884
- const pattern = /xu-exp:(\w+)/;
31885
- const match = attr.match(pattern);
31815
+ // func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31816
+ // const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);
31886
31817
 
31887
- if (!match) {
31888
- // continue if attribute is not expression
31889
- continue;
31890
- }
31891
- // code_in
31892
- const parameter_in_field_id = match?.[1];
31893
- // @code
31894
- if (value.includes(field_id)) {
31895
- // search parameter in field in the target program's progDataSource
31896
- found = progDataSource_str?.includes('@' + parameter_in_field_id);
31897
- if (found) break;
31818
+ // for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31819
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val._ds.prog_id);
31820
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31898
31821
 
31899
- // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
31900
- found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31901
- if (found) break;
31902
- }
31903
- }
31822
+ // var found;
31823
+ // if (fields_changed_arr) {
31824
+ // if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
31825
+ // continue;
31826
+ // }
31827
+ // for (const field_id of fields_changed_arr) {
31828
+ // // get panel attributes
31829
+ // const _attributes = panel_val?.$div?.data()?.xuPanelData?.node?.attributes || {};
31830
+
31831
+ // // detect if program changed
31832
+ // found = _attributes['xu-exp:program']?.includes('@' + field_id);
31833
+ // if (found) break;
31834
+
31835
+ // // _attributes holds also info of parameters in code_in: @code
31836
+ // // search field changed in panel call send parameters exp
31837
+ // for (const [attr, value] of Object.entries(_attributes)) {
31838
+ // const pattern = /xu-exp:(\w+)/;
31839
+ // const match = attr.match(pattern);
31840
+
31841
+ // if (!match) {
31842
+ // // continue if attribute is not expression
31843
+ // continue;
31844
+ // }
31845
+ // // code_in
31846
+ // const parameter_in_field_id = match?.[1];
31847
+ // // @code
31848
+ // if (value.includes(field_id)) {
31849
+ // // search parameter in field in the target program's progDataSource
31850
+ // found = progDataSource_str?.includes('@' + parameter_in_field_id);
31851
+ // if (found) break;
31852
+
31853
+ // // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
31854
+ // found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31855
+ // if (found) break;
31856
+ // }
31857
+ // }
31904
31858
 
31905
- if (found) break;
31859
+ // if (found) break;
31906
31860
 
31907
- // search field changed in the target program's progDataSource // @code
31908
- found = progDataSource_str?.includes('@' + field_id);
31909
- if (found) break;
31910
- }
31911
- }
31861
+ // // search field changed in the target program's progDataSource // @code
31862
+ // found = progDataSource_str?.includes('@' + field_id);
31863
+ // if (found) break;
31864
+ // }
31865
+ // }
31912
31866
 
31913
- if (datasource_changed) {
31914
- if (panel_val._ds.dsSession == datasource_changed) {
31915
- found = true;
31916
- }
31917
- }
31918
- if (found) {
31919
- var $div_elm = panel_val.$div
31920
- .parent()
31921
- .parent()
31922
- .find("[xu-ui-id='" + parent_element_ui_id + "']");
31867
+ // if (datasource_changed) {
31868
+ // if (panel_val._ds.dsSession == datasource_changed) {
31869
+ // found = true;
31870
+ // }
31871
+ // }
31872
+ // if (found) {
31873
+ // var $div_elm = panel_val.$div
31874
+ // .parent()
31875
+ // .parent()
31876
+ // .find("[xu-ui-id='" + parent_element_ui_id + "']");
31923
31877
 
31924
- // restore original panel
31925
- try {
31926
- // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
31878
+ // // restore original panel
31879
+ // try {
31880
+ // // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
31927
31881
 
31928
- const new_$div = await func.UI.screen.render_ui_tree(SESSION_ID, $div_elm, _.cloneDeep(panel_val.$div.data().xuPanelData.node), {}, $div_elm.data().xuData.paramsP, null, null, $div_elm.data().xuData.key, null, $div_elm.data().xuData.parent_node, null, $div_elm.data().xuData.$root_container);
31882
+ // const new_$div = await func.UI.screen.render_ui_tree(SESSION_ID, $div_elm, _.cloneDeep(panel_val.$div.data().xuPanelData.node), {}, $div_elm.data().xuData.paramsP, null, null, $div_elm.data().xuData.key, null, $div_elm.data().xuData.parent_node, null, $div_elm.data().xuData.$root_container);
31929
31883
 
31930
- // remove old panel content
31931
- $.each(panel_val.ids, async function (key, val) {
31932
- $("[xu-ui-id='" + val + "']").remove();
31933
- });
31934
- } catch (error) {
31935
- debugger;
31936
- }
31937
- break;
31938
- }
31939
- }
31940
- };
31884
+ // // remove old panel content
31885
+ // $.each(panel_val.ids, async function (key, val) {
31886
+ // $("[xu-ui-id='" + val + "']").remove();
31887
+ // });
31888
+ // } catch (error) {
31889
+ // debugger;
31890
+ // }
31891
+ // break;
31892
+ // }
31893
+ // }
31894
+ // };
31941
31895
 
31942
31896
  // const get_params_obj = async function (SESSION_ID, prog_id, parameters_obj_inP) {
31943
31897
  // const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
@@ -32948,1422 +32902,7 @@ func.UI.screen.set_attributes_new = async function (SESSION_ID, is_skeleton, $ro
32948
32902
  },
32949
32903
  props: {},
32950
32904
  },
32951
- ],
32952
- },
32953
- ];
32954
- delete nodeP.attributes[key];
32955
- }
32956
- }
32957
-
32958
- for (let [key, val] of Object.entries(nodeP.attributes)) {
32959
- // FIX STATIC DEFAULTS
32960
- val = func.UI.screen.fix_val_defaults(key, val);
32961
-
32962
- // REMOVE UNDEFINED or NULL ATTRIBUTES
32963
- if (typeof val === 'undefined' || val === null) {
32964
- delete nodeP.attributes[key];
32965
- }
32966
-
32967
- // REMOVE ATTRIBUTES WITH EMPTY VALUES
32968
- if (glb.solid_attributes.includes(key) && !val) {
32969
- delete nodeP.attributes[key];
32970
- }
32971
- }
32972
-
32973
- // BEFORE
32974
-
32975
- for await (const [key, attr] of Object.entries(glb.run_xu_before)) {
32976
- if (_ret.abort) break;
32977
- if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) {
32978
- continue;
32979
- }
32980
-
32981
- if (!nodeP.attributes || !nodeP.attributes[attr] & !nodeP.attributes[`xu-exp:${attr}`]) {
32982
- continue;
32983
- }
32984
-
32985
- let ret = await func.UI.screen.execute_xu_functions(
32986
- SESSION_ID,
32987
- is_skeleton,
32988
- $root_container,
32989
- nodeP,
32990
- $container,
32991
- paramsP,
32992
- parent_infoP,
32993
- jobNoP,
32994
- keyP,
32995
- parent_nodeP,
32996
- attr,
32997
- $elm,
32998
- {
32999
- key: attr,
33000
- // value: _value,
33001
- value: (await get_xuExp(attr)) || nodeP.attributes[attr],
33002
- },
33003
- is_init,
33004
- );
33005
- _ret = _.assignIn(_ret, ret);
33006
- }
33007
-
33008
- // ALL
33009
-
33010
- for await (const [key, val] of Object.entries(nodeP.attributes)) {
33011
- if (_ret.abort) break;
33012
- if (glb.html5_events_handler.includes(key) || execute_attributes.includes(key)) {
33013
- continue;
33014
- }
33015
-
33016
- const new_key = key.split(':')[0]; // break expression
33017
- if (
33018
- nodeP.tagName !== 'xu-panel' &&
33019
- nodeP.tagName !== 'xu-teleport' && // nodeP.tagName.substr(0, 3) !== "xu-" &&
33020
- (new_key.substr(0, 2) !== 'xu' || new_key.substr(2, 1) !== '-')
33021
- ) {
33022
- // handle common html attributes
33023
- try {
33024
- $elm.get(0).setAttribute(key, val);
33025
- } catch (err) {
33026
- console.error(err.message);
33027
- }
33028
-
33029
- continue;
33030
- }
33031
- // handle xu attributes
33032
- try {
33033
- $elm.data().xuAttributes[key] = val;
33034
- } catch (error) {
33035
- debugger;
33036
- console.error(error);
33037
- }
33038
-
33039
- if (new_key === 'xu-exp' || nodeP.attributes['xu-exp:' + new_key] || glb.run_xu_before.includes(new_key) || glb.run_xu_after.includes(new_key)) {
33040
- continue;
33041
- }
33042
-
33043
- if (new_key === 'xu-on') {
33044
- let ret = await func.UI.screen.execute_xu_functions(
33045
- SESSION_ID,
33046
- is_skeleton,
33047
- $root_container,
33048
- nodeP,
33049
- $container,
33050
- paramsP,
33051
- parent_infoP,
33052
- jobNoP,
33053
- keyP,
33054
- parent_nodeP,
33055
- 'xu-on',
33056
- $elm,
33057
- {
33058
- key: key,
33059
- value: (await get_xuExp(new_key)) || val,
33060
- },
33061
- is_init,
33062
- refreshed_ds,
33063
- );
33064
- _ret = _.assignIn(_ret, ret);
33065
- continue;
33066
- }
33067
-
33068
- let ret = await func.UI.screen.execute_xu_functions(
33069
- SESSION_ID,
33070
- is_skeleton,
33071
- $root_container,
33072
- nodeP,
33073
- $container,
33074
- paramsP,
33075
- parent_infoP,
33076
- jobNoP,
33077
- keyP,
33078
- parent_nodeP,
33079
- new_key,
33080
- $elm,
33081
- {
33082
- key: key,
33083
- value: (await get_xuExp(new_key)) || val,
33084
- },
33085
- is_init,
33086
- refreshed_ds,
33087
- );
33088
-
33089
- _ret = _.assignIn(_ret, ret);
33090
- }
33091
-
33092
- // EXP for
33093
-
33094
- for await (const [key, val] of Object.entries(nodeP.attributes)) {
33095
- if (_ret.abort) break;
33096
-
33097
- const attr = key.split('xu-exp:')[1];
33098
-
33099
- if (!attr) {
33100
- continue;
33101
- }
33102
-
33103
- if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
33104
-
33105
- if (done_exp.includes(key)) {
33106
- continue;
33107
- }
33108
- let ret = await func.UI.screen.execute_xu_functions(
33109
- SESSION_ID,
33110
- is_skeleton,
33111
- $root_container,
33112
- nodeP,
33113
- $container,
33114
- paramsP,
33115
- parent_infoP,
33116
- jobNoP,
33117
- keyP,
33118
- parent_nodeP,
33119
- 'xu-exp',
33120
- $elm,
33121
- {
33122
- key: attr,
33123
- value: val,
33124
- },
33125
- true,
33126
- refreshed_ds,
33127
- );
33128
- _ret = _.assignIn(_ret, ret);
33129
- }
33130
-
33131
- // AFTER
33132
-
33133
- for await (const [key, attr] of Object.entries(glb.run_xu_after)) {
33134
- if (glb.html5_events_handler.includes(attr) || execute_attributes.includes(attr)) continue;
33135
-
33136
- if (!nodeP.attributes || !nodeP.attributes[attr] & !nodeP.attributes[`xu-exp:${attr}`]) continue;
33137
-
33138
- let ret = await func.UI.screen.execute_xu_functions(
33139
- SESSION_ID,
33140
- is_skeleton,
33141
- $root_container,
33142
- nodeP,
33143
- $container,
33144
- paramsP,
33145
- parent_infoP,
33146
- jobNoP,
33147
- keyP,
33148
- parent_nodeP,
33149
- attr,
33150
- $elm,
33151
- {
33152
- key: attr,
33153
- value: (await get_xuExp(attr)) || nodeP.attributes[attr],
33154
- },
33155
- is_init,
33156
- refreshed_ds,
33157
- );
33158
- _ret = _.assignIn(_ret, ret);
33159
- }
33160
-
33161
- // REGISTER EVENTS ATTRIBUTES
33162
-
33163
- for await (const [key, val] of Object.entries(nodeP.attributes)) {
33164
- if (!glb.html5_events_handler.includes(key)) break;
33165
- $elm.attr(key, await get_xuExp(key)) || val;
33166
- }
33167
-
33168
- return _ret;
33169
- };
33170
-
33171
- func.UI.screen.panel_post_render_handler = async function (
33172
- SESSION_ID,
33173
- $container, // the parent program container
33174
- $wrapper, // the wrapper element contains the rendered panel elements e.g: xu-single-view
33175
- nodeP, // the xu-panel node
33176
- $panel_div, // the panel div
33177
- jobNoP,
33178
- ) {
33179
- const _container_ds = SESSION_OBJ[SESSION_ID].DS_GLB[$container.data().xuData.paramsP.dsSessionP];
33180
- const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[$wrapper.data().xuData.paramsP.dsSessionP];
33181
- const find_old_panels_elements = function () {
33182
- return func.UI.utils.find_in_element_data('xuPanelData', $container.parent(), 'xu-ui-id', $container.data()?.xuPanelData?.xu_panel_xu_ui_id);
33183
- };
33184
- var $old_panel_div = find_old_panels_elements();
33185
- const set_xuPanelData_to_the_new_rendered_items = () => {
33186
- $container.data().xuPanelWrapper = { isWrapper: true, panelXuAttributes: _.clone($wrapper.data().xuAttributes), panelDivData: _.clone($wrapper.data()) };
33187
- $container.attr('xu-panel-wrapper-id', $wrapper.attr('xu-ui-id'));
33188
- $.each($wrapper.children(), function (key, val) {
33189
- if (!$(val).data().xuPanelData) {
33190
- $(val).data().xuPanelData = {};
33191
- }
33192
- $(val).data().xuPanelData.parent_element_ui_id = $old_panel_div?.length ? $container.parent().data().xuData.ui_id : $container.data().xuData.ui_id;
33193
-
33194
- $(val).data().xuPanelData.xu_panel_xu_ui_id = (nodeP.xu_tree_id || nodeP.id) + '-' + _container_ds?.currentRecordId;
33195
- $(val).data().xuPanelData.node = nodeP;
33196
- $(val).data().xuPanelData.$panel_div = $panel_div.clone(true);
33197
- });
33198
- };
33199
- set_xuPanelData_to_the_new_rendered_items();
33200
-
33201
- if ($old_panel_div?.length) {
33202
- $($old_panel_div[0]).after($wrapper.children());
33203
- } else {
33204
- $.each($wrapper.children(), function (key, child) {
33205
- $.each($container.children(), function (key, elm) {
33206
- if ($(elm)?.data()?.xuData && $(elm)?.data()?.xuData?.elem_key === $(child)?.data()?.xuData?.elem_key) {
33207
- $(elm).remove();
33208
- }
33209
- });
33210
- $container.append($(child));
33211
- });
33212
- }
33213
-
33214
- if (!$wrapper.data()?.xuData?.dsSession) return;
33215
-
33216
- if ($old_panel_div?.length) {
33217
- $container.parent().data().xuData.paramsP.dsSessionP = _ds.parentDataSourceNo; // set the new ds when panel replaced
33218
- } else {
33219
- $container.data().xuData.paramsP.dsSessionP = _ds.parentDataSourceNo; // set the new ds when panel replaced
33220
- }
33221
-
33222
- if ($old_panel_div?.length) {
33223
- $old_panel_div.remove();
33224
- }
33225
- return jobNoP;
33226
- };
33227
-
33228
- func.UI.screen.create_container = function (SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, classP, elem_propP, div_typeP, $appendToP, attr_str) {
33229
- const _paramsP = _.cloneDeep(paramsP);
33230
- var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_paramsP.dsSessionP];
33231
- var $appendTo = $container;
33232
- if ($appendToP) $appendTo = $appendToP;
33233
- if (!$appendTo || !$appendTo.length) return null; // screen closed or not exist abort build
33234
- var div = 'div';
33235
- if (div_typeP) div = div_typeP;
33236
- var items = [];
33237
- if (nodeP.children)
33238
- items = nodeP.children.map(function (val) {
33239
- return val.xu_tree_id || val.id;
33240
- });
33241
- var currentRecordId = _ds ? _ds.currentRecordId : '';
33242
- var xu_id = (glb.screen_num++).toString();
33243
- xu_id = xu_id += '_' + currentRecordId;
33244
-
33245
- try {
33246
- const key_path = `${$container?.data()?.xuData?.key_path || '0'}-${keyP || '0'}`;
33247
- const elem_key = `${nodeP.xu_tree_id || nodeP.id}-${key_path}-${currentRecordId}`;
33248
- let ui_id = `${nodeP.id}-${elem_key}-${_paramsP?.dsSessionP?.toString() || ''}`; //nodeP.xu_tree_id ||
33249
-
33250
- /////////////////////////////////
33251
-
33252
- var $div;
33253
- if (div === 'svg') {
33254
- const draw_svg = function (element) {
33255
- const get_tag_str = function (element, prop, val) {
33256
- let class_str = '';
33257
- let attr_str = '';
33258
- for (const [key, val] of Object.entries(prop)) {
33259
- if (key.substr(0, 2) !== 'xu') {
33260
- attr_str += ` ${key}="${val}" `;
33261
- }
33262
- }
33263
- if (element === 'svg') {
33264
- return `<${element} ${attr_str} > `;
33265
- }
33266
- let ret = '';
33267
- if (val?.children?.length) {
33268
- ret = iterate_svg(val);
33269
- }
33270
-
33271
- return `<${element} ${class_str} ${attr_str} > ${ret} </${element}>`;
33272
- };
33273
- let svg_str = get_tag_str(element, prop);
33274
- let inner_str = '';
33275
- const iterate_svg = function (node) {
33276
- let ret = '';
33277
- if (node.children) {
33278
- for (let val of node.children) {
33279
- let prop = val.attributes;
33280
- ret += get_tag_str(val.tagName, prop, val);
33281
- }
33282
- }
33283
- return ret;
33284
- };
33285
- inner_str = iterate_svg(nodeP);
33286
-
33287
- $div = $(svg_str + inner_str + '</svg>').appendTo($appendTo);
33288
- };
33289
-
33290
- draw_svg(div_typeP);
33291
- } else {
33292
- $div = $(`<${div} ${attr_str ? attr_str : ''}>`);
33293
- }
33294
- // const svgNS = "http://www.w3.org/2000/svg";
33295
- // // $div = $(document.createElementNS(svgNS, "svg"));
33296
- // $div = $(`<${div} ${attr_str ? attr_str : ""} ${svg_attributes_str}>`);
33297
- // } else {
33298
- // $div = $(`<${div} ${attr_str ? attr_str : ""}>`);
33299
- $div.attr('xu-ui-id', ui_id).data({
33300
- xuData: {
33301
- prog_id: _paramsP.prog_id,
33302
- nodeid: nodeP.id,
33303
- ui_type: nodeP.tagName,
33304
- xu_id,
33305
- recordid: currentRecordId,
33306
- paramsP: _paramsP,
33307
- key: keyP,
33308
- key_path, //:($container?.data()?.xuData?.key || "0") + "-" + (keyP || "0"),
33309
- screenId: _paramsP.screenId,
33310
- parent_container: $container?.attr('id'),
33311
- elem_key,
33312
- properties: prop,
33313
- node: nodeP,
33314
- node_org: _.cloneDeep(nodeP),
33315
- is_panelP: _paramsP.is_panelP,
33316
- ui_id,
33317
- elem_prop: elem_propP,
33318
- debug_info: {
33319
- id: nodeP.id,
33320
- parent_id: $container?.data()?.xuData?.ui_id,
33321
- items: items,
33322
- },
33323
- parent_node: parent_nodeP,
33324
- currentRecordId: currentRecordId,
33325
- $root_container: $root_container,
33326
- parent_element_ui_id: $container?.data()?.xuData?.ui_id,
33327
- },
33328
- xuAttributes: {},
33329
- });
33330
-
33331
- if (div_typeP !== 'svg') {
33332
- $div.appendTo($appendTo);
33333
- }
33334
- } catch (e) {
33335
- console.error(e);
33336
- }
33337
-
33338
- if (parent_infoP?.iterate_info) {
33339
- $div.data().xuData.iterate_info = parent_infoP.iterate_info;
33340
- }
33341
-
33342
- if (classP) $div.addClass(classP);
33343
-
33344
- return $div;
33345
- };
33346
- func.UI.screen.execute_screen_ready_events = async function (SESSION_ID, paramsP, sourceP, $div, jobNoP, $div_objP) {
33347
- var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
33348
- if (!_ds) return;
33349
- var viewEventExec_arr = [];
33350
- const execute_view_events = async function (sourceP) {
33351
- for await (const val of viewEventExec_arr) {
33352
- cond = val.eventInfo.data.enabled;
33353
- if (val.expression) {
33354
- expCond = await func.expression.get(SESSION_ID, val.expression, paramsP.dsSessionP, 'condition', paramsP.rowIdP); // execute expression
33355
- cond = expCond.result;
33356
- }
33357
- if (cond) {
33358
- await func.events.execute(
33359
- SESSION_ID,
33360
- null,
33361
- val.eventId,
33362
- val.triggerId,
33363
- val.eventInfo.data.action,
33364
- val.eventInfo.data.name,
33365
- null,
33366
- null,
33367
- null,
33368
- null,
33369
- val.eventInfo.data.action, //val.eventInfo[4]
33370
- null,
33371
- paramsP.dsSessionP,
33372
- val.eventId,
33373
- sourceP + ' event',
33374
- true,
33375
- null,
33376
- null,
33377
- paramsP.dsSessionP,
33378
- null,
33379
- null,
33380
- val.eventInfo, // val.eventInfo[8],
33381
- null,
33382
- null,
33383
- null,
33384
- _ds.prog_id,
33385
- _ds.nodeId,
33386
- _ds.parentDataSourceNo,
33387
- $div,
33388
- );
33389
-
33390
- // update changed values to screen added 18/09/13
33391
- var fields_to_refresh = [];
33392
- try {
33393
- var current_record_id = _ds.currentRecordId;
33394
- } catch (e) {
33395
- console.error(e);
33396
- }
33397
-
33398
- if (_ds?.data_feed?.form_fields_changed?.[current_record_id]) {
33399
- $.each(_ds.data_feed.form_fields_changed[current_record_id], function (key, val) {
33400
- fields_to_refresh.push(key);
33401
- });
33402
-
33403
- var containerId = _ds.containerId;
33404
- var $container = $('#' + containerId);
33405
- if ($container?.data()?.xuData?.is_mobile_modal || $container?.data()?.xuData?.params?.is_mobile_page) {
33406
- await func.UI.screen.refresh_container(SESSION_ID, 'init', fields_to_refresh, $container, paramsP.dsSessionP, null);
33407
- } else {
33408
- $container.trigger(containerId + '.refresh', ['init', fields_to_refresh]);
33409
- }
33410
-
33411
- if ($div_objP) {
33412
- await func.UI.screen.refresh_container(SESSION_ID, 'init', fields_to_refresh, $div_objP, paramsP.dsSessionP, null);
33413
- }
33414
- }
33415
- }
33416
- continue;
33417
- }
33418
- };
33419
- const get_view_events_count = async function (typeP) {
33420
- const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
33421
- viewEventExec_arr = [];
33422
-
33423
- if (!_prog.progEvents || _.isEmpty(_prog.progEvents)) {
33424
- return 0;
33425
- }
33426
- for await (const event_obj of _prog.progEvents) {
33427
- if (event_obj.data.type !== typeP) continue;
33428
-
33429
- if (_.isEmpty(event_obj.triggers)) continue;
33430
-
33431
- if (event_obj.data.condition) {
33432
- let res = await func.expression.get(SESSION_ID, event_obj.data.condition, paramsP.dsSessionP, 'condition', paramsP.rowIdP, null, null, null, null, event_obj);
33433
- if (!res.result) {
33434
- continue;
33435
- }
33436
- }
33437
-
33438
- for await (const trigger_obj of event_obj.triggers) {
33439
- var expression = undefined;
33440
- var cond = undefined;
33441
- if (!trigger_obj.data.enabled) {
33442
- continue;
33443
- }
33444
- cond = true;
33445
- if (trigger_obj.props.condition) expression = trigger_obj.props.condition;
33446
- var expCond = {};
33447
- if (expression) {
33448
- expCond = await func.expression.get(SESSION_ID, expression, paramsP.dsSessionP, 'condition', paramsP.rowIdP, trigger_obj.data.type); // execute expression
33449
- cond = expCond.result;
33450
- expCond.conditional = true;
33451
- }
33452
-
33453
- if (!trigger_obj.data.action) {
33454
- func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.viewSourceDesc} reason: missing action`, 'E');
33455
- break;
33456
- }
33457
- if (!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) && !trigger_obj.data.name?.prog) {
33458
- func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.viewSourceDesc} reason: missing reference`, 'E');
33459
- break;
33460
- }
33461
-
33462
- viewEventExec_arr.push({
33463
- eventInfo: trigger_obj,
33464
- eventId: event_obj.id,
33465
- triggerId: trigger_obj.id,
33466
- expression: expression,
33467
- });
33468
- }
33469
- }
33470
- return viewEventExec_arr.length;
33471
- };
33472
-
33473
- let count = await get_view_events_count('screen_ready');
33474
- if (!count) return;
33475
- return await execute_view_events(sourceP);
33476
- };
33477
- func.UI.screen.screen_loading_done = async function (SESSION_ID, paramsP, $div, jobNoP) {
33478
- // await
33479
- func.UI.screen.execute_screen_ready_events(SESSION_ID, paramsP, paramsP.screenInfo.properties?.renderType, $div, jobNoP);
33480
- var _session = SESSION_OBJ[SESSION_ID];
33481
- func.events.delete_job(SESSION_ID, jobNoP);
33482
- func.UI.utils.screen_blocker(false, paramsP.prog_id + (paramsP.sourceScreenP ? '_' + paramsP.sourceScreenP : ''));
33483
- if (_session.prog_id === paramsP.prog_id) {
33484
- _session.system_ready = true;
33485
- if (_session.engine_mode === 'live_preview' && STUDIO_PEER_CONN_SEND_METHOD) {
33486
- STUDIO_PEER_CONN_SEND_METHOD({
33487
- service: 'system_ready',
33488
- data: {},
33489
- id: STUDIO_PEER.id,
33490
- source: 'runtime',
33491
- session_id: SESSION_ID,
33492
- app_id: _session.app_id,
33493
- gtp_token: _session.gtp_token,
33494
- app_token: _session.app_token,
33495
- });
33496
- // }
33497
- }
33498
- }
33499
-
33500
- return $div;
33501
- };
33502
-
33503
- 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) {
33504
- if (!is_skeleton) {
33505
- var _session = SESSION_OBJ[SESSION_ID];
33506
- var _ds = _session.DS_GLB[paramsP.dsSessionP];
33507
- }
33508
- var prop;
33509
- try {
33510
- prop = nodeP.attributes;
33511
- } catch (error) {
33512
- // debugger;
33513
- }
33514
-
33515
- var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
33516
-
33517
- var get_element_info = function () {
33518
- var ret = {};
33519
- let currentRecordId = _ds?.currentRecordId || '';
33520
-
33521
- let $div = func.UI.utils.find_in_element_data('xuData', $container.parent(), 'nodeid', nodeP.id);
33522
-
33523
- $.each($div, function (key, val) {
33524
- if ($(val)?.data().xuData?.recordid === currentRecordId && $(val)?.data().xuData?.key === keyP && $(val)?.prop('tagName') !== 'XURENDER') {
33525
- ret = {
33526
- div: $div,
33527
- };
33528
- }
33529
- });
33530
-
33531
- return ret;
33532
- };
33533
-
33534
- const init = async function () {
33535
- var ret = true;
33536
- if (!nodeP) ret = false;
33537
- return ret;
33538
- };
33539
- const debug = function (is_errorP, error_descP) {
33540
- func.utils.debug.log(SESSION_ID, paramsP.prog_id + '_' + nodeP.id_org + '_ui_prop', {
33541
- module: 'gui',
33542
- action: 'init',
33543
- prop: nodeP.id,
33544
- details: error_descP,
33545
- result: null,
33546
- error: is_errorP,
33547
- source: _ds?.tree_obj?.menuName || '',
33548
- fields: null,
33549
- type: null,
33550
- prog_id: paramsP.prog_id,
33551
- dsSession: null,
33552
- });
33553
- };
33554
-
33555
- const open_modal = async function ($div) {
33556
- const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
33557
- var xu_modal_controller = document.querySelector('xu-modal-controller');
33558
- if (!xu_modal_controller) {
33559
- func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
33560
- xu_modal_controller = document.querySelector('xu-modal-controller');
33561
- }
33562
-
33563
- var controller_params = $(xu_modal_controller).data('xuControllerParams');
33564
-
33565
- if (!controller_params) {
33566
- controller_params = {};
33567
- }
33568
-
33569
- var params = {
33570
- menuTitle: paramsP.screenInfo.properties?.menuTitle,
33571
- screenId: paramsP.screenId,
33572
- $dialogDiv: $div.children(),
33573
- $container: $container,
33574
- dsSession: paramsP.dsSessionP,
33575
- };
33576
-
33577
- controller_params[modal_id] = params;
33578
-
33579
- $(xu_modal_controller).data('xuControllerParams', controller_params);
33580
- const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
33581
-
33582
- if (!APP_MODAL_OBJ[modal_id]) {
33583
- const modal = await modalController.create(SESSION_ID, modal_id, paramsP.screenInfo, close_modal);
33584
- APP_MODAL_OBJ[modal_id] = modal;
33585
- } else {
33586
- $(modal_id).empty();
33587
- }
33588
- await modalController.init(SESSION_ID, modal_id);
33589
-
33590
- return $div;
33591
- };
33592
-
33593
- const close_modal = async function (modal_id) {
33594
- delete APP_MODAL_OBJ[modal_id];
33595
- const xu_modal_controller = document.querySelector('xu-modal-controller');
33596
- var params = $(xu_modal_controller).data().xuControllerParams[modal_id];
33597
- if (params && params.$container) {
33598
- await func.UI.screen.validate_exit_events(SESSION_ID, params.$container.data().xuData.paramsP, null);
33599
- func.datasource.clean_all(SESSION_ID, params.dsSession);
33600
- }
33601
- };
33602
-
33603
- const close_all_modals = function () {
33604
- $.each(APP_MODAL_OBJ, function (key, val) {
33605
- if (val) {
33606
- // close_modal(key);
33607
- UI_FRAMEWORK_PLUGIN.modal.close(key);
33608
- }
33609
- });
33610
- };
33611
-
33612
- const open_popover = async function ($div) {
33613
- const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
33614
-
33615
- $(xu_popover_controller).data('xuControllerParams', {
33616
- menuTitle: paramsP.screenInfo.properties?.menuTitle,
33617
- screenId: paramsP.screenId,
33618
- $dialogDiv: $div.children(),
33619
- $container: $container,
33620
- });
33621
- const popover = new UI_FRAMEWORK_PLUGIN.popover(
33622
- SESSION_ID,
33623
- // ELEMENT_CLICK_EVENT,
33624
- // props
33625
- );
33626
- await popover.open(SESSION_ID);
33627
- CURRENT_APP_POPOVER = popover;
33628
-
33629
- return;
33630
- popoverController
33631
- .create({
33632
- component: 'xu-popover-content-' + SESSION_ID,
33633
- event: ELEMENT_CLICK_EVENT,
33634
- translucent: true,
33635
- })
33636
- .then((modal) => {
33637
- modal.present().then(() => {
33638
- CURRENT_APP_POPOVER = modal;
33639
-
33640
- if (callbackP) callbackP($div);
33641
- });
33642
- });
33643
- };
33644
- const iterate_child = async function ($divP, nodeP, parent_infoP, countP, $root_container, before_record_function) {
33645
- if (!is_mobile && nodeP.busy) return;
33646
- nodeP.busy = true;
33647
- const done = async function ($divP) {
33648
- setTimeout(function () {
33649
- nodeP.busy = false;
33650
- }, 1000);
33651
-
33652
- return $divP;
33653
- };
33654
- if (!nodeP || !nodeP.children) {
33655
- return await done($divP);
33656
- }
33657
-
33658
- if (before_record_function) {
33659
- await before_record_function();
33660
- }
33661
- if (nodeP?.children?.length) {
33662
- for await (const [key, val] of Object.entries(nodeP.children)) {
33663
- 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);
33664
- }
33665
- }
33666
- return await done($divP);
33667
- };
33668
-
33669
- const _$ = function ($elm) {
33670
- try {
33671
- const id = $elm.attr('xu-ui-id');
33672
- if (!id) return $elm;
33673
- const $el = $(`[xu-ui-id="${id}"]`); // $("#" + id);
33674
-
33675
- if ($el.length > 1) {
33676
- console.warn('Multiple elements for xu-ui-id: ' + id, $el);
33677
- }
33678
-
33679
- return $($el[0]);
33680
- } catch (e) {
33681
- console.error(e);
33682
- }
33683
- };
33684
-
33685
- const hover_in = function ($div) {
33686
- if (is_skeleton) return;
33687
- CLIENT_ACTIVITY_TS = Date.now();
33688
- if (_$($container)?.data()?.xuData?.debug_info) _$($container).data().xuData.debug_info.hover_item = $div.attr('xu-ui-id');
33689
- if (!_ds) return;
33690
- ///////// SET Attributes///////////
33691
- let attributes = {};
33692
- $.each($div[0].attributes, function (index, attr) {
33693
- attributes[attr.name] = attr.value;
33694
- });
33695
-
33696
- SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = attributes;
33697
- //////////////////////////////////
33698
- if (!$div.data()?.xuData) return;
33699
- const _iterate_info = $div.data().xuData.iterate_info;
33700
- if (_iterate_info) {
33701
- if (_iterate_info.is_key_dynamic_field) {
33702
- _ds.dynamic_fields[_iterate_info.iterator_key].value = _iterate_info._key;
33703
- } else {
33704
- try {
33705
- const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
33706
- _ds.data_feed.rows[row_idx][_iterate_info.iterator_key] = _iterate_info._key;
33707
- } catch (err) {
33708
- console.error(err);
33709
- }
33710
- }
33711
-
33712
- if (_iterate_info.is_val_dynamic_field) {
33713
- _ds.dynamic_fields[_iterate_info.iterator_val].value = _iterate_info._val;
33714
- } else {
33715
- try {
33716
- const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
33717
- _ds.data_feed.rows[row_idx][_iterate_info.iterator_val] = _iterate_info._val;
33718
- } catch (err) {
33719
- console.error(err);
33720
- }
33721
- }
33722
- }
33723
-
33724
- if ($div && _$($div) && _ds && paramsP.renderType === 'grid') {
33725
- func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'update_datasource', { currentRecordId: _$($div).data().xuData.currentRecordId }, null, null, paramsP.dsSessionP);
33726
- }
33727
-
33728
- const set_value = function (field_id, value) {
33729
- var currentRecordId = _$($div).data().xuData.currentRecordId;
33730
-
33731
- func.UI.worker.add_to_queue(
33732
- SESSION_ID,
33733
- 'gui event',
33734
- 'update_datasource',
33735
- {
33736
- currentRecordId,
33737
- field_id,
33738
- field_value: value,
33739
- },
33740
- null,
33741
- null,
33742
- paramsP.dsSessionP,
33743
- );
33744
- };
33745
-
33746
- if ($div?.data()?.iterate_info) {
33747
- var data = $div.data().xuData.iterate_info;
33748
- if (data.iterator_key) {
33749
- set_value(data.iterator_key, data._key);
33750
- }
33751
- if (data.iterator_val) {
33752
- set_value(data.iterator_val, data._val);
33753
- }
33754
- }
33755
- };
33756
- const hover_out = function () {
33757
- if (is_skeleton) return;
33758
-
33759
- CLIENT_ACTIVITY_TS = Date.now();
33760
- if (_$($container)?.data()?.xuData?.debug_info) {
33761
- _$($container).data().xuData.debug_info.hover_item = null;
33762
- }
33763
- if (_ds?.data_system) {
33764
- SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_OBJ_WIN_ELEMENT_HOVERED_ATTRIBUTES = {};
33765
- }
33766
- };
33767
- const render_screen_type = async function ($div) {
33768
- const set_call_screen_properties_values = async function (ui_framework) {
33769
- params.properties = {};
33770
- const get_values = async function (property) {
33771
- var property_value = paramsP?.screenInfo?.properties?.[property] || paramsP?.screenInfo?.properties?.frameworkProperties?.[property];
33772
- if (paramsP?.call_screen_propertiesP) {
33773
- if (paramsP.call_screen_propertiesP?.[property]) {
33774
- property_value = paramsP.call_screen_propertiesP[property];
33775
- }
33776
- if (paramsP.call_screen_propertiesP[`xu-exp:${property}`]) {
33777
- property_value = (await func.expression.get(SESSION_ID, paramsP.call_screen_propertiesP[`xu-exp:${property}`], paramsP.dsSessionP, property)).result;
33778
- }
33779
- }
33780
- return property_value;
33781
- };
33782
- params.properties['name'] = await get_values('menuTitle');
33783
- if (await ui_framework?.properties()) {
33784
- for await (const [key, val] of Object.entries(await ui_framework.properties())) {
33785
- params.properties[key] = await get_values(key);
33786
- }
33787
- }
33788
- };
33789
-
33790
- var $div_content = $div.children();
33791
-
33792
- $.each($div_content, function (key, val) {
33793
- if (!$(val)?.data()?.xuData?.parent_container) {
33794
- return true;
33795
- }
33796
- $(val).data().xuData.parent_container = $div.data().xuData.parent_container;
33797
- });
33798
-
33799
- let $ret = $div;
33800
- var $nav = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav');
33801
- var params;
33802
- switch (paramsP.screen_type) {
33803
- case 'modal':
33804
- const modal_id = 'app_modal-' + paramsP.dsSessionP.toString();
33805
- var xu_modal_controller = document.querySelector('xu-modal-controller');
33806
- if (!xu_modal_controller) {
33807
- func.UI.component.create_app_modal_component(SESSION_ID, modal_id);
33808
- xu_modal_controller = document.querySelector('xu-modal-controller');
33809
- }
33810
-
33811
- var controller_params = $(xu_modal_controller).data('xuControllerParams');
33812
-
33813
- if (!controller_params) {
33814
- controller_params = {};
33815
- }
33816
-
33817
- params = {
33818
- screenId: paramsP.screenId,
33819
- $dialogDiv: $div.children(),
33820
- $container: $container,
33821
- dsSession: paramsP.dsSessionP,
33822
- modal_id,
33823
- screenInfo: paramsP.screenInfo,
33824
- close_callback: close_modal,
33825
- paramsP,
33826
- };
33827
-
33828
- controller_params[modal_id] = params;
33829
-
33830
- $(xu_modal_controller).data('xuControllerParams', controller_params);
33831
- const modalController = await new UI_FRAMEWORK_PLUGIN.modal();
33832
- await set_call_screen_properties_values(modalController);
33833
- if (!APP_MODAL_OBJ[modal_id]) {
33834
- const modal = await modalController.create(params);
33835
-
33836
- APP_MODAL_OBJ[modal_id] = modal;
33837
- } else {
33838
- $(modal_id).empty();
33839
- }
33840
-
33841
- await modalController.init(params);
33842
-
33843
- break;
33844
-
33845
- case 'popover':
33846
- // open_popover($div);
33847
-
33848
- const xu_popover_controller = func.UI.component.create_app_popover_component(SESSION_ID);
33849
- params = {
33850
- menuTitle: paramsP.screenInfo.properties?.menuTitle,
33851
- screenId: paramsP.screenId,
33852
- $dialogDiv: $div.children(),
33853
- $container: $container,
33854
- };
33855
-
33856
- $(xu_popover_controller).data('xuControllerParams', params);
33857
- const popover = new UI_FRAMEWORK_PLUGIN.popover(SESSION_ID);
33858
- await set_call_screen_properties_values(popover);
33859
- await popover.open(params);
33860
- CURRENT_APP_POPOVER = popover;
33861
-
33862
- func.UI.utils.screen_blocker(false, paramsP.prog_id + '_' + paramsP.sourceScreenP);
33863
- break;
33864
-
33865
- case 'page':
33866
- const nav = $nav[0];
33867
-
33868
- params = {
33869
- div: $div_content,
33870
- name: paramsP.screenInfo.properties?.menuTitle,
33871
- screenId: paramsP.screenId,
33872
- $container: $container,
33873
- dsSession: paramsP.dsSessionP,
33874
- SESSION_ID,
33875
- nav,
33876
- paramsP,
33877
- };
33878
-
33879
- var component_name = 'xu-page-component-' + paramsP.dsSessionP;
33880
- if (!$(nav).data().xuData.nav_params) {
33881
- $(nav).data().xuData.nav_params = {};
33882
- }
33883
-
33884
- //restore validate
33885
- if ($(nav)?.data()?.xuData?.params?.[paramsP.dsSessionP]) {
33886
- params.$container.data().xuData.validate_screen_ready = $(nav).data().xuData.params[paramsP.dsSessionP].$container.data().xuData.validate_screen_ready;
33887
- }
33888
-
33889
- if (!$(nav)?.data()?.xuData) return;
33890
- $(nav).data().xuData.nav_params[paramsP.dsSessionP] = params;
33891
- if (!$(component_name).length) {
33892
- await func.UI.component.create_app_page_component(SESSION_ID, paramsP.dsSessionP);
33893
- const page = new UI_FRAMEWORK_PLUGIN.page();
33894
- await set_call_screen_properties_values(page);
33895
- await page.create(params);
33896
- await page.init(params);
33897
- nav.push(component_name, { params });
33898
- } else {
33899
- debugger;
33900
- $(component_name).empty();
33901
-
33902
- await UI_FRAMEWORK_PLUGIN.page(SESSION_ID, paramsP.dsSessionP);
33903
- }
33904
- $div.data().xuData.paramsP = $container.data().xuData.paramsP;
33905
- break;
33906
-
33907
- case 'panel':
33908
- $container.append($div_content);
33909
- $ret = $container;
33910
- break;
33911
-
33912
- default: // set data to nav to use in the component
33913
- if ($nav && $nav.length) {
33914
- // refresh made
33915
- } else {
33916
- $nav = $('<xu-nav>');
33917
- $container.append($nav);
33918
- func.UI.component.init_xu_nav($container, $nav);
33919
- }
33920
-
33921
- $nav.data().xuData.$div = $div_content;
33922
-
33923
- await $nav[0].setRoot('xu-root-component-' + SESSION_ID);
33924
- $ret = $container;
33925
- break;
33926
- }
33927
- return $ret;
33928
- };
33929
-
33930
- if (!(await init())) return;
33931
- debug();
33932
- const fx = {
33933
- widget: async function () {
33934
- var _session = SESSION_OBJ[SESSION_ID];
33935
-
33936
- var exist_elm_obj = get_element_info();
33937
- var $div = exist_elm_obj.div;
33938
- if (!exist_elm_obj.div) {
33939
- $div = 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);
33940
-
33941
- //////////////////////////
33942
-
33943
- let plugin_name = prop['xu-widget'],
33944
- method = prop['xu-method'],
33945
- dsP = paramsP.dsSessionP,
33946
- propsP = prop,
33947
- sourceP = 'widgets';
33948
-
33949
- // const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
33950
- // var obj = _.clone(docP);
33951
- // obj.date = await func.utils.get_dateTime(
33952
- // SESSION_ID,
33953
- // "SYS_DATE",
33954
- // docP.date
33955
- // );
33956
- // obj.time = await func.utils.get_dateTime(
33957
- // SESSION_ID,
33958
- // "SYS_TIME",
33959
- // docP.date
33960
- // );
33961
-
33962
- // var datasource_changes = {
33963
- // [0]: {
33964
- // ["data_system"]: {
33965
- // ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
33966
- // },
33967
- // },
33968
- // };
33969
- // await func.datasource.update(SESSION_ID, datasource_changes);
33970
- // };
33971
- const call_plugin_api = async function (plugin_nameP, dataP) {
33972
- return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
33973
- };
33974
- const report_error = function (descP, warn) {
33975
- func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
33976
- module: 'widgets',
33977
- action: 'Init',
33978
- source: sourceP,
33979
- prop: descP,
33980
- details: descP,
33981
- result: null,
33982
- error: warn ? false : true,
33983
- fields: null,
33984
- type: 'widgets',
33985
- prog_id: _session.DS_GLB[dsP].prog_id,
33986
- });
33987
- };
33988
- const get_fields_data = async function (fields, props) {
33989
- const report_error = function (descP, warn) {
33990
- func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
33991
- module: 'widgets',
33992
- action: 'Init',
33993
- source: sourceP,
33994
- prop: descP,
33995
- details: descP,
33996
- result: null,
33997
- error: warn ? false : true,
33998
- fields: null,
33999
- type: 'widgets',
34000
- prog_id: _session.DS_GLB[dsP].prog_id,
34001
- });
34002
- };
34003
- const get_property_value = async function (fieldIdP, val) {
34004
- if (!val) return;
34005
- var value = props[fieldIdP] || (typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue);
34006
- if (val.render === 'eventId') {
34007
- value = props?.[fieldIdP]?.event;
34008
- }
34009
-
34010
- if (props[`xu-exp:${fieldIdP}`]) {
34011
- value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
34012
- }
34013
-
34014
- return func.common.get_cast_val(
34015
- SESSION_ID,
34016
- 'widgets',
34017
- fieldIdP,
34018
- val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
34019
- value,
34020
- null,
34021
- );
34022
- };
34023
- var data_obj = {};
34024
- var return_code = 1;
34025
- // $.each(fields, function (key, val) {
34026
- for await (const [key, val] of Object.entries(fields)) {
34027
- data_obj[key] = await get_property_value(key, val);
34028
- if (!data_obj[key] && val.mandatory) {
34029
- return_code = -1;
34030
- report_error(`${key} is a mandatory field.`);
34031
- break;
34032
- }
34033
- // console.log(val);
34034
- }
34035
- for await (const key of ['xu-bind']) {
34036
- data_obj[key] = await get_property_value(key, props[key]);
34037
- }
34038
-
34039
- return { code: return_code, data: data_obj };
34040
- };
34041
-
34042
- const load_css_style = function () {
34043
- let path = get_path('style.css');
34044
- func.utils.load_css_on_demand(path);
34045
- };
34046
-
34047
- const get_path = function (resource) {
34048
- if (_session.worker_type === 'Dev') {
34049
- return `../../plugins/${plugin_name}/${resource}`;
34050
- }
34051
- return `https://${_session.domain}/plugins/${plugin_name}/${resource}?gtp_token=${_session.gtp_token}&app_id=${_session.app_id}`;
34052
- };
34053
- const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
34054
- const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
34055
- const methods = index.methods;
34056
- if (methods && !methods[method]) {
34057
- return report_error('method not found');
34058
- }
34059
-
34060
- const fields_ret = await get_fields_data(methods[method].fields, propsP);
34061
- if (fields_ret.code < 0) {
34062
- return report_error(fields_ret.data);
34063
- }
34064
- const fields = fields_ret.data;
34065
-
34066
- let exclude_attributes = [];
34067
- for await (const [key, val] of Object.entries(propsP)) {
34068
- if (typeof fields[key] !== 'undefined' || typeof fields[`xu-exp:${key}`] !== 'undefined') {
34069
- exclude_attributes.push(key);
34070
- }
34071
- }
34072
-
34073
- 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);
34074
-
34075
- $div.addClass('widget_wrapper'); // class get override in set_attributes_new
34076
-
34077
- if (!APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name]) {
34078
- return report_error(`plugin ${plugin_name} not found`);
34079
- }
34080
-
34081
- if (APP_OBJ[_session.app_id].app_plugins_purchased[plugin_name].manifest['style.css'].exist) {
34082
- load_css_style();
34083
- }
34084
-
34085
- const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
34086
- if (plugin_setup_ret.code < 0) {
34087
- return report_error(plugin_setup_ret);
34088
- }
34089
-
34090
- const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
34091
- func,
34092
- glb,
34093
- SESSION_OBJ,
34094
- SESSION_ID,
34095
- APP_OBJ,
34096
- dsSession: paramsP.dsSessionP,
34097
- job_id: jobNoP,
34098
- });
34099
-
34100
- const params = {
34101
- SESSION_ID,
34102
- method,
34103
- _session,
34104
- dsP,
34105
- sourceP,
34106
- propsP,
34107
- plugin_name,
34108
- $containerP: $div,
34109
- plugin_setup: plugin_setup_ret.data,
34110
-
34111
- report_error,
34112
- call_plugin_api,
34113
- // set_SYS_GLOBAL_OBJ_WIDGET_INFO,
34114
- api_utils,
34115
- };
34116
-
34117
- const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
34118
-
34119
- if (_plugin?.manifest?.['runtime.mjs'].dist && _plugin?.manifest?.['runtime.mjs']?.css) {
34120
- const plugin_runtime_css_url = await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, 'dist/runtime.css');
34121
- func.utils.load_css_on_demand(plugin_runtime_css_url);
34122
- }
34123
-
34124
- if (!fx[method]) {
34125
- throw `Method: ${method} does not exist`;
34126
- }
34127
- try {
34128
- await fx[method](fields, params);
34129
- } catch (err) {
34130
- func.utils.debug_report(SESSION_ID, `${plugin_name} widget`, err.message, 'E');
34131
- }
34132
- }
34133
- return $div;
34134
- },
34135
- [`xu-single-view`]: async function () {
34136
- var exist_elm_obj = get_element_info();
34137
- var $div = exist_elm_obj.div;
34138
-
34139
- if (!exist_elm_obj.div) {
34140
- var $wrapper = $('<div>');
34141
- $div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, 'div', $wrapper, '');
34142
-
34143
- if (!$div) return;
34144
-
34145
- if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
34146
- close_all_modals();
34147
- }
34148
-
34149
- $div.hover(
34150
- function (e) {
34151
- hover_in();
34152
- },
34153
- function (e) {
34154
- hover_out();
34155
- },
34156
- );
34157
- }
34158
-
34159
- const ret = await iterate_child($div, nodeP, null, null, $div);
34160
- if (_.isEmpty($container.data().xuAttributes)) {
34161
- await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
34162
- }
34163
-
34164
- $.each($div.data().xuData, function (key, val) {
34165
- $container.data().xuData[key] = _.cloneDeep(val);
34166
- });
34167
- $.each($div.data().xuAttributes, function (key, val) {
34168
- $container.data().xuAttributes[key] = _.cloneDeep(val);
34169
- });
34170
-
34171
- return await render_screen_type($div);
34172
- },
34173
- [`xu-multi-view`]: async function () {
34174
- var $div = $container;
34175
-
34176
- if (!$div.data().xuData.node || !$div.data().xuData.node.children) {
34177
- $div.data().xuData.node = nodeP;
34178
- }
34179
-
34180
- if (!$div.data().xuData.debug_info) {
34181
- $div.data().xuData.debug_info = {
34182
- id: nodeP.id,
34183
- parent_id: $container.data().xuData.ui_id,
34184
- };
34185
- }
34186
-
34187
- const done = async function (continuous_idx) {
34188
- // const do_callback = async function ($div) {
34189
- // // if ($root_container.data().xuData.progress_bar_circle) {
34190
- // // setTimeout(function () {
34191
- // // $.each(
34192
- // // $root_container.data().xuData.progress_bar_circle,
34193
- // // function (key, val) {
34194
- // // val.bar.set(parseFloat(val.value)); // Number from 0.0 to 1.0
34195
- // // }
34196
- // // );
34197
- // // }, 2000);
34198
- // // }
34199
-
34200
- // if (paramsP.screenInfo.properties?.rtl) {
34201
- // $div_content.attr('dir', 'rtl');
34202
- // }
34203
-
34204
- // return $div;
34205
- // };
34206
- await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
34207
-
34208
- return await render_screen_type($div);
34209
- };
34210
-
34211
- if (!REFRESHER_IN_PROGRESS && (paramsP.is_mobile_popover || paramsP.is_mobile_page)) {
34212
- close_all_modals();
34213
- }
34214
-
34215
- const empty_result = async function () {
34216
- var content = prop.empty_result_content || '';
34217
-
34218
- var res = await func.expression.get(
34219
- SESSION_ID,
34220
- content, // prop["xu-exp:empty_result_content"],
34221
- paramsP.dsSessionP,
34222
- 'empty_result_content_EXP',
34223
- _ds.currentRecordId,
34224
- );
34225
- content = res.result;
34226
- // }
34227
-
34228
- let empty_result_node = {
34229
- type: 'element',
34230
- id: crypto.randomUUID(),
34231
- content,
34232
- // : content || (typeof content === "undefined" && "Empty results"),
34233
- tagName: 'div',
34234
- attributes: {},
34235
- children: [],
34236
- };
34237
-
34238
- 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);
34239
- await func.events.validate(SESSION_ID, 'record_not_found', paramsP.dsSessionP);
34240
- return await done(null);
34241
- };
34242
- var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[paramsP.dsSessionP];
34243
-
34244
- var continuous_idx = null;
34245
-
34246
- if (!_ds.data_feed || _.isEmpty(_ds.data_feed.rows)) {
34247
- return await empty_result();
34248
- }
34249
-
34250
- var i = 0;
34251
- for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
34252
- var node = JSON.parse(JSON.stringify(nodeP));
34253
-
34254
- _ds.currentRecordId = val._ROWID;
34255
- const ret = await iterate_child($div, node, { continuous_idx }, null, $root_container);
34256
-
34257
- if (_.isEmpty($container.data().xuAttributes)) {
34258
- await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $container, true);
34259
- }
34260
- }
34261
-
34262
- return await done(continuous_idx);
34263
- },
34264
- [`xu-panel`]: async function () {
34265
- const done = async function ($new_div) {
34266
- if (!$container.data()?.xuData?.paramsP) {
34267
- return $container;
34268
- }
34269
- var $div_items = $div.data().xuData.node.children;
34270
-
34271
- await func.UI.screen.panel_post_render_handler(SESSION_ID, $container, $new_div, nodeP, $div, jobNoP);
34272
-
34273
- // TO FIX should be timeout
34274
- $container.data().xuData.node.children = $div_items;
34275
-
34276
- return $container;
34277
- };
34278
-
34279
- var $wrapper = $('<div>');
34280
- $div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, null, $wrapper, '');
34281
-
34282
- 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);
34283
- if (ret.abort) {
34284
- // // program null
34285
- // if (ret.program_null) {
34286
- // return render_screen_type($div);
34287
- // }
34288
-
34289
- // render N
34290
- return (ret.$new_div = $('<template>').append($div));
34291
-
34292
- // ret.$new_div = $("<template>").append($div);
34293
- }
34294
- let ret_done = await done(ret.$new_div);
34295
- return ret_done;
34296
- },
34297
- };
34298
-
34299
- const draw_html_element = async function (element) {
34300
- const done = async function () {
34301
- return $div;
34302
- };
34303
- if (!element || element === 'script') return await done();
34304
- let str = '';
34305
-
34306
- var $div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
34307
-
34308
- $div.hover(
34309
- function (e) {
34310
- hover_in($div);
34311
- },
34312
- function (e) {
34313
- hover_out();
34314
- },
34315
- );
34316
-
34317
- 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);
34318
- if (ret.abort) return await done();
34319
- // check if iterator made to prevent children render
34320
-
34321
- const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
34322
- return await done();
34323
- };
34324
-
34325
- if (nodeP.content && nodeP.attributes) {
34326
- nodeP.attributes['xu-content'] = nodeP.content;
34327
- }
34328
- if (nodeP.tagName === 'xu-widget') {
34329
- if (is_skeleton) return;
34330
- return await fx['widget']();
34331
- }
34332
- if (fx[nodeP.tagName]) {
34333
- return await fx[nodeP.tagName]();
34334
- }
34335
-
34336
- return await draw_html_element(nodeP.tagName);
34337
- };
34338
-
34339
- func.UI.screen.refresh_document_changes_for_realtime_update = async function (SESSION_ID, doc_change) {
34340
- let _session = SESSION_OBJ[SESSION_ID];
34341
- for (const [key, _ds] of Object.entries(_session.DS_GLB)) {
34342
- let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
34343
- if (prog_obj?.progDataSource?.dataSourceRealtime && prog_obj?.progDataSource?.dataSourceTableId === doc_change.table_id) {
34344
- try {
34345
- // disabled in purpose to support create row
34346
-
34347
- // const row_idx = func.common.find_ROWID_idx(_ds, doc_change.row_id);
34348
-
34349
- // console.log(
34350
- // "refresh_document_changes_for_realtime_update",
34351
- // _ds.data_feed.rows[row_idx]
34352
- // );
34353
-
34354
- if (!_ds.screen_params) continue;
34355
- if (_ds.screen_params.is_panelP) {
34356
- func.UI.screen.refresh_screen(SESSION_ID, null, key);
34357
- } else {
34358
- func.action.execute(SESSION_ID, 'act_refresh', _ds, null, null);
34359
- }
34360
- } catch (err) {
34361
- // console.error(err);
34362
- }
34363
- }
34364
- }
34365
- };
34366
- func.UI.component = {};
32905
+ func.UI.component = {};
34367
32906
 
34368
32907
  func.UI.component.create_app_modal_component = function (
34369
32908
  SESSION_ID,