@xuda.io/runtime-bundle 1.0.290 → 1.0.292
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 +2 -292
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +2 -292
- package/js/xuda-runtime-slim.min.es.js +2 -292
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +2 -292
- package/js/xuda-worker-bundle.js +2 -292
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -4280,6 +4280,7 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
|
|
|
4280
4280
|
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', 'newRecord');
|
|
4281
4281
|
}
|
|
4282
4282
|
}
|
|
4283
|
+
await func.datasource.callback(SESSION_ID, dataSourceSession, args.dataSourceNoP, args.rowIdP, args.jobNoP, null, _ds.prog_id);
|
|
4283
4284
|
};
|
|
4284
4285
|
if (!rows) {
|
|
4285
4286
|
await row_not_found();
|
|
@@ -4567,64 +4568,6 @@ func.datasource.render_fields_form = async function (SESSION_ID, dataSourceSessi
|
|
|
4567
4568
|
}
|
|
4568
4569
|
};
|
|
4569
4570
|
|
|
4570
|
-
// func.datasource.run_rows_form = async function (
|
|
4571
|
-
// SESSION_ID,
|
|
4572
|
-
// dataSourceSession,
|
|
4573
|
-
// rowIdxP,
|
|
4574
|
-
// raw_data_row
|
|
4575
|
-
// ) {
|
|
4576
|
-
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
4577
|
-
// if (!_ds) return;
|
|
4578
|
-
// let _ROWID = raw_data_row.id;
|
|
4579
|
-
// // var val = _ds.data_feed.rows[rowIdxP];
|
|
4580
|
-
|
|
4581
|
-
// var idx = rowIdxP;
|
|
4582
|
-
|
|
4583
|
-
// const find_ROWID_idx_from_raw_data_arr = function (rowId) {
|
|
4584
|
-
// if (!_ds?.v?.raw_data?.rows) {
|
|
4585
|
-
// throw new Error("ds.v.raw_data.rows not found");
|
|
4586
|
-
// }
|
|
4587
|
-
|
|
4588
|
-
// const index = _ds.v.raw_data.rows.findIndex((item) => item.id === rowId);
|
|
4589
|
-
// if (index === -1) {
|
|
4590
|
-
// throw new Error(`item.id "${rowId}" not found`);
|
|
4591
|
-
// }
|
|
4592
|
-
// return index;
|
|
4593
|
-
// };
|
|
4594
|
-
|
|
4595
|
-
// try {
|
|
4596
|
-
// idx = find_ROWID_idx_from_raw_data_arr(raw_data_row.id);
|
|
4597
|
-
// } catch (e) {
|
|
4598
|
-
// _ROWID = "newRecord";
|
|
4599
|
-
// _ds.data_feed.rows.push({ _ROWID });
|
|
4600
|
-
// idx = func.common.find_ROWID_idx(_ds, _ROWID);
|
|
4601
|
-
// }
|
|
4602
|
-
|
|
4603
|
-
// _ds.currentRecordId = _ROWID; // set temporary to allow expression decoder work
|
|
4604
|
-
|
|
4605
|
-
// await func.datasource.render_fields_form(
|
|
4606
|
-
// SESSION_ID,
|
|
4607
|
-
// dataSourceSession,
|
|
4608
|
-
// raw_data_row
|
|
4609
|
-
// );
|
|
4610
|
-
// const init_count = await func.datasource.get_field_init_count(
|
|
4611
|
-
// SESSION_ID,
|
|
4612
|
-
// dataSourceSession,
|
|
4613
|
-
// _ROWID,
|
|
4614
|
-
// false,
|
|
4615
|
-
// _ds.oninit_triggers_to_run
|
|
4616
|
-
// );
|
|
4617
|
-
// if (init_count > 0) {
|
|
4618
|
-
// await func.datasource.execute_field_init_events(
|
|
4619
|
-
// SESSION_ID,
|
|
4620
|
-
// dataSourceSession,
|
|
4621
|
-
// "form",
|
|
4622
|
-
// _ds.data_feed.rows[idx]._ROWID
|
|
4623
|
-
// );
|
|
4624
|
-
// }
|
|
4625
|
-
// // await form_continue();
|
|
4626
|
-
// };
|
|
4627
|
-
|
|
4628
4571
|
func.datasource.execute_field_init_events = async function (SESSION_ID, dataSourceSession, sourceP, rowIdP) {
|
|
4629
4572
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
4630
4573
|
var args = _ds.args;
|
|
@@ -5246,11 +5189,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5246
5189
|
_ds.currentRecordId = record_id;
|
|
5247
5190
|
}
|
|
5248
5191
|
}
|
|
5249
|
-
// if (!_ds.data_feed.rows_changed) {
|
|
5250
|
-
// _ds.data_feed.rows_changed = [];
|
|
5251
|
-
// }
|
|
5252
|
-
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
5253
|
-
// _ds.data_feed.rows_changed.push(record_id);
|
|
5254
5192
|
}
|
|
5255
5193
|
}
|
|
5256
5194
|
|
|
@@ -5284,238 +5222,10 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5284
5222
|
});
|
|
5285
5223
|
};
|
|
5286
5224
|
|
|
5287
|
-
// func.datasource.update = async function (
|
|
5288
|
-
// SESSION_ID,
|
|
5289
|
-
// datasource_changes,
|
|
5290
|
-
// update_local_scope_only
|
|
5291
|
-
// ) {
|
|
5292
|
-
// return new Promise(async (resolve, reject) => {
|
|
5293
|
-
// var _session = SESSION_OBJ[SESSION_ID];
|
|
5294
|
-
|
|
5295
|
-
// if (typeof glb.GLOBAL_VARS === "undefined") {
|
|
5296
|
-
// glb.GLOBAL_VARS = (
|
|
5297
|
-
// await func.common.get_module(
|
|
5298
|
-
// SESSION_ID,
|
|
5299
|
-
// "xuda-system-globals-module.mjs"
|
|
5300
|
-
// )
|
|
5301
|
-
// ).system_globals;
|
|
5302
|
-
// }
|
|
5303
|
-
|
|
5304
|
-
// let fieldComputed_datasource_changes = {};
|
|
5305
|
-
|
|
5306
|
-
// const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
5307
|
-
|
|
5308
|
-
// // iterate child ds
|
|
5309
|
-
// for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5310
|
-
// if (parent_ds !== null) {
|
|
5311
|
-
// if (_ds.parentDataSourceNo != parent_ds) continue
|
|
5312
|
-
// } else {
|
|
5313
|
-
// if (dsSession != dsNo) continue
|
|
5314
|
-
// }
|
|
5315
|
-
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5316
|
-
// if (tree_ret.menuType === "component" || tree_ret.menuType === "globals") {
|
|
5317
|
-
// // check if field has fieldComputed property
|
|
5318
|
-
// const _progFields = await func.datasource.get_progFields(
|
|
5319
|
-
// SESSION_ID,
|
|
5320
|
-
// dsSession
|
|
5321
|
-
// );
|
|
5322
|
-
// // find if field is computed
|
|
5323
|
-
// let propExpressions
|
|
5324
|
-
// for await (const val of _progFields) {
|
|
5325
|
-
|
|
5326
|
-
// const fieldId = val.data.field_id;
|
|
5327
|
-
|
|
5328
|
-
// if (fieldId !== field_id) continue
|
|
5329
|
-
// if (val.data.type !== "virtual" || !val.props.fieldComputed) break
|
|
5330
|
-
|
|
5331
|
-
// const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
5332
|
-
// if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
5333
|
-
// propExpressions = _propExpressions
|
|
5334
|
-
// }
|
|
5335
|
-
// }
|
|
5336
|
-
|
|
5337
|
-
// if (!propExpressions) return
|
|
5338
|
-
|
|
5339
|
-
// if (!fieldComputed_datasource_changes[dsSession]) {
|
|
5340
|
-
// fieldComputed_datasource_changes[dsSession] = {}
|
|
5341
|
-
// }
|
|
5342
|
-
// // iterate ds rows
|
|
5343
|
-
// for (const row of _ds.data_feed?.rows || []) {
|
|
5344
|
-
// // iterate row fields
|
|
5345
|
-
// for (const [key, val] of Object.entries(row)) {
|
|
5346
|
-
// if (key !== field_id) return
|
|
5347
|
-
// try {
|
|
5348
|
-
// if (!fieldComputed_datasource_changes[dsSession][row._ROWID]) {
|
|
5349
|
-
// fieldComputed_datasource_changes[dsSession][row._ROWID] = {}
|
|
5350
|
-
// }
|
|
5351
|
-
// let ret = await func.expression.get(
|
|
5352
|
-
// SESSION_ID,
|
|
5353
|
-
// propExpressions,
|
|
5354
|
-
// dsNo,
|
|
5355
|
-
// "update",
|
|
5356
|
-
// row._ROWID
|
|
5357
|
-
// );
|
|
5358
|
-
// fieldComputed_datasource_changes[dsSession][row._ROWID][field_id] = ret.result
|
|
5359
|
-
// // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5360
|
-
|
|
5361
|
-
// // _ds.data_feed.rows[row_idx][field_id] = ret.result;
|
|
5362
|
-
// } catch (err) {
|
|
5363
|
-
// console.error(err);
|
|
5364
|
-
// }
|
|
5365
|
-
// }
|
|
5366
|
-
// }
|
|
5367
|
-
// }
|
|
5368
|
-
// await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
5369
|
-
// }
|
|
5370
|
-
// debugger
|
|
5371
|
-
|
|
5372
|
-
// }
|
|
5373
|
-
|
|
5374
|
-
// var fields_changed = [];
|
|
5375
|
-
// var datasource_changed = [];
|
|
5376
|
-
// let client_datasource_changes={}
|
|
5377
|
-
// // iterate changes datasource
|
|
5378
|
-
// for await (const [dataSource, row_data] of Object.entries(
|
|
5379
|
-
// datasource_changes
|
|
5380
|
-
// )) {
|
|
5381
|
-
// var _ds = _session.DS_GLB[dataSource];
|
|
5382
|
-
// if (!_ds) {
|
|
5383
|
-
// continue;
|
|
5384
|
-
// }
|
|
5385
|
-
// // iterate changes records
|
|
5386
|
-
// for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
5387
|
-
// // iterate changes fields
|
|
5388
|
-
// for (const [field_id, value] of Object.entries(fields_data)) {
|
|
5389
|
-
// // mechanism to make update directly on the datasource object
|
|
5390
|
-
// if (record_id === "datasource_main") {
|
|
5391
|
-
// _.set(_ds, field_id, value);
|
|
5392
|
-
// continue;
|
|
5393
|
-
// }
|
|
5394
|
-
|
|
5395
|
-
// if (typeof fields_data === "object") {
|
|
5396
|
-
// if (glb.GLOBAL_VARS[field_id]) {
|
|
5397
|
-
// _ds.data_system[field_id] = value;
|
|
5398
|
-
|
|
5399
|
-
// continue;
|
|
5400
|
-
// }
|
|
5401
|
-
|
|
5402
|
-
// try {
|
|
5403
|
-
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5404
|
-
// _ds.data_feed.rows[row_idx][field_id] = value;
|
|
5405
|
-
// await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
5406
|
-
// } catch (err) {
|
|
5407
|
-
// console.error(err);
|
|
5408
|
-
// }
|
|
5409
|
-
|
|
5410
|
-
// if (!fields_changed.includes(field_id)) {
|
|
5411
|
-
// fields_changed.push(field_id);
|
|
5412
|
-
// }
|
|
5413
|
-
// if (!datasource_changed.includes(dataSource)) {
|
|
5414
|
-
// datasource_changed.push(dataSource);
|
|
5415
|
-
// }
|
|
5416
|
-
// } else if (fields_data === "set") {
|
|
5417
|
-
// _ds.currentRecordId = record_id;
|
|
5418
|
-
// }
|
|
5419
|
-
|
|
5420
|
-
// if (!update_local_scope_only) {
|
|
5421
|
-
// if (glb.IS_WORKER) {
|
|
5422
|
-
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5423
|
-
|
|
5424
|
-
// if (tree_ret.menuType === "globals") {
|
|
5425
|
-
|
|
5426
|
-
// const _progFields = await func.datasource.get_progFields(
|
|
5427
|
-
// SESSION_ID,
|
|
5428
|
-
// dataSource
|
|
5429
|
-
// );
|
|
5430
|
-
// let view_field_obj = func.common.find_item_by_key(
|
|
5431
|
-
// _progFields,
|
|
5432
|
-
// "field_id",
|
|
5433
|
-
// field_id
|
|
5434
|
-
// );
|
|
5435
|
-
// if (view_field_obj?.data?.serverField) {
|
|
5436
|
-
// delete datasource_changes[dataSource][record_id][field_id]
|
|
5437
|
-
// }
|
|
5438
|
-
|
|
5439
|
-
// if (record_id === "data_system") {
|
|
5440
|
-
// delete datasource_changes[dataSource][record_id]
|
|
5441
|
-
// }
|
|
5442
|
-
// }
|
|
5443
|
-
// }
|
|
5444
|
-
// }
|
|
5445
|
-
// }
|
|
5446
|
-
// if (!_ds.data_feed.rows_changed) {
|
|
5447
|
-
// _ds.data_feed.rows_changed = [];
|
|
5448
|
-
// }
|
|
5449
|
-
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
5450
|
-
// _ds.data_feed.rows_changed.push(record_id);
|
|
5451
|
-
// }
|
|
5452
|
-
|
|
5453
|
-
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
5454
|
-
|
|
5455
|
-
// if (!update_local_scope_only) {
|
|
5456
|
-
// if (glb.IS_WORKER) {
|
|
5457
|
-
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5458
|
-
|
|
5459
|
-
// if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
5460
|
-
// continue;
|
|
5461
|
-
// }
|
|
5462
|
-
|
|
5463
|
-
// if (tree_ret.menuType !== "component" && tree_ret.menuType !== "globals") {
|
|
5464
|
-
|
|
5465
|
-
// continue;
|
|
5466
|
-
|
|
5467
|
-
// }
|
|
5468
|
-
|
|
5469
|
-
// // update client
|
|
5470
|
-
|
|
5471
|
-
// func.utils.post_back_to_client(
|
|
5472
|
-
// SESSION_ID,
|
|
5473
|
-
// "update_client_eventChangesResults_from_worker",
|
|
5474
|
-
// _session.worker_id,
|
|
5475
|
-
// new_datasource_changes
|
|
5476
|
-
// );
|
|
5477
|
-
// return resolve();
|
|
5478
|
-
// }
|
|
5479
|
-
|
|
5480
|
-
// if (!glb.IS_WORKER) {
|
|
5481
|
-
// if (_ds._run_at !== "client" || _ds.tree_obj.menuType === "globals") {
|
|
5482
|
-
// // no need to update worker
|
|
5483
|
-
// // return resolve();
|
|
5484
|
-
// // continue;
|
|
5485
|
-
// // }
|
|
5486
|
-
|
|
5487
|
-
// const ret = await func.index.call_worker(SESSION_ID, {
|
|
5488
|
-
// service: "update_datasource_changes_from_client",
|
|
5489
|
-
// data: {
|
|
5490
|
-
// session_id: SESSION_ID,
|
|
5491
|
-
// new_datasource_changes,
|
|
5492
|
-
// },
|
|
5493
|
-
// id: _ds.worker_id,
|
|
5494
|
-
// });
|
|
5495
|
-
// }
|
|
5496
|
-
// }
|
|
5497
|
-
// }
|
|
5498
|
-
// }
|
|
5499
|
-
// if (!glb.IS_WORKER) {
|
|
5500
|
-
// ///// REFRESH SCREEN
|
|
5501
|
-
// if (fields_changed.length) {
|
|
5502
|
-
// await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
5503
|
-
// await func.UI.screen.refresh_screen(
|
|
5504
|
-
// SESSION_ID,
|
|
5505
|
-
// fields_changed,
|
|
5506
|
-
// null,
|
|
5507
|
-
// datasource_changed[0] // refresh the current datasource only
|
|
5508
|
-
// );
|
|
5509
|
-
// }
|
|
5510
|
-
// }
|
|
5511
|
-
// return resolve();
|
|
5512
|
-
// });
|
|
5513
|
-
// };
|
|
5514
|
-
|
|
5515
5225
|
func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, jobNoP, NA_callingDataSourceP, NA_isInitP, nodeIdP) {
|
|
5516
5226
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5517
5227
|
var _ds = _session.DS_GLB[dsSessionP];
|
|
5518
|
-
|
|
5228
|
+
debugger;
|
|
5519
5229
|
try {
|
|
5520
5230
|
const row_idx = func.common.find_ROWID_idx(_ds, 'dataset');
|
|
5521
5231
|
|
|
@@ -4281,6 +4281,7 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
|
|
|
4281
4281
|
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', 'newRecord');
|
|
4282
4282
|
}
|
|
4283
4283
|
}
|
|
4284
|
+
await func.datasource.callback(SESSION_ID, dataSourceSession, args.dataSourceNoP, args.rowIdP, args.jobNoP, null, _ds.prog_id);
|
|
4284
4285
|
};
|
|
4285
4286
|
if (!rows) {
|
|
4286
4287
|
await row_not_found();
|
|
@@ -4568,64 +4569,6 @@ func.datasource.render_fields_form = async function (SESSION_ID, dataSourceSessi
|
|
|
4568
4569
|
}
|
|
4569
4570
|
};
|
|
4570
4571
|
|
|
4571
|
-
// func.datasource.run_rows_form = async function (
|
|
4572
|
-
// SESSION_ID,
|
|
4573
|
-
// dataSourceSession,
|
|
4574
|
-
// rowIdxP,
|
|
4575
|
-
// raw_data_row
|
|
4576
|
-
// ) {
|
|
4577
|
-
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
4578
|
-
// if (!_ds) return;
|
|
4579
|
-
// let _ROWID = raw_data_row.id;
|
|
4580
|
-
// // var val = _ds.data_feed.rows[rowIdxP];
|
|
4581
|
-
|
|
4582
|
-
// var idx = rowIdxP;
|
|
4583
|
-
|
|
4584
|
-
// const find_ROWID_idx_from_raw_data_arr = function (rowId) {
|
|
4585
|
-
// if (!_ds?.v?.raw_data?.rows) {
|
|
4586
|
-
// throw new Error("ds.v.raw_data.rows not found");
|
|
4587
|
-
// }
|
|
4588
|
-
|
|
4589
|
-
// const index = _ds.v.raw_data.rows.findIndex((item) => item.id === rowId);
|
|
4590
|
-
// if (index === -1) {
|
|
4591
|
-
// throw new Error(`item.id "${rowId}" not found`);
|
|
4592
|
-
// }
|
|
4593
|
-
// return index;
|
|
4594
|
-
// };
|
|
4595
|
-
|
|
4596
|
-
// try {
|
|
4597
|
-
// idx = find_ROWID_idx_from_raw_data_arr(raw_data_row.id);
|
|
4598
|
-
// } catch (e) {
|
|
4599
|
-
// _ROWID = "newRecord";
|
|
4600
|
-
// _ds.data_feed.rows.push({ _ROWID });
|
|
4601
|
-
// idx = func.common.find_ROWID_idx(_ds, _ROWID);
|
|
4602
|
-
// }
|
|
4603
|
-
|
|
4604
|
-
// _ds.currentRecordId = _ROWID; // set temporary to allow expression decoder work
|
|
4605
|
-
|
|
4606
|
-
// await func.datasource.render_fields_form(
|
|
4607
|
-
// SESSION_ID,
|
|
4608
|
-
// dataSourceSession,
|
|
4609
|
-
// raw_data_row
|
|
4610
|
-
// );
|
|
4611
|
-
// const init_count = await func.datasource.get_field_init_count(
|
|
4612
|
-
// SESSION_ID,
|
|
4613
|
-
// dataSourceSession,
|
|
4614
|
-
// _ROWID,
|
|
4615
|
-
// false,
|
|
4616
|
-
// _ds.oninit_triggers_to_run
|
|
4617
|
-
// );
|
|
4618
|
-
// if (init_count > 0) {
|
|
4619
|
-
// await func.datasource.execute_field_init_events(
|
|
4620
|
-
// SESSION_ID,
|
|
4621
|
-
// dataSourceSession,
|
|
4622
|
-
// "form",
|
|
4623
|
-
// _ds.data_feed.rows[idx]._ROWID
|
|
4624
|
-
// );
|
|
4625
|
-
// }
|
|
4626
|
-
// // await form_continue();
|
|
4627
|
-
// };
|
|
4628
|
-
|
|
4629
4572
|
func.datasource.execute_field_init_events = async function (SESSION_ID, dataSourceSession, sourceP, rowIdP) {
|
|
4630
4573
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
4631
4574
|
var args = _ds.args;
|
|
@@ -5247,11 +5190,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5247
5190
|
_ds.currentRecordId = record_id;
|
|
5248
5191
|
}
|
|
5249
5192
|
}
|
|
5250
|
-
// if (!_ds.data_feed.rows_changed) {
|
|
5251
|
-
// _ds.data_feed.rows_changed = [];
|
|
5252
|
-
// }
|
|
5253
|
-
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
5254
|
-
// _ds.data_feed.rows_changed.push(record_id);
|
|
5255
5193
|
}
|
|
5256
5194
|
}
|
|
5257
5195
|
|
|
@@ -5285,238 +5223,10 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5285
5223
|
});
|
|
5286
5224
|
};
|
|
5287
5225
|
|
|
5288
|
-
// func.datasource.update = async function (
|
|
5289
|
-
// SESSION_ID,
|
|
5290
|
-
// datasource_changes,
|
|
5291
|
-
// update_local_scope_only
|
|
5292
|
-
// ) {
|
|
5293
|
-
// return new Promise(async (resolve, reject) => {
|
|
5294
|
-
// var _session = SESSION_OBJ[SESSION_ID];
|
|
5295
|
-
|
|
5296
|
-
// if (typeof glb.GLOBAL_VARS === "undefined") {
|
|
5297
|
-
// glb.GLOBAL_VARS = (
|
|
5298
|
-
// await func.common.get_module(
|
|
5299
|
-
// SESSION_ID,
|
|
5300
|
-
// "xuda-system-globals-module.mjs"
|
|
5301
|
-
// )
|
|
5302
|
-
// ).system_globals;
|
|
5303
|
-
// }
|
|
5304
|
-
|
|
5305
|
-
// let fieldComputed_datasource_changes = {};
|
|
5306
|
-
|
|
5307
|
-
// const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
5308
|
-
|
|
5309
|
-
// // iterate child ds
|
|
5310
|
-
// for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5311
|
-
// if (parent_ds !== null) {
|
|
5312
|
-
// if (_ds.parentDataSourceNo != parent_ds) continue
|
|
5313
|
-
// } else {
|
|
5314
|
-
// if (dsSession != dsNo) continue
|
|
5315
|
-
// }
|
|
5316
|
-
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5317
|
-
// if (tree_ret.menuType === "component" || tree_ret.menuType === "globals") {
|
|
5318
|
-
// // check if field has fieldComputed property
|
|
5319
|
-
// const _progFields = await func.datasource.get_progFields(
|
|
5320
|
-
// SESSION_ID,
|
|
5321
|
-
// dsSession
|
|
5322
|
-
// );
|
|
5323
|
-
// // find if field is computed
|
|
5324
|
-
// let propExpressions
|
|
5325
|
-
// for await (const val of _progFields) {
|
|
5326
|
-
|
|
5327
|
-
// const fieldId = val.data.field_id;
|
|
5328
|
-
|
|
5329
|
-
// if (fieldId !== field_id) continue
|
|
5330
|
-
// if (val.data.type !== "virtual" || !val.props.fieldComputed) break
|
|
5331
|
-
|
|
5332
|
-
// const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
5333
|
-
// if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
5334
|
-
// propExpressions = _propExpressions
|
|
5335
|
-
// }
|
|
5336
|
-
// }
|
|
5337
|
-
|
|
5338
|
-
// if (!propExpressions) return
|
|
5339
|
-
|
|
5340
|
-
// if (!fieldComputed_datasource_changes[dsSession]) {
|
|
5341
|
-
// fieldComputed_datasource_changes[dsSession] = {}
|
|
5342
|
-
// }
|
|
5343
|
-
// // iterate ds rows
|
|
5344
|
-
// for (const row of _ds.data_feed?.rows || []) {
|
|
5345
|
-
// // iterate row fields
|
|
5346
|
-
// for (const [key, val] of Object.entries(row)) {
|
|
5347
|
-
// if (key !== field_id) return
|
|
5348
|
-
// try {
|
|
5349
|
-
// if (!fieldComputed_datasource_changes[dsSession][row._ROWID]) {
|
|
5350
|
-
// fieldComputed_datasource_changes[dsSession][row._ROWID] = {}
|
|
5351
|
-
// }
|
|
5352
|
-
// let ret = await func.expression.get(
|
|
5353
|
-
// SESSION_ID,
|
|
5354
|
-
// propExpressions,
|
|
5355
|
-
// dsNo,
|
|
5356
|
-
// "update",
|
|
5357
|
-
// row._ROWID
|
|
5358
|
-
// );
|
|
5359
|
-
// fieldComputed_datasource_changes[dsSession][row._ROWID][field_id] = ret.result
|
|
5360
|
-
// // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5361
|
-
|
|
5362
|
-
// // _ds.data_feed.rows[row_idx][field_id] = ret.result;
|
|
5363
|
-
// } catch (err) {
|
|
5364
|
-
// console.error(err);
|
|
5365
|
-
// }
|
|
5366
|
-
// }
|
|
5367
|
-
// }
|
|
5368
|
-
// }
|
|
5369
|
-
// await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
5370
|
-
// }
|
|
5371
|
-
// debugger
|
|
5372
|
-
|
|
5373
|
-
// }
|
|
5374
|
-
|
|
5375
|
-
// var fields_changed = [];
|
|
5376
|
-
// var datasource_changed = [];
|
|
5377
|
-
// let client_datasource_changes={}
|
|
5378
|
-
// // iterate changes datasource
|
|
5379
|
-
// for await (const [dataSource, row_data] of Object.entries(
|
|
5380
|
-
// datasource_changes
|
|
5381
|
-
// )) {
|
|
5382
|
-
// var _ds = _session.DS_GLB[dataSource];
|
|
5383
|
-
// if (!_ds) {
|
|
5384
|
-
// continue;
|
|
5385
|
-
// }
|
|
5386
|
-
// // iterate changes records
|
|
5387
|
-
// for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
5388
|
-
// // iterate changes fields
|
|
5389
|
-
// for (const [field_id, value] of Object.entries(fields_data)) {
|
|
5390
|
-
// // mechanism to make update directly on the datasource object
|
|
5391
|
-
// if (record_id === "datasource_main") {
|
|
5392
|
-
// _.set(_ds, field_id, value);
|
|
5393
|
-
// continue;
|
|
5394
|
-
// }
|
|
5395
|
-
|
|
5396
|
-
// if (typeof fields_data === "object") {
|
|
5397
|
-
// if (glb.GLOBAL_VARS[field_id]) {
|
|
5398
|
-
// _ds.data_system[field_id] = value;
|
|
5399
|
-
|
|
5400
|
-
// continue;
|
|
5401
|
-
// }
|
|
5402
|
-
|
|
5403
|
-
// try {
|
|
5404
|
-
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5405
|
-
// _ds.data_feed.rows[row_idx][field_id] = value;
|
|
5406
|
-
// await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
5407
|
-
// } catch (err) {
|
|
5408
|
-
// console.error(err);
|
|
5409
|
-
// }
|
|
5410
|
-
|
|
5411
|
-
// if (!fields_changed.includes(field_id)) {
|
|
5412
|
-
// fields_changed.push(field_id);
|
|
5413
|
-
// }
|
|
5414
|
-
// if (!datasource_changed.includes(dataSource)) {
|
|
5415
|
-
// datasource_changed.push(dataSource);
|
|
5416
|
-
// }
|
|
5417
|
-
// } else if (fields_data === "set") {
|
|
5418
|
-
// _ds.currentRecordId = record_id;
|
|
5419
|
-
// }
|
|
5420
|
-
|
|
5421
|
-
// if (!update_local_scope_only) {
|
|
5422
|
-
// if (glb.IS_WORKER) {
|
|
5423
|
-
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5424
|
-
|
|
5425
|
-
// if (tree_ret.menuType === "globals") {
|
|
5426
|
-
|
|
5427
|
-
// const _progFields = await func.datasource.get_progFields(
|
|
5428
|
-
// SESSION_ID,
|
|
5429
|
-
// dataSource
|
|
5430
|
-
// );
|
|
5431
|
-
// let view_field_obj = func.common.find_item_by_key(
|
|
5432
|
-
// _progFields,
|
|
5433
|
-
// "field_id",
|
|
5434
|
-
// field_id
|
|
5435
|
-
// );
|
|
5436
|
-
// if (view_field_obj?.data?.serverField) {
|
|
5437
|
-
// delete datasource_changes[dataSource][record_id][field_id]
|
|
5438
|
-
// }
|
|
5439
|
-
|
|
5440
|
-
// if (record_id === "data_system") {
|
|
5441
|
-
// delete datasource_changes[dataSource][record_id]
|
|
5442
|
-
// }
|
|
5443
|
-
// }
|
|
5444
|
-
// }
|
|
5445
|
-
// }
|
|
5446
|
-
// }
|
|
5447
|
-
// if (!_ds.data_feed.rows_changed) {
|
|
5448
|
-
// _ds.data_feed.rows_changed = [];
|
|
5449
|
-
// }
|
|
5450
|
-
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
5451
|
-
// _ds.data_feed.rows_changed.push(record_id);
|
|
5452
|
-
// }
|
|
5453
|
-
|
|
5454
|
-
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
5455
|
-
|
|
5456
|
-
// if (!update_local_scope_only) {
|
|
5457
|
-
// if (glb.IS_WORKER) {
|
|
5458
|
-
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5459
|
-
|
|
5460
|
-
// if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
5461
|
-
// continue;
|
|
5462
|
-
// }
|
|
5463
|
-
|
|
5464
|
-
// if (tree_ret.menuType !== "component" && tree_ret.menuType !== "globals") {
|
|
5465
|
-
|
|
5466
|
-
// continue;
|
|
5467
|
-
|
|
5468
|
-
// }
|
|
5469
|
-
|
|
5470
|
-
// // update client
|
|
5471
|
-
|
|
5472
|
-
// func.utils.post_back_to_client(
|
|
5473
|
-
// SESSION_ID,
|
|
5474
|
-
// "update_client_eventChangesResults_from_worker",
|
|
5475
|
-
// _session.worker_id,
|
|
5476
|
-
// new_datasource_changes
|
|
5477
|
-
// );
|
|
5478
|
-
// return resolve();
|
|
5479
|
-
// }
|
|
5480
|
-
|
|
5481
|
-
// if (!glb.IS_WORKER) {
|
|
5482
|
-
// if (_ds._run_at !== "client" || _ds.tree_obj.menuType === "globals") {
|
|
5483
|
-
// // no need to update worker
|
|
5484
|
-
// // return resolve();
|
|
5485
|
-
// // continue;
|
|
5486
|
-
// // }
|
|
5487
|
-
|
|
5488
|
-
// const ret = await func.index.call_worker(SESSION_ID, {
|
|
5489
|
-
// service: "update_datasource_changes_from_client",
|
|
5490
|
-
// data: {
|
|
5491
|
-
// session_id: SESSION_ID,
|
|
5492
|
-
// new_datasource_changes,
|
|
5493
|
-
// },
|
|
5494
|
-
// id: _ds.worker_id,
|
|
5495
|
-
// });
|
|
5496
|
-
// }
|
|
5497
|
-
// }
|
|
5498
|
-
// }
|
|
5499
|
-
// }
|
|
5500
|
-
// if (!glb.IS_WORKER) {
|
|
5501
|
-
// ///// REFRESH SCREEN
|
|
5502
|
-
// if (fields_changed.length) {
|
|
5503
|
-
// await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
5504
|
-
// await func.UI.screen.refresh_screen(
|
|
5505
|
-
// SESSION_ID,
|
|
5506
|
-
// fields_changed,
|
|
5507
|
-
// null,
|
|
5508
|
-
// datasource_changed[0] // refresh the current datasource only
|
|
5509
|
-
// );
|
|
5510
|
-
// }
|
|
5511
|
-
// }
|
|
5512
|
-
// return resolve();
|
|
5513
|
-
// });
|
|
5514
|
-
// };
|
|
5515
|
-
|
|
5516
5226
|
func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, jobNoP, NA_callingDataSourceP, NA_isInitP, nodeIdP) {
|
|
5517
5227
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5518
5228
|
var _ds = _session.DS_GLB[dsSessionP];
|
|
5519
|
-
|
|
5229
|
+
debugger;
|
|
5520
5230
|
try {
|
|
5521
5231
|
const row_idx = func.common.find_ROWID_idx(_ds, 'dataset');
|
|
5522
5232
|
|