@xuda.io/runtime-bundle 1.0.715 → 1.0.717

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.
@@ -3861,8 +3861,8 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3861
3861
  }
3862
3862
 
3863
3863
  // initiated with Update but no rows found
3864
- // if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
3865
- if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_raw_data_rows?.length) {
3864
+ if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
3865
+ // if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_raw_data_rows?.length) {
3866
3866
  _ds.set_mode = 'C';
3867
3867
  // _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
3868
3868
 
@@ -9592,71 +9592,71 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
9592
9592
  }
9593
9593
  };
9594
9594
 
9595
- // // check the main program
9596
- // if (fields_changed_datasource) {
9597
- // const _session = SESSION_OBJ[SESSION_ID];
9598
- // const _ds = _session.DS_GLB[fields_changed_datasource];
9599
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9600
- // if (prog_doc.progUi) {
9601
- // validate_change(prog_doc, null, true);
9602
- // if (found) {
9603
- // const $elm = $(`#container_${_ds.prog_id}_0`);
9604
- // if ($elm?.length) {
9605
- // const elm_data = $elm.data();
9606
- // const $wrapper = $elm.parent();
9607
- // // const wrapper_data = $wrapper.data();
9608
- // const refreshed_ds = _ds.dsSession;
9609
-
9610
- // // let elm_to_delete = [];
9611
- // // const ts = Date.now();
9612
- // // $.each($elm.find('xu-root-component-' + SESSION_ID).find('*'), function (key, val) {
9613
- // // let xu_ui_id = $(val).attr('xu-ui-id');
9614
- // // if (xu_ui_id) {
9615
- // // let new_id = xu_ui_id + ts;
9616
- // // elm_to_delete.push(new_id);
9617
-
9618
- // // $(val).attr('xu-ui-id', new_id).removeData();
9619
- // // }
9620
- // // // else {
9621
- // // // $(val).remove();
9622
- // // // }
9623
- // // });
9624
-
9625
- // $elm.empty();
9626
- // if ($elm.data()) {
9627
- // const new_$div = await func.UI.screen.render_ui_tree(
9628
- // SESSION_ID,
9629
- // $elm, // the wrapper
9630
- // _.cloneDeep($elm.data().xuData.node), // the xu-panel node
9631
- // {},
9632
- // elm_data.xuData.paramsP, // the wrapper params
9633
- // null,
9634
- // null,
9635
- // elm_data.xuData.key, // the wrapper key
9636
- // refreshed_ds, // the refreshed_ds
9637
- // elm_data.xuData.parent_node, // the wrapper parent node
9638
- // null,
9639
- // elm_data.xuData.$root_container, // the wrapper root container
9640
- // );
9641
-
9642
- // // // remove old screen content
9643
- // // $.each(elm_to_delete, async function (key, val) {
9644
- // // $("[xu-ui-id='" + elm_to_delete + "']").remove();
9645
- // // });
9646
-
9647
- // if (_session.engine_mode === 'live_preview') {
9648
- // console.info('========= refresh main info ==============');
9649
- // console.info('reason:', refresh_reason);
9650
- // console.info('element:', $elm);
9651
- // console.info('==========================================');
9652
- // }
9653
-
9654
- // return;
9655
- // }
9656
- // }
9657
- // }
9658
- // }
9659
- // }
9595
+ // check the main program
9596
+ if (fields_changed_datasource) {
9597
+ const _session = SESSION_OBJ[SESSION_ID];
9598
+ const _ds = _session.DS_GLB[fields_changed_datasource];
9599
+ const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9600
+ if (prog_doc.progUi) {
9601
+ validate_change(prog_doc, null, true);
9602
+ if (found) {
9603
+ const $elm = $(`#container_${_ds.prog_id}_0`);
9604
+ if ($elm?.length) {
9605
+ const elm_data = $elm.data();
9606
+ const $wrapper = $elm.parent();
9607
+ // const wrapper_data = $wrapper.data();
9608
+ const refreshed_ds = _ds.dsSession;
9609
+
9610
+ // let elm_to_delete = [];
9611
+ // const ts = Date.now();
9612
+ // $.each($elm.find('xu-root-component-' + SESSION_ID).find('*'), function (key, val) {
9613
+ // let xu_ui_id = $(val).attr('xu-ui-id');
9614
+ // if (xu_ui_id) {
9615
+ // let new_id = xu_ui_id + ts;
9616
+ // elm_to_delete.push(new_id);
9617
+
9618
+ // $(val).attr('xu-ui-id', new_id).removeData();
9619
+ // }
9620
+ // // else {
9621
+ // // $(val).remove();
9622
+ // // }
9623
+ // });
9624
+
9625
+ $elm.empty();
9626
+ if ($elm.data()) {
9627
+ const new_$div = await func.UI.screen.render_ui_tree(
9628
+ SESSION_ID,
9629
+ $elm, // the wrapper
9630
+ _.cloneDeep($elm.data().xuData.node), // the xu-panel node
9631
+ {},
9632
+ elm_data.xuData.paramsP, // the wrapper params
9633
+ null,
9634
+ null,
9635
+ elm_data.xuData.key, // the wrapper key
9636
+ refreshed_ds, // the refreshed_ds
9637
+ elm_data.xuData.parent_node, // the wrapper parent node
9638
+ null,
9639
+ elm_data.xuData.$root_container, // the wrapper root container
9640
+ );
9641
+
9642
+ // // remove old screen content
9643
+ // $.each(elm_to_delete, async function (key, val) {
9644
+ // $("[xu-ui-id='" + elm_to_delete + "']").remove();
9645
+ // });
9646
+
9647
+ if (_session.engine_mode === 'live_preview') {
9648
+ console.info('========= refresh main info ==============');
9649
+ console.info('reason:', refresh_reason);
9650
+ console.info('element:', $elm);
9651
+ console.info('==========================================');
9652
+ }
9653
+
9654
+ return;
9655
+ }
9656
+ }
9657
+ }
9658
+ }
9659
+ }
9660
9660
 
