@xuda.io/runtime-bundle 1.0.681 → 1.0.682

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,88 +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;
11837
+ }
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
+ for (const field_id of fields_changed_arr || []) {
11848
+ }
11849
+ }
11850
+
11851
+ const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11852
+
11853
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
11854
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
11855
+
11856
+ if (fields_changed_arr) {
11857
+ if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
11858
+ continue;
11842
11859
  }
11860
+ validate_change(panel_val.prog_doc, panel_val?.panelXuAttributes);
11843
11861
  }
11844
11862
 
11845
11863
  if (datasource_changed) {
@@ -11910,25 +11928,40 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11910
11928
  }
11911
11929
  };
11912
11930
 
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);
11931
+ // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
11932
+ // // check the main program
11933
+ // if (fields_changed_datasource) {
11934
+ // const _session = SESSION_OBJ[SESSION_ID];
11935
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
11936
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
11937
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
11938
+ // for (const field_id of fields_changed_arr || []) {
11939
+
11940
+ // }
11941
+ // }
11942
+
11943
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11915
11944
 
11916
11945
  // 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);
11946
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
11919
11947
 
11920
- // var found;
11948
+ // var found, refresh_reason, refresh_details;
11921
11949
  // if (fields_changed_arr) {
11922
- // if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
11950
+ // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
11923
11951
  // continue;
11924
11952
  // }
11925
11953
  // for (const field_id of fields_changed_arr) {
11926
11954
  // // get panel attributes
11927
- // const _attributes = panel_val?.$div?.data()?.xuPanelData?.node?.attributes || {};
11955
+ // const _attributes = panel_val?.panelXuAttributes || {};
11928
11956
 
11929
11957
  // // detect if program changed
11930
11958
  // found = _attributes['xu-exp:program']?.includes('@' + field_id);
11931
- // if (found) break;
11959
+
11960
+ // if (found) {
11961
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
11962
+ // refresh_details = _attributes;
11963
+ // break;
11964
+ // }
11932
11965
 
11933
11966
  // // _attributes holds also info of parameters in code_in: @code
11934
11967
  // // search field changed in panel call send parameters exp
@@ -11946,11 +11979,23 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11946
11979
  // if (value.includes(field_id)) {
11947
11980
  // // search parameter in field in the target program's progDataSource
11948
11981
  // found = progDataSource_str?.includes('@' + parameter_in_field_id);
11949
- // if (found) break;
11982
+
11983
+ // if (found) {
11984
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
11985
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
11986
+
11987
+ // break;
11988
+ // }
11950
11989
 
11951
11990
  // // 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;
11991
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
11992
+
11993
+ // if (found) {
11994
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
11995
+ // refresh_details = found;
11996
+
11997
+ // break;
11998
+ // }
11954
11999
  // }
11955
12000
  // }
11956
12001
 
@@ -11958,63 +12003,93 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11958
12003
 
11959
12004
  // // search field changed in the target program's progDataSource // @code
11960
12005
  // found = progDataSource_str?.includes('@' + field_id);
11961
- // if (found) break;
12006
+ // if (found) {
12007
+ // refresh_reason = `field ${field_id} in progDataSource changed`;
12008
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
12009
+
12010
+ // break;
12011
+ // }
12012
+
12013
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
12014
+ // if (found) {
12015
+ // refresh_reason = `field ${field_id} in progUi xu-for changed`;
12016
+ // refresh_details = found;
12017
+
12018
+ // break;
12019
+ // }
12020
+
12021
+ // if (found) {
12022
+ // break;
12023
+ // }
11962
12024
  // }
11963
12025
  // }
11964
12026
 
11965
12027
  // if (datasource_changed) {
11966
12028
  // if (panel_val._ds.dsSession == datasource_changed) {
12029
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
12030
+ // refresh_details = '';
12031
+
11967
12032
  // found = true;
11968
12033
  // }
11969
12034
  // }
11970
12035
  // if (found) {
11971
- // var $div_elm = panel_val.$div
11972
- // .parent()
11973
- // .parent()
11974
- // .find("[xu-ui-id='" + parent_element_ui_id + "']");
12036
+ // const _session = SESSION_OBJ[SESSION_ID];
12037
+ // if (_session.engine_mode === 'live_preview') {
12038
+ // console.info('========= refresh info ==============');
12039
+ // console.info('reason:', refresh_reason);
12040
+ // console.info('details:', refresh_details);
12041
+ // console.info('panel:', panel_val);
12042
+ // console.info('=====================================');
12043
+ // }
12044
+ // const $div_elm = panel_val.$panel_div;
12045
+ // const wrapper_data = $div_elm.data();
12046
+
12047
+ // if (_.isEmpty(wrapper_data)) continue;
11975
12048
 
11976
- // // restore original panel
11977
12049
  // try {
11978
- // // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
12050
+ // const ts = Date.now();
12051
+ // // remove old panel content
12052
+ // $.each(panel_val.ids, async function (key, val) {
12053
+ // $("[xu-ui-id='" + val + "']")
12054
+ // .attr('xu-ui-id', val + ts)
12055
+ // .removeData();
12056
+ // });
11979
12057
 
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);
12058
+ // let refreshed_ds;
12059
+ // // check if ds exist and deleted by garbage collector
12060
+
12061
+ // if (_session.DS_GLB[panel_val._ds.dsSession]) {
12062
+ // refreshed_ds = panel_val._ds.dsSession;
12063
+ // }
12064
+ // for await (const item of wrapper_data.xuData.node_org.children) {
12065
+ // if (item.tagName !== 'xu-panel') continue;
12066
+
12067
+ // const new_$div = await func.UI.screen.render_ui_tree(
12068
+ // SESSION_ID,
12069
+ // $div_elm, // the wrapper
12070
+ // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
12071
+ // {},
12072
+ // wrapper_data.xuData.paramsP, // the wrapper params
12073
+ // null,
12074
+ // null,
12075
+ // wrapper_data.xuData.key, // the wrapper key
12076
+ // refreshed_ds, // the refreshed_ds
12077
+ // wrapper_data.xuData.parent_node, // the wrapper parent node
12078
+ // null,
12079
+ // wrapper_data.xuData.$root_container, // the wrapper root container
12080
+ // );
12081
+ // }
11981
12082
 
11982
12083
  // // remove old panel content
11983
12084
  // $.each(panel_val.ids, async function (key, val) {
11984
- // $("[xu-ui-id='" + val + "']").remove();
12085
+ // $("[xu-ui-id='" + val + ts + "']").remove();
11985
12086
  // });
11986
12087
  // } catch (error) {
11987
12088
  // debugger;
11988
12089
  // }
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`);
12090
+ // // continue;
12015
12091
  // }
12016
12092
  // }
12017
- // return params_obj;
12018
12093
  // };
12019
12094
 
12020
12095
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {