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