@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.
@@ -3860,8 +3860,8 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3860
3860
  }
3861
3861
 
3862
3862
  // initiated with Update but no rows found
3863
- // if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
3864
- if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_raw_data_rows?.length) {
3863
+ if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
3864
+ // if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_raw_data_rows?.length) {
3865
3865
  _ds.set_mode = 'C';
3866
3866
  // _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
3867
3867
 
@@ -11870,71 +11870,71 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
11870
11870
  }
11871
11871
  };
11872
11872
 
11873
- // // check the main program
11874
- // if (fields_changed_datasource) {
11875
- // const _session = SESSION_OBJ[SESSION_ID];
11876
- // const _ds = _session.DS_GLB[fields_changed_datasource];
11877
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
11878
- // if (prog_doc.progUi) {
11879
- // validate_change(prog_doc, null, true);
11880
- // if (found) {
11881
- // const $elm = $(`#container_${_ds.prog_id}_0`);
11882
- // if ($elm?.length) {
11883
- // const elm_data = $elm.data();
11884
- // const $wrapper = $elm.parent();
11885
- // // const wrapper_data = $wrapper.data();
11886
- // const refreshed_ds = _ds.dsSession;
11887
-
11888
- // // let elm_to_delete = [];
11889
- // // const ts = Date.now();
11890
- // // $.each($elm.find('xu-root-component-' + SESSION_ID).find('*'), function (key, val) {
11891
- // // let xu_ui_id = $(val).attr('xu-ui-id');
11892
- // // if (xu_ui_id) {
11893
- // // let new_id = xu_ui_id + ts;
11894
- // // elm_to_delete.push(new_id);
11895
-
11896
- // // $(val).attr('xu-ui-id', new_id).removeData();
11897
- // // }
11898
- // // // else {
11899
- // // // $(val).remove();
11900
- // // // }
11901
- // // });
11902
-
11903
- // $elm.empty();
11904
- // if ($elm.data()) {
11905
- // const new_$div = await func.UI.screen.render_ui_tree(
11906
- // SESSION_ID,
11907
- // $elm, // the wrapper
11908
- // _.cloneDeep($elm.data().xuData.node), // the xu-panel node
11909
- // {},
11910
- // elm_data.xuData.paramsP, // the wrapper params
11911
- // null,
11912
- // null,
11913
- // elm_data.xuData.key, // the wrapper key
11914
- // refreshed_ds, // the refreshed_ds
11915
- // elm_data.xuData.parent_node, // the wrapper parent node
11916
- // null,
11917
- // elm_data.xuData.$root_container, // the wrapper root container
11918
- // );
11919
-
11920
- // // // remove old screen content
11921
- // // $.each(elm_to_delete, async function (key, val) {
11922
- // // $("[xu-ui-id='" + elm_to_delete + "']").remove();
11923
- // // });
11924
-
11925
- // if (_session.engine_mode === 'live_preview') {
11926
- // console.info('========= refresh main info ==============');
11927
- // console.info('reason:', refresh_reason);
11928
- // console.info('element:', $elm);
11929
- // console.info('==========================================');
11930
- // }
11931
-
11932
- // return;
11933
- // }
11934
- // }
11935
- // }
11936
- // }
11937
- // }
11873
+ // check the main program
11874
+ if (fields_changed_datasource) {
11875
+ const _session = SESSION_OBJ[SESSION_ID];
11876
+ const _ds = _session.DS_GLB[fields_changed_datasource];
11877
+ const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
11878
+ if (prog_doc.progUi) {
11879
+ validate_change(prog_doc, null, true);
11880
+ if (found) {
11881
+ const $elm = $(`#container_${_ds.prog_id}_0`);
11882
+ if ($elm?.length) {
11883
+ const elm_data = $elm.data();
11884
+ const $wrapper = $elm.parent();
11885
+ // const wrapper_data = $wrapper.data();
11886
+ const refreshed_ds = _ds.dsSession;
11887
+
11888
+ // let elm_to_delete = [];
11889
+ // const ts = Date.now();
11890
+ // $.each($elm.find('xu-root-component-' + SESSION_ID).find('*'), function (key, val) {
11891
+ // let xu_ui_id = $(val).attr('xu-ui-id');
11892
+ // if (xu_ui_id) {
11893
+ // let new_id = xu_ui_id + ts;
11894
+ // elm_to_delete.push(new_id);
11895
+
11896
+ // $(val).attr('xu-ui-id', new_id).removeData();
11897
+ // }
11898
+ // // else {
11899
+ // // $(val).remove();
11900
+ // // }
11901
+ // });
11902
+
11903
+ $elm.empty();
11904
+ if ($elm.data()) {
11905
+ const new_$div = await func.UI.screen.render_ui_tree(
11906
+ SESSION_ID,
11907
+ $elm, // the wrapper
11908
+ _.cloneDeep($elm.data().xuData.node), // the xu-panel node
11909
+ {},
11910
+ elm_data.xuData.paramsP, // the wrapper params
11911
+ null,
11912
+ null,
11913
+ elm_data.xuData.key, // the wrapper key
11914
+ refreshed_ds, // the refreshed_ds
11915
+ elm_data.xuData.parent_node, // the wrapper parent node
11916
+ null,
11917
+ elm_data.xuData.$root_container, // the wrapper root container
11918
+ );
11919
+
11920
+ // // remove old screen content
11921
+ // $.each(elm_to_delete, async function (key, val) {
11922
+ // $("[xu-ui-id='" + elm_to_delete + "']").remove();
11923
+ // });
11924
+
11925
+ if (_session.engine_mode === 'live_preview') {
11926
+ console.info('========= refresh main info ==============');
11927
+ console.info('reason:', refresh_reason);
11928
+ console.info('element:', $elm);
11929
+ console.info('==========================================');
11930
+ }
11931
+
11932
+ return;
11933
+ }
11934
+ }
11935
+ }
11936
+ }
11937
+ }
11938
11938
 
