@xuda.io/runtime-bundle 1.0.428 → 1.0.430

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