@xuda.io/runtime-bundle 1.0.718 → 1.0.720

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.
@@ -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) {
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) {
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,6 +8964,7 @@ 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,
8967
8968
  };
8968
8969
 
8969
8970
  switch (screen_type) {
@@ -9130,7 +9131,7 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
9130
9131
  rowIdP,
9131
9132
  jobNoP,
9132
9133
  null,
9133
- null,
9134
+ parameters_raw_obj,
9134
9135
  null,
9135
9136
  null,
9136
9137
  null,
@@ -9737,212 +9738,200 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
9737
9738
  }
9738
9739
  };
9739
9740
 
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 || []) {
9748
-
9749
- // }
9750
- // }
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
+ }
9751
9751
 
9752
- // 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);
9753
9753
 
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);
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);
9756
9756
 
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 || {};
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 || {};
9765
9765
 
9766
- // // detect if program changed
9767
- // found = _attributes['xu-exp:program']?.includes('@' + field_id);
9766
+ // detect if program changed
9767
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
9768
9768
 
9769
- // if (found) {
9770
- // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9771
- // refresh_details = _attributes;
9772
- // break;
9773
- // }
9769
+ if (found) {
9770
+ refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9771
+ refresh_details = _attributes;
9772
+ break;
9773
+ }
9774
9774
 
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);
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);
9780
9780
 
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);
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);
9791
9791
 
9792
- // if (found) {
9793
- // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9794
- // 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;
9795
9795
 
9796
- // break;
9797
- // }
9796
+ break;
9797
+ }
9798
9798
 
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;
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;
9801
9801
 
9802
- // if (found) {
9803
- // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9804
- // refresh_details = found;
9802
+ if (found) {
9803
+ refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9804
+ refresh_details = found;
9805
9805
 
9806
- // break;
9807
- // }
9808
- // }
9809
- // }
9806
+ break;
9807
+ }
9808
+ }
9809
+ }
9810
9810
 
9811
- // if (found) break;
9811
+ if (found) break;
9812
9812
 
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;
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;
9818
9818
 
9819
- // break;
9820
- // }
9819
+ break;
9820
+ }
9821
9821
 
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;
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;
9826
9826
 
9827
- // break;
9828
- // }
9827
+ break;
9828
+ }
9829
9829
 
9830
- // if (found) {
9831
- // break;
9832
- // }
9833
- // }
9834
- // }
9830
+ if (found) {
9831
+ break;
9832
+ }
9833
+ }
9834
+ }
9835
9835
 
9836
- // if (datasource_changed) {
9837
- // if (panel_val._ds.dsSession == datasource_changed) {
9838
- // refresh_reason = `panel datasource ${datasource_changed} changed`;
9839
- // 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 = '';
9840
9840
 
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();
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();
9855
9855
 
9856
- // if (_.isEmpty(wrapper_data)) continue;
9856
+ if (_.isEmpty(wrapper_data)) continue;
9857
9857
 
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
- // });
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
+ });
9866
9866
 
9867
- // let refreshed_ds;
9868
- // // check if ds exist and deleted by garbage collector
9867
+ let refreshed_ds;
9868
+ // check if ds exist and deleted by garbage collector
9869
9869
 
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;
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;
9875
9875
 
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
- // }
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
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
- // };
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
- var params_obj = {};
9909
+ let params_res = {},
9910
+ params_raw = {};
9910
9911
  if (_prog?.properties?.progParams) {
9911
9912
  for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
9912
9913
  if (!['in', 'out'].includes(val.data.dir)) continue;
9913
9914
 
9914
9915
  if (nodeP.attributes) {
9915
9916
  if (nodeP.attributes[val.data.parameter]) {
9916
- params_obj[val.data.parameter] = nodeP.attributes[val.data.parameter];
9917
+ params_res[val.data.parameter] = nodeP.attributes[val.data.parameter];
9917
9918
  } else if (nodeP.attributes[`xu-exp:${val.data.parameter}`]) {
9918
9919
  if (val.data.dir == 'out') {
9919
9920
  // only reference
9920
- params_obj[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
9921
+ params_res[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
9921
9922
  } else {
9922
9923
  // in parameter
9923
9924
  let ret = await func.expression.get(SESSION_ID, nodeP.attributes[`xu-exp:${val.data.parameter}`], dsSession, 'parameters');
9924
- params_obj[val.data.parameter] = ret.result;
9925
+ params_res[val.data.parameter] = ret.result;
9926
+ params_raw[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`];
9925
9927
  }
9926
9928
  }
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
- // }
9940
9929
  continue;
9941
9930
  }
9942
9931
  console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
9943
9932
  }
9944
9933
  }
9945
- return params_obj;
9934
+ return { params_res, params_raw };
9946
9935
  };
9947
9936
 
9948
9937
  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) {
@@ -9959,8 +9948,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
9959
9948
  const init_program = async function () {
9960
9949
  async function render_panel() {
9961
9950
  const prog_id = val.value?.prog || val.value;
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);
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);
9964
9953
  ret = { $new_div: ret_panel };
9965
9954
  $container.data().xuData.xuPanelProps = $elm.data().xuAttributes;
9966
9955
  $container.data().xuData.xuPanelData = ret_panel.data();
@@ -10009,8 +9998,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10009
9998
  const program = val.value?.prog || val.value;
10010
9999
  var $wrapper = $('<div>');
10011
10000
  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, '');
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');
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);
10014
10003
  ret = {
10015
10004
  $new_div: ret_init,
10016
10005
  abort: true,