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