@xuda.io/runtime-bundle 1.0.681 → 1.0.683

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.
@@ -3858,7 +3858,8 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3858
3858
  }
3859
3859
 
3860
3860
  // initiated with Update but no rows found
3861
- if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
3861
+ // if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
3862
+ if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_raw_data_rows?.length) {
3862
3863
  _ds.set_mode = 'C';
3863
3864
  // _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
3864
3865
 
@@ -11758,89 +11759,105 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11758
11759
  };
11759
11760
 
11760
11761
  func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
11761
- const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11762
-
11763
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11764
- const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
11765
-
11766
- var found, refresh_reason, refresh_details;
11767
- if (fields_changed_arr) {
11768
- if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
11769
- continue;
11762
+ var found, refresh_reason, refresh_details;
11763
+ const validate_change = function (prog_doc, panelXuAttributes) {
11764
+ found = null;
11765
+ refresh_reason = null;
11766
+ refresh_details = null;
11767
+ const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
11768
+ for (const field_id of fields_changed_arr) {
11769
+ // get panel attributes
11770
+ const _attributes = panelXuAttributes || {};
11771
+
11772
+ // detect if program changed
11773
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
11774
+
11775
+ if (found) {
11776
+ refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
11777
+ refresh_details = _attributes;
11778
+ break;
11770
11779
  }
11771
- for (const field_id of fields_changed_arr) {
11772
- // get panel attributes
11773
- const _attributes = panel_val?.panelXuAttributes || {};
11774
11780
 
11775
- // detect if program changed
11776
- found = _attributes['xu-exp:program']?.includes('@' + field_id);
11781
+ // _attributes holds also info of parameters in code_in: @code
11782
+ // search field changed in panel call send parameters exp
11783
+ for (const [attr, value] of Object.entries(_attributes)) {
11784
+ const pattern = /xu-exp:(\w+)/;
11785
+ const match = attr.match(pattern);
11777
11786
 
11778
- if (found) {
11779
- refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
11780
- refresh_details = _attributes;
11781
- break;
11787
+ if (!match) {
11788
+ // continue if attribute is not expression
11789
+ continue;
11782
11790
  }
11791
+ // code_in
11792
+ const parameter_in_field_id = match?.[1];
11793
+ // @code
11794
+ if (value.includes(field_id)) {
11795
+ // search parameter in field in the target program's progDataSource
11796
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
11783
11797
 
11784
- // _attributes holds also info of parameters in code_in: @code
11785
- // search field changed in panel call send parameters exp
11786
- for (const [attr, value] of Object.entries(_attributes)) {
11787
- const pattern = /xu-exp:(\w+)/;
11788
- const match = attr.match(pattern);
11798
+ if (found) {
11799
+ refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
11800
+ refresh_details = prog_doc?.progDataSource;
11789
11801
 
11790
- if (!match) {
11791
- // continue if attribute is not expression
11792
- continue;
11802
+ break;
11793
11803
  }
11794
- // code_in
11795
- const parameter_in_field_id = match?.[1];
11796
- // @code
11797
- if (value.includes(field_id)) {
11798
- // search parameter in field in the target program's progDataSource
11799
- found = progDataSource_str?.includes('@' + parameter_in_field_id);
11800
11804
 
11801
- if (found) {
11802
- refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
11803
- refresh_details = panel_val?.prog_doc?.progDataSource;
11805
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
11804
11806
 
11805
- break;
11806
- }
11807
-
11808
- // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
11809
- found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
11807
+ if (found) {
11808
+ refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
11809
+ refresh_details = found;
11810
11810
 
11811
- if (found) {
11812
- refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
11813
- refresh_details = found;
11814
-
11815
- break;
11816
- }
11811
+ break;
11817
11812
  }
11818
11813
  }
11814
+ }
11819
11815
 
11820
- if (found) break;
11816
+ if (found) break;
11821
11817
 
11822
- // search field changed in the target program's progDataSource // @code
11823
- found = progDataSource_str?.includes('@' + field_id);
11824
- if (found) {
11825
- refresh_reason = `field ${field_id} in progDataSource changed`;
11826
- refresh_details = panel_val?.prog_doc?.progDataSource;
11818
+ // search field changed in the target program's progDataSource // @code
11819
+ found = progDataSource_str?.includes('@' + field_id);
11820
+ if (found) {
11821
+ refresh_reason = `field ${field_id} in progDataSource changed`;
11822
+ refresh_details = prog_doc?.progDataSource;
11827
11823
 
11828
- break;
11829
- }
11824
+ break;
11825
+ }
11830
11826
 
11831
- found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
11832
- if (found) {
11833
- refresh_reason = `field ${field_id} in progUi xu-for changed`;
11834
- refresh_details = found;
11827
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, field_id, 'xu-for').length;
11828
+ if (found) {
11829
+ refresh_reason = `field ${field_id} in progUi xu-for changed`;
11830
+ refresh_details = found;
11835
11831
 
11836
- break;
11837
- }
11832
+ break;
11833
+ }
11838
11834
 
11839
- if (found) {
11840
- break;
11841
- }
11835
+ if (found) {
11836
+ break;
11842
11837
  }
11843
11838
  }
11839
+ };
11840
+
11841
+ // check the main program
11842
+ if (fields_changed_datasource) {
11843
+ const _session = SESSION_OBJ[SESSION_ID];
11844
+ const _ds = _session.DS_GLB[fields_changed_datasource];
11845
+ const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
11846
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
11847
+ validate_change(prog_doc);
11848
+ }
11849
+
11850
+ const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11851
+
11852
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11853
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
11854
+
11855
+ if (fields_changed_arr) {
11856
+ if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
11857
+ continue;
11858
+ }
11859
+ validate_change(panel_val.prog_doc, panel_val?.panelXuAttributes);
11860
+ }
11844
11861
 
11845
11862
  if (datasource_changed) {
11846
11863
  if (panel_val._ds.dsSession == datasource_changed) {
@@ -11910,25 +11927,40 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11910
11927
  }
11911
11928
  };
11912
11929
 
11913
- // func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
11914
- // const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);
11930
+ // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
11931
+ // // check the main program
11932
+ // if (fields_changed_datasource) {
11933
+ // const _session = SESSION_OBJ[SESSION_ID];
11934
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
11935
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
11936
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
11937
+ // for (const field_id of fields_changed_arr || []) {
11938
+
11939
+ // }
11940
+ // }
11941
+
11942
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11915
11943
 
11916
11944
  // for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11917
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val._ds.prog_id);
11918
- // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
11945
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
11919
11946
 
11920
- // var found;
11947
+ // var found, refresh_reason, refresh_details;
11921
11948
  // if (fields_changed_arr) {
11922
- // if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
11949
+ // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
11923
11950
  // continue;
11924
11951
  // }
11925
11952
  // for (const field_id of fields_changed_arr) {
11926
11953
  // // get panel attributes
11927
- // const _attributes = panel_val?.$div?.data()?.xuPanelData?.node?.attributes || {};
11954
+ // const _attributes = panel_val?.panelXuAttributes || {};
11928
11955
 
11929
11956
  // // detect if program changed
11930
11957
  // found = _attributes['xu-exp:program']?.includes('@' + field_id);
11931
- // if (found) break;
11958
+
11959
+ // if (found) {
11960
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
11961
+ // refresh_details = _attributes;
11962
+ // break;
11963
+ // }
11932
11964
 
11933
11965
  // // _attributes holds also info of parameters in code_in: @code
11934
11966
  // // search field changed in panel call send parameters exp
@@ -11946,11 +11978,23 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11946
11978
  // if (value.includes(field_id)) {
11947
11979
  // // search parameter in field in the target program's progDataSource
11948
11980
  // found = progDataSource_str?.includes('@' + parameter_in_field_id);
11949
- // if (found) break;
11981
+
11982
+ // if (found) {
11983
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
11984
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
11985
+
11986
+ // break;
11987
+ // }
11950
11988
 
11951
11989
  // // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
11952
- // found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
11953
- // if (found) break;
11990
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
11991
+
11992
+ // if (found) {
11993
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
11994
+ // refresh_details = found;
11995
+
11996
+ // break;
11997
+ // }
11954
11998
  // }
11955
11999
  // }
11956
12000
 
@@ -11958,63 +12002,93 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11958
12002
 
11959
12003
  // // search field changed in the target program's progDataSource // @code
11960
12004
  // found = progDataSource_str?.includes('@' + field_id);
11961
- // if (found) break;
12005
+ // if (found) {
12006
+ // refresh_reason = `field ${field_id} in progDataSource changed`;
12007
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
12008
+
12009
+ // break;
12010
+ // }
12011
+
12012
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
12013
+ // if (found) {
12014
+ // refresh_reason = `field ${field_id} in progUi xu-for changed`;
12015
+ // refresh_details = found;
12016
+
12017
+ // break;
12018
+ // }
12019
+
12020
+ // if (found) {
12021
+ // break;
12022
+ // }
11962
12023
  // }
11963
12024
  // }
11964
12025
 
11965
12026
  // if (datasource_changed) {
11966
12027
  // if (panel_val._ds.dsSession == datasource_changed) {
12028
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
12029
+ // refresh_details = '';
12030
+
11967
12031
  // found = true;
11968
12032
  // }
11969
12033
  // }
11970
12034
  // if (found) {
11971
- // var $div_elm = panel_val.$div
11972
- // .parent()
11973
- // .parent()
11974
- // .find("[xu-ui-id='" + parent_element_ui_id + "']");
12035
+ // const _session = SESSION_OBJ[SESSION_ID];
12036
+ // if (_session.engine_mode === 'live_preview') {
12037
+ // console.info('========= refresh info ==============');
12038
+ // console.info('reason:', refresh_reason);
12039
+ // console.info('details:', refresh_details);
12040
+ // console.info('panel:', panel_val);
12041
+ // console.info('=====================================');
12042
+ // }
12043
+ // const $div_elm = panel_val.$panel_div;
12044
+ // const wrapper_data = $div_elm.data();
12045
+
12046
+ // if (_.isEmpty(wrapper_data)) continue;
11975
12047
 
11976
- // // restore original panel
11977
12048
  // try {
11978
- // // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
12049
+ // const ts = Date.now();
12050
+ // // remove old panel content
12051
+ // $.each(panel_val.ids, async function (key, val) {
12052
+ // $("[xu-ui-id='" + val + "']")
12053
+ // .attr('xu-ui-id', val + ts)
12054
+ // .removeData();
12055
+ // });
11979
12056
 
11980
- // 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);
12057
+ // let refreshed_ds;
12058
+ // // check if ds exist and deleted by garbage collector
12059
+
12060
+ // if (_session.DS_GLB[panel_val._ds.dsSession]) {
12061
+ // refreshed_ds = panel_val._ds.dsSession;
12062
+ // }
12063
+ // for await (const item of wrapper_data.xuData.node_org.children) {
12064
+ // if (item.tagName !== 'xu-panel') continue;
12065
+
12066
+ // const new_$div = await func.UI.screen.render_ui_tree(
12067
+ // SESSION_ID,
12068
+ // $div_elm, // the wrapper
12069
+ // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
12070
+ // {},
12071
+ // wrapper_data.xuData.paramsP, // the wrapper params
12072
+ // null,
12073
+ // null,
12074
+ // wrapper_data.xuData.key, // the wrapper key
12075
+ // refreshed_ds, // the refreshed_ds
12076
+ // wrapper_data.xuData.parent_node, // the wrapper parent node
12077
+ // null,
12078
+ // wrapper_data.xuData.$root_container, // the wrapper root container
12079
+ // );
12080
+ // }
11981
12081
 
11982
12082
  // // remove old panel content
11983
12083
  // $.each(panel_val.ids, async function (key, val) {
11984
- // $("[xu-ui-id='" + val + "']").remove();
12084
+ // $("[xu-ui-id='" + val + ts + "']").remove();
11985
12085
  // });
11986
12086
  // } catch (error) {
11987
12087
  // debugger;
11988
12088
  // }
11989
- // break;
11990
- // }
11991
- // }
11992
- // };
11993
-
11994
- // const get_params_obj = async function (SESSION_ID, prog_id, parameters_obj_inP) {
11995
- // const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
11996
- // if (!_prog) {
11997
- // return;
11998
- // }
11999
-
12000
- // // get in parameters
12001
- // var params_obj = {};
12002
- // if (_prog?.properties?.progParams) {
12003
- // for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
12004
- // if (!val.data.dir === 'in') continue;
12005
- // if (typeof parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
12006
- // if (parameters_obj_inP?.[val.data.parameter].fx) {
12007
- // let ret = await func.expression.get(SESSION_ID, parameters_obj_inP?.[val.data.parameter].fx, dsSession, 'parameters');
12008
- // params_obj[val.data.parameter] = ret.result;
12009
- // } else {
12010
- // params_obj[val.data.parameter] = parameters_obj_inP?.[val.data.parameter].value;
12011
- // }
12012
- // continue;
12013
- // }
12014
- // console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
12089
+ // // continue;
12015
12090
  // }
12016
12091
  // }
12017
- // return params_obj;
12018
12092
  // };
12019
12093
 
12020
12094
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {