@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.
@@ -8635,28 +8635,37 @@ func.UI.utils.get_panels_wrapper_from_dom = async function (SESSION_ID, $xu_embe
8635
8635
  // set panels_obj
8636
8636
  for (const [elem_key, elem_val] of Object.entries($elm)) {
8637
8637
  if (elem_key === 'length') break;
8638
- var $div = $(elem_val);
8638
+ var $panel_div = $(elem_val);
8639
8639
 
8640
- const panelXuAttributes = $div?.data().xuPanelWrapper?.panelXuAttributes;
8640
+ const panelXuAttributes = $panel_div?.data().xuPanelWrapper?.panelXuAttributes;
8641
8641
 
8642
8642
  if (!panelXuAttributes) continue; // skip if no longer in dom
8643
8643
 
8644
- let prog_id = panelXuAttributes?.program;
8645
- const exp = panelXuAttributes?.['xu-exp:program'];
8646
- if (exp) {
8647
- let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
8648
- prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
8649
- }
8650
- let prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, prog_id);
8651
- if (!ignore_disableAutoRefresh && prog_doc.properties.disableAutoRefresh) {
8652
- continue;
8653
- }
8654
- const xu_ui_id = $div.attr('xu-ui-id');
8644
+ // let prog_id = panelXuAttributes?.program;
8645
+ // const exp = panelXuAttributes?.['xu-exp:program'];
8646
+ // if (exp) {
8647
+ // let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
8648
+ // prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
8649
+ // }
8650
+
8651
+ const xu_ui_id = $panel_div.attr('xu-ui-id');
8652
+
8655
8653
  if (!panels_obj[xu_ui_id]) {
8654
+ var _session = SESSION_OBJ[SESSION_ID];
8655
+ let _ds = _session?.DS_GLB[$panel_div.data().xuData.dsSessionP];
8656
+
8657
+ let prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
8658
+ if (!ignore_disableAutoRefresh && prog_doc.properties.disableAutoRefresh) {
8659
+ continue;
8660
+ }
8661
+
8656
8662
  panels_obj[xu_ui_id] = {
8657
- prog_id,
8663
+ // prog_id,
8658
8664
  panelXuAttributes,
8659
8665
  progUi: prog_doc.progUi,
8666
+ prog_doc,
8667
+ $panel_div,
8668
+ _ds,
8660
8669
  };
8661
8670
  }
8662
8671
  }
@@ -11595,13 +11604,38 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11595
11604
  if (val?.includes(field_id)) {
11596
11605
  const parent_element_ui_id = node_id;
11597
11606
 
11598
- const _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
11607
+ let _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
11599
11608
 
11600
- if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
11601
-
11602
- if (!_$elem?.length) continue;
11603
11609
  const _elem_key = parent_element_ui_id;
11604
11610
  const _elem_val = { attributes: [], $elm: _$elem };
11611
+ if (!_$elem?.length) continue;
11612
+
11613
+ // if (!_$elem?.length) {
11614
+ // // xu-for may exist in the panel root
11615
+ // if (!panel_wrapper_element_ui_id) continue;
11616
+
11617
+ // $.each(item.attributes, function (key, val) {
11618
+ // _elem_val.attributes.push(key);
11619
+ // });
11620
+ // // _$elem = $(`[xu-ui-id="${panel_wrapper_element}"]`);
11621
+ // await func.UI.worker.add_to_queue(
11622
+ // SESSION_ID,
11623
+ // 'gui event',
11624
+ // 'execute_xu_for',
11625
+ // {
11626
+ // ui_type: _elem_val.$elm.data().xuData.ui_type,
11627
+ // SESSION_ID,
11628
+ // elem_key: _elem_key,
11629
+ // elem_val: _elem_val,
11630
+ // fields_arr,
11631
+ // },
11632
+ // new_job,
11633
+ // _elem_val.$elm,
11634
+ // _elem_val.$elm.data().xuData.paramsP.dsSessionP,
11635
+ // );
11636
+ // }
11637
+
11638
+ if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
11605
11639
 
11606
11640
  $.each(_$elem.data()?.xuAttributes, function (key, val) {
11607
11641
  _elem_val.attributes.push(key);
@@ -11662,7 +11696,7 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11662
11696
  }
11663
11697
  }
11664
11698
  // run panels
11665
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11699
+ for await (const [panel_wrapper_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11666
11700
  // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val.prog_id);
11667
11701
  await iterate_field_in_progUi(panel_val.progUi, field_id);
11668
11702
  }
@@ -11678,6 +11712,86 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11678
11712
  };
11679
11713
 
11680
11714
  func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
11715
+ const panels_obj = func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11716
+
11717
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11718
+ const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
11719
+
11720
+ var found;
11721
+ if (fields_changed_arr) {
11722
+ if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
11723
+ continue;
11724
+ }
11725
+ for (const field_id of fields_changed_arr) {
11726
+ // get panel attributes
11727
+ const _attributes = panel_val?.panelXuAttributes || {};
11728
+
11729
+ // detect if program changed
11730
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
11731
+ if (found) break;
11732
+
11733
+ // _attributes holds also info of parameters in code_in: @code
11734
+ // search field changed in panel call send parameters exp
11735
+ for (const [attr, value] of Object.entries(_attributes)) {
11736
+ const pattern = /xu-exp:(\w+)/;
11737
+ const match = attr.match(pattern);
11738
+
11739
+ if (!match) {
11740
+ // continue if attribute is not expression
11741
+ continue;
11742
+ }
11743
+ // code_in
11744
+ const parameter_in_field_id = match?.[1];
11745
+ // @code
11746
+ if (value.includes(field_id)) {
11747
+ // search parameter in field in the target program's progDataSource
11748
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
11749
+ if (found) break;
11750
+
11751
+ // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
11752
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
11753
+ if (found) break;
11754
+ }
11755
+ }
11756
+
11757
+ if (found) break;
11758
+
11759
+ // search field changed in the target program's progDataSource // @code
11760
+ found = progDataSource_str?.includes('@' + field_id);
11761
+ if (found) break;
11762
+ }
11763
+ }
11764
+
11765
+ if (datasource_changed) {
11766
+ if (panel_val._ds.dsSession == datasource_changed) {
11767
+ found = true;
11768
+ }
11769
+ }
11770
+ if (found) {
11771
+ var $div_elm = panel_val.$div
11772
+ .parent()
11773
+ .parent()
11774
+ .find("[xu-ui-id='" + parent_element_ui_id + "']");
11775
+
11776
+ // restore original panel
11777
+ try {
11778
+ // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
11779
+
11780
+ 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);
11781
+
11782
+ // remove old panel content
11783
+ $.each(panel_val.ids, async function (key, val) {
11784
+ $("[xu-ui-id='" + val + "']").remove();
11785
+ });
11786
+ } catch (error) {
11787
+ debugger;
11788
+ }
11789
+ break;
11790
+ }
11791
+ }
11792
+ };
11793
+
11794
+ func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
11681
11795
  // const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
