@xuda.io/runtime-bundle 1.0.428 → 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,28 +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;
27822
+ const panelXuAttributes = $panel_div?.data().xuPanelWrapper?.panelXuAttributes;
27823
27823
 
27824
27824
  if (!panelXuAttributes) continue; // skip if no longer in dom
27825
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
- }
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
+ // }
27832
27832
  let prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, prog_id);
27833
27833
  if (!ignore_disableAutoRefresh && prog_doc.properties.disableAutoRefresh) {
27834
27834
  continue;
27835
27835
  }
27836
- const xu_ui_id = $div.attr('xu-ui-id');
27836
+ const xu_ui_id = $panel_div.attr('xu-ui-id');
27837
+
27837
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];
27838
27841
  panels_obj[xu_ui_id] = {
27839
- prog_id,
27842
+ // prog_id,
27840
27843
  panelXuAttributes,
27841
27844
  progUi: prog_doc.progUi,
27845
+ prog_doc,
27846
+ $panel_div,
27847
+ _ds,
27842
27848
  };
27843
27849
  }
27844
27850
  }
@@ -31627,13 +31633,38 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31627
31633
  if (val?.includes(field_id)) {
31628
31634
  const parent_element_ui_id = node_id;
31629
31635
 
31630
- const _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
31636
+ let _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
31631
31637
 
31632
- if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
31633
-
31634
- if (!_$elem?.length) continue;
31635
31638
  const _elem_key = parent_element_ui_id;
31636
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;
31637
31668
 
31638
31669
  $.each(_$elem.data()?.xuAttributes, function (key, val) {
31639
31670
  _elem_val.attributes.push(key);
@@ -31694,7 +31725,7 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31694
31725
  }
31695
31726
  }
31696
31727
  // run panels
31697
- 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)) {
31698
31729
  // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val.prog_id);
31699
31730
  await iterate_field_in_progUi(panel_val.progUi, field_id);
31700
31731
  }
@@ -31710,6 +31741,86 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31710
31741
  };
31711
31742
 
31712
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) {
31713
31824
  // const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
31714
31825
 
31715
31826
  const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);