11939
11939
  const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
11940
11940
 
@@ -12016,169 +12016,168 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
12016
12016
  }
12017
12017
  };
12018
12018
 
12019
- // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
12020
- // // check the main program
12021
- // if (fields_changed_datasource) {
12022
- // const _session = SESSION_OBJ[SESSION_ID];
12023
- // const _ds = _session.DS_GLB[fields_changed_datasource];
12024
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
12025
- // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
12026
- // for (const field_id of fields_changed_arr || []) {
12027
-
12028
- // }
12029
- // }
12019
+ func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
12020
+ // check the main program
12021
+ if (fields_changed_datasource) {
12022
+ const _session = SESSION_OBJ[SESSION_ID];
12023
+ const _ds = _session.DS_GLB[fields_changed_datasource];
12024
+ const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
12025
+ const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
12026
+ for (const field_id of fields_changed_arr || []) {
12027
+ }
12028
+ }
12030
12029
 
12031
- // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
12030
+ const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
12032
12031
 
12033
- // for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
12034
- // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
12032
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
12033
+ const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
12035
12034
 
12036
- // var found, refresh_reason, refresh_details;
12037
- // if (fields_changed_arr) {
12038
- // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
12039
- // continue;
12040
- // }
12041
- // for (const field_id of fields_changed_arr) {
12042
- // // get panel attributes
12043
- // const _attributes = panel_val?.panelXuAttributes || {};
12035
+ var found, refresh_reason, refresh_details;
12036
+ if (fields_changed_arr) {
12037
+ if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
12038
+ continue;
12039
+ }
12040
+ for (const field_id of fields_changed_arr) {
12041
+ // get panel attributes
12042
+ const _attributes = panel_val?.panelXuAttributes || {};
12044
12043
 
12045
- // // detect if program changed
12046
- // found = _attributes['xu-exp:program']?.includes('@' + field_id);
12044
+ // detect if program changed
12045
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
12047
12046
 
12048
- // if (found) {
12049
- // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
12050
- // refresh_details = _attributes;
12051
- // break;
12052
- // }
12047
+ if (found) {
12048
+ refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
12049
+ refresh_details = _attributes;
12050
+ break;
12051
+ }
12053
12052
 
12054
- // // _attributes holds also info of parameters in code_in: @code
12055
- // // search field changed in panel call send parameters exp
12056
- // for (const [attr, value] of Object.entries(_attributes)) {
12057
- // const pattern = /xu-exp:(\w+)/;
12058
- // const match = attr.match(pattern);
12053
+ // _attributes holds also info of parameters in code_in: @code
12054
+ // search field changed in panel call send parameters exp
12055
+ for (const [attr, value] of Object.entries(_attributes)) {
12056
+ const pattern = /xu-exp:(\w+)/;
12057
+ const match = attr.match(pattern);
12059
12058
 
12060
- // if (!match) {
12061
- // // continue if attribute is not expression
12062
- // continue;
12063
- // }
12064
- // // code_in
12065
- // const parameter_in_field_id = match?.[1];
12066
- // // @code
12067
- // if (value.includes(field_id)) {
12068
- // // search parameter in field in the target program's progDataSource
12069
- // found = progDataSource_str?.includes('@' + parameter_in_field_id);
12059
+ if (!match) {
12060
+ // continue if attribute is not expression
12061
+ continue;
12062
+ }
12063
+ // code_in
12064
+ const parameter_in_field_id = match?.[1];
12065
+ // @code
12066
+ if (value.includes(field_id)) {
12067
+ // search parameter in field in the target program's progDataSource
12068
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
12070
12069
 
12071
- // if (found) {
12072
- // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
12073
- // refresh_details = panel_val?.prog_doc?.progDataSource;
12070
+ if (found) {
12071
+ refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
12072
+ refresh_details = panel_val?.prog_doc?.progDataSource;
12074
12073
 
12075
- // break;
12076
- // }
12074
+ break;
12075
+ }
12077
12076
 
12078
- // // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
12079
- // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
12077
+ // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
12078
+ found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
12080
12079
 
12081
- // if (found) {
12082
- // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
12083
- // refresh_details = found;
12080
+ if (found) {
12081
+ refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
12082
+ refresh_details = found;
12084
12083
 
12085
- // break;
12086
- // }
12087
- // }
12088
- // }
12084
+ break;
12085
+ }
12086
+ }
12087
+ }
12089
12088
 
12090
- // if (found) break;
12089
+ if (found) break;
12091
12090
 
12092
- // // search field changed in the target program's progDataSource // @code
12093
- // found = progDataSource_str?.includes('@' + field_id);
12094
- // if (found) {
12095
- // refresh_reason = `field ${field_id} in progDataSource changed`;
12096
- // refresh_details = panel_val?.prog_doc?.progDataSource;
12091
+ // search field changed in the target program's progDataSource // @code
12092
+ found = progDataSource_str?.includes('@' + field_id);
12093
+ if (found) {
12094
+ refresh_reason = `field ${field_id} in progDataSource changed`;
12095
+ refresh_details = panel_val?.prog_doc?.progDataSource;
12097
12096
 
12098
- // break;
12099
- // }
12097
+ break;
12098
+ }
12100
12099
 
12101
- // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
12102
- // if (found) {
12103
- // refresh_reason = `field ${field_id} in progUi xu-for changed`;
12104
- // refresh_details = found;
12100
+ found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
12101
+ if (found) {
12102
+ refresh_reason = `field ${field_id} in progUi xu-for changed`;
12103
+ refresh_details = found;
12105
12104
 
12106
- // break;
12107
- // }
12105
+ break;
12106
+ }
12108
12107
 
12109
- // if (found) {
12110
- // break;
12111
- // }
12112
- // }
12113
- // }
12108
+ if (found) {
12109
+ break;
12110
+ }
12111
+ }
12112
+ }
12114
12113
 
