@xuda.io/runtime-bundle 1.0.289 → 1.0.291

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.
@@ -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,234 +5223,6 @@ 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];
@@ -5532,20 +5242,20 @@ func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, j
5532
5242
  }
5533
5243
  }
5534
5244
 
5535
- // if (_ds?.progDataSource?.datasetOutputField) {
5536
- // let datasource_changes = {};
5245
+ if (_ds?.progDataSource?.datasetOutputField) {
5246
+ let datasource_changes = {};
5537
5247
 
5538
- // let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
5539
- // if (!datasource_changes[_ds.dsSession]) {
5540
- // datasource_changes[_ds.dsSession] = {};
5541
- // }
5542
- // if (!datasource_changes[_ds.dsSession][_ds.currentRecordId]) {
5543
- // datasource_changes[_ds.dsSession][_ds.currentRecordId] = {};
5248
+ let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
5249
+ if (!datasource_changes[_ds.dsSession]) {
5250
+ datasource_changes[_ds.dsSession] = {};
5251
+ }
5252
+ if (!datasource_changes[_ds.dsSession][_ds.currentRecordId]) {
5253
+ datasource_changes[_ds.dsSession][_ds.currentRecordId] = {};
5544
5254
 
5545
- // datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][_ds?.progDataSource?.datasetOutputField] = _ds?.data_feed?.rows || [];
5546
- // await func.datasource.update(SESSION_ID, datasource_changes);
5547
- // }
5548
- // }
5255
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][_ds?.progDataSource?.datasetOutputField] = _ds?.data_feed?.rows || [];
5256
+ await func.datasource.update(SESSION_ID, datasource_changes);
5257
+ }
5258
+ }
5549
5259
  } catch (err) {
5550
5260
  // console.error(err);
5551
5261
  }