@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.
@@ -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
 
@@ -11189,7 +11189,7 @@ func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id,
11189
11189
  }
11190
11190
  };
11191
11191
  func.UI.screen = {};
11192
- 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) {
11192
+ 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) {
11193
11193
  if (!prog_id) return console.error('program is empty');
11194
11194
  let screen_ret = await func.utils.get_screen_obj(SESSION_ID, prog_id);
11195
11195
  if (!screen_ret) return console.error('program is not a screen object');
@@ -11242,7 +11242,6 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
11242
11242
  screenInfo,
11243
11243
  call_screen_propertiesP,
11244
11244
  parentDataSourceNoP: _session.DS_GLB?.[callingDataSource_objP?.dsSession]?.dsSession || callingDataSource_objP?.parentDataSourceNo || 0,
11245
- parameters_raw_obj,
11246
11245
  };
11247
11246
 
11248
11247
  switch (screen_type) {
@@ -11409,7 +11408,7 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
11409
11408
  rowIdP,
11410
11409
  jobNoP,
11411
11410
  null,
11412
- parameters_raw_obj,
11411
+ null,
11413
11412
  null,
11414
11413
  null,
11415
11414
  null,
@@ -12016,200 +12015,212 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
12016
12015
  }
12017
12016
  };
12018
12017
 
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
- }
12018
+ // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
12019
+ // // check the main program
12020
+ // if (fields_changed_datasource) {
12021
+ // const _session = SESSION_OBJ[SESSION_ID];
12022
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
12023
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
12024
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
12025
+ // for (const field_id of fields_changed_arr || []) {
12029
12026
 
12030
- const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
12027
+ // }
12028
+ // }
12031
12029
 
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);
12030
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
12034
12031
 
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 || {};
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);
12043
12034
 
12044
- // detect if program changed
12045
- found = _attributes['xu-exp:program']?.includes('@' + field_id);
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 || {};
12046
12043
 
12047
- if (found) {
12048
- refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
12049
- refresh_details = _attributes;
12050
- break;
12051
- }
12044
+ // // detect if program changed
12045
+ // found = _attributes['xu-exp:program']?.includes('@' + field_id);
12052
12046
 
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);
12047
+ // if (found) {
12048
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
12049
+ // refresh_details = _attributes;
12050
+ // break;
12051
+ // }
12058
12052
 
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);
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);
12069
12058
 
12070
- if (found) {
12071
- refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
12072
- refresh_details = panel_val?.prog_doc?.progDataSource;
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);
12073
12069
 
12074
- break;
12075
- }
12070
+ // if (found) {
12071
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
12072
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
12076
12073
 
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;
12074
+ // break;
12075
+ // }
12079
12076
 
12080
- if (found) {
12081
- refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
12082
- refresh_details = found;
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;
12083
12079
 
12084
- break;
12085
- }
12086
- }
12087
- }
12080
+ // if (found) {
12081
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
12082
+ // refresh_details = found;
12088
12083
 
12089
- if (found) break;
12084
+ // break;
12085
+ // }
12086
+ // }
12087
+ // }
12090
12088
 
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;
12089
+ // if (found) break;
12096
12090
 
12097
- break;
12098
- }
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;
12099
12096
 
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;
12097
+ // break;
12098
+ // }
12104
12099
 
12105
- break;
12106
- }
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;
12107
12104
 
12108
- if (found) {
12109
- break;
12110
- }
12111
- }
12112
- }
12105
+ // break;
12106
+ // }
12113
12107
 
12114
- if (datasource_changed) {
12115
- if (panel_val._ds.dsSession == datasource_changed) {
12116
- refresh_reason = `panel datasource ${datasource_changed} changed`;
12117
- refresh_details = '';
12108
+ // if (found) {
12109
+ // break;
12110
+ // }
12111
+ // }
12112
+ // }
12118
12113
 
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();
12114
+ // if (datasource_changed) {
12115
+ // if (panel_val._ds.dsSession == datasource_changed) {
12116
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
12117
+ // refresh_details = '';
12133
12118
 
12134
- if (_.isEmpty(wrapper_data)) continue;
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();
12135
12133
 
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
- });
12134
+ // if (_.isEmpty(wrapper_data)) continue;
12144
12135
 