12115
- // if (datasource_changed) {
12116
- // if (panel_val._ds.dsSession == datasource_changed) {
12117
- // refresh_reason = `panel datasource ${datasource_changed} changed`;
12118
- // refresh_details = '';
12114
+ if (datasource_changed) {
12115
+ if (panel_val._ds.dsSession == datasource_changed) {
12116
+ refresh_reason = `panel datasource ${datasource_changed} changed`;
12117
+ refresh_details = '';
12119
12118
 
12120
- // found = true;
12121
- // }
12122
- // }
12123
- // if (found) {
12124
- // const _session = SESSION_OBJ[SESSION_ID];
12125
- // if (_session.engine_mode === 'live_preview') {
12126
- // console.info('========= refresh info ==============');
12127
- // console.info('reason:', refresh_reason);
12128
- // console.info('details:', refresh_details);
12129
- // console.info('panel:', panel_val);
12130
- // console.info('=====================================');
12131
- // }
12132
- // const $div_elm = panel_val.$panel_div;
12133
- // const wrapper_data = $div_elm.data();
12119
+ found = true;
12120
+ }
12121
+ }
12122
+ if (found) {
12123
+ const _session = SESSION_OBJ[SESSION_ID];
12124
+ if (_session.engine_mode === 'live_preview') {
12125
+ console.info('========= refresh info ==============');
12126
+ console.info('reason:', refresh_reason);
12127
+ console.info('details:', refresh_details);
12128
+ console.info('panel:', panel_val);
12129
+ console.info('=====================================');
12130
+ }
12131
+ const $div_elm = panel_val.$panel_div;
12132
+ const wrapper_data = $div_elm.data();
12134
12133
 
12135
- // if (_.isEmpty(wrapper_data)) continue;
12134
+ if (_.isEmpty(wrapper_data)) continue;
12136
12135
 
12137
- // try {
12138
- // const ts = Date.now();
12139
- // // remove old panel content
12140
- // $.each(panel_val.ids, async function (key, val) {
12141
- // $("[xu-ui-id='" + val + "']")
12142
- // .attr('xu-ui-id', val + ts)
12143
- // .removeData();
12144
- // });
12136
+ try {
12137
+ const ts = Date.now();
12138
+ // remove old panel content
12139
+ $.each(panel_val.ids, async function (key, val) {
12140
+ $("[xu-ui-id='" + val + "']")
12141
+ .attr('xu-ui-id', val + ts)
12142
+ .removeData();
12143
+ });
12145
12144
 
12146
- // let refreshed_ds;
12147
- // // check if ds exist and deleted by garbage collector
12145
+ let refreshed_ds;
12146
+ // check if ds exist and deleted by garbage collector
12148
12147
 
12149
- // if (_session.DS_GLB[panel_val._ds.dsSession]) {
12150
- // refreshed_ds = panel_val._ds.dsSession;
12151
- // }
12152
- // for await (const item of wrapper_data.xuData.node_org.children) {
12153
- // if (item.tagName !== 'xu-panel') continue;
12148
+ if (_session.DS_GLB[panel_val._ds.dsSession]) {
12149
+ refreshed_ds = panel_val._ds.dsSession;
12150
+ }
12151
+ for await (const item of wrapper_data.xuData.node_org.children) {
12152
+ if (item.tagName !== 'xu-panel') continue;
12154
12153
 
12155
- // const new_$div = await func.UI.screen.render_ui_tree(
12156
- // SESSION_ID,
12157
- // $div_elm, // the wrapper
12158
- // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
12159
- // {},
12160
- // wrapper_data.xuData.paramsP, // the wrapper params
12161
- // null,
12162
- // null,
12163
- // wrapper_data.xuData.key, // the wrapper key
12164
- // refreshed_ds, // the refreshed_ds
12165
- // wrapper_data.xuData.parent_node, // the wrapper parent node
12166
- // null,
12167
- // wrapper_data.xuData.$root_container, // the wrapper root container
12168
- // );
12169
- // }
12154
+ const new_$div = await func.UI.screen.render_ui_tree(
12155
+ SESSION_ID,
12156
+ $div_elm, // the wrapper
12157
+ _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
12158
+ {},
12159
+ wrapper_data.xuData.paramsP, // the wrapper params
12160
+ null,
12161
+ null,
12162
+ wrapper_data.xuData.key, // the wrapper key
12163
+ refreshed_ds, // the refreshed_ds
12164
+ wrapper_data.xuData.parent_node, // the wrapper parent node
12165
+ null,
12166
+ wrapper_data.xuData.$root_container, // the wrapper root container
12167
+ );
12168
+ }
12170
12169
 
12171
- // // remove old panel content
12172
- // $.each(panel_val.ids, async function (key, val) {
12173
- // $("[xu-ui-id='" + val + ts + "']").remove();
12174
- // });
12175
- // } catch (error) {
12176
- // debugger;
12177
- // }
12178
- // // continue;
12179
- // }
12180
- // }
12181
- // };
12170
+ // remove old panel content
12171
+ $.each(panel_val.ids, async function (key, val) {
12172
+ $("[xu-ui-id='" + val + ts + "']").remove();
12173
+ });
12174
+ } catch (error) {
12175
+ debugger;
12176
+ }
12177
+ // continue;
12178
+ }
12179
+ }
12180
+ };
12182
12181
 
12183
12182
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {
12184
12183
  const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);