@xuda.io/runtime-bundle 1.0.506 → 1.0.508
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.
- package/js/xuda-runtime-bundle.js +217 -12
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +217 -12
- package/js/xuda-runtime-slim.min.es.js +217 -12
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +201 -12
- package/js/xuda-worker-bundle.js +201 -12
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -3286,8 +3286,11 @@ func.datasource.create = async function (
|
|
|
3286
3286
|
};
|
|
3287
3287
|
|
|
3288
3288
|
var run_at = _prog_obj?.properties?.runAt;
|
|
3289
|
-
|
|
3290
|
-
|
|
3289
|
+
|
|
3290
|
+
if (_session.engine_mode !== 'live_preview') {
|
|
3291
|
+
if (_session.opt.app_computing_mode === 'main') {
|
|
3292
|
+
run_at = 'client';
|
|
3293
|
+
}
|
|
3291
3294
|
}
|
|
3292
3295
|
|
|
3293
3296
|
if (_prog_obj?.properties.menuType === 'globals') {
|
|
@@ -5043,7 +5046,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5043
5046
|
}
|
|
5044
5047
|
perform_delete();
|
|
5045
5048
|
};
|
|
5046
|
-
func.datasource.
|
|
5049
|
+
func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
5047
5050
|
return new Promise(async (resolve, reject) => {
|
|
5048
5051
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5049
5052
|
|
|
@@ -5146,7 +5149,202 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5146
5149
|
if (typeof fields_data === 'object') {
|
|
5147
5150
|
if (glb.GLOBAL_VARS[field_id]) {
|
|
5148
5151
|
_ds.data_system[field_id] = value;
|
|
5152
|
+
continue;
|
|
5153
|
+
}
|
|
5154
|
+
|
|
5155
|
+
// try {
|
|
5156
|
+
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5157
|
+
if (_ds.data_feed.rows[row_idx][field_id] !== value) {
|
|
5158
|
+
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
5159
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
5160
|
+
|
|
5161
|
+
// search the field in refs
|
|
5162
|
+
update_xu_ref();
|
|
5163
|
+
|
|
5164
|
+
if (!update_local_scope_only) {
|
|
5165
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5166
|
+
if (glb.IS_WORKER) {
|
|
5167
|
+
// RUN AT SERVER
|
|
5168
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5169
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5170
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5171
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5172
|
+
if (!client_datasource_changes[dataSource]) {
|
|
5173
|
+
client_datasource_changes[dataSource] = {};
|
|
5174
|
+
}
|
|
5175
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5176
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
5177
|
+
}
|
|
5178
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
} else {
|
|
5182
|
+
// RUN AT CLIENT
|
|
5183
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5184
|
+
if (!server_datasource_changes[dataSource]) {
|
|
5185
|
+
server_datasource_changes[dataSource] = {};
|
|
5186
|
+
}
|
|
5187
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5188
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
5189
|
+
}
|
|
5190
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5191
|
+
}
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5195
|
+
if (!fields_changed.includes(field_id)) {
|
|
5196
|
+
fields_changed.push(field_id);
|
|
5197
|
+
}
|
|
5198
|
+
if (!datasource_changed.includes(dataSource)) {
|
|
5199
|
+
datasource_changed.push(dataSource);
|
|
5200
|
+
}
|
|
5201
|
+
|
|
5202
|
+
if (!_ds.data_feed.rows_changed) {
|
|
5203
|
+
_ds.data_feed.rows_changed = [];
|
|
5204
|
+
}
|
|
5205
|
+
if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
|
|
5206
|
+
}
|
|
5207
|
+
} else if (fields_data === 'set') {
|
|
5208
|
+
_ds.currentRecordId = record_id;
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5214
|
+
if (glb.IS_WORKER) {
|
|
5215
|
+
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
5216
|
+
func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
|
|
5217
|
+
}
|
|
5218
|
+
} else {
|
|
5219
|
+
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
5220
|
+
const ret = await func.index.call_worker(SESSION_ID, {
|
|
5221
|
+
service: 'update_datasource_changes_from_client',
|
|
5222
|
+
data: {
|
|
5223
|
+
session_id: SESSION_ID,
|
|
5224
|
+
datasource_changes: server_datasource_changes,
|
|
5225
|
+
},
|
|
5226
|
+
id: _ds.worker_id,
|
|
5227
|
+
});
|
|
5228
|
+
}
|
|
5229
|
+
///// REFRESH SCREEN
|
|
5230
|
+
if (!avoid_refresh && fields_changed.length) {
|
|
5231
|
+
await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
5232
|
+
// await removed from the below function cause to dead lock Mar 3 25
|
|
5233
|
+
func.UI.screen.refresh_screen(
|
|
5234
|
+
SESSION_ID,
|
|
5235
|
+
fields_changed,
|
|
5236
|
+
null,
|
|
5237
|
+
datasource_changed[0], // refresh the current datasource only
|
|
5238
|
+
);
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
resolve();
|
|
5242
|
+
});
|
|
5243
|
+
};
|
|
5244
|
+
|
|
5245
|
+
func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
5246
|
+
return new Promise(async (resolve, reject) => {
|
|
5247
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
5248
|
+
|
|
5249
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
5250
|
+
update_local_scope_only = true;
|
|
5251
|
+
}
|
|
5149
5252
|
|
|
5253
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
5254
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5257
|
+
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
5258
|
+
// iterate child ds
|
|
5259
|
+
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5260
|
+
if (parent_ds !== null) {
|
|
5261
|
+
if (_ds.parentDataSourceNo != parent_ds) continue;
|
|
5262
|
+
} else {
|
|
5263
|
+
if (dsSession != dsNo) continue;
|
|
5264
|
+
}
|
|
5265
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5266
|
+
if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
|
|
5267
|
+
// check if field has fieldComputed property
|
|
5268
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
|
|
5269
|
+
// find if field is computed
|
|
5270
|
+
let fieldComputed_propExpressions, fieldComputed_id;
|
|
5271
|
+
for await (const val of _progFields) {
|
|
5272
|
+
const fieldId = val.data.field_id;
|
|
5273
|
+
|
|
5274
|
+
// if (fieldId !== field_id) continue
|
|
5275
|
+
if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
|
|
5276
|
+
|
|
5277
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue;
|
|
5278
|
+
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
5279
|
+
fieldComputed_propExpressions = _propExpressions;
|
|
5280
|
+
fieldComputed_id = fieldId;
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
|
|
5284
|
+
if (!fieldComputed_id) return;
|
|
5285
|
+
|
|
5286
|
+
// iterate ds rows
|
|
5287
|
+
for (const row of _ds.data_feed?.rows || []) {
|
|
5288
|
+
// iterate row fields
|
|
5289
|
+
for (const [key, val] of Object.entries(row)) {
|
|
5290
|
+
if (key !== fieldComputed_id) continue;
|
|
5291
|
+
try {
|
|
5292
|
+
let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
|
|
5293
|
+
|
|
5294
|
+
const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
|
|
5295
|
+
if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
|
|
5296
|
+
_ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
|
|
5297
|
+
if (!fields_changed.includes(fieldComputed_id)) {
|
|
5298
|
+
fields_changed.push(fieldComputed_id);
|
|
5299
|
+
}
|
|
5300
|
+
if (!datasource_changed.includes(dsSession)) {
|
|
5301
|
+
datasource_changed.push(dsSession);
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
} catch (err) {
|
|
5305
|
+
console.error(err);
|
|
5306
|
+
}
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
|
|
5311
|
+
}
|
|
5312
|
+
};
|
|
5313
|
+
|
|
5314
|
+
var fields_changed = [];
|
|
5315
|
+
var datasource_changed = [];
|
|
5316
|
+
let client_datasource_changes = {};
|
|
5317
|
+
let server_datasource_changes = {};
|
|
5318
|
+
// iterate changes datasource
|
|
5319
|
+
for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
|
|
5320
|
+
var _ds = _session.DS_GLB[dataSource];
|
|
5321
|
+
if (!_ds) {
|
|
5322
|
+
continue;
|
|
5323
|
+
}
|
|
5324
|
+
|
|
5325
|
+
const update_xu_ref = async function () {
|
|
5326
|
+
let _ds_0 = _session.DS_GLB[0];
|
|
5327
|
+
for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
|
|
5328
|
+
if (val.ds.dsSession == dataSource) {
|
|
5329
|
+
func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
|
|
5330
|
+
}
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5333
|
+
|
|
5334
|
+
// iterate changes records
|
|
5335
|
+
for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
5336
|
+
// iterate changes fields
|
|
5337
|
+
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
5338
|
+
// mechanism to make update directly on the datasource object
|
|
5339
|
+
if (record_id === 'datasource_main') {
|
|
5340
|
+
_.set(_ds, field_id, value);
|
|
5341
|
+
update_xu_ref();
|
|
5342
|
+
continue;
|
|
5343
|
+
}
|
|
5344
|
+
|
|
5345
|
+
if (typeof fields_data === 'object') {
|
|
5346
|
+
if (glb.GLOBAL_VARS[field_id]) {
|
|
5347
|
+
_ds.data_system[field_id] = value;
|
|
5150
5348
|
continue;
|
|
5151
5349
|
}
|
|
5152
5350
|
|
|
@@ -5158,15 +5356,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5158
5356
|
|
|
5159
5357
|
// search the field in refs
|
|
5160
5358
|
update_xu_ref();
|
|
5161
|
-
// let _ds_0 = _session.DS_GLB[0];
|
|
5162
|
-
// for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
|
|
5163
|
-
// if (val.ds.dsSession == dataSource) {
|
|
5164
|
-
// func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
|
|
5165
|
-
// // if (!fields_changed.includes(ref_name)) {
|
|
5166
|
-
// // fields_changed.push(ref_name);
|
|
5167
|
-
// // }
|
|
5168
|
-
// }
|
|
5169
|
-
// }
|
|
5170
5359
|
|
|
5171
5360
|
if (!update_local_scope_only) {
|
|
5172
5361
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
@@ -9126,6 +9315,22 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9126
9315
|
SYS_GLOBAL_OBJ_REFS[ref_field_id].attributes = attributes;
|
|
9127
9316
|
SYS_GLOBAL_OBJ_REFS[ref_field_id].xu_ui_id = $elm.attr('xu-ui-id');
|
|
9128
9317
|
}
|
|
9318
|
+
|
|
9319
|
+
// let obj = { ds: _ds, data: _ds?.data_feed?.rows?.[row_idx] || {}, props: _ds.in_parameters || {} };
|
|
9320
|
+
|
|
9321
|
+
// if ($elm) {
|
|
9322
|
+
// const attributes = $elm?.data()?.xuData?.xuPanelProps || $elm?.data()?.xuData?.debug_info?.attribute_stat || {};
|
|
9323
|
+
// obj.attributes = attributes;
|
|
9324
|
+
// obj.xu_ui_id = $elm.attr('xu-ui-id');
|
|
9325
|
+
// }
|
|
9326
|
+
|
|
9327
|
+
// func.datasource.update(SESSION_ID, {
|
|
9328
|
+
// [0]: {
|
|
9329
|
+
// ['datasource_main']: {
|
|
9330
|
+
// 'data_system.SYS_GLOBAL_OBJ_REFS': { [`${ref_field_id}`]: obj },
|
|
9331
|
+
// },
|
|
9332
|
+
// },
|
|
9333
|
+
// });
|
|
9129
9334
|
};
|
|
9130
9335
|
|
|
9131
9336
|
func.UI.find_field_in_progUi_attributes = function (progUi, field_id, prop, tag_name) {
|
|
@@ -3287,8 +3287,11 @@ func.datasource.create = async function (
|
|
|
3287
3287
|
};
|
|
3288
3288
|
|
|
3289
3289
|
var run_at = _prog_obj?.properties?.runAt;
|
|
3290
|
-
|
|
3291
|
-
|
|
3290
|
+
|
|
3291
|
+
if (_session.engine_mode !== 'live_preview') {
|
|
3292
|
+
if (_session.opt.app_computing_mode === 'main') {
|
|
3293
|
+
run_at = 'client';
|
|
3294
|
+
}
|
|
3292
3295
|
}
|
|
3293
3296
|
|
|
3294
3297
|
if (_prog_obj?.properties.menuType === 'globals') {
|
|
@@ -5044,7 +5047,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5044
5047
|
}
|
|
5045
5048
|
perform_delete();
|
|
5046
5049
|
};
|
|
5047
|
-
func.datasource.
|
|
5050
|
+
func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
5048
5051
|
return new Promise(async (resolve, reject) => {
|
|
5049
5052
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5050
5053
|
|
|
@@ -5147,7 +5150,202 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5147
5150
|
if (typeof fields_data === 'object') {
|
|
5148
5151
|
if (glb.GLOBAL_VARS[field_id]) {
|
|
5149
5152
|
_ds.data_system[field_id] = value;
|
|
5153
|
+
continue;
|
|
5154
|
+
}
|
|
5155
|
+
|
|
5156
|
+
// try {
|
|
5157
|
+
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5158
|
+
if (_ds.data_feed.rows[row_idx][field_id] !== value) {
|
|
5159
|
+
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
5160
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
5161
|
+
|
|
5162
|
+
// search the field in refs
|
|
5163
|
+
update_xu_ref();
|
|
5164
|
+
|
|
5165
|
+
if (!update_local_scope_only) {
|
|
5166
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5167
|
+
if (glb.IS_WORKER) {
|
|
5168
|
+
// RUN AT SERVER
|
|
5169
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5170
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5171
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5172
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5173
|
+
if (!client_datasource_changes[dataSource]) {
|
|
5174
|
+
client_datasource_changes[dataSource] = {};
|
|
5175
|
+
}
|
|
5176
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5177
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
5178
|
+
}
|
|
5179
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
} else {
|
|
5183
|
+
// RUN AT CLIENT
|
|
5184
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5185
|
+
if (!server_datasource_changes[dataSource]) {
|
|
5186
|
+
server_datasource_changes[dataSource] = {};
|
|
5187
|
+
}
|
|
5188
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5189
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
5190
|
+
}
|
|
5191
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
}
|
|
5195
|
+
|
|
5196
|
+
if (!fields_changed.includes(field_id)) {
|
|
5197
|
+
fields_changed.push(field_id);
|
|
5198
|
+
}
|
|
5199
|
+
if (!datasource_changed.includes(dataSource)) {
|
|
5200
|
+
datasource_changed.push(dataSource);
|
|
5201
|
+
}
|
|
5202
|
+
|
|
5203
|
+
if (!_ds.data_feed.rows_changed) {
|
|
5204
|
+
_ds.data_feed.rows_changed = [];
|
|
5205
|
+
}
|
|
5206
|
+
if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
|
|
5207
|
+
}
|
|
5208
|
+
} else if (fields_data === 'set') {
|
|
5209
|
+
_ds.currentRecordId = record_id;
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
|
|
5215
|
+
if (glb.IS_WORKER) {
|
|
5216
|
+
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
5217
|
+
func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
|
|
5218
|
+
}
|
|
5219
|
+
} else {
|
|
5220
|
+
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
5221
|
+
const ret = await func.index.call_worker(SESSION_ID, {
|
|
5222
|
+
service: 'update_datasource_changes_from_client',
|
|
5223
|
+
data: {
|
|
5224
|
+
session_id: SESSION_ID,
|
|
5225
|
+
datasource_changes: server_datasource_changes,
|
|
5226
|
+
},
|
|
5227
|
+
id: _ds.worker_id,
|
|
5228
|
+
});
|
|
5229
|
+
}
|
|
5230
|
+
///// REFRESH SCREEN
|
|
5231
|
+
if (!avoid_refresh && fields_changed.length) {
|
|
5232
|
+
await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
5233
|
+
// await removed from the below function cause to dead lock Mar 3 25
|
|
5234
|
+
func.UI.screen.refresh_screen(
|
|
5235
|
+
SESSION_ID,
|
|
5236
|
+
fields_changed,
|
|
5237
|
+
null,
|
|
5238
|
+
datasource_changed[0], // refresh the current datasource only
|
|
5239
|
+
);
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
resolve();
|
|
5243
|
+
});
|
|
5244
|
+
};
|
|
5245
|
+
|
|
5246
|
+
func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
5247
|
+
return new Promise(async (resolve, reject) => {
|
|
5248
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
5249
|
+
|
|
5250
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
5251
|
+
update_local_scope_only = true;
|
|
5252
|
+
}
|
|
5150
5253
|
|
|
5254
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
5255
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
5256
|
+
}
|
|
5257
|
+
|
|
5258
|
+
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
5259
|
+
// iterate child ds
|
|
5260
|
+
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5261
|
+
if (parent_ds !== null) {
|
|
5262
|
+
if (_ds.parentDataSourceNo != parent_ds) continue;
|
|
5263
|
+
} else {
|
|
5264
|
+
if (dsSession != dsNo) continue;
|
|
5265
|
+
}
|
|
5266
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5267
|
+
if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
|
|
5268
|
+
// check if field has fieldComputed property
|
|
5269
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
|
|
5270
|
+
// find if field is computed
|
|
5271
|
+
let fieldComputed_propExpressions, fieldComputed_id;
|
|
5272
|
+
for await (const val of _progFields) {
|
|
5273
|
+
const fieldId = val.data.field_id;
|
|
5274
|
+
|
|
5275
|
+
// if (fieldId !== field_id) continue
|
|
5276
|
+
if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
|
|
5277
|
+
|
|
5278
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue;
|
|
5279
|
+
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
5280
|
+
fieldComputed_propExpressions = _propExpressions;
|
|
5281
|
+
fieldComputed_id = fieldId;
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
|
|
5285
|
+
if (!fieldComputed_id) return;
|
|
5286
|
+
|
|
5287
|
+
// iterate ds rows
|
|
5288
|
+
for (const row of _ds.data_feed?.rows || []) {
|
|
5289
|
+
// iterate row fields
|
|
5290
|
+
for (const [key, val] of Object.entries(row)) {
|
|
5291
|
+
if (key !== fieldComputed_id) continue;
|
|
5292
|
+
try {
|
|
5293
|
+
let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
|
|
5294
|
+
|
|
5295
|
+
const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
|
|
5296
|
+
if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
|
|
5297
|
+
_ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
|
|
5298
|
+
if (!fields_changed.includes(fieldComputed_id)) {
|
|
5299
|
+
fields_changed.push(fieldComputed_id);
|
|
5300
|
+
}
|
|
5301
|
+
if (!datasource_changed.includes(dsSession)) {
|
|
5302
|
+
datasource_changed.push(dsSession);
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5305
|
+
} catch (err) {
|
|
5306
|
+
console.error(err);
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
}
|
|
5311
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
|
|
5312
|
+
}
|
|
5313
|
+
};
|
|
5314
|
+
|
|
5315
|
+
var fields_changed = [];
|
|
5316
|
+
var datasource_changed = [];
|
|
5317
|
+
let client_datasource_changes = {};
|
|
5318
|
+
let server_datasource_changes = {};
|
|
5319
|
+
// iterate changes datasource
|
|
5320
|
+
for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
|
|
5321
|
+
var _ds = _session.DS_GLB[dataSource];
|
|
5322
|
+
if (!_ds) {
|
|
5323
|
+
continue;
|
|
5324
|
+
}
|
|
5325
|
+
|
|
5326
|
+
const update_xu_ref = async function () {
|
|
5327
|
+
let _ds_0 = _session.DS_GLB[0];
|
|
5328
|
+
for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
|
|
5329
|
+
if (val.ds.dsSession == dataSource) {
|
|
5330
|
+
func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
};
|
|
5334
|
+
|
|
5335
|
+
// iterate changes records
|
|
5336
|
+
for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
5337
|
+
// iterate changes fields
|
|
5338
|
+
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
5339
|
+
// mechanism to make update directly on the datasource object
|
|
5340
|
+
if (record_id === 'datasource_main') {
|
|
5341
|
+
_.set(_ds, field_id, value);
|
|
5342
|
+
update_xu_ref();
|
|
5343
|
+
continue;
|
|
5344
|
+
}
|
|
5345
|
+
|
|
5346
|
+
if (typeof fields_data === 'object') {
|
|
5347
|
+
if (glb.GLOBAL_VARS[field_id]) {
|
|
5348
|
+
_ds.data_system[field_id] = value;
|
|
5151
5349
|
continue;
|
|
5152
5350
|
}
|
|
5153
5351
|
|
|
@@ -5159,15 +5357,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5159
5357
|
|
|
5160
5358
|
// search the field in refs
|
|
5161
5359
|
update_xu_ref();
|
|
5162
|
-
// let _ds_0 = _session.DS_GLB[0];
|
|
5163
|
-
// for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
|
|
5164
|
-
// if (val.ds.dsSession == dataSource) {
|
|
5165
|
-
// func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
|
|
5166
|
-
// // if (!fields_changed.includes(ref_name)) {
|
|
5167
|
-
// // fields_changed.push(ref_name);
|
|
5168
|
-
// // }
|
|
5169
|
-
// }
|
|
5170
|
-
// }
|
|
5171
5360
|
|
|
5172
5361
|
if (!update_local_scope_only) {
|
|
5173
5362
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
@@ -9127,6 +9316,22 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9127
9316
|
SYS_GLOBAL_OBJ_REFS[ref_field_id].attributes = attributes;
|
|
9128
9317
|
SYS_GLOBAL_OBJ_REFS[ref_field_id].xu_ui_id = $elm.attr('xu-ui-id');
|
|
9129
9318
|
}
|
|
9319
|
+
|
|
9320
|
+
// let obj = { ds: _ds, data: _ds?.data_feed?.rows?.[row_idx] || {}, props: _ds.in_parameters || {} };
|
|
9321
|
+
|
|
9322
|
+
// if ($elm) {
|
|
9323
|
+
// const attributes = $elm?.data()?.xuData?.xuPanelProps || $elm?.data()?.xuData?.debug_info?.attribute_stat || {};
|
|
9324
|
+
// obj.attributes = attributes;
|
|
9325
|
+
// obj.xu_ui_id = $elm.attr('xu-ui-id');
|
|
9326
|
+
// }
|
|
9327
|
+
|
|
9328
|
+
// func.datasource.update(SESSION_ID, {
|
|
9329
|
+
// [0]: {
|
|
9330
|
+
// ['datasource_main']: {
|
|
9331
|
+
// 'data_system.SYS_GLOBAL_OBJ_REFS': { [`${ref_field_id}`]: obj },
|
|
9332
|
+
// },
|
|
9333
|
+
// },
|
|
9334
|
+
// });
|
|
9130
9335
|
};
|
|
9131
9336
|
|
|
9132
9337
|
func.UI.find_field_in_progUi_attributes = function (progUi, field_id, prop, tag_name) {
|