12145
- let refreshed_ds;
12146
- // check if ds exist and deleted by garbage collector
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
+ // });
12147
12144
 
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;
12145
+ // let refreshed_ds;
12146
+ // // check if ds exist and deleted by garbage collector
12153
12147
 
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
- }
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;
12169
12153
 
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
- };
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
+ // }
12169
+
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
+ // };
12181
12181
 
12182
12182
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {
12183
12183
  const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
12184
12184
  if (!_prog) return;
12185
12185
 
12186
12186
  // get in parameters
12187
- let params_res = {},
12188
- params_raw = {};
12187
+ var params_obj = {};
12189
12188
  if (_prog?.properties?.progParams) {
12190
12189
  for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
12191
12190
  if (!['in', 'out'].includes(val.data.dir)) continue;
12192
12191
 
12193
12192
  if (nodeP.attributes) {
12194
12193
  if (nodeP.attributes[val.data.parameter]) {
12195
- params_res[val.data.parameter] = nodeP.attributes[val.data.parameter];
12194
+ params_obj[val.data.parameter] = nodeP.attributes[val.data.parameter];
12196
12195
  } else if (nodeP.attributes[`xu-exp:${val.data.parameter}`]) {
12197
12196
  if (val.data.dir == 'out') {
12198
12197
  // only reference
12199
- params_res[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
12198
+ params_obj[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`].replaceAll('@', '');
12200
12199
  } else {
12201
12200
  // in parameter
12202
12201
  let ret = await func.expression.get(SESSION_ID, nodeP.attributes[`xu-exp:${val.data.parameter}`], dsSession, 'parameters');
12203
- params_res[val.data.parameter] = ret.result;
12204
- params_raw[val.data.parameter] = nodeP.attributes[`xu-exp:${val.data.parameter}`];
12202
+ params_obj[val.data.parameter] = ret.result;
12205
12203
  }
12206
12204
  }
12205
+
12206
+ // if (parameters_obj_inP?.[val.data.parameter].fx) {
12207
+ // let ret = await func.expression.get(
12208
+ // SESSION_ID,
12209
+ // parameters_obj_inP?.[val.data.parameter].fx,
12210
+ // dsSession,
12211
+ // "parameters"
12212
+ // );
12213
+ // params_obj[val.data.parameter] = ret.result;
12214
+ // } else {
12215
+ // params_obj[val.data.parameter] =
12216
+ // parameters_obj_inP?.[val.data.parameter].value;
12217
+ // }
12207
12218
  continue;
12208
12219
  }
12209
12220
  console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
12210
12221
  }
12211
12222
  }
12212
- return { params_res, params_raw };
12223
+ return params_obj;
12213
12224
  };
12214
12225
 
12215
12226
  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) {
@@ -12226,8 +12237,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12226
12237
  const init_program = async function () {
12227
12238
  async function render_panel() {
12228
12239
  const prog_id = val.value?.prog || val.value;
12229
- const params_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
12230
- 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);
12240
+ const param_obj = await get_params_obj_new(SESSION_ID, prog_id, nodeP, paramsP.dsSessionP);
12241
+ 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);
12231
12242
  ret = { $new_div: ret_panel };
12232
12243
  $container.data().xuData.xuPanelProps = $elm.data().xuAttributes;
12233
12244
  $container.data().xuData.xuPanelData = ret_panel.data();
@@ -12276,8 +12287,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12276
12287
  const program = val.value?.prog || val.value;
12277
12288
  var $wrapper = $('<div>');
12278
12289
  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, '');
12279
- const params_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
12280
- 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);
12290
+ const param_obj = await get_params_obj_new(SESSION_ID, program, nodeP, paramsP.dsSessionP);
12291
+ let ret_init = await func.UI.screen.init(SESSION_ID, program, paramsP.screenId, _ds, $div, null, _ds.currentRecordId, jobNoP, true, param_obj, 'alterXu_panel');
12281
12292
  ret = {
12282
12293
  $new_div: ret_init,
12283
12294
  abort: true,