@xuda.io/runtime-bundle 1.0.426 → 1.0.429

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.
@@ -27817,25 +27817,34 @@ func.UI.utils.get_panels_wrapper_from_dom = async function (SESSION_ID, $xu_embe
27817
27817
  // set panels_obj
27818
27818
  for (const [elem_key, elem_val] of Object.entries($elm)) {
27819
27819
  if (elem_key === 'length') break;
27820
- var $div = $(elem_val);
27820
+ var $panel_div = $(elem_val);
27821
27821
 
27822
- const panelXuAttributes = $div?.data().xuPanelWrapper?.panelXuAttributes;
27823
- let prog_id = panelXuAttributes?.program;
27824
- const exp = panelXuAttributes?.['xu-exp:program'];
27825
- if (exp) {
27826
- let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
27827
- prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
27828
- }
27822
+ const panelXuAttributes = $panel_div?.data().xuPanelWrapper?.panelXuAttributes;
27823
+
27824
+ if (!panelXuAttributes) continue; // skip if no longer in dom
27825
+
27826
+ // let prog_id = panelXuAttributes?.program;
27827
+ // const exp = panelXuAttributes?.['xu-exp:program'];
27828
+ // if (exp) {
27829
+ // let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
27830
+ // prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
27831
+ // }
27829
27832
  let prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, prog_id);
27830
27833
  if (!ignore_disableAutoRefresh && prog_doc.properties.disableAutoRefresh) {
27831
27834
  continue;
27832
27835
  }
27833
- const xu_ui_id = $div.attr('xu-ui-id');
27836
+ const xu_ui_id = $panel_div.attr('xu-ui-id');
27837
+
27834
27838
  if (!panels_obj[xu_ui_id]) {
27839
+ var _session = SESSION_OBJ[SESSION_ID];
27840
+ let _ds = _session?.DS_GLB[$panel_div.data().xuData.dsSessionP];
27835
27841
  panels_obj[xu_ui_id] = {
27836
- prog_id,
27842
+ // prog_id,
27837
27843
  panelXuAttributes,
27838
27844
  progUi: prog_doc.progUi,
27845
+ prog_doc,
27846
+ $panel_div,
27847
+ _ds,
27839
27848
  };
27840
27849
  }
27841
27850
  }
@@ -31624,13 +31633,38 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31624
31633
  if (val?.includes(field_id)) {
31625
31634
  const parent_element_ui_id = node_id;
31626
31635
 
31627
- const _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
31628
-
31629
- if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
31636
+ let _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
31630
31637
 
31631
- if (!_$elem?.length) continue;
31632
31638
  const _elem_key = parent_element_ui_id;
31633
31639
  const _elem_val = { attributes: [], $elm: _$elem };
31640
+ if (!_$elem?.length) continue;
31641
+
31642
+ // if (!_$elem?.length) {
31643
+ // // xu-for may exist in the panel root
31644
+ // if (!panel_wrapper_element_ui_id) continue;
31645
+
31646
+ // $.each(item.attributes, function (key, val) {
31647
+ // _elem_val.attributes.push(key);
31648
+ // });
31649
+ // // _$elem = $(`[xu-ui-id="${panel_wrapper_element}"]`);
31650
+ // await func.UI.worker.add_to_queue(
31651
+ // SESSION_ID,
31652
+ // 'gui event',
31653
+ // 'execute_xu_for',
31654
+ // {
31655
+ // ui_type: _elem_val.$elm.data().xuData.ui_type,
31656
+ // SESSION_ID,
31657
+ // elem_key: _elem_key,
31658
+ // elem_val: _elem_val,
31659
+ // fields_arr,
31660
+ // },
31661
+ // new_job,
31662
+ // _elem_val.$elm,
31663
+ // _elem_val.$elm.data().xuData.paramsP.dsSessionP,
31664
+ // );
31665
+ // }
31666
+
31667
+ if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
31634
31668
 
31635
31669
  $.each(_$elem.data()?.xuAttributes, function (key, val) {
31636
31670
  _elem_val.attributes.push(key);
@@ -31691,7 +31725,7 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31691
31725
  }
31692
31726
  }
31693
31727
  // run panels
31694
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31728
+ for await (const [panel_wrapper_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31695
31729
  // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val.prog_id);
31696
31730
  await iterate_field_in_progUi(panel_val.progUi, field_id);
31697
31731
  }
@@ -31707,6 +31741,86 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31707
31741
  };
31708
31742
 
31709
31743
  func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31744
+ const panels_obj = func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
31745
+
31746
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31747
+ const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
31748
+
31749
+ var found;
31750
+ if (fields_changed_arr) {
31751
+ if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
31752
+ continue;
31753
+ }
31754
+ for (const field_id of fields_changed_arr) {
31755
+ // get panel attributes
31756
+ const _attributes = panel_val?.panelXuAttributes || {};
31757
+
31758
+ // detect if program changed
31759
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
31760
+ if (found) break;
31761
+
31762
+ // _attributes holds also info of parameters in code_in: @code
31763
+ // search field changed in panel call send parameters exp
31764
+ for (const [attr, value] of Object.entries(_attributes)) {
31765
+ const pattern = /xu-exp:(\w+)/;
31766
+ const match = attr.match(pattern);
31767
+
31768
+ if (!match) {
31769
+ // continue if attribute is not expression
31770
+ continue;
31771
+ }
31772
+ // code_in
31773
+ const parameter_in_field_id = match?.[1];
31774
+ // @code
31775
+ if (value.includes(field_id)) {
31776
+ // search parameter in field in the target program's progDataSource
31777
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
31778
+ if (found) break;
31779
+
31780
+ // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
31781
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31782
+ if (found) break;
31783
+ }
31784
+ }
31785
+
31786
+ if (found) break;
31787
+
31788
+ // search field changed in the target program's progDataSource // @code
31789
+ found = progDataSource_str?.includes('@' + field_id);
31790
+ if (found) break;
31791
+ }
31792
+ }
31793
+
31794
+ if (datasource_changed) {
31795
+ if (panel_val._ds.dsSession == datasource_changed) {
31796
+ found = true;
31797
+ }
31798
+ }
31799
+ if (found) {
31800
+ var $div_elm = panel_val.$div
31801
+ .parent()
31802
+ .parent()
31803
+ .find("[xu-ui-id='" + parent_element_ui_id + "']");
31804
+
31805
+ // restore original panel
31806
+ try {
31807
+ // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
31808
+
31809
+ 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);
31810
+
31811
+ // remove old panel content
31812
+ $.each(panel_val.ids, async function (key, val) {
31813
+ $("[xu-ui-id='" + val + "']").remove();
31814
+ });
31815
+ } catch (error) {
31816
+ debugger;
31817
+ }
31818
+ break;
31819
+ }
31820
+ }
31821
+ };
31822
+
31823
+ func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31710
31824
  // const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
31711
31825
 
31712
31826
  const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);