9661
9661
  const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9662
9662
 
@@ -9738,169 +9738,168 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
9738
9738
  }
9739
9739
  };
9740
9740
 
9741
- // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9742
- // // check the main program
9743
- // if (fields_changed_datasource) {
9744
- // const _session = SESSION_OBJ[SESSION_ID];
9745
- // const _ds = _session.DS_GLB[fields_changed_datasource];
9746
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9747
- // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
9748
- // for (const field_id of fields_changed_arr || []) {
9749
-
9750
- // }
9751
- // }
9741
+ func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9742
+ // check the main program
9743
+ if (fields_changed_datasource) {
9744
+ const _session = SESSION_OBJ[SESSION_ID];
9745
+ const _ds = _session.DS_GLB[fields_changed_datasource];
9746
+ const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9747
+ const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
9748
+ for (const field_id of fields_changed_arr || []) {
9749
+ }
9750
+ }
9752
9751
 
9753
- // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9752
+ const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9754
9753
 
9755
- // for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9756
- // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
9754
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9755
+ const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
9757
9756
 
9758
- // var found, refresh_reason, refresh_details;
9759
- // if (fields_changed_arr) {
9760
- // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
9761
- // continue;
9762
- // }
9763
- // for (const field_id of fields_changed_arr) {
9764
- // // get panel attributes
9765
- // const _attributes = panel_val?.panelXuAttributes || {};
9757
+ var found, refresh_reason, refresh_details;
9758
+ if (fields_changed_arr) {
9759
+ if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
9760
+ continue;
9761
+ }
9762
+ for (const field_id of fields_changed_arr) {
9763
+ // get panel attributes
9764
+ const _attributes = panel_val?.panelXuAttributes || {};
9766
9765
 
9767
- // // detect if program changed
9768
- // found = _attributes['xu-exp:program']?.includes('@' + field_id);
9766
+ // detect if program changed
9767
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
9769
9768
 
9770
- // if (found) {
9771
- // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9772
- // refresh_details = _attributes;
9773
- // break;
9774
- // }
9769
+ if (found) {
9770
+ refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9771
+ refresh_details = _attributes;
9772
+ break;
9773
+ }
9775
9774
 
9776
- // // _attributes holds also info of parameters in code_in: @code
9777
- // // search field changed in panel call send parameters exp
9778
- // for (const [attr, value] of Object.entries(_attributes)) {
9779
- // const pattern = /xu-exp:(\w+)/;
9780
- // const match = attr.match(pattern);
9775
+ // _attributes holds also info of parameters in code_in: @code
9776
+ // search field changed in panel call send parameters exp
9777
+ for (const [attr, value] of Object.entries(_attributes)) {
9778
+ const pattern = /xu-exp:(\w+)/;
9779
+ const match = attr.match(pattern);
9781
9780
 
9782
- // if (!match) {
9783
- // // continue if attribute is not expression
9784
- // continue;
9785
- // }
9786
- // // code_in
9787
- // const parameter_in_field_id = match?.[1];
9788
- // // @code
9789
- // if (value.includes(field_id)) {
9790
- // // search parameter in field in the target program's progDataSource
9791
- // found = progDataSource_str?.includes('@' + parameter_in_field_id);
9781
+ if (!match) {
9782
+ // continue if attribute is not expression
9783
+ continue;
9784
+ }
9785
+ // code_in
9786
+ const parameter_in_field_id = match?.[1];
9787
+ // @code
9788
+ if (value.includes(field_id)) {
9789
+ // search parameter in field in the target program's progDataSource
9790
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
9792
9791
 
9793
- // if (found) {
9794
- // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9795
- // refresh_details = panel_val?.prog_doc?.progDataSource;
9792
+ if (found) {
9793
+ refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9794
+ refresh_details = panel_val?.prog_doc?.progDataSource;
9796
9795
 
9797
- // break;
9798
- // }
9796
+ break;
9797
+ }
9799
9798
 
9800
- // // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
9801
- // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
9799
+ // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
9800
+ found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
9802
9801
 
9803
- // if (found) {
9804
- // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9805
- // refresh_details = found;
9802
+ if (found) {
9803
+ refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9804
+ refresh_details = found;
9806
9805
 
9807
- // break;
9808
- // }
9809
- // }
9810
- // }
9806
+ break;
9807
+ }
9808
+ }
9809
+ }
9811
9810
 
9812
- // if (found) break;
9811
+ if (found) break;
9813
9812
 
9814
- // // search field changed in the target program's progDataSource // @code
9815
- // found = progDataSource_str?.includes('@' + field_id);
9816
- // if (found) {
9817
- // refresh_reason = `field ${field_id} in progDataSource changed`;
9818
- // refresh_details = panel_val?.prog_doc?.progDataSource;
9813
+ // search field changed in the target program's progDataSource // @code
9814
+ found = progDataSource_str?.includes('@' + field_id);
9815
+ if (found) {
9816
+ refresh_reason = `field ${field_id} in progDataSource changed`;
9817
+ refresh_details = panel_val?.prog_doc?.progDataSource;
9819
9818
 
9820
- // break;
9821
- // }
9819
+ break;
9820
+ }
9822
9821
 
9823
- // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
9824
- // if (found) {
9825
- // refresh_reason = `field ${field_id} in progUi xu-for changed`;
9826
- // refresh_details = found;
9822
+ found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
9823
+ if (found) {
9824
+ refresh_reason = `field ${field_id} in progUi xu-for changed`;
9825
+ refresh_details = found;
9827
9826
 
9828
- // break;
9829
- // }
9827
+ break;
9828
+ }
9830
9829
 
9831
- // if (found) {
9832
- // break;
9833
- // }
9834
- // }
9835
- // }
9830
+ if (found) {
9831
+ break;
9832
+ }
9833
+ }
9834
+ }
9836
9835
 
