@xuda.io/runtime-bundle 1.0.717 → 1.0.718

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
 
@@ -8911,7 +8911,7 @@ func.UI.find_field_in_progUi_attributes = function (progUi, field_id, prop, tag_
8911
8911
  return elm_nodes;
8912
8912
  };
8913
8913
  func.UI.screen = {};
8914
- func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callingDataSource_objP, $callingContainerP, triggerIdP, rowIdP, jobNoP, is_panelP, parameters_obj_inP, source_functionP, call_screen_propertiesP, refreshed_ds, parameters_raw_obj) {
8914
+ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callingDataSource_objP, $callingContainerP, triggerIdP, rowIdP, jobNoP, is_panelP, parameters_obj_inP, source_functionP, call_screen_propertiesP, refreshed_ds) {
8915
8915
  if (!prog_id) return console.error('program is empty');
8916
8916
  let screen_ret = await func.utils.get_screen_obj(SESSION_ID, prog_id);
8917
8917
  if (!screen_ret) return console.error('program is not a screen object');
@@ -8964,7 +8964,6 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
8964
8964
  screenInfo,
8965
8965
  call_screen_propertiesP,
8966
8966
  parentDataSourceNoP: _session.DS_GLB?.[callingDataSource_objP?.dsSession]?.dsSession || callingDataSource_objP?.parentDataSourceNo || 0,
8967
- parameters_raw_obj,
8968
8967
  };
8969
8968
 
8970
8969
  switch (screen_type) {
@@ -9131,7 +9130,7 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
9131
9130
  rowIdP,
9132
9131
  jobNoP,
9133
9132
  null,
9134
- parameters_raw_obj,
9133
+ null,
9135
9134
  null,
9136
9135
  null,
9137
9136
  null,
@@ -9738,200 +9737,212 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
9738
9737
  }
9739
9738
  };
9740
9739
 
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
- }
9740
+ // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9741
+ // // check the main program
9742
+ // if (fields_changed_datasource) {
9743
+ // const _session = SESSION_OBJ[SESSION_ID];
9744
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
9745
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9746
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
9747
+ // for (const field_id of fields_changed_arr || []) {
9751
9748
 
9752
- const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9749
+ // }
9750
+ // }
9753
9751
 
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);
9752
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9756
9753
 
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 || {};
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);
9765
9756
 
9766
- // detect if program changed
9767
- found = _attributes['xu-exp:program']?.includes('@' + field_id);
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 || {};
9768
9765
 
9769
- if (found) {
9770
- refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9771
- refresh_details = _attributes;
9772
- break;
9773
- }
9766
+ // // detect if program changed
9767
+ // found = _attributes['xu-exp:program']?.includes('@' + field_id);
9774
9768
 
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);
9769
+ // if (found) {
9770
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9771
+ // refresh_details = _attributes;
9772
+ // break;
9773
+ // }
9780
9774
 
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);
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);
9791
9780
 
9792
- if (found) {
9793
- refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9794
- refresh_details = panel_val?.prog_doc?.progDataSource;
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);
9795
9791
 
9796
- break;
9797
- }
9792
+ // if (found) {
9793
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9794
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
9798
9795
 
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;
9796
+ // break;
9797
+ // }
9801
9798
 
9802
- if (found) {
9803
- refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9804
- refresh_details = found;
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;
9805
9801
 
9806
- break;
9807
- }
9808
- }
9809
- }
9802
+ // if (found) {
9803
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9804
+ // refresh_details = found;
9810
9805
 
9811
- if (found) break;
9806
+ // break;
9807
+ // }
9808
+ // }
9809
+ // }
9812
9810
 
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;
9811
+ // if (found) break;
9818
9812
 
9819
- break;
9820
- }
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;
9821
9818
 
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;
9819
+ // break;
9820
+ // }
9826
9821
 
9827
- break;
9828
- }
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;
9829
9826
 
9830
- if (found) {
9831
- break;
9832
- }
9833
- }
9834
- }
9827
+ // break;
9828
+ // }
9835
9829
 
9836
- if (datasource_changed) {
9837
- if (panel_val._ds.dsSession == datasource_changed) {
9838
- refresh_reason = `panel datasource ${datasource_changed} changed`;
9839
- refresh_details = '';
9830
+ // if (found) {
9831
+ // break;
9832
+ // }
9833
+ // }
9834
+ // }
9840
9835
 
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();
9836
+ // if (datasource_changed) {
9837
+ // if (panel_val._ds.dsSession == datasource_changed) {
9838
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
9839
+ // refresh_details = '';
9855
9840
 
9856
- if (_.isEmpty(wrapper_data)) continue;
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();
9857
9855
 
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
- });
9856
+ // if (_.isEmpty(wrapper_data)) continue;
9866
9857
 
