@xuda.io/runtime-bundle 1.0.319 → 1.0.321

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.
@@ -25574,7 +25574,7 @@ func.utils.job_worker = function (session_id) {
25574
25574
  val.containerP,
25575
25575
  val.elementP,
25576
25576
  val.rowP,
25577
- null,
25577
+ val.evt,
25578
25578
  val.descP,
25579
25579
  val.rootScreenIdP,
25580
25580
  val.dsSessionP,
@@ -32733,8 +32733,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
32733
32733
  'xu-on': async function ($elm, val) {
32734
32734
  CLIENT_ACTIVITY_TS = Date.now();
32735
32735
  const trigger = val.key.split('xu-on:')[1].toLowerCase();
32736
- $elm.on(trigger, async function (e) {
32737
- for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + e.type])) {
32736
+ $elm.on(trigger, async function (evt) {
32737
+ for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
32738
32738
  if (val.handler === 'custom') {
32739
32739
  // do BL
32740
32740
  for await (const [key2, val2] of Object.entries(val.event)) {
@@ -32745,11 +32745,11 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
32745
32745
  }
32746
32746
  if (!cond) continue;
32747
32747
 
32748
- if (val.event_modifiers && e[val.event_modifiers]) {
32749
- e[val.event_modifiers]();
32748
+ if (val.event_modifiers && evt[val.event_modifiers]) {
32749
+ evt[val.event_modifiers]();
32750
32750
  }
32751
32751
 
32752
- func.events.add_to_queue(SESSION_ID, 'element event', val2.id, e.type, val2.data.action, val2.data.name, null, $elm.attr('xu-ui-id'), null, null, null, null, null, paramsP.dsSessionP, null, null, null, e.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
32752
+ func.events.add_to_queue(SESSION_ID, 'element event', val2.id, evt.type, val2.data.action, val2.data.name, null, $elm.attr('xu-ui-id'), null, evt, null, null, null, paramsP.dsSessionP, null, null, null, evt.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
32753
32753
  }
32754
32754
  }
32755
32755
  }
@@ -36078,15 +36078,7 @@ func.expression.secure_eval = async function (
36078
36078
  }
36079
36079
  };
36080
36080
  func.events = {};
36081
- func.events.validate = async function (
36082
- SESSION_ID,
36083
- triggerP,
36084
- dsSessionP,
36085
- eventIdP,
36086
- sourceP,
36087
- argumentsP,
36088
- return_validation_onlyP
36089
- ) {
36081
+ func.events.validate = async function (SESSION_ID, triggerP, dsSessionP, eventIdP, sourceP, argumentsP, return_validation_onlyP) {
36090
36082
  var _session = SESSION_OBJ[SESSION_ID];
36091
36083
  var _ds = _session.DS_GLB[dsSessionP];
36092
36084
  var args = {
@@ -36099,16 +36091,8 @@ func.events.validate = async function (
36099
36091
  return_validation_onlyP,
36100
36092
  };
36101
36093
  const search_event_in_parent_ds = async function () {
36102
- if (_ds && typeof _ds.parentDataSourceNo !== "undefined") {
36103
- await func.events.validate(
36104
- SESSION_ID,
36105
- triggerP,
36106
- _ds.parentDataSourceNo,
36107
- eventIdP,
36108
- sourceP,
36109
- argumentsP,
36110
- return_validation_onlyP
36111
- );
36094
+ if (_ds && typeof _ds.parentDataSourceNo !== 'undefined') {
36095
+ await func.events.validate(SESSION_ID, triggerP, _ds.parentDataSourceNo, eventIdP, sourceP, argumentsP, return_validation_onlyP);
36112
36096
  }
36113
36097
  };
36114
36098
  var ret = false;
@@ -36130,29 +36114,13 @@ func.events.validate = async function (
36130
36114
  var eventProp = undefined;
36131
36115
  if (val.data.type === triggerP) {
36132
36116
  // compare event trigger
36133
- if (
36134
- (triggerP !== "user_defined") |
36135
- (triggerP === "user_defined" && eventIdP === val.data.event_name)
36136
- ) {
36117
+ if ((triggerP !== 'user_defined') | (triggerP === 'user_defined' && eventIdP === val.data.event_name)) {
36137
36118
  // compare user defined name
36138
36119
 
36139
36120
  var expCond;
36140
- if (val.data.condition)
36141
- expCond = await func.expression.get(
36142
- SESSION_ID,
36143
- val.data.condition,
36144
- dsSessionP,
36145
- "condition"
36146
- );
36121
+ if (val.data.condition) expCond = await func.expression.get(SESSION_ID, val.data.condition, dsSessionP, 'condition');
36147
36122
  if (!val.data.condition || expCond.result) {
36148
- func.utils.debug.watch(
36149
- SESSION_ID,
36150
- _ds.prog_id + "%" + val.id,
36151
- "view_event",
36152
- val,
36153
- triggerP + " " + eventIdP,
36154
- expCond
36155
- );
36123
+ func.utils.debug.watch(SESSION_ID, _ds.prog_id + '%' + val.id, 'view_event', val, triggerP + ' ' + eventIdP, expCond);
36156
36124
  ret = true;
36157
36125
  if (return_validation_onlyP) break;
36158
36126
  const set_arguments = async function () {
@@ -36190,48 +36158,24 @@ func.events.validate = async function (
36190
36158
  // await func.datasource.update(SESSION_ID, datasource_changes);
36191
36159
  // }
36192
36160
 
36193
- for await (let [key, fieldId] of Object.entries(
36194
- val.data.parameters
36195
- )) {
36196
- const field_info = func.common.find_item_by_key(
36197
- _view_obj.progFields,
36198
- "field_id",
36199
- fieldId
36200
- );
36161
+ for await (let [key, fieldId] of Object.entries(val.data.parameters)) {
36162
+ const field_info = func.common.find_item_by_key(_view_obj.progFields, 'field_id', fieldId);
36201
36163
 
36202
- if (field_info?.data?.type !== "virtual") {
36203
- console.warn("parameter field must be virtual, update ignored");
36164
+ if (field_info?.data?.type !== 'virtual') {
36165
+ console.warn('parameter field must be virtual, update ignored');
36204
36166
  continue;
36205
36167
  }
36206
36168
 
36207
- if (!args[fieldId]) continue
36208
-
36169
+ if (!args[fieldId]) continue;
36209
36170
 
36210
-
36211
- let value = await func.common.get_cast_val(
36212
- SESSION_ID,
36213
- "events",
36214
- fieldId,
36215
- field_info.props.fieldType,
36216
- args[fieldId].value
36217
- );
36171
+ let value = await func.common.get_cast_val(SESSION_ID, 'events', fieldId, field_info.props.fieldType, args[fieldId].value);
36218
36172
 
36219
36173
  if (!_.isEmpty(args[fieldId].fx)) {
36220
- const fx_ret = await func.expression.get(
36221
- SESSION_ID,
36222
- args[fieldId].fx,
36223
- dsSessionP,
36224
- "update"
36225
- )
36174
+ const fx_ret = await func.expression.get(SESSION_ID, args[fieldId].fx, dsSessionP, 'update');
36226
36175
  value = fx_ret.result;
36227
36176
  }
36228
36177
  // find the target field in the program dataset
36229
- const ret = await func.datasource.get_value(
36230
- SESSION_ID,
36231
- fieldId,
36232
- dsSessionP,
36233
- _ds.currentRecordId
36234
- );
36178
+ const ret = await func.datasource.get_value(SESSION_ID, fieldId, dsSessionP, _ds.currentRecordId);
36235
36179
 
36236
36180
  const datasource_changes = {
36237
36181
  [ret.dsSessionP]: {
@@ -36244,11 +36188,7 @@ func.events.validate = async function (
36244
36188
  await add_event();
36245
36189
  };
36246
36190
  const add_event = async function () {
36247
- const _event = func.common.find_item_by_key_root(
36248
- _view_obj.progEvents,
36249
- "id",
36250
- val.id
36251
- );
36191
+ const _event = func.common.find_item_by_key_root(_view_obj.progEvents, 'id', val.id);
36252
36192
  if (_event.triggers) {
36253
36193
  // check if event property exist
36254
36194
 
@@ -36271,22 +36211,19 @@ func.events.validate = async function (
36271
36211
  if (!glb.IS_WORKER) {
36272
36212
  if (_ds.panel_div_id) {
36273
36213
  try {
36274
- container = "#" + _ds.panel_div_id;
36214
+ container = '#' + _ds.panel_div_id;
36275
36215
  if ($(container).data().xuData.panel_info) {
36276
- screen_prop =
36277
- $(container).data().xuData.panel_info.paramsP;
36216
+ screen_prop = $(container).data().xuData.panel_info.paramsP;
36278
36217
  } else {
36279
36218
  ///////////////
36280
- container =
36281
- "#" + _session.DS_GLB[dsSessionP].screenId;
36219
+ container = '#' + _session.DS_GLB[dsSessionP].screenId;
36282
36220
 
36283
36221
  if ($(container) && $(container).data()) {
36284
36222
  screen_prop = $(container).data().xuData.paramsP;
36285
36223
  }
36286
36224
 
36287
36225
  if (!$(container) || !$(container).length) {
36288
- container =
36289
- "#" + _session.DS_GLB[dsSessionP].containerId;
36226
+ container = '#' + _session.DS_GLB[dsSessionP].containerId;
36290
36227
  }
36291
36228
  //////////////
36292
36229
  }
@@ -36294,14 +36231,14 @@ func.events.validate = async function (
36294
36231
  console.error(e);
36295
36232
  }
36296
36233
  } else {
36297
- container = "#" + _ds.screenId;
36234
+ container = '#' + _ds.screenId;
36298
36235
 
36299
36236
  if ($(container) && $(container).data()) {
36300
36237
  screen_prop = $(container).data().xuData.paramsP;
36301
36238
  }
36302
36239
 
36303
36240
  if (!$(container) || !$(container).length) {
36304
- container = "#" + _ds.containerId;
36241
+ container = '#' + _ds.containerId;
36305
36242
  }
36306
36243
  }
36307
36244
  } else {
@@ -36313,7 +36250,7 @@ func.events.validate = async function (
36313
36250
  jobs.push(
36314
36251
  await func.events.add_to_queue(
36315
36252
  SESSION_ID,
36316
- sourceP + " event",
36253
+ sourceP + ' event',
36317
36254
  trigger_obj.id,
36318
36255
  null, // was click
36319
36256
  trigger_obj.data.action,
@@ -36339,8 +36276,8 @@ func.events.validate = async function (
36339
36276
  null,
36340
36277
  args,
36341
36278
  null,
36342
- null
36343
- )
36279
+ null,
36280
+ ),
36344
36281
  );
36345
36282
  }
36346
36283
  }
@@ -36352,15 +36289,7 @@ func.events.validate = async function (
36352
36289
  }
36353
36290
  } else {
36354
36291
  if (val.data.condition && !expCond.result) {
36355
- func.utils.debug.watch(
36356
- SESSION_ID,
36357
- _ds.prog_id + "%" + val.id,
36358
- "view_event",
36359
- val,
36360
- triggerP + " " + eventIdP,
36361
- expCond,
36362
- true
36363
- );
36292
+ func.utils.debug.watch(SESSION_ID, _ds.prog_id + '%' + val.id, 'view_event', val, triggerP + ' ' + eventIdP, expCond, true);
36364
36293
  }
36365
36294
  }
36366
36295
  }
@@ -36383,7 +36312,7 @@ func.events.add_to_queue = async function (
36383
36312
  containerP,
36384
36313
  elementP,
36385
36314
  rowP,
36386
- NA_colP,
36315
+ evt,
36387
36316
  descP,
36388
36317
  NA_rootScreenIdP,
36389
36318
  NA_callingEventIdP,
@@ -36401,7 +36330,7 @@ func.events.add_to_queue = async function (
36401
36330
  calling_job,
36402
36331
  args,
36403
36332
  $div,
36404
- $container
36333
+ $container,
36405
36334
  ) {
36406
36335
  var _session = SESSION_OBJ[SESSION_ID];
36407
36336
  var obj = {
@@ -36426,11 +36355,11 @@ func.events.add_to_queue = async function (
36426
36355
  args,
36427
36356
  $div,
36428
36357
  $container,
36429
-
36358
+ evt,
36430
36359
  job_num: _session.WORKER_OBJ.num,
36431
36360
  };
36432
36361
  var _ds = _session.DS_GLB[dsSessionP];
36433
- if (typeof dsSessionP !== "undefined" && dsSessionP !== null) {
36362
+ if (typeof dsSessionP !== 'undefined' && dsSessionP !== null) {
36434
36363
  obj.prog_id = _ds.prog_id;
36435
36364
  obj.parentDataSourceNo = _ds.parentDataSourceNo;
36436
36365
  obj.nodeId = _ds.nodeId;
@@ -36438,21 +36367,16 @@ func.events.add_to_queue = async function (
36438
36367
  ///////
36439
36368
  if (glb.IS_WORKER && func.utils.is_onscreen_event(functionP)) {
36440
36369
  obj.client = true;
36441
- if (functionP === "call_library") {
36370
+ if (functionP === 'call_library') {
36442
36371
  obj.client = false;
36443
36372
  }
36444
- if (typeof dsSessionP !== "undefined" && dsSessionP !== null) {
36373
+ if (typeof dsSessionP !== 'undefined' && dsSessionP !== null) {
36445
36374
  obj.ds_obj = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
36446
36375
  }
36447
36376
  if (obj.client) {
36448
36377
  _session.WORKER_OBJ.num++;
36449
36378
  // if (!_session.IS_API)
36450
- func.utils.post_back_to_client(
36451
- SESSION_ID,
36452
- "job",
36453
- _session.worker_id,
36454
- obj
36455
- );
36379
+ func.utils.post_back_to_client(SESSION_ID, 'job', _session.worker_id, obj);
36456
36380
  return;
36457
36381
  }
36458
36382
  }
@@ -36466,14 +36390,10 @@ func.events.add_to_queue = async function (
36466
36390
  _session.WORKER_OBJ.jobs[job_index].splice_count = 0;
36467
36391
  }
36468
36392
  _session.WORKER_OBJ.jobs[job_index].splice_count++;
36469
- _session.WORKER_OBJ.jobs.splice(
36470
- job_index + _session.WORKER_OBJ.jobs[job_index].splice_count,
36471
- 0,
36472
- obj
36473
- );
36393
+ _session.WORKER_OBJ.jobs.splice(job_index + _session.WORKER_OBJ.jobs[job_index].splice_count, 0, obj);
36474
36394
  // }
36475
36395
  } catch (e) {
36476
- console.error("bug");
36396
+ console.error('bug');
36477
36397
  // _session.WORKER_OBJ.jobs.splice(0, 0, obj);
36478
36398
  }
36479
36399
  } else {
@@ -36505,7 +36425,7 @@ func.events.execute = async function (
36505
36425
  containerP,
36506
36426
  elementP,
36507
36427
  rowP,
36508
- NA_colP,
36428
+ evt,
36509
36429
  descP,
36510
36430
  rootScreenIdP,
36511
36431
  dsSessionP,
@@ -36523,14 +36443,14 @@ func.events.execute = async function (
36523
36443
  NA_viewIdP,
36524
36444
  NA_nodeIdP,
36525
36445
  NA_parentDataSourceNoP,
36526
- $div
36446
+ $div,
36527
36447
  ) {
36528
36448
  var _session = SESSION_OBJ[SESSION_ID];
36529
36449
  var _ds = _session.DS_GLB[dsSessionP];
36530
- if (functionP === "update") refIdP = null; // in case of left over when program changing from call function to update
36450
+ if (functionP === 'update') refIdP = null; // in case of left over when program changing from call function to update
36531
36451
 
36532
36452
  var job_index = func.events.find_job_index(SESSION_ID, jobNoP);
36533
- if (_session.WORKER_OBJ.jobs?.[job_index]?.stat === "busy") {
36453
+ if (_session.WORKER_OBJ.jobs?.[job_index]?.stat === 'busy') {
36534
36454
  if (jobNoP) _session.WORKER_OBJ.stat = job_index;
36535
36455
  return;
36536
36456
  }
@@ -36547,61 +36467,44 @@ func.events.execute = async function (
36547
36467
  }
36548
36468
 
36549
36469
  if (_session.WORKER_OBJ.jobs[job_index]) {
36550
- _session.WORKER_OBJ.jobs[job_index].stat = "busy";
36470
+ _session.WORKER_OBJ.jobs[job_index].stat = 'busy';
36551
36471
  }
36552
36472
 
36553
36473
  var dsSession = dsSessionP; // new 2020420
36554
36474
  var field_elm = elementP;
36555
36475
 
36556
36476
  var calling_field_id = field_elm;
36557
- if (field_elm && typeof field_elm === "object")
36558
- calling_field_id = field_elm.attr("xu-ui-id");
36477
+ if (field_elm && typeof field_elm === 'object') calling_field_id = field_elm.attr('xu-ui-id');
36559
36478
 
36560
36479
  var log_nodeId;
36561
36480
  var log_prog_id;
36562
36481
  var log_source;
36563
36482
 
36564
- if (_session.DS_GLB[dsSession]?.prog_id)
36565
- log_prog_id = _session.DS_GLB[dsSession].prog_id;
36566
- log_nodeId = log_prog_id + "_" + eventIdP;
36483
+ if (_session.DS_GLB[dsSession]?.prog_id) log_prog_id = _session.DS_GLB[dsSession].prog_id;
36484
+ log_nodeId = log_prog_id + '_' + eventIdP;
36567
36485
  var log_prop = callingSourceP;
36568
- if (callingSourceP === "system event") {
36569
- log_prop = "global event";
36486
+ if (callingSourceP === 'system event') {
36487
+ log_prop = 'global event';
36570
36488
  }
36571
36489
  if (calling_field_id) {
36572
36490
  const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
36573
- let _field_obj = func.common.find_item_by_key(
36574
- _view_obj.progFields,
36575
- "field_id",
36576
- calling_field_id
36577
- );
36578
- log_nodeId = log_prog_id + "_" + eventIdP + "_" + _field_obj?.id;
36491
+ let _field_obj = func.common.find_item_by_key(_view_obj.progFields, 'field_id', calling_field_id);
36492
+ log_nodeId = log_prog_id + '_' + eventIdP + '_' + _field_obj?.id;
36579
36493
 
36580
36494
  log_source = calling_field_id;
36581
36495
  }
36582
36496
  if (elementP) {
36583
36497
  log_prop = triggerP;
36584
- log_nodeId = log_nodeId + "_ui_prop"; //+"_"+eventIdP;
36498
+ log_nodeId = log_nodeId + '_ui_prop'; //+"_"+eventIdP;
36585
36499
  }
36586
36500
  //check condition
36587
36501
  var expCond;
36588
36502
  if (event_propertiesP) {
36589
36503
  // conditional event
36590
36504
  if (event_propertiesP?.props?.condition) {
36591
- expCond = await func.expression.get(
36592
- SESSION_ID,
36593
- event_propertiesP.props.condition,
36594
- dsSession,
36595
- "condition",
36596
- null,
36597
- null,
36598
- null,
36599
- calling_field_id ? calling_field_id : calling_triggerP,
36600
- null,
36601
- descP
36602
- ); // execute expression
36505
+ expCond = await func.expression.get(SESSION_ID, event_propertiesP.props.condition, dsSession, 'condition', null, null, null, calling_field_id ? calling_field_id : calling_triggerP, null, descP); // execute expression
36603
36506
  func.utils.debug.log(SESSION_ID, log_nodeId, {
36604
- module: "event",
36507
+ module: 'event',
36605
36508
  action: log_prop,
36606
36509
  source: log_source,
36607
36510
  prop: descP,
@@ -36609,7 +36512,7 @@ func.events.execute = async function (
36609
36512
  result: expCond.result,
36610
36513
  error: expCond.error,
36611
36514
  fields: expCond.fields,
36612
- type: "event",
36515
+ type: 'event',
36613
36516
  prog_id: log_prog_id,
36614
36517
  conditional: true,
36615
36518
  });
@@ -36618,21 +36521,13 @@ func.events.execute = async function (
36618
36521
  // condition failed // === true 03/04/16
36619
36522
  func.events.delete_job(SESSION_ID, jobNoP);
36620
36523
 
36621
- func.utils.debug.watch(
36622
- SESSION_ID,
36623
- calling_trigger_prop?.id,
36624
- functionP,
36625
- "",
36626
- "",
36627
- expCond,
36628
- true
36629
- );
36524
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, '', '', expCond, true);
36630
36525
  return;
36631
36526
  }
36632
36527
  } // Non conditional event
36633
36528
  else {
36634
36529
  func.utils.debug.log(SESSION_ID, log_nodeId, {
36635
- module: "event",
36530
+ module: 'event',
36636
36531
  action: log_prop,
36637
36532
  source: log_source,
36638
36533
  prop: descP,
@@ -36640,7 +36535,7 @@ func.events.execute = async function (
36640
36535
  result: null,
36641
36536
  error: null,
36642
36537
  fields: null,
36643
- type: "event",
36538
+ type: 'event',
36644
36539
  prog_id: log_prog_id,
36645
36540
  });
36646
36541
  }
@@ -36663,47 +36558,27 @@ func.events.execute = async function (
36663
36558
  // };
36664
36559
 
36665
36560
  const get_params_obj = async function () {
36666
- const _prog = await func.utils.VIEWS_OBJ.get(
36667
- SESSION_ID,
36668
- await get_prog_id()
36669
- );
36561
+ const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, await get_prog_id());
36670
36562
  if (!_prog) {
36671
36563
  func.events.delete_job(SESSION_ID, jobNoP);
36672
- return func.utils.debug_report(
36673
- SESSION_ID,
36674
- "func.events.execute",
36675
- "Program not found: " + refIdP.prog,
36676
- "E"
36677
- );
36564
+ return func.utils.debug_report(SESSION_ID, 'func.events.execute', 'Program not found: ' + refIdP.prog, 'E');
36678
36565
  }
36679
36566
 
36680
36567
  // get in parameters
36681
36568
  var params_obj = {};
36682
36569
  if (_prog?.properties?.progParams) {
36683
- for await (const [key, val] of Object.entries(
36684
- _prog.properties.progParams
36685
- )) {
36686
- if (!val.data.dir === "in") continue;
36687
- if (
36688
- typeof args.parameters_obj_inP?.[val.data.parameter] !== "undefined"
36689
- ) {
36570
+ for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
36571
+ if (!val.data.dir === 'in') continue;
36572
+ if (typeof args.parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
36690
36573
  if (args.parameters_obj_inP?.[val.data.parameter].fx) {
36691
- let ret = await func.expression.get(
36692
- SESSION_ID,
36693
- args.parameters_obj_inP?.[val.data.parameter].fx,
36694
- dsSession,
36695
- "parameters"
36696
- );
36574
+ let ret = await func.expression.get(SESSION_ID, args.parameters_obj_inP?.[val.data.parameter].fx, dsSession, 'parameters');
36697
36575
  params_obj[val.data.parameter] = ret.result;
36698
36576
  } else {
36699
- params_obj[val.data.parameter] =
36700
- args.parameters_obj_inP?.[val.data.parameter].value;
36577
+ params_obj[val.data.parameter] = args.parameters_obj_inP?.[val.data.parameter].value;
36701
36578
  }
36702
36579
  continue;
36703
36580
  }
36704
- console.warn(
36705
- `Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`
36706
- );
36581
+ console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
36707
36582
  }
36708
36583
  }
36709
36584
  return params_obj;
@@ -36712,15 +36587,8 @@ func.events.execute = async function (
36712
36587
  const get_prog_id = async function () {
36713
36588
  let _prop = args?.calling_trigger_prop?.data?.name?.properties;
36714
36589
  let _prog_id = args.prog_id;
36715
- if (_prop?.["xu-exp:prog"]) {
36716
- _prog_id = (
36717
- await func.expression.get(
36718
- SESSION_ID,
36719
- _prop["xu-exp:prog"],
36720
- dsSession,
36721
- "prog_id expression"
36722
- )
36723
- ).result;
36590
+ if (_prop?.['xu-exp:prog']) {
36591
+ _prog_id = (await func.expression.get(SESSION_ID, _prop['xu-exp:prog'], dsSession, 'prog_id expression')).result;
36724
36592
  }
36725
36593
 
36726
36594
  return _prog_id;
@@ -36742,7 +36610,6 @@ func.events.execute = async function (
36742
36610
  // return _value;
36743
36611
  // };
36744
36612
 
36745
-
36746
36613
  var args = {
36747
36614
  prog_id: refIdP?.prog,
36748
36615
  screenIdP: refIdP?.prog,
@@ -36770,40 +36637,20 @@ func.events.execute = async function (
36770
36637
  var $calling_container;
36771
36638
  if (_session.WORKER_OBJ.jobs[job_index]) {
36772
36639
  if (_session.WORKER_OBJ.jobs[job_index].paramsP) {
36773
- $calling_container = $(
36774
- "#" + _session.WORKER_OBJ.jobs[job_index].paramsP.callingContainerP
36775
- );
36640
+ $calling_container = $('#' + _session.WORKER_OBJ.jobs[job_index].paramsP.callingContainerP);
36776
36641
  } else {
36777
- $calling_container = ""; // calling from datasource 0
36642
+ $calling_container = ''; // calling from datasource 0
36778
36643
  _session.WORKER_OBJ.jobs[job_index].paramsP = {};
36779
36644
  }
36780
36645
  }
36781
36646
 
36782
36647
  if (!refIdP.prog) {
36783
36648
  func.events.delete_job(SESSION_ID, jobNoP);
36784
- return func.utils.debug_report(
36785
- SESSION_ID,
36786
- "func.events.execute",
36787
- "Program is empty",
36788
- "E"
36789
- );
36649
+ return func.utils.debug_report(SESSION_ID, 'func.events.execute', 'Program is empty', 'E');
36790
36650
  }
36791
36651
 
36792
36652
  const params_obj = await get_params_obj();
36793
- return await func.UI.screen.init(
36794
- SESSION_ID,
36795
- await get_prog_id(),
36796
- $(containerP)?.data()?.xuData.screenId,
36797
- _session.DS_GLB[dsSession],
36798
- $calling_container,
36799
- eventIdP,
36800
- rowP,
36801
- jobNoP,
36802
- is_panel,
36803
- params_obj,
36804
- functionP,
36805
- args.call_screen_propertiesP
36806
- );
36653
+ return await func.UI.screen.init(SESSION_ID, await get_prog_id(), $(containerP)?.data()?.xuData.screenId, _session.DS_GLB[dsSession], $calling_container, eventIdP, rowP, jobNoP, is_panel, params_obj, functionP, args.call_screen_propertiesP);
36807
36654
  },
36808
36655
  call_modal: async function () {
36809
36656
  return await fx.Call_window();
@@ -36826,101 +36673,66 @@ func.events.execute = async function (
36826
36673
 
36827
36674
  const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
36828
36675
  var obj = _.clone(docP);
36829
- obj.date = await func.utils.get_dateTime(
36830
- SESSION_ID,
36831
- "SYS_DATE",
36832
- docP.date
36833
- );
36834
- obj.time = await func.utils.get_dateTime(
36835
- SESSION_ID,
36836
- "SYS_TIME",
36837
- docP.date
36838
- );
36676
+ obj.date = await func.utils.get_dateTime(SESSION_ID, 'SYS_DATE', docP.date);
36677
+ obj.time = await func.utils.get_dateTime(SESSION_ID, 'SYS_TIME', docP.date);
36839
36678
 
36840
36679
  var datasource_changes = {
36841
36680
  [0]: {
36842
- ["data_system"]: {
36843
- ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
36681
+ ['data_system']: {
36682
+ ['SYS_GLOBAL_OBJ_WIDGET_INFO']: obj,
36844
36683
  },
36845
36684
  },
36846
36685
  };
36847
36686
  await func.datasource.update(SESSION_ID, datasource_changes);
36848
36687
  };
36849
36688
  const call_plugin_api = async function (plugin_nameP, dataP) {
36850
- return await func.utils.call_plugin_api(
36851
- SESSION_ID,
36852
- plugin_nameP,
36853
- dataP
36854
- );
36689
+ return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
36855
36690
  };
36856
36691
  const report_error = function (descP, warn) {
36857
- func.utils.debug.log(
36858
- SESSION_ID,
36859
- _session.DS_GLB[dsP].prog_id +
36860
- "_" +
36861
- _session.DS_GLB[dsP].callingMenuId,
36862
- {
36863
- module: "widgets",
36864
- action: "Init",
36692
+ func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
36693
+ module: 'widgets',
36694
+ action: 'Init',
36695
+ source: sourceP,
36696
+ prop: descP,
36697
+ details: descP,
36698
+ result: null,
36699
+ error: warn ? false : true,
36700
+ fields: null,
36701
+ type: 'widgets',
36702
+ prog_id: _session.DS_GLB[dsP].prog_id,
36703
+ });
36704
+ };
36705
+ const get_fields_data = async function (fields, props) {
36706
+ const report_error = function (descP, warn) {
36707
+ func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
36708
+ module: 'widgets',
36709
+ action: 'Init',
36865
36710
  source: sourceP,
36866
36711
  prop: descP,
36867
36712
  details: descP,
36868
36713
  result: null,
36869
36714
  error: warn ? false : true,
36870
36715
  fields: null,
36871
- type: "widgets",
36716
+ type: 'widgets',
36872
36717
  prog_id: _session.DS_GLB[dsP].prog_id,
36873
- }
36874
- );
36875
- };
36876
- const get_fields_data = async function (fields, props) {
36877
- const report_error = function (descP, warn) {
36878
- func.utils.debug.log(
36879
- SESSION_ID,
36880
- _session.DS_GLB[dsP].prog_id +
36881
- "_" +
36882
- _session.DS_GLB[dsP].callingMenuId,
36883
- {
36884
- module: "widgets",
36885
- action: "Init",
36886
- source: sourceP,
36887
- prop: descP,
36888
- details: descP,
36889
- result: null,
36890
- error: warn ? false : true,
36891
- fields: null,
36892
- type: "widgets",
36893
- prog_id: _session.DS_GLB[dsP].prog_id,
36894
- }
36895
- );
36718
+ });
36896
36719
  };
36897
36720
  const get_property_value = async function (fieldIdP, val) {
36898
36721
  // var value = props[fieldIdP];
36899
36722
 
36900
- var value =
36901
- props[fieldIdP] ||
36902
- (typeof val.defaultValue === "function"
36903
- ? val?.defaultValue?.()
36904
- : val?.defaultValue);
36723
+ var value = props[fieldIdP] || (typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue);
36905
36724
 
36906
36725
  if (props[`xu-exp:${fieldIdP}`]) {
36907
- value = (
36908
- await func.expression.get(
36909
- SESSION_ID,
36910
- props[`xu-exp:${fieldIdP}`],
36911
- dsP,
36912
- "widget property"
36913
- )
36914
- ).result;
36726
+ value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
36915
36727
  }
36916
36728
 
36917
36729
  return func.common.get_cast_val(
36918
36730
  SESSION_ID,
36919
- "widgets",
36731
+ 'widgets',
36920
36732
  fieldIdP,
36921
36733
  val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
36922
36734
  value,
36923
- null
36735
+ null,
36924
36736
  );
36925
36737
  };
36926
36738
  var data_obj = {};
@@ -36943,51 +36755,36 @@ func.events.execute = async function (
36943
36755
  };
36944
36756
 
36945
36757
  try {
36946
- const _plugin =
36947
- APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
36758
+ const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
36948
36759
 
36949
- const index = await func.utils.get_plugin_resource(
36950
- SESSION_ID,
36951
- plugin_name,
36952
- `${_plugin.manifest["index.mjs"].dist ? "dist/" : ""}index.mjs`
36953
- );
36760
+ const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
36954
36761
 
36955
36762
  const methods = index.methods;
36956
36763
  if (methods && !methods[method]) {
36957
- return report_error("method not found");
36764
+ return report_error('method not found');
36958
36765
  }
36959
36766
 
36960
- const fields_ret = await get_fields_data(
36961
- methods[method].fields,
36962
- propsP
36963
- );
36767
+ const fields_ret = await get_fields_data(methods[method].fields, propsP);
36964
36768
 
36965
36769
  if (fields_ret.code < 0) {
36966
36770
  return report_error(fields_ret.data);
36967
36771
  }
36968
36772
  const fields = fields_ret.data;
36969
36773
 
36970
- const plugin_setup_ret = await func.utils.get_plugin_setup(
36971
- SESSION_ID,
36972
- plugin_name
36973
- );
36774
+ const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
36974
36775
  if (plugin_setup_ret.code < 0) {
36975
36776
  return report_error(plugin_setup_ret);
36976
36777
  }
36977
36778
 
36978
- const api_utils = await func.common.get_module(
36779
+ const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
36780
+ func,
36781
+ glb,
36782
+ SESSION_OBJ,
36979
36783
  SESSION_ID,
36980
- "xuda-api-library.mjs",
36981
- {
36982
- func,
36983
- glb,
36984
- SESSION_OBJ,
36985
- SESSION_ID,
36986
- APP_OBJ,
36987
- dsSession: dsP,
36988
- job_id: jobNoP,
36989
- }
36990
- );
36784
+ APP_OBJ,
36785
+ dsSession: dsP,
36786
+ job_id: jobNoP,
36787
+ });
36991
36788
 
36992
36789
  const params = {
36993
36790
  SESSION_ID,
@@ -37006,11 +36803,7 @@ func.events.execute = async function (
37006
36803
  api_utils,
37007
36804
  };
37008
36805
 
37009
- const fx = await func.utils.get_plugin_resource(
37010
- SESSION_ID,
37011
- plugin_name,
37012
- `${_plugin.manifest["runtime.mjs"].dist ? "dist/" : ""}runtime.mjs`
37013
- );
36806
+ const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
37014
36807
 
37015
36808
  if (!fx[method]) {
37016
36809
  throw `Method: ${method} does not exist`;
@@ -37024,41 +36817,21 @@ func.events.execute = async function (
37024
36817
  },
37025
36818
 
37026
36819
  call_native_javascript: async function () {
37027
- const module = await func.common.get_module(
37028
- SESSION_ID,
37029
- "xuda-event-javascript-module.mjs"
37030
- );
37031
- const result = await module.call_javascript(
37032
- SESSION_ID,
37033
- jobNoP,
37034
- refIdP,
37035
- dsSession
37036
- );
36820
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
36821
+ const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession);
37037
36822
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
37038
36823
 
37039
- return result
36824
+ return result;
37040
36825
  },
37041
36826
  call_evaluate_javascript: async function () {
37042
- const module = await func.common.get_module(
37043
- SESSION_ID,
37044
- "xuda-event-javascript-module.mjs"
37045
- );
37046
- const result = await module.call_javascript(
37047
- SESSION_ID,
37048
- jobNoP,
37049
- refIdP,
37050
- dsSession,
37051
- true
37052
- );
36827
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
36828
+ const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, true);
37053
36829
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
37054
36830
 
37055
- return result
36831
+ return result;
37056
36832
  },
37057
36833
  execute_native_javascript: async function () {
37058
- const module = await func.common.get_module(
37059
- SESSION_ID,
37060
- "xuda-event-javascript-module.mjs"
37061
- );
36834
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
37062
36835
 
37063
36836
  const result = await module.run_javascript(
37064
36837
  SESSION_ID,
@@ -37066,17 +36839,14 @@ func.events.execute = async function (
37066
36839
  dsSession,
37067
36840
  `(async function(el) {
37068
36841
  ${refIdP.value}
37069
- })(document.querySelector(\`[xu-ui-id=${elementP}]\`))`
36842
+ })(document.querySelector(\`[xu-ui-id=${elementP}]\`))`,
37070
36843
  );
37071
36844
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
37072
36845
 
37073
- return result
36846
+ return result;
37074
36847
  },
37075
36848
  execute_evaluate_javascript: async function () {
37076
- const module = await func.common.get_module(
37077
- SESSION_ID,
37078
- "xuda-event-javascript-module.mjs"
37079
- );
36849
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
37080
36850
 
37081
36851
  const result = await module.run_javascript(
37082
36852
  SESSION_ID,
@@ -37085,11 +36855,11 @@ func.events.execute = async function (
37085
36855
  `(async function(el) {
37086
36856
  ${refIdP.value}
37087
36857
  })(document.querySelector(\`[xu-ui-id=${elementP}]\`))`,
37088
- true
36858
+ true,
37089
36859
  );
37090
36860
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
37091
36861
 
37092
- return result
36862
+ return result;
37093
36863
  },
37094
36864
  loader_on: async function () {
37095
36865
  glb.CURRENT_APP_LOADING = null;
@@ -37110,131 +36880,59 @@ func.events.execute = async function (
37110
36880
  // if (descP.value) {
37111
36881
  $(document).trigger(refIdP.value, [_session.DS_GLB[dsSession]]);
37112
36882
  } else {
37113
- func.utils.debug_report(
37114
- SESSION_ID,
37115
- "func.events.execute",
37116
- "Event name missing",
37117
- "E"
37118
- );
36883
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', 'Event name missing', 'E');
37119
36884
  }
37120
36885
  func.events.delete_job(SESSION_ID, jobNoP);
37121
36886
  // if (callbackP) callbackP();
37122
36887
  },
37123
36888
 
37124
36889
  invoke_action: async function () {
37125
- func.utils.debug.watch(
37126
- SESSION_ID,
37127
- calling_trigger_prop?.id,
37128
- functionP,
37129
- null,
37130
- null,
37131
- expCond
37132
- );
36890
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, null, null, expCond);
37133
36891
 
37134
- await func.action.execute(
37135
- SESSION_ID,
37136
- refIdP.value,
37137
- _ds,
37138
- null,
37139
- null,
37140
- jobNoP,
37141
- containerP
37142
- );
36892
+ await func.action.execute(SESSION_ID, refIdP.value, _ds, null, null, jobNoP, containerP);
37143
36893
  },
37144
36894
  raise_event: async function () {
37145
36895
  var _ds = _session.DS_GLB[dsSession];
37146
36896
  const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
37147
- if (callingSourceP === "grid" || callingSourceP === "form") {
37148
- let _field_obj = func.common.find_item_by_key(
37149
- _view_obj.progFields,
37150
- "field_id",
37151
- field_elm
37152
- );
36897
+ if (callingSourceP === 'grid' || callingSourceP === 'form') {
36898
+ let _field_obj = func.common.find_item_by_key(_view_obj.progFields, 'field_id', field_elm);
37153
36899
  var event_name = _field_obj?.triggers?.[eventIdP].name.event;
37154
36900
 
37155
- if (_field_obj?.triggers?.[eventIdP].name?.properties["xu-exp:event"]) {
37156
- event_name = (
37157
- await func.expression.get(
37158
- SESSION_ID,
37159
- props[`xu-exp:event`],
37160
- dsSession,
37161
- "event_name expression"
37162
- )
37163
- ).result;
36901
+ if (_field_obj?.triggers?.[eventIdP].name?.properties['xu-exp:event']) {
36902
+ event_name = (await func.expression.get(SESSION_ID, props[`xu-exp:event`], dsSession, 'event_name expression')).result;
37164
36903
  }
37165
36904
 
37166
36905
  if (field_elm && event_name) {
37167
36906
  // get container for fields events
37168
- const dsP = await func.datasource.find_event_dataSource(
37169
- SESSION_ID,
37170
- event_name,
37171
- dsSession
37172
- );
36907
+ const dsP = await func.datasource.find_event_dataSource(SESSION_ID, event_name, dsSession);
37173
36908
 
37174
- return await func.datasource.run_events_functions(
37175
- SESSION_ID,
37176
- dsP,
37177
- event_name,
37178
- jobNoP,
37179
- null,
37180
- calling_trigger_prop?.data?.name?.parameters || {}
37181
- );
36909
+ return await func.datasource.run_events_functions(SESSION_ID, dsP, event_name, jobNoP, null, calling_trigger_prop?.data?.name?.parameters || {});
37182
36910
  }
37183
36911
  // done_execution(event_name);
37184
36912
  }
37185
- if (callingSourceP.includes("event")) {
36913
+ if (callingSourceP.includes('event')) {
37186
36914
  let event_name = refIdP.event;
37187
36915
 
37188
- if (refIdP?.properties?.["xu-exp:event"]) {
37189
- event_name = (
37190
- await func.expression.get(
37191
- SESSION_ID,
37192
- refIdP.properties["xu-exp:event"],
37193
- dsSession,
37194
- "event_name expression"
37195
- )
37196
- ).result;
36916
+ if (refIdP?.properties?.['xu-exp:event']) {
36917
+ event_name = (await func.expression.get(SESSION_ID, refIdP.properties['xu-exp:event'], dsSession, 'event_name expression')).result;
37197
36918
  }
37198
36919
 
37199
- const dsP = await func.datasource.find_event_dataSource(
37200
- SESSION_ID,
37201
- event_name,
37202
- dsSession
37203
- );
36920
+ const dsP = await func.datasource.find_event_dataSource(SESSION_ID, event_name, dsSession);
37204
36921
 
37205
- await func.datasource.run_events_functions(
37206
- SESSION_ID,
37207
- dsP,
37208
- event_name,
37209
- jobNoP,
37210
- calling_trigger_prop?.props?.async,
37211
- calling_trigger_prop?.data?.name?.parameters || {}
37212
- );
36922
+ await func.datasource.run_events_functions(SESSION_ID, dsP, event_name, jobNoP, calling_trigger_prop?.props?.async, calling_trigger_prop?.data?.name?.parameters || {});
37213
36923
  // done_execution(event_name);
37214
36924
  }
37215
36925
 
37216
36926
  func.events.delete_job(SESSION_ID, jobNoP);
37217
36927
  // if (callbackP) callbackP();
37218
36928
 
37219
- func.utils.debug.watch(
37220
- SESSION_ID,
37221
- calling_trigger_prop?.id,
37222
- functionP,
37223
- "",
37224
- "",
37225
- expCond
37226
- );
36929
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, '', '', expCond);
37227
36930
  },
37228
36931
  get_data: async function () {
37229
36932
  const params_obj = await get_params_obj();
37230
36933
 
37231
36934
  if (!(await get_prog_id())) {
37232
- func.utils.debug_report(
37233
- SESSION_ID,
37234
- "func.events.execute",
37235
- `${elementP} > ${triggerP} > ${functionP} > program ${prog} is missing`,
37236
- "E"
37237
- );
36935
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} > ${triggerP} > ${functionP} > program ${prog} is missing`, 'E');
37238
36936
  func.events.delete_job(SESSION_ID, jobNoP);
37239
36937
  return;
37240
36938
  }
@@ -37247,41 +36945,14 @@ func.events.execute = async function (
37247
36945
 
37248
36946
  // args.prog_id = _viewId;
37249
36947
  if (_ds) {
37250
- func.utils.debug.watch(
37251
- SESSION_ID,
37252
- calling_trigger_prop?.id,
37253
- functionP,
37254
- null,
37255
- calling_trigger_prop,
37256
- expCond
37257
- );
36948
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, null, calling_trigger_prop, expCond);
37258
36949
  // }
37259
- const ret = await func.datasource.create(
37260
- SESSION_ID,
37261
- await get_prog_id(),
37262
- args.dataSourceNoP,
37263
- args.parentDataSourceNoP,
37264
- args.containerIdP,
37265
- args.rowIdP,
37266
- args.jobNoP,
37267
- args.calling_trigger_prop,
37268
- null,
37269
- null,
37270
- args.callingSourceP,
37271
- args.calling_jobP,
37272
- args.screen_dsP,
37273
- args.is_panelP,
37274
- params_obj
37275
- );
36950
+ const ret = await func.datasource.create(SESSION_ID, await get_prog_id(), args.dataSourceNoP, args.parentDataSourceNoP, args.containerIdP, args.rowIdP, args.jobNoP, args.calling_trigger_prop, null, null, args.callingSourceP, args.calling_jobP, args.screen_dsP, args.is_panelP, params_obj);
37276
36951
 
37277
36952
  let _ds_new = _session.DS_GLB[ret.dsSessionP];
37278
36953
  let parameters = args?.calling_trigger_prop?.data?.name?.parameters;
37279
36954
  if (parameters && !_.isEmpty(parameters)) {
37280
- await func.datasource.update_changes_for_out_parameter(
37281
- SESSION_ID,
37282
- _ds_new.dsSession,
37283
- _ds.dsSession
37284
- );
36955
+ await func.datasource.update_changes_for_out_parameter(SESSION_ID, _ds_new.dsSession, _ds.dsSession);
37285
36956
  }
37286
36957
  // if (parameters && !_.isEmpty(parameters) && _ds_new.PARAM_OUT_INFO) {
37287
36958
  // let data = {};
@@ -37310,7 +36981,7 @@ func.events.execute = async function (
37310
36981
  // }
37311
36982
 
37312
36983
  func.events.delete_job(SESSION_ID, jobNoP);
37313
- return _ds_new
36984
+ return _ds_new;
37314
36985
  }
37315
36986
  },
37316
36987
  set_data: async function () {
@@ -37320,24 +36991,12 @@ func.events.execute = async function (
37320
36991
  const result = await this.get_data();
37321
36992
 
37322
36993
  // await set_outputField(SESSION_ID, elementP, triggerP, functionP, dsSessionP, result);
37323
- return result
37324
-
36994
+ return result;
37325
36995
  },
37326
36996
  update: async function () {
37327
- const obj_values_to_update =
37328
- func.datasource.get_viewFields_for_update_function(
37329
- SESSION_ID,
37330
- calling_trigger_prop,
37331
- null,
37332
- dsSessionP
37333
- );
36997
+ const obj_values_to_update = func.datasource.get_viewFields_for_update_function(SESSION_ID, calling_trigger_prop, null, dsSessionP);
37334
36998
  if (!obj_values_to_update || _.isEmpty(obj_values_to_update)) {
37335
- func.utils.debug_report(
37336
- SESSION_ID,
37337
- "Update values object is empty",
37338
- "",
37339
- "W"
37340
- );
36999
+ func.utils.debug_report(SESSION_ID, 'Update values object is empty', '', 'W');
37341
37000
  if (jobNoP) func.events.delete_job(SESSION_ID, jobNoP);
37342
37001
  return;
37343
37002
  }
@@ -37350,32 +37009,8 @@ func.events.execute = async function (
37350
37009
  $element = $(`[xu-ui-id="${elementP}"]`).clone(true);
37351
37010
  }
37352
37011
 
37353
- let ret_field_id = await func.expression.get(
37354
- SESSION_ID,
37355
- val.id.trim(),
37356
- dsSessionP,
37357
- "update",
37358
- null,
37359
- null,
37360
- null,
37361
- null,
37362
- null,
37363
- null,
37364
- $element?.length ? $element?.data()?.xuData?.iterate_info : null
37365
- );
37366
- let ret_value = await func.expression.get(
37367
- SESSION_ID,
37368
- val.val.trim(),
37369
- dsSessionP,
37370
- "update",
37371
- null,
37372
- null,
37373
- null,
37374
- null,
37375
- null,
37376
- null,
37377
- $element?.length ? $element?.data()?.xuData?.iterate_info : null
37378
- );
37012
+ let ret_field_id = await func.expression.get(SESSION_ID, val.id.trim(), dsSessionP, 'update', null, null, null, null, null, null, $element?.length ? $element?.data()?.xuData?.iterate_info : null);
37013
+ let ret_value = await func.expression.get(SESSION_ID, val.val.trim(), dsSessionP, 'update', null, null, null, null, null, null, $element?.length ? $element?.data()?.xuData?.iterate_info : null);
37379
37014
  let _field_id = ret_field_id.result;
37380
37015
  let _value = ret_value.result;
37381
37016
 
@@ -37384,25 +37019,16 @@ func.events.execute = async function (
37384
37019
 
37385
37020
  let datasource_changes = {};
37386
37021
  for await (const change of updates) {
37387
- let ret_get_value = await func.datasource.get_value(
37388
- SESSION_ID,
37389
- change._field_id,
37390
- dsSessionP
37391
- );
37022
+ let ret_get_value = await func.datasource.get_value(SESSION_ID, change._field_id, dsSessionP);
37392
37023
  if (ret_get_value.found) {
37393
37024
  let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
37394
37025
  if (!datasource_changes[_ds.dsSession]) {
37395
37026
  datasource_changes[_ds.dsSession] = {};
37396
37027
  }
37397
- if (
37398
- !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
37399
- ) {
37400
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
37401
- {};
37028
+ if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
37029
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
37402
37030
  }
37403
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
37404
- change._field_id
37405
- ] = change._value;
37031
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][change._field_id] = change._value;
37406
37032
  }
37407
37033
  }
37408
37034
 
@@ -37411,23 +37037,11 @@ func.events.execute = async function (
37411
37037
  // return changes;
37412
37038
  },
37413
37039
  call_alert: async function () {
37414
- await func.utils.alerts.invoke(
37415
- SESSION_ID,
37416
- "call_alert",
37417
- refIdP,
37418
- log_source,
37419
- dsSession
37420
- );
37040
+ await func.utils.alerts.invoke(SESSION_ID, 'call_alert', refIdP, log_source, dsSession);
37421
37041
  func.events.delete_job(SESSION_ID, jobNoP);
37422
37042
  },
37423
37043
  alert: async function () {
37424
- await func.utils.alerts.invoke(
37425
- SESSION_ID,
37426
- "alert",
37427
- refIdP,
37428
- log_source,
37429
- dsSession
37430
- );
37044
+ await func.utils.alerts.invoke(SESSION_ID, 'alert', refIdP, log_source, dsSession);
37431
37045
  func.events.delete_job(SESSION_ID, jobNoP);
37432
37046
  },
37433
37047
  delay: async function () {
@@ -37446,18 +37060,11 @@ func.events.execute = async function (
37446
37060
  const _prog_id = await get_prog_id();
37447
37061
 
37448
37062
  if (!_prog_id) {
37449
- func.utils.debug_report(
37450
- SESSION_ID,
37451
- "func.events.execute",
37452
- `${elementP} > ${triggerP} > ${functionP} > program not defined`,
37453
- "E"
37454
- );
37063
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} > ${triggerP} > ${functionP} > program not defined`, 'E');
37455
37064
  func.events.delete_job(SESSION_ID, jobNoP);
37456
37065
  return;
37457
37066
  }
37458
37067
 
37459
-
37460
-
37461
37068
  // if (!output_field) {
37462
37069
  // func.utils.debug_report(
37463
37070
  // SESSION_ID,
@@ -37473,37 +37080,24 @@ func.events.execute = async function (
37473
37080
 
37474
37081
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, api_ret, args);
37475
37082
 
37476
-
37477
37083
  func.events.delete_job(SESSION_ID, jobNoP);
37478
37084
  },
37479
37085
  call_system_api: async function () {
37480
- const api_method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "api_method");
37086
+ const api_method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'api_method');
37481
37087
 
37482
37088
  if (!api_method) {
37483
- func.utils.debug_report(
37484
- SESSION_ID,
37485
- "func.events.execute",
37486
- `${elementP} >${triggerP} >${functionP} > api_method not defined`,
37487
- "E"
37488
- );
37089
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} >${triggerP} >${functionP} > api_method not defined`, 'E');
37489
37090
  func.events.delete_job(SESSION_ID, jobNoP);
37490
37091
  return;
37491
37092
  }
37492
37093
  let payload = {};
37493
- const _payload = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "payload");
37094
+ const _payload = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'payload');
37494
37095
  if (_payload) {
37495
37096
  const get_payload_property_value = async function (prop_name) {
37496
37097
  let _prop = _payload;
37497
37098
  let _value = _prop[prop_name];
37498
37099
  if (_prop?.[`xu-exp:${prop_name}`]) {
37499
- _value = (
37500
- await func.expression.get(
37501
- SESSION_ID,
37502
- _prop[`xu-exp:${prop_name}`],
37503
- dsSession,
37504
- `${prop_name} expression`
37505
- )
37506
- ).result;
37100
+ _value = (await func.expression.get(SESSION_ID, _prop[`xu-exp:${prop_name}`], dsSession, `${prop_name} expression`)).result;
37507
37101
  }
37508
37102
 
37509
37103
  return _value;
@@ -37511,7 +37105,7 @@ func.events.execute = async function (
37511
37105
 
37512
37106
  for await (let [key, val] of Object.entries(_payload)) {
37513
37107
  // if (key.substring(0, 7) !== "xu-exp:") {
37514
- const new_key = key.replaceAll("xu-exp:", ""); //key.substring(0, 7) === "xu-exp:" ? key.substring(7): key
37108
+ const new_key = key.replaceAll('xu-exp:', ''); //key.substring(0, 7) === "xu-exp:" ? key.substring(7): key
37515
37109
  payload[new_key] = await get_payload_property_value(new_key);
37516
37110
  // }
37517
37111
  }
@@ -37528,7 +37122,7 @@ func.events.execute = async function (
37528
37122
  // return;
37529
37123
  // }
37530
37124
 
37531
- const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "outputField");
37125
+ const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'outputField');
37532
37126
 
37533
37127
  // if (!output_field) {
37534
37128
  // func.utils.debug_report(
@@ -37545,89 +37139,57 @@ func.events.execute = async function (
37545
37139
  if (output_field) {
37546
37140
  let datasource_changes = {};
37547
37141
 
37548
- let ret_get_value = await func.datasource.get_value(
37549
- SESSION_ID,
37550
- output_field,
37551
- dsSessionP
37552
- );
37142
+ let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
37553
37143
  if (ret_get_value.found) {
37554
37144
  let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
37555
37145
  if (!datasource_changes[_ds.dsSession]) {
37556
37146
  datasource_changes[_ds.dsSession] = {};
37557
37147
  }
37558
- if (
37559
- !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
37560
- ) {
37561
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
37562
- {};
37148
+ if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
37149
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
37563
37150
  }
37564
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
37565
- output_field
37566
- ] = api_ret;
37151
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = api_ret;
37567
37152
  await func.datasource.update(SESSION_ID, datasource_changes);
37568
37153
  }
37569
37154
  }
37570
37155
  func.events.delete_job(SESSION_ID, jobNoP);
37571
37156
  },
37572
37157
  call_external_api: async function () {
37573
- const method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "method");
37158
+ const method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'method');
37574
37159
 
37575
37160
  if (!method) {
37576
- func.utils.debug_report(
37577
- SESSION_ID,
37578
- "func.events.execute",
37579
- `${elementP} >${triggerP} >${functionP} > method not defined`,
37580
- "E"
37581
- );
37161
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} >${triggerP} >${functionP} > method not defined`, 'E');
37582
37162
  func.events.delete_job(SESSION_ID, jobNoP);
37583
37163
  return;
37584
37164
  }
37585
37165
 
37586
- const url = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "url");
37166
+ const url = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'url');
37587
37167
 
37588
37168
  if (!url) {
37589
- func.utils.debug_report(
37590
- SESSION_ID,
37591
- "func.events.execute",
37592
- `${elementP} >${triggerP} >${functionP} > url not defined`,
37593
- "E"
37594
- );
37169
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} >${triggerP} >${functionP} > url not defined`, 'E');
37595
37170
  func.events.delete_job(SESSION_ID, jobNoP);
37596
37171
  return;
37597
37172
  }
37598
37173
 
37599
- const payload_arr = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "payload");
37174
+ const payload_arr = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'payload');
37600
37175
 
37601
37176
  const report_conversion_error = function (res, typeP, valP) {
37602
37177
  var msg = `${elementP} >${triggerP} >${functionP} > error converting from ${valP} to ${typeP}`;
37603
37178
  if (error) {
37604
- return func.utils.debug_report(SESSION_ID, msg, "", "W");
37179
+ return func.utils.debug_report(SESSION_ID, msg, '', 'W');
37605
37180
  }
37606
- func.utils.debug_report(
37607
- SESSION_ID,
37608
- msg + " " + _.capitalize(source) + prog_info,
37609
- "",
37610
- "E"
37611
- );
37181
+ func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'E');
37612
37182
  };
37613
37183
  const report_conversion_warn = function (res) {
37614
37184
  var msg = `${elementP} >${triggerP} >${functionP} > type mismatch auto conversion from value ${valP} to ${typeP}`;
37615
- func.utils.debug_report(
37616
- SESSION_ID,
37617
- msg + " " + _.capitalize(source) + prog_info,
37618
- "",
37619
- "W"
37620
- );
37185
+ func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'W');
37621
37186
  };
37622
37187
  // var ret = valP;
37623
37188
  if (error) {
37624
37189
  return report_conversion_error();
37625
37190
  }
37626
37191
 
37627
- const module = await func.common.get_module(
37628
- SESSION_ID,
37629
- "xuda-get-cast-util-module.mjs"
37630
- );
37192
+ const module = await func.common.get_module(SESSION_ID, 'xuda-get-cast-util-module.mjs');
37631
37193
  // return module.cast(
37632
37194
  // typeP,
37633
37195
  // valP,
@@ -37638,16 +37200,11 @@ func.events.execute = async function (
37638
37200
  var payload = _.reduce(
37639
37201
  payload_arr,
37640
37202
  (ret, val, key) => {
37641
- ret[val.key] = module.cast(
37642
- val.type,
37643
- val.val,
37644
- report_conversion_error,
37645
- report_conversion_warn
37646
- );
37203
+ ret[val.key] = module.cast(val.type, val.val, report_conversion_error, report_conversion_warn);
37647
37204
 
37648
37205
  return ret;
37649
37206
  },
37650
- {}
37207
+ {},
37651
37208
  );
37652
37209
  // if (!payload) {
37653
37210
  // func.utils.debug_report(
@@ -37660,7 +37217,7 @@ func.events.execute = async function (
37660
37217
  // return;
37661
37218
  // }
37662
37219
 
37663
- const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "outputField");
37220
+ const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'outputField');
37664
37221
 
37665
37222
  // if (!output_field) {
37666
37223
  // func.utils.debug_report(
@@ -37677,25 +37234,16 @@ func.events.execute = async function (
37677
37234
  if (output_field) {
37678
37235
  let datasource_changes = {};
37679
37236
 
37680
- let ret_get_value = await func.datasource.get_value(
37681
- SESSION_ID,
37682
- output_field,
37683
- dsSessionP
37684
- );
37237
+ let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
37685
37238
  if (ret_get_value.found) {
37686
37239
  let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
37687
37240
  if (!datasource_changes[_ds.dsSession]) {
37688
37241
  datasource_changes[_ds.dsSession] = {};
37689
37242
  }
37690
- if (
37691
- !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
37692
- ) {
37693
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
37694
- {};
37243
+ if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
37244
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
37695
37245
  }
37696
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
37697
- output_field
37698
- ] = api_ret;
37246
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = api_ret;
37699
37247
  await func.datasource.update(SESSION_ID, datasource_changes);
37700
37248
  }
37701
37249
  }
@@ -37728,16 +37276,9 @@ func.events.delete_job = function (SESSION_ID, jobNoP) {
37728
37276
  var dsSession = _session.WORKER_OBJ.jobs[job_index].dsSessionP;
37729
37277
  let ds_obj = _session?.DS_GLB[dsSession];
37730
37278
  if (ds_obj) {
37731
- delete SCREEN_BLOCKER_OBJ[
37732
- ds_obj.screenId +
37733
- (ds_obj.callingScreenId ? "_" + ds_obj.callingScreenId : "")
37734
- ];
37279
+ delete SCREEN_BLOCKER_OBJ[ds_obj.screenId + (ds_obj.callingScreenId ? '_' + ds_obj.callingScreenId : '')];
37735
37280
  }
37736
- if (
37737
- dsSession &&
37738
- ds_obj?.loops_limit &&
37739
- ds_obj?.loops_count < ds_obj?.loops_limit - 1
37740
- ) {
37281
+ if (dsSession && ds_obj?.loops_limit && ds_obj?.loops_count < ds_obj?.loops_limit - 1) {
37741
37282
  return;
37742
37283
  }
37743
37284
  _session.WORKER_OBJ.stat = null;
@@ -37755,17 +37296,9 @@ func.events.delete_job_0 = function (SESSION_ID) {
37755
37296
  var dsSession = _session.WORKER_OBJ.jobs[job_index].dsSession;
37756
37297
  let ds_obj = _session?.DS_GLB[dsSession];
37757
37298
  if (ds_obj) {
37758
- delete SCREEN_BLOCKER_OBJ[
37759
- ds_obj.screenId +
37760
- (ds_obj.callingScreenId ? "_" + ds_obj.callingScreenId : "")
37761
- ];
37299
+ delete SCREEN_BLOCKER_OBJ[ds_obj.screenId + (ds_obj.callingScreenId ? '_' + ds_obj.callingScreenId : '')];
37762
37300
  }
37763
- if (
37764
- dsSession &&
37765
- ds_obj &&
37766
- ds_obj.loops_limit &&
37767
- ds_obj.loops_count < ds_obj.loops_limit - 1
37768
- ) {
37301
+ if (dsSession && ds_obj && ds_obj.loops_limit && ds_obj.loops_count < ds_obj.loops_limit - 1) {
37769
37302
  return;
37770
37303
  }
37771
37304
  _session.WORKER_OBJ.stat = null;
@@ -37807,8 +37340,7 @@ setInterval(function () {
37807
37340
  }, 1000);
37808
37341
 
37809
37342
  func.events.set_browser_changes = function (dsP, fieldsChangedP) {
37810
- if (fieldsChangedP.includes("SYS_GLOBAL_STR_BROWSER_TITLE"))
37811
- document.title = dsP.dataset_new["SYS_GLOBAL_STR_BROWSER_TITLE"];
37343
+ if (fieldsChangedP.includes('SYS_GLOBAL_STR_BROWSER_TITLE')) document.title = dsP.dataset_new['SYS_GLOBAL_STR_BROWSER_TITLE'];
37812
37344
  };
37813
37345
 
37814
37346
  func.events.execute_PENDING_OPEN_URL_EVENTS = async function () {
@@ -37817,52 +37349,29 @@ func.events.execute_PENDING_OPEN_URL_EVENTS = async function () {
37817
37349
  glb.WINDOW_LOCATION_SEARCH = url;
37818
37350
  glb.ROOT_ELEMENT_ATTRIBUTES = func.UI.utils.get_root_element_attributes();
37819
37351
 
37820
- const params_obj = func.common.getObjectFromUrl(
37821
- url,
37822
- glb.ROOT_ELEMENT_ATTRIBUTES
37823
- );
37352
+ const params_obj = func.common.getObjectFromUrl(url, glb.ROOT_ELEMENT_ATTRIBUTES);
37824
37353
  if (!params_obj.prog) {
37825
- return console.warn("prog empty");
37354
+ return console.warn('prog empty');
37826
37355
  }
37827
37356
 
37828
37357
  await func.utils.TREE_OBJ.get(SESSION_ID, params_obj.prog);
37829
- let screen_ret = await func.utils.get_screen_obj(
37830
- SESSION_ID,
37831
- params_obj.prog
37832
- );
37358
+ let screen_ret = await func.utils.get_screen_obj(SESSION_ID, params_obj.prog);
37833
37359
 
37834
37360
  if (screen_ret) {
37835
- await func.UI.screen.init(
37836
- SESSION_ID,
37837
- params_obj.prog,
37838
- null,
37839
- null,
37840
- $("#embed_" + SESSION_ID),
37841
- null,
37842
- null,
37843
- null,
37844
- null,
37845
- null,
37846
- "pendingUrlEvent_embed"
37847
- );
37361
+ await func.UI.screen.init(SESSION_ID, params_obj.prog, null, null, $('#embed_' + SESSION_ID), null, null, null, null, null, 'pendingUrlEvent_embed');
37848
37362
  } else {
37849
- console.error("Program not exist", params_obj.prog_id);
37850
- func.UI.utils.progressScreen.show(
37851
- SESSION_ID,
37852
- "Program not exist",
37853
- null,
37854
- true
37855
- );
37363
+ console.error('Program not exist', params_obj.prog_id);
37364
+ func.UI.utils.progressScreen.show(SESSION_ID, 'Program not exist', null, true);
37856
37365
  }
37857
37366
  } else {
37858
- console.warn("url empty");
37367
+ console.warn('url empty');
37859
37368
  }
37860
37369
  }
37861
37370
  };
37862
37371
  func.events.invoke = async function (event_id) {
37863
37372
  var _session = SESSION_OBJ[SESSION_ID];
37864
37373
  if (!event_id) {
37865
- console.warn("event_id Cannot be empty");
37374
+ console.warn('event_id Cannot be empty');
37866
37375
  return false;
37867
37376
  }
37868
37377
  var ds;
@@ -37871,10 +37380,7 @@ func.events.invoke = async function (event_id) {
37871
37380
  if (_.isEmpty(_view_obj.progEvents)) continue;
37872
37381
  if (ds) break;
37873
37382
  for await (const [key, val] of Object.entries(_view_obj.progEvents)) {
37874
- if (
37875
- val?.data?.type === "user_defined" &&
37876
- val.data.event_name === event_id
37877
- ) {
37383
+ if (val?.data?.type === 'user_defined' && val.data.event_name === event_id) {
37878
37384
  ds = ds_key;
37879
37385
  break;
37880
37386
  }
@@ -37882,11 +37388,11 @@ func.events.invoke = async function (event_id) {
37882
37388
  }
37883
37389
 
37884
37390
  if (!ds) {
37885
- console.warn("event_id not found");
37391
+ console.warn('event_id not found');
37886
37392
  return false;
37887
37393
  }
37888
37394
 
37889
- func.events.validate(SESSION_ID, "user_defined", ds, event_id);
37395
+ func.events.validate(SESSION_ID, 'user_defined', ds, event_id);
37890
37396
  };
37891
37397
  func.action = {};
37892
37398
  func.action.execute = async function (