9837
- // if (datasource_changed) {
9838
- // if (panel_val._ds.dsSession == datasource_changed) {
9839
- // refresh_reason = `panel datasource ${datasource_changed} changed`;
9840
- // refresh_details = '';
9836
+ if (datasource_changed) {
9837
+ if (panel_val._ds.dsSession == datasource_changed) {
9838
+ refresh_reason = `panel datasource ${datasource_changed} changed`;
9839
+ refresh_details = '';
9841
9840
 
9842
- // found = true;
9843
- // }
9844
- // }
9845
- // if (found) {
9846
- // const _session = SESSION_OBJ[SESSION_ID];
9847
- // if (_session.engine_mode === 'live_preview') {
9848
- // console.info('========= refresh info ==============');
9849
- // console.info('reason:', refresh_reason);
9850
- // console.info('details:', refresh_details);
9851
- // console.info('panel:', panel_val);
9852
- // console.info('=====================================');
9853
- // }
9854
- // const $div_elm = panel_val.$panel_div;
9855
- // const wrapper_data = $div_elm.data();
9841
+ found = true;
9842
+ }
9843
+ }
9844
+ if (found) {
9845
+ const _session = SESSION_OBJ[SESSION_ID];
9846
+ if (_session.engine_mode === 'live_preview') {
9847
+ console.info('========= refresh info ==============');
9848
+ console.info('reason:', refresh_reason);
9849
+ console.info('details:', refresh_details);
9850
+ console.info('panel:', panel_val);
9851
+ console.info('=====================================');
9852
+ }
9853
+ const $div_elm = panel_val.$panel_div;
9854
+ const wrapper_data = $div_elm.data();
9856
9855
 
9857
- // if (_.isEmpty(wrapper_data)) continue;
9856
+ if (_.isEmpty(wrapper_data)) continue;
9858
9857
 
9859
- // try {
9860
- // const ts = Date.now();
9861
- // // remove old panel content
9862
- // $.each(panel_val.ids, async function (key, val) {
9863
- // $("[xu-ui-id='" + val + "']")
9864
- // .attr('xu-ui-id', val + ts)
9865
- // .removeData();
9866
- // });
9858
+ try {
9859
+ const ts = Date.now();
9860
+ // remove old panel content
9861
+ $.each(panel_val.ids, async function (key, val) {
9862
+ $("[xu-ui-id='" + val + "']")
9863
+ .attr('xu-ui-id', val + ts)
9864
+ .removeData();
9865
+ });
9867
9866
 
9868
- // let refreshed_ds;
9869
- // // check if ds exist and deleted by garbage collector
9867
+ let refreshed_ds;
9868
+ // check if ds exist and deleted by garbage collector
9870
9869
 
9871
- // if (_session.DS_GLB[panel_val._ds.dsSession]) {
9872
- // refreshed_ds = panel_val._ds.dsSession;
9873
- // }
9874
- // for await (const item of wrapper_data.xuData.node_org.children) {
9875
- // if (item.tagName !== 'xu-panel') continue;
9870
+ if (_session.DS_GLB[panel_val._ds.dsSession]) {
9871
+ refreshed_ds = panel_val._ds.dsSession;
9872
+ }
9873
+ for await (const item of wrapper_data.xuData.node_org.children) {
9874
+ if (item.tagName !== 'xu-panel') continue;
9876
9875
 
9877
- // const new_$div = await func.UI.screen.render_ui_tree(
9878
- // SESSION_ID,
9879
- // $div_elm, // the wrapper
9880
- // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
9881
- // {},
9882
- // wrapper_data.xuData.paramsP, // the wrapper params
9883
- // null,
9884
- // null,
9885
- // wrapper_data.xuData.key, // the wrapper key
9886
- // refreshed_ds, // the refreshed_ds
9887
- // wrapper_data.xuData.parent_node, // the wrapper parent node
9888
- // null,
9889
- // wrapper_data.xuData.$root_container, // the wrapper root container
9890
- // );
9891
- // }
9876
+ const new_$div = await func.UI.screen.render_ui_tree(
9877
+ SESSION_ID,
9878
+ $div_elm, // the wrapper
9879
+ _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
9880
+ {},
9881
+ wrapper_data.xuData.paramsP, // the wrapper params
9882
+ null,
9883
+ null,
9884
+ wrapper_data.xuData.key, // the wrapper key
9885
+ refreshed_ds, // the refreshed_ds
9886
+ wrapper_data.xuData.parent_node, // the wrapper parent node
9887
+ null,
9888
+ wrapper_data.xuData.$root_container, // the wrapper root container
9889
+ );
9890
+ }
9892
9891
 
9893
- // // remove old panel content
9894
- // $.each(panel_val.ids, async function (key, val) {
9895
- // $("[xu-ui-id='" + val + ts + "']").remove();
9896
- // });
9897
- // } catch (error) {
9898
- // debugger;
9899
- // }
9900
- // // continue;
9901
- // }
9902
- // }
9903
- // };
9892
+ // remove old panel content
9893
+ $.each(panel_val.ids, async function (key, val) {
9894
+ $("[xu-ui-id='" + val + ts + "']").remove();
9895
+ });
9896
+ } catch (error) {
9897
+ debugger;
9898
+ }
9899
+ // continue;
9900
+ }
9901
+ }
9902
+ };
9904
9903
 
9905
9904
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {
9906
9905
  const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);