9867
- let refreshed_ds;
9868
- // check if ds exist and deleted by garbage collector
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
+ // });
9869
9866
 
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;
9867
+ // let refreshed_ds;
9868
+ // // check if ds exist and deleted by garbage collector
9875
9869
 
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
- }
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;
9891
9875
 
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
- };
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
+ // }
9891
+
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
+ // };
9903
9903
 
9904
9904
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {
9905
9905
  const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
9906
9906
  if (!_prog) return;
9907
9907
 
9908
9908
  // get in parameters
9909
- let params_res = {},
9910
- params_raw = {};
9909
+ var params_obj = {};
9911
9910
  if (_prog?.properties?.progParams) {
9912
9911
  for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
9913
9912
  if (!['in', 'out'].includes(val.data.dir)) continue;
9914
9913
 
9915
9914
  if (nodeP.attributes) {
9916
9915
  if (nodeP.attributes[val.data.parameter]) {
9917
- params_res[val.data.parameter] = nodeP.attributes[val.data.parameter];
9916
+ params_obj[val.data.parameter] = nodeP.attributes[val.data.parameter];
9918
9917
  } else if (nodeP.attributes[`xu-exp:${val.data.parameter}`]) {
9919
9918
  if (val.data.dir == 'out') {
9920
9919
  // only reference
9921
- params_res[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
9920
+ params_obj[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
9922
9921
  } else {
9923
9922
  // in parameter
9924
9923
  let ret = await func.expression.get(SESSION_ID, nodeP.attributes[`xu-exp:${val.data.parameter}`], dsSession, 'parameters');
9925
- params_res[val.data.parameter] = ret.result;
9926
- params_raw[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`];
9924
+ params_obj[val.data.parameter] = ret.result;
9927
9925
  }
9928
9926
  }
9927
+
9928
+ // if (parameters_obj_inP?.[val.data.parameter].fx) {
9929
+ // let ret = await func.expression.get(
9930
+ // SESSION_ID,
9931
+ // parameters_obj_inP?.[val.data.parameter].fx,
9932
+ // dsSession,
9933
+ // "parameters"
9934
+ // );
9935
+ // params_obj[val.data.parameter] = ret.result;
9936
+ // } else {
9937
+ // params_obj[val.data.parameter] =
9938
+ // parameters_obj_inP?.[val.data.parameter].value;
9939
+ // }
9929
9940
  continue;
9930
9941
  }
9931
9942
  console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
9932
9943
  }
9933
9944
  }
9934
- return { params_res, params_raw };
9945
+ return params_obj;
9935
9946
  };
9936
9947
 
9937
9948
  func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, xu_func, $elm, val, is_init, refreshed_ds) {
@@ -9948,8 +9959,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
9948
9959
  const init_program = async function () {
9949
9960
  async function render_panel() {
9950
9961
  const prog_id = val.value?.prog || val.value;
9951
- const params_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
9952
- let ret_panel = await func.UI.screen.init(SESSION_ID, prog_id, paramsP.screenId, _ds, $elm, null, _ds.currentRecordId, null, true, params_obj.params_res, 'initXu_panel', undefined, prog_id !== _ds.prog_id ? null : refreshed_ds, params_obj.params_raw);
9962
+ const param_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
9963
+ let ret_panel = await func.UI.screen.init(SESSION_ID, prog_id, paramsP.screenId, _ds, $elm, null, _ds.currentRecordId, null, true, param_obj, 'initXu_panel', undefined, prog_id !== _ds.prog_id ? null : refreshed_ds);
9953
9964
  ret = { $new_div: ret_panel };
9954
9965
  $container.data().xuData.xuPanelProps = $elm.data().xuAttributes;
9955
9966
  $container.data().xuData.xuPanelData = ret_panel.data();
@@ -9998,8 +10009,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
9998
10009
  const program = val.value?.prog || val.value;
9999
10010
  var $wrapper = $('<div>');
10000
10011
  var $div = func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, nodeP.attributes, null, null, null, $wrapper, '');
10001
- const params_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
10002
- let ret_init = await func.UI.screen.init(SESSION_ID, program, paramsP.screenId, _ds, $div, null, _ds.currentRecordId, jobNoP, true, params_obj.params_res, 'alterXu_panel', undefined, undefined, params_obj.params_raw);
10012
+ const param_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
10013
+ let ret_init = await func.UI.screen.init(SESSION_ID, program, paramsP.screenId, _ds, $div, null, _ds.currentRecordId, jobNoP, true, param_obj, 'alterXu_panel');
10003
10014
  ret = {
10004
10015
  $new_div: ret_init,
10005
10016
  abort: true,