11682
11796
 
11683
11797
  const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);
@@ -8636,28 +8636,37 @@ func.UI.utils.get_panels_wrapper_from_dom = async function (SESSION_ID, $xu_embe
8636
8636
  // set panels_obj
8637
8637
  for (const [elem_key, elem_val] of Object.entries($elm)) {
8638
8638
  if (elem_key === 'length') break;
8639
- var $div = $(elem_val);
8639
+ var $panel_div = $(elem_val);
8640
8640
 
8641
- const panelXuAttributes = $div?.data().xuPanelWrapper?.panelXuAttributes;
8641
+ const panelXuAttributes = $panel_div?.data().xuPanelWrapper?.panelXuAttributes;
8642
8642
 
8643
8643
  if (!panelXuAttributes) continue; // skip if no longer in dom
8644
8644
 
8645
- let prog_id = panelXuAttributes?.program;
8646
- const exp = panelXuAttributes?.['xu-exp:program'];
8647
- if (exp) {
8648
- let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
8649
- prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
8650
- }
8651
- let prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, prog_id);
8652
- if (!ignore_disableAutoRefresh && prog_doc.properties.disableAutoRefresh) {
8653
- continue;
8654
- }
8655
- const xu_ui_id = $div.attr('xu-ui-id');
8645
+ // let prog_id = panelXuAttributes?.program;
8646
+ // const exp = panelXuAttributes?.['xu-exp:program'];
8647
+ // if (exp) {
8648
+ // let exp_ret = await func.expression.get(SESSION_ID, exp, $xu_embed_container?.data()?.xuData?.paramsP?.dsSessionP, 'UI Attr EXP');
8649
+ // prog_id = func.UI.screen.fix_val_defaults('program', exp_ret.result);
8650
+ // }
8651
+
8652
+ const xu_ui_id = $panel_div.attr('xu-ui-id');
8653
+
8656
8654
  if (!panels_obj[xu_ui_id]) {
8655
+ var _session = SESSION_OBJ[SESSION_ID];
8656
+ let _ds = _session?.DS_GLB[$panel_div.data().xuData.dsSessionP];
8657
+
8658
+ let prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
8659
+ if (!ignore_disableAutoRefresh && prog_doc.properties.disableAutoRefresh) {
8660
+ continue;
8661
+ }
8662
+
8657
8663
  panels_obj[xu_ui_id] = {
8658
- prog_id,
8664
+ // prog_id,
8659
8665
  panelXuAttributes,
8660
8666
  progUi: prog_doc.progUi,
8667
+ prog_doc,
8668
+ $panel_div,
8669
+ _ds,
8661
8670
  };
8662
8671
  }
8663
8672
  }
@@ -9668,13 +9677,38 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
9668
9677
  if (val?.includes(field_id)) {
9669
9678
  const parent_element_ui_id = node_id;
9670
9679
 
9671
- const _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
9680
+ let _$elem = $(`[xu-ui-id^=${parent_element_ui_id}]`);
9672
9681
 
9673
- if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
9674
-
9675
- if (!_$elem?.length) continue;
9676
9682
  const _elem_key = parent_element_ui_id;
9677
9683
  const _elem_val = { attributes: [], $elm: _$elem };
9684
+ if (!_$elem?.length) continue;
9685
+
9686
+ // if (!_$elem?.length) {
9687
+ // // xu-for may exist in the panel root
9688
+ // if (!panel_wrapper_element_ui_id) continue;
9689
+
9690
+ // $.each(item.attributes, function (key, val) {
9691
+ // _elem_val.attributes.push(key);
9692
+ // });
9693
+ // // _$elem = $(`[xu-ui-id="${panel_wrapper_element}"]`);
9694
+ // await func.UI.worker.add_to_queue(
9695
+ // SESSION_ID,
9696
+ // 'gui event',
9697
+ // 'execute_xu_for',
9698
+ // {
9699
+ // ui_type: _elem_val.$elm.data().xuData.ui_type,
9700
+ // SESSION_ID,
9701
+ // elem_key: _elem_key,
9702
+ // elem_val: _elem_val,
9703
+ // fields_arr,
9704
+ // },
9705
+ // new_job,
9706
+ // _elem_val.$elm,
9707
+ // _elem_val.$elm.data().xuData.paramsP.dsSessionP,
9708
+ // );
9709
+ // }
9710
+
9711
+ if (refreshed_ids.includes(_$elem.attr('xu-ui-id'))) break;
9678
9712
 
9679
9713
  $.each(_$elem.data()?.xuAttributes, function (key, val) {
9680
9714
  _elem_val.attributes.push(key);
@@ -9735,7 +9769,7 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
9735
9769
  }
9736
9770
  }
9737
9771
  // run panels
9738
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9772
+ for await (const [panel_wrapper_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9739
9773
  // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val.prog_id);
9740
9774
  await iterate_field_in_progUi(panel_val.progUi, field_id);
9741
9775
  }
@@ -9751,6 +9785,86 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
9751
9785
  };
9752
9786
 
9753
9787
  func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9788
+ const panels_obj = func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9789
+
9790
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9791
+ const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
9792
+
9793
+ var found;
9794
+ if (fields_changed_arr) {
9795
+ if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
9796
+ continue;
9797
+ }
9798
+ for (const field_id of fields_changed_arr) {
9799
+ // get panel attributes
9800
+ const _attributes = panel_val?.panelXuAttributes || {};
9801
+
9802
+ // detect if program changed
9803
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
9804
+ if (found) break;
9805
+
9806
+ // _attributes holds also info of parameters in code_in: @code
9807
+ // search field changed in panel call send parameters exp
9808
+ for (const [attr, value] of Object.entries(_attributes)) {
9809
+ const pattern = /xu-exp:(\w+)/;
9810
+ const match = attr.match(pattern);
9811
+
9812
+ if (!match) {
9813
+ // continue if attribute is not expression
9814
+ continue;
9815
+ }
9816
+ // code_in
9817
+ const parameter_in_field_id = match?.[1];
9818
+ // @code
9819
+ if (value.includes(field_id)) {
9820
+ // search parameter in field in the target program's progDataSource
9821
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
9822
+ if (found) break;
9823
+
9824
+ // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
9825
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
9826
+ if (found) break;
9827
+ }
9828
+ }
9829
+
9830
+ if (found) break;
9831
+
9832
+ // search field changed in the target program's progDataSource // @code
9833
+ found = progDataSource_str?.includes('@' + field_id);
9834
+ if (found) break;
9835
+ }
9836
+ }
9837
+
9838
+ if (datasource_changed) {
9839
+ if (panel_val._ds.dsSession == datasource_changed) {
9840
+ found = true;
9841
+ }
9842
+ }
9843
+ if (found) {
9844
+ var $div_elm = panel_val.$div
9845
+ .parent()
9846
+ .parent()
9847
+ .find("[xu-ui-id='" + parent_element_ui_id + "']");
9848
+
9849
+ // restore original panel
9850
+ try {
9851
+ // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
9852
+
9853
+ 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);
9854
+
9855
+ // remove old panel content
9856
+ $.each(panel_val.ids, async function (key, val) {
9857
+ $("[xu-ui-id='" + val + "']").remove();
9858
+ });
9859
+ } catch (error) {
9860
+ debugger;
9861
+ }
9862
+ break;
9863
+ }
9864
+ }
9865
+ };
9866
+
9867
+ func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9754
9868
  // const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
9755
9869
 
9756
9870
  const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);