@xuda.io/runtime-bundle 1.0.319 → 1.0.320

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.
@@ -6380,7 +6380,7 @@ func.utils.job_worker = function (session_id) {
6380
6380
  val.containerP,
6381
6381
  val.elementP,
6382
6382
  val.rowP,
6383
- null,
6383
+ val.evt,
6384
6384
  val.descP,
6385
6385
  val.rootScreenIdP,
6386
6386
  val.dsSessionP,
@@ -10774,8 +10774,8 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10774
10774
  'xu-on': async function ($elm, val) {
10775
10775
  CLIENT_ACTIVITY_TS = Date.now();
10776
10776
  const trigger = val.key.split('xu-on:')[1].toLowerCase();
10777
- $elm.on(trigger, async function (e) {
10778
- for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + e.type])) {
10777
+ $elm.on(trigger, async function (evt) {
10778
+ for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
10779
10779
  if (val.handler === 'custom') {
10780
10780
  // do BL
10781
10781
  for await (const [key2, val2] of Object.entries(val.event)) {
@@ -10786,11 +10786,11 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10786
10786
  }
10787
10787
  if (!cond) continue;
10788
10788
 
10789
- if (val.event_modifiers && e[val.event_modifiers]) {
10790
- e[val.event_modifiers]();
10789
+ if (val.event_modifiers && evt[val.event_modifiers]) {
10790
+ evt[val.event_modifiers]();
10791
10791
  }
10792
10792
 
10793
- 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);
10793
+ 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, evt, null, null, null, paramsP.dsSessionP, null, null, null, e.type, val2.data.name, null, null, val2, null, null, null, null, null, null);
10794
10794
  }
10795
10795
  }
10796
10796
  }
@@ -13339,15 +13339,7 @@ func.UI.component.init_xu_nav = function ($container, $nav) {
13339
13339
  });
13340
13340
  };
13341
13341
  func.events = {};
13342
- func.events.validate = async function (
13343
- SESSION_ID,
13344
- triggerP,
13345
- dsSessionP,
13346
- eventIdP,
13347
- sourceP,
13348
- argumentsP,
13349
- return_validation_onlyP
13350
- ) {
13342
+ func.events.validate = async function (SESSION_ID, triggerP, dsSessionP, eventIdP, sourceP, argumentsP, return_validation_onlyP) {
13351
13343
  var _session = SESSION_OBJ[SESSION_ID];
13352
13344
  var _ds = _session.DS_GLB[dsSessionP];
13353
13345
  var args = {
@@ -13360,16 +13352,8 @@ func.events.validate = async function (
13360
13352
  return_validation_onlyP,
13361
13353
  };
13362
13354
  const search_event_in_parent_ds = async function () {
13363
- if (_ds && typeof _ds.parentDataSourceNo !== "undefined") {
13364
- await func.events.validate(
13365
- SESSION_ID,
13366
- triggerP,
13367
- _ds.parentDataSourceNo,
13368
- eventIdP,
13369
- sourceP,
13370
- argumentsP,
13371
- return_validation_onlyP
13372
- );
13355
+ if (_ds && typeof _ds.parentDataSourceNo !== 'undefined') {
13356
+ await func.events.validate(SESSION_ID, triggerP, _ds.parentDataSourceNo, eventIdP, sourceP, argumentsP, return_validation_onlyP);
13373
13357
  }
13374
13358
  };
13375
13359
  var ret = false;
@@ -13391,29 +13375,13 @@ func.events.validate = async function (
13391
13375
  var eventProp = undefined;
13392
13376
  if (val.data.type === triggerP) {
13393
13377
  // compare event trigger
13394
- if (
13395
- (triggerP !== "user_defined") |
13396
- (triggerP === "user_defined" && eventIdP === val.data.event_name)
13397
- ) {
13378
+ if ((triggerP !== 'user_defined') | (triggerP === 'user_defined' && eventIdP === val.data.event_name)) {
13398
13379
  // compare user defined name
13399
13380
 
13400
13381
  var expCond;
13401
- if (val.data.condition)
13402
- expCond = await func.expression.get(
13403
- SESSION_ID,
13404
- val.data.condition,
13405
- dsSessionP,
13406
- "condition"
13407
- );
13382
+ if (val.data.condition) expCond = await func.expression.get(SESSION_ID, val.data.condition, dsSessionP, 'condition');
13408
13383
  if (!val.data.condition || expCond.result) {
13409
- func.utils.debug.watch(
13410
- SESSION_ID,
13411
- _ds.prog_id + "%" + val.id,
13412
- "view_event",
13413
- val,
13414
- triggerP + " " + eventIdP,
13415
- expCond
13416
- );
13384
+ func.utils.debug.watch(SESSION_ID, _ds.prog_id + '%' + val.id, 'view_event', val, triggerP + ' ' + eventIdP, expCond);
13417
13385
  ret = true;
13418
13386
  if (return_validation_onlyP) break;
13419
13387
  const set_arguments = async function () {
@@ -13451,48 +13419,24 @@ func.events.validate = async function (
13451
13419
  // await func.datasource.update(SESSION_ID, datasource_changes);
13452
13420
  // }
13453
13421
 
13454
- for await (let [key, fieldId] of Object.entries(
13455
- val.data.parameters
13456
- )) {
13457
- const field_info = func.common.find_item_by_key(
13458
- _view_obj.progFields,
13459
- "field_id",
13460
- fieldId
13461
- );
13422
+ for await (let [key, fieldId] of Object.entries(val.data.parameters)) {
13423
+ const field_info = func.common.find_item_by_key(_view_obj.progFields, 'field_id', fieldId);
13462
13424
 
13463
- if (field_info?.data?.type !== "virtual") {
13464
- console.warn("parameter field must be virtual, update ignored");
13425
+ if (field_info?.data?.type !== 'virtual') {
13426
+ console.warn('parameter field must be virtual, update ignored');
13465
13427
  continue;
13466
13428
  }
13467
13429
 
13468
- if (!args[fieldId]) continue
13469
-
13430
+ if (!args[fieldId]) continue;
13470
13431
 
13471
-
13472
- let value = await func.common.get_cast_val(
13473
- SESSION_ID,
13474
- "events",
13475
- fieldId,
13476
- field_info.props.fieldType,
13477
- args[fieldId].value
13478
- );
13432
+ let value = await func.common.get_cast_val(SESSION_ID, 'events', fieldId, field_info.props.fieldType, args[fieldId].value);
13479
13433
 
13480
13434
  if (!_.isEmpty(args[fieldId].fx)) {
13481
- const fx_ret = await func.expression.get(
13482
- SESSION_ID,
13483
- args[fieldId].fx,
13484
- dsSessionP,
13485
- "update"
13486
- )
13435
+ const fx_ret = await func.expression.get(SESSION_ID, args[fieldId].fx, dsSessionP, 'update');
13487
13436
  value = fx_ret.result;
13488
13437
  }
13489
13438
  // find the target field in the program dataset
13490
- const ret = await func.datasource.get_value(
13491
- SESSION_ID,
13492
- fieldId,
13493
- dsSessionP,
13494
- _ds.currentRecordId
13495
- );
13439
+ const ret = await func.datasource.get_value(SESSION_ID, fieldId, dsSessionP, _ds.currentRecordId);
13496
13440
 
13497
13441
  const datasource_changes = {
13498
13442
  [ret.dsSessionP]: {
@@ -13505,11 +13449,7 @@ func.events.validate = async function (
13505
13449
  await add_event();
13506
13450
  };
13507
13451
  const add_event = async function () {
13508
- const _event = func.common.find_item_by_key_root(
13509
- _view_obj.progEvents,
13510
- "id",
13511
- val.id
13512
- );
13452
+ const _event = func.common.find_item_by_key_root(_view_obj.progEvents, 'id', val.id);
13513
13453
  if (_event.triggers) {
13514
13454
  // check if event property exist
13515
13455
 
@@ -13532,22 +13472,19 @@ func.events.validate = async function (
13532
13472
  if (!glb.IS_WORKER) {
13533
13473
  if (_ds.panel_div_id) {
13534
13474
  try {
13535
- container = "#" + _ds.panel_div_id;
13475
+ container = '#' + _ds.panel_div_id;
13536
13476
  if ($(container).data().xuData.panel_info) {
13537
- screen_prop =
13538
- $(container).data().xuData.panel_info.paramsP;
13477
+ screen_prop = $(container).data().xuData.panel_info.paramsP;
13539
13478
  } else {
13540
13479
  ///////////////
13541
- container =
13542
- "#" + _session.DS_GLB[dsSessionP].screenId;
13480
+ container = '#' + _session.DS_GLB[dsSessionP].screenId;
13543
13481
 
13544
13482
  if ($(container) && $(container).data()) {
13545
13483
  screen_prop = $(container).data().xuData.paramsP;
13546
13484
  }
13547
13485
 
13548
13486
  if (!$(container) || !$(container).length) {
13549
- container =
13550
- "#" + _session.DS_GLB[dsSessionP].containerId;
13487
+ container = '#' + _session.DS_GLB[dsSessionP].containerId;
13551
13488
  }
13552
13489
  //////////////
13553
13490
  }
@@ -13555,14 +13492,14 @@ func.events.validate = async function (
13555
13492
  console.error(e);
13556
13493
  }
13557
13494
  } else {
13558
- container = "#" + _ds.screenId;
13495
+ container = '#' + _ds.screenId;
13559
13496
 
13560
13497
  if ($(container) && $(container).data()) {
13561
13498
  screen_prop = $(container).data().xuData.paramsP;
13562
13499
  }
13563
13500
 
13564
13501
  if (!$(container) || !$(container).length) {
13565
- container = "#" + _ds.containerId;
13502
+ container = '#' + _ds.containerId;
13566
13503
  }
13567
13504
  }
13568
13505
  } else {
@@ -13574,7 +13511,7 @@ func.events.validate = async function (
13574
13511
  jobs.push(
13575
13512
  await func.events.add_to_queue(
13576
13513
  SESSION_ID,
13577
- sourceP + " event",
13514
+ sourceP + ' event',
13578
13515
  trigger_obj.id,
13579
13516
  null, // was click
13580
13517
  trigger_obj.data.action,
@@ -13600,8 +13537,8 @@ func.events.validate = async function (
13600
13537
  null,
13601
13538
  args,
13602
13539
  null,
13603
- null
13604
- )
13540
+ null,
13541
+ ),
13605
13542
  );
13606
13543
  }
13607
13544
  }
@@ -13613,15 +13550,7 @@ func.events.validate = async function (
13613
13550
  }
13614
13551
  } else {
13615
13552
  if (val.data.condition && !expCond.result) {
13616
- func.utils.debug.watch(
13617
- SESSION_ID,
13618
- _ds.prog_id + "%" + val.id,
13619
- "view_event",
13620
- val,
13621
- triggerP + " " + eventIdP,
13622
- expCond,
13623
- true
13624
- );
13553
+ func.utils.debug.watch(SESSION_ID, _ds.prog_id + '%' + val.id, 'view_event', val, triggerP + ' ' + eventIdP, expCond, true);
13625
13554
  }
13626
13555
  }
13627
13556
  }
@@ -13644,7 +13573,7 @@ func.events.add_to_queue = async function (
13644
13573
  containerP,
13645
13574
  elementP,
13646
13575
  rowP,
13647
- NA_colP,
13576
+ evt,
13648
13577
  descP,
13649
13578
  NA_rootScreenIdP,
13650
13579
  NA_callingEventIdP,
@@ -13662,7 +13591,7 @@ func.events.add_to_queue = async function (
13662
13591
  calling_job,
13663
13592
  args,
13664
13593
  $div,
13665
- $container
13594
+ $container,
13666
13595
  ) {
13667
13596
  var _session = SESSION_OBJ[SESSION_ID];
13668
13597
  var obj = {
@@ -13687,11 +13616,11 @@ func.events.add_to_queue = async function (
13687
13616
  args,
13688
13617
  $div,
13689
13618
  $container,
13690
-
13619
+ evt,
13691
13620
  job_num: _session.WORKER_OBJ.num,
13692
13621
  };
13693
13622
  var _ds = _session.DS_GLB[dsSessionP];
13694
- if (typeof dsSessionP !== "undefined" && dsSessionP !== null) {
13623
+ if (typeof dsSessionP !== 'undefined' && dsSessionP !== null) {
13695
13624
  obj.prog_id = _ds.prog_id;
13696
13625
  obj.parentDataSourceNo = _ds.parentDataSourceNo;
13697
13626
  obj.nodeId = _ds.nodeId;
@@ -13699,21 +13628,16 @@ func.events.add_to_queue = async function (
13699
13628
  ///////
13700
13629
  if (glb.IS_WORKER && func.utils.is_onscreen_event(functionP)) {
13701
13630
  obj.client = true;
13702
- if (functionP === "call_library") {
13631
+ if (functionP === 'call_library') {
13703
13632
  obj.client = false;
13704
13633
  }
13705
- if (typeof dsSessionP !== "undefined" && dsSessionP !== null) {
13634
+ if (typeof dsSessionP !== 'undefined' && dsSessionP !== null) {
13706
13635
  obj.ds_obj = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
13707
13636
  }
13708
13637
  if (obj.client) {
13709
13638
  _session.WORKER_OBJ.num++;
13710
13639
  // if (!_session.IS_API)
13711
- func.utils.post_back_to_client(
13712
- SESSION_ID,
13713
- "job",
13714
- _session.worker_id,
13715
- obj
13716
- );
13640
+ func.utils.post_back_to_client(SESSION_ID, 'job', _session.worker_id, obj);
13717
13641
  return;
13718
13642
  }
13719
13643
  }
@@ -13727,14 +13651,10 @@ func.events.add_to_queue = async function (
13727
13651
  _session.WORKER_OBJ.jobs[job_index].splice_count = 0;
13728
13652
  }
13729
13653
  _session.WORKER_OBJ.jobs[job_index].splice_count++;
13730
- _session.WORKER_OBJ.jobs.splice(
13731
- job_index + _session.WORKER_OBJ.jobs[job_index].splice_count,
13732
- 0,
13733
- obj
13734
- );
13654
+ _session.WORKER_OBJ.jobs.splice(job_index + _session.WORKER_OBJ.jobs[job_index].splice_count, 0, obj);
13735
13655
  // }
13736
13656
  } catch (e) {
13737
- console.error("bug");
13657
+ console.error('bug');
13738
13658
  // _session.WORKER_OBJ.jobs.splice(0, 0, obj);
13739
13659
  }
13740
13660
  } else {
@@ -13766,7 +13686,7 @@ func.events.execute = async function (
13766
13686
  containerP,
13767
13687
  elementP,
13768
13688
  rowP,
13769
- NA_colP,
13689
+ evt,
13770
13690
  descP,
13771
13691
  rootScreenIdP,
13772
13692
  dsSessionP,
@@ -13784,14 +13704,14 @@ func.events.execute = async function (
13784
13704
  NA_viewIdP,
13785
13705
  NA_nodeIdP,
13786
13706
  NA_parentDataSourceNoP,
13787
- $div
13707
+ $div,
13788
13708
  ) {
13789
13709
  var _session = SESSION_OBJ[SESSION_ID];
13790
13710
  var _ds = _session.DS_GLB[dsSessionP];
13791
- if (functionP === "update") refIdP = null; // in case of left over when program changing from call function to update
13711
+ if (functionP === 'update') refIdP = null; // in case of left over when program changing from call function to update
13792
13712
 
13793
13713
  var job_index = func.events.find_job_index(SESSION_ID, jobNoP);
13794
- if (_session.WORKER_OBJ.jobs?.[job_index]?.stat === "busy") {
13714
+ if (_session.WORKER_OBJ.jobs?.[job_index]?.stat === 'busy') {
13795
13715
  if (jobNoP) _session.WORKER_OBJ.stat = job_index;
13796
13716
  return;
13797
13717
  }
@@ -13808,61 +13728,44 @@ func.events.execute = async function (
13808
13728
  }
13809
13729
 
13810
13730
  if (_session.WORKER_OBJ.jobs[job_index]) {
13811
- _session.WORKER_OBJ.jobs[job_index].stat = "busy";
13731
+ _session.WORKER_OBJ.jobs[job_index].stat = 'busy';
13812
13732
  }
13813
13733
 
13814
13734
  var dsSession = dsSessionP; // new 2020420
13815
13735
  var field_elm = elementP;
13816
13736
 
13817
13737
  var calling_field_id = field_elm;
13818
- if (field_elm && typeof field_elm === "object")
13819
- calling_field_id = field_elm.attr("xu-ui-id");
13738
+ if (field_elm && typeof field_elm === 'object') calling_field_id = field_elm.attr('xu-ui-id');
13820
13739
 
13821
13740
  var log_nodeId;
13822
13741
  var log_prog_id;
13823
13742
  var log_source;
13824
13743
 
13825
- if (_session.DS_GLB[dsSession]?.prog_id)
13826
- log_prog_id = _session.DS_GLB[dsSession].prog_id;
13827
- log_nodeId = log_prog_id + "_" + eventIdP;
13744
+ if (_session.DS_GLB[dsSession]?.prog_id) log_prog_id = _session.DS_GLB[dsSession].prog_id;
13745
+ log_nodeId = log_prog_id + '_' + eventIdP;
13828
13746
  var log_prop = callingSourceP;
13829
- if (callingSourceP === "system event") {
13830
- log_prop = "global event";
13747
+ if (callingSourceP === 'system event') {
13748
+ log_prop = 'global event';
13831
13749
  }
13832
13750
  if (calling_field_id) {
13833
13751
  const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
13834
- let _field_obj = func.common.find_item_by_key(
13835
- _view_obj.progFields,
13836
- "field_id",
13837
- calling_field_id
13838
- );
13839
- log_nodeId = log_prog_id + "_" + eventIdP + "_" + _field_obj?.id;
13752
+ let _field_obj = func.common.find_item_by_key(_view_obj.progFields, 'field_id', calling_field_id);
13753
+ log_nodeId = log_prog_id + '_' + eventIdP + '_' + _field_obj?.id;
13840
13754
 
13841
13755
  log_source = calling_field_id;
13842
13756
  }
13843
13757
  if (elementP) {
13844
13758
  log_prop = triggerP;
13845
- log_nodeId = log_nodeId + "_ui_prop"; //+"_"+eventIdP;
13759
+ log_nodeId = log_nodeId + '_ui_prop'; //+"_"+eventIdP;
13846
13760
  }
13847
13761
  //check condition
13848
13762
  var expCond;
13849
13763
  if (event_propertiesP) {
13850
13764
  // conditional event
13851
13765
  if (event_propertiesP?.props?.condition) {
13852
- expCond = await func.expression.get(
13853
- SESSION_ID,
13854
- event_propertiesP.props.condition,
13855
- dsSession,
13856
- "condition",
13857
- null,
13858
- null,
13859
- null,
13860
- calling_field_id ? calling_field_id : calling_triggerP,
13861
- null,
13862
- descP
13863
- ); // execute expression
13766
+ 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
13864
13767
  func.utils.debug.log(SESSION_ID, log_nodeId, {
13865
- module: "event",
13768
+ module: 'event',
13866
13769
  action: log_prop,
13867
13770
  source: log_source,
13868
13771
  prop: descP,
@@ -13870,7 +13773,7 @@ func.events.execute = async function (
13870
13773
  result: expCond.result,
13871
13774
  error: expCond.error,
13872
13775
  fields: expCond.fields,
13873
- type: "event",
13776
+ type: 'event',
13874
13777
  prog_id: log_prog_id,
13875
13778
  conditional: true,
13876
13779
  });
@@ -13879,21 +13782,13 @@ func.events.execute = async function (
13879
13782
  // condition failed // === true 03/04/16
13880
13783
  func.events.delete_job(SESSION_ID, jobNoP);
13881
13784
 
13882
- func.utils.debug.watch(
13883
- SESSION_ID,
13884
- calling_trigger_prop?.id,
13885
- functionP,
13886
- "",
13887
- "",
13888
- expCond,
13889
- true
13890
- );
13785
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, '', '', expCond, true);
13891
13786
  return;
13892
13787
  }
13893
13788
  } // Non conditional event
13894
13789
  else {
13895
13790
  func.utils.debug.log(SESSION_ID, log_nodeId, {
13896
- module: "event",
13791
+ module: 'event',
13897
13792
  action: log_prop,
13898
13793
  source: log_source,
13899
13794
  prop: descP,
@@ -13901,7 +13796,7 @@ func.events.execute = async function (
13901
13796
  result: null,
13902
13797
  error: null,
13903
13798
  fields: null,
13904
- type: "event",
13799
+ type: 'event',
13905
13800
  prog_id: log_prog_id,
13906
13801
  });
13907
13802
  }
@@ -13924,47 +13819,27 @@ func.events.execute = async function (
13924
13819
  // };
13925
13820
 
13926
13821
  const get_params_obj = async function () {
13927
- const _prog = await func.utils.VIEWS_OBJ.get(
13928
- SESSION_ID,
13929
- await get_prog_id()
13930
- );
13822
+ const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, await get_prog_id());
13931
13823
  if (!_prog) {
13932
13824
  func.events.delete_job(SESSION_ID, jobNoP);
13933
- return func.utils.debug_report(
13934
- SESSION_ID,
13935
- "func.events.execute",
13936
- "Program not found: " + refIdP.prog,
13937
- "E"
13938
- );
13825
+ return func.utils.debug_report(SESSION_ID, 'func.events.execute', 'Program not found: ' + refIdP.prog, 'E');
13939
13826
  }
13940
13827
 
13941
13828
  // get in parameters
13942
13829
  var params_obj = {};
13943
13830
  if (_prog?.properties?.progParams) {
13944
- for await (const [key, val] of Object.entries(
13945
- _prog.properties.progParams
13946
- )) {
13947
- if (!val.data.dir === "in") continue;
13948
- if (
13949
- typeof args.parameters_obj_inP?.[val.data.parameter] !== "undefined"
13950
- ) {
13831
+ for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
13832
+ if (!val.data.dir === 'in') continue;
13833
+ if (typeof args.parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
13951
13834
  if (args.parameters_obj_inP?.[val.data.parameter].fx) {
13952
- let ret = await func.expression.get(
13953
- SESSION_ID,
13954
- args.parameters_obj_inP?.[val.data.parameter].fx,
13955
- dsSession,
13956
- "parameters"
13957
- );
13835
+ let ret = await func.expression.get(SESSION_ID, args.parameters_obj_inP?.[val.data.parameter].fx, dsSession, 'parameters');
13958
13836
  params_obj[val.data.parameter] = ret.result;
13959
13837
  } else {
13960
- params_obj[val.data.parameter] =
13961
- args.parameters_obj_inP?.[val.data.parameter].value;
13838
+ params_obj[val.data.parameter] = args.parameters_obj_inP?.[val.data.parameter].value;
13962
13839
  }
13963
13840
  continue;
13964
13841
  }
13965
- console.warn(
13966
- `Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`
13967
- );
13842
+ console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
13968
13843
  }
13969
13844
  }
13970
13845
  return params_obj;
@@ -13973,15 +13848,8 @@ func.events.execute = async function (
13973
13848
  const get_prog_id = async function () {
13974
13849
  let _prop = args?.calling_trigger_prop?.data?.name?.properties;
13975
13850
  let _prog_id = args.prog_id;
13976
- if (_prop?.["xu-exp:prog"]) {
13977
- _prog_id = (
13978
- await func.expression.get(
13979
- SESSION_ID,
13980
- _prop["xu-exp:prog"],
13981
- dsSession,
13982
- "prog_id expression"
13983
- )
13984
- ).result;
13851
+ if (_prop?.['xu-exp:prog']) {
13852
+ _prog_id = (await func.expression.get(SESSION_ID, _prop['xu-exp:prog'], dsSession, 'prog_id expression')).result;
13985
13853
  }
13986
13854
 
13987
13855
  return _prog_id;
@@ -14003,7 +13871,6 @@ func.events.execute = async function (
14003
13871
  // return _value;
14004
13872
  // };
14005
13873
 
14006
-
14007
13874
  var args = {
14008
13875
  prog_id: refIdP?.prog,
14009
13876
  screenIdP: refIdP?.prog,
@@ -14031,40 +13898,20 @@ func.events.execute = async function (
14031
13898
  var $calling_container;
14032
13899
  if (_session.WORKER_OBJ.jobs[job_index]) {
14033
13900
  if (_session.WORKER_OBJ.jobs[job_index].paramsP) {
14034
- $calling_container = $(
14035
- "#" + _session.WORKER_OBJ.jobs[job_index].paramsP.callingContainerP
14036
- );
13901
+ $calling_container = $('#' + _session.WORKER_OBJ.jobs[job_index].paramsP.callingContainerP);
14037
13902
  } else {
14038
- $calling_container = ""; // calling from datasource 0
13903
+ $calling_container = ''; // calling from datasource 0
14039
13904
  _session.WORKER_OBJ.jobs[job_index].paramsP = {};
14040
13905
  }
14041
13906
  }
14042
13907
 
14043
13908
  if (!refIdP.prog) {
14044
13909
  func.events.delete_job(SESSION_ID, jobNoP);
14045
- return func.utils.debug_report(
14046
- SESSION_ID,
14047
- "func.events.execute",
14048
- "Program is empty",
14049
- "E"
14050
- );
13910
+ return func.utils.debug_report(SESSION_ID, 'func.events.execute', 'Program is empty', 'E');
14051
13911
  }
14052
13912
 
14053
13913
  const params_obj = await get_params_obj();
14054
- return await func.UI.screen.init(
14055
- SESSION_ID,
14056
- await get_prog_id(),
14057
- $(containerP)?.data()?.xuData.screenId,
14058
- _session.DS_GLB[dsSession],
14059
- $calling_container,
14060
- eventIdP,
14061
- rowP,
14062
- jobNoP,
14063
- is_panel,
14064
- params_obj,
14065
- functionP,
14066
- args.call_screen_propertiesP
14067
- );
13914
+ 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);
14068
13915
  },
14069
13916
  call_modal: async function () {
14070
13917
  return await fx.Call_window();
@@ -14087,101 +13934,66 @@ func.events.execute = async function (
14087
13934
 
14088
13935
  const set_SYS_GLOBAL_OBJ_WIDGET_INFO = async function (docP) {
14089
13936
  var obj = _.clone(docP);
14090
- obj.date = await func.utils.get_dateTime(
14091
- SESSION_ID,
14092
- "SYS_DATE",
14093
- docP.date
14094
- );
14095
- obj.time = await func.utils.get_dateTime(
14096
- SESSION_ID,
14097
- "SYS_TIME",
14098
- docP.date
14099
- );
13937
+ obj.date = await func.utils.get_dateTime(SESSION_ID, 'SYS_DATE', docP.date);
13938
+ obj.time = await func.utils.get_dateTime(SESSION_ID, 'SYS_TIME', docP.date);
14100
13939
 
14101
13940
  var datasource_changes = {
14102
13941
  [0]: {
14103
- ["data_system"]: {
14104
- ["SYS_GLOBAL_OBJ_WIDGET_INFO"]: obj,
13942
+ ['data_system']: {
13943
+ ['SYS_GLOBAL_OBJ_WIDGET_INFO']: obj,
14105
13944
  },
14106
13945
  },
14107
13946
  };
14108
13947
  await func.datasource.update(SESSION_ID, datasource_changes);
14109
13948
  };
14110
13949
  const call_plugin_api = async function (plugin_nameP, dataP) {
14111
- return await func.utils.call_plugin_api(
14112
- SESSION_ID,
14113
- plugin_nameP,
14114
- dataP
14115
- );
13950
+ return await func.utils.call_plugin_api(SESSION_ID, plugin_nameP, dataP);
14116
13951
  };
14117
13952
  const report_error = function (descP, warn) {
14118
- func.utils.debug.log(
14119
- SESSION_ID,
14120
- _session.DS_GLB[dsP].prog_id +
14121
- "_" +
14122
- _session.DS_GLB[dsP].callingMenuId,
14123
- {
14124
- module: "widgets",
14125
- action: "Init",
13953
+ func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
13954
+ module: 'widgets',
13955
+ action: 'Init',
13956
+ source: sourceP,
13957
+ prop: descP,
13958
+ details: descP,
13959
+ result: null,
13960
+ error: warn ? false : true,
13961
+ fields: null,
13962
+ type: 'widgets',
13963
+ prog_id: _session.DS_GLB[dsP].prog_id,
13964
+ });
13965
+ };
13966
+ const get_fields_data = async function (fields, props) {
13967
+ const report_error = function (descP, warn) {
13968
+ func.utils.debug.log(SESSION_ID, _session.DS_GLB[dsP].prog_id + '_' + _session.DS_GLB[dsP].callingMenuId, {
13969
+ module: 'widgets',
13970
+ action: 'Init',
14126
13971
  source: sourceP,
14127
13972
  prop: descP,
14128
13973
  details: descP,
14129
13974
  result: null,
14130
13975
  error: warn ? false : true,
14131
13976
  fields: null,
14132
- type: "widgets",
13977
+ type: 'widgets',
14133
13978
  prog_id: _session.DS_GLB[dsP].prog_id,
14134
- }
14135
- );
14136
- };
14137
- const get_fields_data = async function (fields, props) {
14138
- const report_error = function (descP, warn) {
14139
- func.utils.debug.log(
14140
- SESSION_ID,
14141
- _session.DS_GLB[dsP].prog_id +
14142
- "_" +
14143
- _session.DS_GLB[dsP].callingMenuId,
14144
- {
14145
- module: "widgets",
14146
- action: "Init",
14147
- source: sourceP,
14148
- prop: descP,
14149
- details: descP,
14150
- result: null,
14151
- error: warn ? false : true,
14152
- fields: null,
14153
- type: "widgets",
14154
- prog_id: _session.DS_GLB[dsP].prog_id,
14155
- }
14156
- );
13979
+ });
14157
13980
  };
14158
13981
  const get_property_value = async function (fieldIdP, val) {
14159
13982
  // var value = props[fieldIdP];
14160
13983
 
14161
- var value =
14162
- props[fieldIdP] ||
14163
- (typeof val.defaultValue === "function"
14164
- ? val?.defaultValue?.()
14165
- : val?.defaultValue);
13984
+ var value = props[fieldIdP] || (typeof val.defaultValue === 'function' ? val?.defaultValue?.() : val?.defaultValue);
14166
13985
 
14167
13986
  if (props[`xu-exp:${fieldIdP}`]) {
14168
- value = (
14169
- await func.expression.get(
14170
- SESSION_ID,
14171
- props[`xu-exp:${fieldIdP}`],
14172
- dsP,
14173
- "widget property"
14174
- )
14175
- ).result;
13987
+ value = (await func.expression.get(SESSION_ID, props[`xu-exp:${fieldIdP}`], dsP, 'widget property')).result;
14176
13988
  }
14177
13989
 
14178
13990
  return func.common.get_cast_val(
14179
13991
  SESSION_ID,
14180
- "widgets",
13992
+ 'widgets',
14181
13993
  fieldIdP,
14182
13994
  val.type, //val.type !== "string" || val.type !== "number" ? "string" : val.type,
14183
13995
  value,
14184
- null
13996
+ null,
14185
13997
  );
14186
13998
  };
14187
13999
  var data_obj = {};
@@ -14204,51 +14016,36 @@ func.events.execute = async function (
14204
14016
  };
14205
14017
 
14206
14018
  try {
14207
- const _plugin =
14208
- APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
14019
+ const _plugin = APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name];
14209
14020
 
14210
- const index = await func.utils.get_plugin_resource(
14211
- SESSION_ID,
14212
- plugin_name,
14213
- `${_plugin.manifest["index.mjs"].dist ? "dist/" : ""}index.mjs`
14214
- );
14021
+ const index = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['index.mjs'].dist ? 'dist/' : ''}index.mjs`);
14215
14022
 
14216
14023
  const methods = index.methods;
14217
14024
  if (methods && !methods[method]) {
14218
- return report_error("method not found");
14025
+ return report_error('method not found');
14219
14026
  }
14220
14027
 
14221
- const fields_ret = await get_fields_data(
14222
- methods[method].fields,
14223
- propsP
14224
- );
14028
+ const fields_ret = await get_fields_data(methods[method].fields, propsP);
14225
14029
 
14226
14030
  if (fields_ret.code < 0) {
14227
14031
  return report_error(fields_ret.data);
14228
14032
  }
14229
14033
  const fields = fields_ret.data;
14230
14034
 
14231
- const plugin_setup_ret = await func.utils.get_plugin_setup(
14232
- SESSION_ID,
14233
- plugin_name
14234
- );
14035
+ const plugin_setup_ret = await func.utils.get_plugin_setup(SESSION_ID, plugin_name);
14235
14036
  if (plugin_setup_ret.code < 0) {
14236
14037
  return report_error(plugin_setup_ret);
14237
14038
  }
14238
14039
 
14239
- const api_utils = await func.common.get_module(
14040
+ const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
14041
+ func,
14042
+ glb,
14043
+ SESSION_OBJ,
14240
14044
  SESSION_ID,
14241
- "xuda-api-library.mjs",
14242
- {
14243
- func,
14244
- glb,
14245
- SESSION_OBJ,
14246
- SESSION_ID,
14247
- APP_OBJ,
14248
- dsSession: dsP,
14249
- job_id: jobNoP,
14250
- }
14251
- );
14045
+ APP_OBJ,
14046
+ dsSession: dsP,
14047
+ job_id: jobNoP,
14048
+ });
14252
14049
 
14253
14050
  const params = {
14254
14051
  SESSION_ID,
@@ -14267,11 +14064,7 @@ func.events.execute = async function (
14267
14064
  api_utils,
14268
14065
  };
14269
14066
 
14270
- const fx = await func.utils.get_plugin_resource(
14271
- SESSION_ID,
14272
- plugin_name,
14273
- `${_plugin.manifest["runtime.mjs"].dist ? "dist/" : ""}runtime.mjs`
14274
- );
14067
+ const fx = await func.utils.get_plugin_resource(SESSION_ID, plugin_name, `${_plugin.manifest['runtime.mjs'].dist ? 'dist/' : ''}runtime.mjs`);
14275
14068
 
14276
14069
  if (!fx[method]) {
14277
14070
  throw `Method: ${method} does not exist`;
@@ -14285,41 +14078,21 @@ func.events.execute = async function (
14285
14078
  },
14286
14079
 
14287
14080
  call_native_javascript: async function () {
14288
- const module = await func.common.get_module(
14289
- SESSION_ID,
14290
- "xuda-event-javascript-module.mjs"
14291
- );
14292
- const result = await module.call_javascript(
14293
- SESSION_ID,
14294
- jobNoP,
14295
- refIdP,
14296
- dsSession
14297
- );
14081
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
14082
+ const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession);
14298
14083
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
14299
14084
 
14300
- return result
14085
+ return result;
14301
14086
  },
14302
14087
  call_evaluate_javascript: async function () {
14303
- const module = await func.common.get_module(
14304
- SESSION_ID,
14305
- "xuda-event-javascript-module.mjs"
14306
- );
14307
- const result = await module.call_javascript(
14308
- SESSION_ID,
14309
- jobNoP,
14310
- refIdP,
14311
- dsSession,
14312
- true
14313
- );
14088
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
14089
+ const result = await module.call_javascript(SESSION_ID, jobNoP, refIdP, dsSession, true);
14314
14090
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
14315
14091
 
14316
- return result
14092
+ return result;
14317
14093
  },
14318
14094
  execute_native_javascript: async function () {
14319
- const module = await func.common.get_module(
14320
- SESSION_ID,
14321
- "xuda-event-javascript-module.mjs"
14322
- );
14095
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
14323
14096
 
14324
14097
  const result = await module.run_javascript(
14325
14098
  SESSION_ID,
@@ -14327,17 +14100,14 @@ func.events.execute = async function (
14327
14100
  dsSession,
14328
14101
  `(async function(el) {
14329
14102
  ${refIdP.value}
14330
- })(document.querySelector(\`[xu-ui-id=${elementP}]\`))`
14103
+ })(document.querySelector(\`[xu-ui-id=${elementP}]\`))`,
14331
14104
  );
14332
14105
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
14333
14106
 
14334
- return result
14107
+ return result;
14335
14108
  },
14336
14109
  execute_evaluate_javascript: async function () {
14337
- const module = await func.common.get_module(
14338
- SESSION_ID,
14339
- "xuda-event-javascript-module.mjs"
14340
- );
14110
+ const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
14341
14111
 
14342
14112
  const result = await module.run_javascript(
14343
14113
  SESSION_ID,
@@ -14346,11 +14116,11 @@ func.events.execute = async function (
14346
14116
  `(async function(el) {
14347
14117
  ${refIdP.value}
14348
14118
  })(document.querySelector(\`[xu-ui-id=${elementP}]\`))`,
14349
- true
14119
+ true,
14350
14120
  );
14351
14121
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, result, args);
14352
14122
 
14353
- return result
14123
+ return result;
14354
14124
  },
14355
14125
  loader_on: async function () {
14356
14126
  glb.CURRENT_APP_LOADING = null;
@@ -14371,131 +14141,59 @@ func.events.execute = async function (
14371
14141
  // if (descP.value) {
14372
14142
  $(document).trigger(refIdP.value, [_session.DS_GLB[dsSession]]);
14373
14143
  } else {
14374
- func.utils.debug_report(
14375
- SESSION_ID,
14376
- "func.events.execute",
14377
- "Event name missing",
14378
- "E"
14379
- );
14144
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', 'Event name missing', 'E');
14380
14145
  }
14381
14146
  func.events.delete_job(SESSION_ID, jobNoP);
14382
14147
  // if (callbackP) callbackP();
14383
14148
  },
14384
14149
 
14385
14150
  invoke_action: async function () {
14386
- func.utils.debug.watch(
14387
- SESSION_ID,
14388
- calling_trigger_prop?.id,
14389
- functionP,
14390
- null,
14391
- null,
14392
- expCond
14393
- );
14151
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, null, null, expCond);
14394
14152
 
14395
- await func.action.execute(
14396
- SESSION_ID,
14397
- refIdP.value,
14398
- _ds,
14399
- null,
14400
- null,
14401
- jobNoP,
14402
- containerP
14403
- );
14153
+ await func.action.execute(SESSION_ID, refIdP.value, _ds, null, null, jobNoP, containerP);
14404
14154
  },
14405
14155
  raise_event: async function () {
14406
14156
  var _ds = _session.DS_GLB[dsSession];
14407
14157
  const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
14408
- if (callingSourceP === "grid" || callingSourceP === "form") {
14409
- let _field_obj = func.common.find_item_by_key(
14410
- _view_obj.progFields,
14411
- "field_id",
14412
- field_elm
14413
- );
14158
+ if (callingSourceP === 'grid' || callingSourceP === 'form') {
14159
+ let _field_obj = func.common.find_item_by_key(_view_obj.progFields, 'field_id', field_elm);
14414
14160
  var event_name = _field_obj?.triggers?.[eventIdP].name.event;
14415
14161
 
14416
- if (_field_obj?.triggers?.[eventIdP].name?.properties["xu-exp:event"]) {
14417
- event_name = (
14418
- await func.expression.get(
14419
- SESSION_ID,
14420
- props[`xu-exp:event`],
14421
- dsSession,
14422
- "event_name expression"
14423
- )
14424
- ).result;
14162
+ if (_field_obj?.triggers?.[eventIdP].name?.properties['xu-exp:event']) {
14163
+ event_name = (await func.expression.get(SESSION_ID, props[`xu-exp:event`], dsSession, 'event_name expression')).result;
14425
14164
  }
14426
14165
 
14427
14166
  if (field_elm && event_name) {
14428
14167
  // get container for fields events
14429
- const dsP = await func.datasource.find_event_dataSource(
14430
- SESSION_ID,
14431
- event_name,
14432
- dsSession
14433
- );
14168
+ const dsP = await func.datasource.find_event_dataSource(SESSION_ID, event_name, dsSession);
14434
14169
 
14435
- return await func.datasource.run_events_functions(
14436
- SESSION_ID,
14437
- dsP,
14438
- event_name,
14439
- jobNoP,
14440
- null,
14441
- calling_trigger_prop?.data?.name?.parameters || {}
14442
- );
14170
+ return await func.datasource.run_events_functions(SESSION_ID, dsP, event_name, jobNoP, null, calling_trigger_prop?.data?.name?.parameters || {});
14443
14171
  }
14444
14172
  // done_execution(event_name);
14445
14173
  }
14446
- if (callingSourceP.includes("event")) {
14174
+ if (callingSourceP.includes('event')) {
14447
14175
  let event_name = refIdP.event;
14448
14176
 
14449
- if (refIdP?.properties?.["xu-exp:event"]) {
14450
- event_name = (
14451
- await func.expression.get(
14452
- SESSION_ID,
14453
- refIdP.properties["xu-exp:event"],
14454
- dsSession,
14455
- "event_name expression"
14456
- )
14457
- ).result;
14177
+ if (refIdP?.properties?.['xu-exp:event']) {
14178
+ event_name = (await func.expression.get(SESSION_ID, refIdP.properties['xu-exp:event'], dsSession, 'event_name expression')).result;
14458
14179
  }
14459
14180
 
14460
- const dsP = await func.datasource.find_event_dataSource(
14461
- SESSION_ID,
14462
- event_name,
14463
- dsSession
14464
- );
14181
+ const dsP = await func.datasource.find_event_dataSource(SESSION_ID, event_name, dsSession);
14465
14182
 
14466
- await func.datasource.run_events_functions(
14467
- SESSION_ID,
14468
- dsP,
14469
- event_name,
14470
- jobNoP,
14471
- calling_trigger_prop?.props?.async,
14472
- calling_trigger_prop?.data?.name?.parameters || {}
14473
- );
14183
+ await func.datasource.run_events_functions(SESSION_ID, dsP, event_name, jobNoP, calling_trigger_prop?.props?.async, calling_trigger_prop?.data?.name?.parameters || {});
14474
14184
  // done_execution(event_name);
14475
14185
  }
14476
14186
 
14477
14187
  func.events.delete_job(SESSION_ID, jobNoP);
14478
14188
  // if (callbackP) callbackP();
14479
14189
 
14480
- func.utils.debug.watch(
14481
- SESSION_ID,
14482
- calling_trigger_prop?.id,
14483
- functionP,
14484
- "",
14485
- "",
14486
- expCond
14487
- );
14190
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, '', '', expCond);
14488
14191
  },
14489
14192
  get_data: async function () {
14490
14193
  const params_obj = await get_params_obj();
14491
14194
 
14492
14195
  if (!(await get_prog_id())) {
14493
- func.utils.debug_report(
14494
- SESSION_ID,
14495
- "func.events.execute",
14496
- `${elementP} > ${triggerP} > ${functionP} > program ${prog} is missing`,
14497
- "E"
14498
- );
14196
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} > ${triggerP} > ${functionP} > program ${prog} is missing`, 'E');
14499
14197
  func.events.delete_job(SESSION_ID, jobNoP);
14500
14198
  return;
14501
14199
  }
@@ -14508,41 +14206,14 @@ func.events.execute = async function (
14508
14206
 
14509
14207
  // args.prog_id = _viewId;
14510
14208
  if (_ds) {
14511
- func.utils.debug.watch(
14512
- SESSION_ID,
14513
- calling_trigger_prop?.id,
14514
- functionP,
14515
- null,
14516
- calling_trigger_prop,
14517
- expCond
14518
- );
14209
+ func.utils.debug.watch(SESSION_ID, calling_trigger_prop?.id, functionP, null, calling_trigger_prop, expCond);
14519
14210
  // }
14520
- const ret = await func.datasource.create(
14521
- SESSION_ID,
14522
- await get_prog_id(),
14523
- args.dataSourceNoP,
14524
- args.parentDataSourceNoP,
14525
- args.containerIdP,
14526
- args.rowIdP,
14527
- args.jobNoP,
14528
- args.calling_trigger_prop,
14529
- null,
14530
- null,
14531
- args.callingSourceP,
14532
- args.calling_jobP,
14533
- args.screen_dsP,
14534
- args.is_panelP,
14535
- params_obj
14536
- );
14211
+ 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);
14537
14212
 
14538
14213
  let _ds_new = _session.DS_GLB[ret.dsSessionP];
14539
14214
  let parameters = args?.calling_trigger_prop?.data?.name?.parameters;
14540
14215
  if (parameters && !_.isEmpty(parameters)) {
14541
- await func.datasource.update_changes_for_out_parameter(
14542
- SESSION_ID,
14543
- _ds_new.dsSession,
14544
- _ds.dsSession
14545
- );
14216
+ await func.datasource.update_changes_for_out_parameter(SESSION_ID, _ds_new.dsSession, _ds.dsSession);
14546
14217
  }
14547
14218
  // if (parameters && !_.isEmpty(parameters) && _ds_new.PARAM_OUT_INFO) {
14548
14219
  // let data = {};
@@ -14571,7 +14242,7 @@ func.events.execute = async function (
14571
14242
  // }
14572
14243
 
14573
14244
  func.events.delete_job(SESSION_ID, jobNoP);
14574
- return _ds_new
14245
+ return _ds_new;
14575
14246
  }
14576
14247
  },
14577
14248
  set_data: async function () {
@@ -14581,24 +14252,12 @@ func.events.execute = async function (
14581
14252
  const result = await this.get_data();
14582
14253
 
14583
14254
  // await set_outputField(SESSION_ID, elementP, triggerP, functionP, dsSessionP, result);
14584
- return result
14585
-
14255
+ return result;
14586
14256
  },
14587
14257
  update: async function () {
14588
- const obj_values_to_update =
14589
- func.datasource.get_viewFields_for_update_function(
14590
- SESSION_ID,
14591
- calling_trigger_prop,
14592
- null,
14593
- dsSessionP
14594
- );
14258
+ const obj_values_to_update = func.datasource.get_viewFields_for_update_function(SESSION_ID, calling_trigger_prop, null, dsSessionP);
14595
14259
  if (!obj_values_to_update || _.isEmpty(obj_values_to_update)) {
14596
- func.utils.debug_report(
14597
- SESSION_ID,
14598
- "Update values object is empty",
14599
- "",
14600
- "W"
14601
- );
14260
+ func.utils.debug_report(SESSION_ID, 'Update values object is empty', '', 'W');
14602
14261
  if (jobNoP) func.events.delete_job(SESSION_ID, jobNoP);
14603
14262
  return;
14604
14263
  }
@@ -14611,32 +14270,8 @@ func.events.execute = async function (
14611
14270
  $element = $(`[xu-ui-id="${elementP}"]`).clone(true);
14612
14271
  }
14613
14272
 
14614
- let ret_field_id = await func.expression.get(
14615
- SESSION_ID,
14616
- val.id.trim(),
14617
- dsSessionP,
14618
- "update",
14619
- null,
14620
- null,
14621
- null,
14622
- null,
14623
- null,
14624
- null,
14625
- $element?.length ? $element?.data()?.xuData?.iterate_info : null
14626
- );
14627
- let ret_value = await func.expression.get(
14628
- SESSION_ID,
14629
- val.val.trim(),
14630
- dsSessionP,
14631
- "update",
14632
- null,
14633
- null,
14634
- null,
14635
- null,
14636
- null,
14637
- null,
14638
- $element?.length ? $element?.data()?.xuData?.iterate_info : null
14639
- );
14273
+ 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);
14274
+ 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);
14640
14275
  let _field_id = ret_field_id.result;
14641
14276
  let _value = ret_value.result;
14642
14277
 
@@ -14645,25 +14280,16 @@ func.events.execute = async function (
14645
14280
 
14646
14281
  let datasource_changes = {};
14647
14282
  for await (const change of updates) {
14648
- let ret_get_value = await func.datasource.get_value(
14649
- SESSION_ID,
14650
- change._field_id,
14651
- dsSessionP
14652
- );
14283
+ let ret_get_value = await func.datasource.get_value(SESSION_ID, change._field_id, dsSessionP);
14653
14284
  if (ret_get_value.found) {
14654
14285
  let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
14655
14286
  if (!datasource_changes[_ds.dsSession]) {
14656
14287
  datasource_changes[_ds.dsSession] = {};
14657
14288
  }
14658
- if (
14659
- !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
14660
- ) {
14661
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
14662
- {};
14289
+ if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
14290
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
14663
14291
  }
14664
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
14665
- change._field_id
14666
- ] = change._value;
14292
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][change._field_id] = change._value;
14667
14293
  }
14668
14294
  }
14669
14295
 
@@ -14672,23 +14298,11 @@ func.events.execute = async function (
14672
14298
  // return changes;
14673
14299
  },
14674
14300
  call_alert: async function () {
14675
- await func.utils.alerts.invoke(
14676
- SESSION_ID,
14677
- "call_alert",
14678
- refIdP,
14679
- log_source,
14680
- dsSession
14681
- );
14301
+ await func.utils.alerts.invoke(SESSION_ID, 'call_alert', refIdP, log_source, dsSession);
14682
14302
  func.events.delete_job(SESSION_ID, jobNoP);
14683
14303
  },
14684
14304
  alert: async function () {
14685
- await func.utils.alerts.invoke(
14686
- SESSION_ID,
14687
- "alert",
14688
- refIdP,
14689
- log_source,
14690
- dsSession
14691
- );
14305
+ await func.utils.alerts.invoke(SESSION_ID, 'alert', refIdP, log_source, dsSession);
14692
14306
  func.events.delete_job(SESSION_ID, jobNoP);
14693
14307
  },
14694
14308
  delay: async function () {
@@ -14707,18 +14321,11 @@ func.events.execute = async function (
14707
14321
  const _prog_id = await get_prog_id();
14708
14322
 
14709
14323
  if (!_prog_id) {
14710
- func.utils.debug_report(
14711
- SESSION_ID,
14712
- "func.events.execute",
14713
- `${elementP} > ${triggerP} > ${functionP} > program not defined`,
14714
- "E"
14715
- );
14324
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} > ${triggerP} > ${functionP} > program not defined`, 'E');
14716
14325
  func.events.delete_job(SESSION_ID, jobNoP);
14717
14326
  return;
14718
14327
  }
14719
14328
 
14720
-
14721
-
14722
14329
  // if (!output_field) {
14723
14330
  // func.utils.debug_report(
14724
14331
  // SESSION_ID,
@@ -14734,37 +14341,24 @@ func.events.execute = async function (
14734
14341
 
14735
14342
  await func.datasource.set_outputField(SESSION_ID, dsSessionP, api_ret, args);
14736
14343
 
14737
-
14738
14344
  func.events.delete_job(SESSION_ID, jobNoP);
14739
14345
  },
14740
14346
  call_system_api: async function () {
14741
- const api_method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "api_method");
14347
+ const api_method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'api_method');
14742
14348
 
14743
14349
  if (!api_method) {
14744
- func.utils.debug_report(
14745
- SESSION_ID,
14746
- "func.events.execute",
14747
- `${elementP} >${triggerP} >${functionP} > api_method not defined`,
14748
- "E"
14749
- );
14350
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} >${triggerP} >${functionP} > api_method not defined`, 'E');
14750
14351
  func.events.delete_job(SESSION_ID, jobNoP);
14751
14352
  return;
14752
14353
  }
14753
14354
  let payload = {};
14754
- const _payload = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "payload");
14355
+ const _payload = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'payload');
14755
14356
  if (_payload) {
14756
14357
  const get_payload_property_value = async function (prop_name) {
14757
14358
  let _prop = _payload;
14758
14359
  let _value = _prop[prop_name];
14759
14360
  if (_prop?.[`xu-exp:${prop_name}`]) {
14760
- _value = (
14761
- await func.expression.get(
14762
- SESSION_ID,
14763
- _prop[`xu-exp:${prop_name}`],
14764
- dsSession,
14765
- `${prop_name} expression`
14766
- )
14767
- ).result;
14361
+ _value = (await func.expression.get(SESSION_ID, _prop[`xu-exp:${prop_name}`], dsSession, `${prop_name} expression`)).result;
14768
14362
  }
14769
14363
 
14770
14364
  return _value;
@@ -14772,7 +14366,7 @@ func.events.execute = async function (
14772
14366
 
14773
14367
  for await (let [key, val] of Object.entries(_payload)) {
14774
14368
  // if (key.substring(0, 7) !== "xu-exp:") {
14775
- const new_key = key.replaceAll("xu-exp:", ""); //key.substring(0, 7) === "xu-exp:" ? key.substring(7): key
14369
+ const new_key = key.replaceAll('xu-exp:', ''); //key.substring(0, 7) === "xu-exp:" ? key.substring(7): key
14776
14370
  payload[new_key] = await get_payload_property_value(new_key);
14777
14371
  // }
14778
14372
  }
@@ -14789,7 +14383,7 @@ func.events.execute = async function (
14789
14383
  // return;
14790
14384
  // }
14791
14385
 
14792
- const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "outputField");
14386
+ const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'outputField');
14793
14387
 
14794
14388
  // if (!output_field) {
14795
14389
  // func.utils.debug_report(
@@ -14806,89 +14400,57 @@ func.events.execute = async function (
14806
14400
  if (output_field) {
14807
14401
  let datasource_changes = {};
14808
14402
 
14809
- let ret_get_value = await func.datasource.get_value(
14810
- SESSION_ID,
14811
- output_field,
14812
- dsSessionP
14813
- );
14403
+ let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
14814
14404
  if (ret_get_value.found) {
14815
14405
  let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
14816
14406
  if (!datasource_changes[_ds.dsSession]) {
14817
14407
  datasource_changes[_ds.dsSession] = {};
14818
14408
  }
14819
- if (
14820
- !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
14821
- ) {
14822
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
14823
- {};
14409
+ if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
14410
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
14824
14411
  }
14825
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
14826
- output_field
14827
- ] = api_ret;
14412
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = api_ret;
14828
14413
  await func.datasource.update(SESSION_ID, datasource_changes);
14829
14414
  }
14830
14415
  }
14831
14416
  func.events.delete_job(SESSION_ID, jobNoP);
14832
14417
  },
14833
14418
  call_external_api: async function () {
14834
- const method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "method");
14419
+ const method = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'method');
14835
14420
 
14836
14421
  if (!method) {
14837
- func.utils.debug_report(
14838
- SESSION_ID,
14839
- "func.events.execute",
14840
- `${elementP} >${triggerP} >${functionP} > method not defined`,
14841
- "E"
14842
- );
14422
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} >${triggerP} >${functionP} > method not defined`, 'E');
14843
14423
  func.events.delete_job(SESSION_ID, jobNoP);
14844
14424
  return;
14845
14425
  }
14846
14426
 
14847
- const url = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "url");
14427
+ const url = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'url');
14848
14428
 
14849
14429
  if (!url) {
14850
- func.utils.debug_report(
14851
- SESSION_ID,
14852
- "func.events.execute",
14853
- `${elementP} >${triggerP} >${functionP} > url not defined`,
14854
- "E"
14855
- );
14430
+ func.utils.debug_report(SESSION_ID, 'func.events.execute', `${elementP} >${triggerP} >${functionP} > url not defined`, 'E');
14856
14431
  func.events.delete_job(SESSION_ID, jobNoP);
14857
14432
  return;
14858
14433
  }
14859
14434
 
14860
- const payload_arr = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "payload");
14435
+ const payload_arr = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'payload');
14861
14436
 
14862
14437
  const report_conversion_error = function (res, typeP, valP) {
14863
14438
  var msg = `${elementP} >${triggerP} >${functionP} > error converting from ${valP} to ${typeP}`;
14864
14439
  if (error) {
14865
- return func.utils.debug_report(SESSION_ID, msg, "", "W");
14440
+ return func.utils.debug_report(SESSION_ID, msg, '', 'W');
14866
14441
  }
14867
- func.utils.debug_report(
14868
- SESSION_ID,
14869
- msg + " " + _.capitalize(source) + prog_info,
14870
- "",
14871
- "E"
14872
- );
14442
+ func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'E');
14873
14443
  };
14874
14444
  const report_conversion_warn = function (res) {
14875
14445
  var msg = `${elementP} >${triggerP} >${functionP} > type mismatch auto conversion from value ${valP} to ${typeP}`;
14876
- func.utils.debug_report(
14877
- SESSION_ID,
14878
- msg + " " + _.capitalize(source) + prog_info,
14879
- "",
14880
- "W"
14881
- );
14446
+ func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'W');
14882
14447
  };
14883
14448
  // var ret = valP;
14884
14449
  if (error) {
14885
14450
  return report_conversion_error();
14886
14451
  }
14887
14452
 
14888
- const module = await func.common.get_module(
14889
- SESSION_ID,
14890
- "xuda-get-cast-util-module.mjs"
14891
- );
14453
+ const module = await func.common.get_module(SESSION_ID, 'xuda-get-cast-util-module.mjs');
14892
14454
  // return module.cast(
14893
14455
  // typeP,
14894
14456
  // valP,
@@ -14899,16 +14461,11 @@ func.events.execute = async function (
14899
14461
  var payload = _.reduce(
14900
14462
  payload_arr,
14901
14463
  (ret, val, key) => {
14902
- ret[val.key] = module.cast(
14903
- val.type,
14904
- val.val,
14905
- report_conversion_error,
14906
- report_conversion_warn
14907
- );
14464
+ ret[val.key] = module.cast(val.type, val.val, report_conversion_error, report_conversion_warn);
14908
14465
 
14909
14466
  return ret;
14910
14467
  },
14911
- {}
14468
+ {},
14912
14469
  );
14913
14470
  // if (!payload) {
14914
14471
  // func.utils.debug_report(
@@ -14921,7 +14478,7 @@ func.events.execute = async function (
14921
14478
  // return;
14922
14479
  // }
14923
14480
 
14924
- const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, "outputField");
14481
+ const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSession, args, 'outputField');
14925
14482
 
14926
14483
  // if (!output_field) {
14927
14484
  // func.utils.debug_report(
@@ -14938,25 +14495,16 @@ func.events.execute = async function (
14938
14495
  if (output_field) {
14939
14496
  let datasource_changes = {};
14940
14497
 
14941
- let ret_get_value = await func.datasource.get_value(
14942
- SESSION_ID,
14943
- output_field,
14944
- dsSessionP
14945
- );
14498
+ let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
14946
14499
  if (ret_get_value.found) {
14947
14500
  let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
14948
14501
  if (!datasource_changes[_ds.dsSession]) {
14949
14502
  datasource_changes[_ds.dsSession] = {};
14950
14503
  }
14951
- if (
14952
- !datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]
14953
- ) {
14954
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
14955
- {};
14504
+ if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
14505
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
14956
14506
  }
14957
- datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
14958
- output_field
14959
- ] = api_ret;
14507
+ datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = api_ret;
14960
14508
  await func.datasource.update(SESSION_ID, datasource_changes);
14961
14509
  }
14962
14510
  }
@@ -14989,16 +14537,9 @@ func.events.delete_job = function (SESSION_ID, jobNoP) {
14989
14537
  var dsSession = _session.WORKER_OBJ.jobs[job_index].dsSessionP;
14990
14538
  let ds_obj = _session?.DS_GLB[dsSession];
14991
14539
  if (ds_obj) {
14992
- delete SCREEN_BLOCKER_OBJ[
14993
- ds_obj.screenId +
14994
- (ds_obj.callingScreenId ? "_" + ds_obj.callingScreenId : "")
14995
- ];
14540
+ delete SCREEN_BLOCKER_OBJ[ds_obj.screenId + (ds_obj.callingScreenId ? '_' + ds_obj.callingScreenId : '')];
14996
14541
  }
14997
- if (
14998
- dsSession &&
14999
- ds_obj?.loops_limit &&
15000
- ds_obj?.loops_count < ds_obj?.loops_limit - 1
15001
- ) {
14542
+ if (dsSession && ds_obj?.loops_limit && ds_obj?.loops_count < ds_obj?.loops_limit - 1) {
15002
14543
  return;
15003
14544
  }
15004
14545
  _session.WORKER_OBJ.stat = null;
@@ -15016,17 +14557,9 @@ func.events.delete_job_0 = function (SESSION_ID) {
15016
14557
  var dsSession = _session.WORKER_OBJ.jobs[job_index].dsSession;
15017
14558
  let ds_obj = _session?.DS_GLB[dsSession];
15018
14559
  if (ds_obj) {
15019
- delete SCREEN_BLOCKER_OBJ[
15020
- ds_obj.screenId +
15021
- (ds_obj.callingScreenId ? "_" + ds_obj.callingScreenId : "")
15022
- ];
14560
+ delete SCREEN_BLOCKER_OBJ[ds_obj.screenId + (ds_obj.callingScreenId ? '_' + ds_obj.callingScreenId : '')];
15023
14561
  }
15024
- if (
15025
- dsSession &&
15026
- ds_obj &&
15027
- ds_obj.loops_limit &&
15028
- ds_obj.loops_count < ds_obj.loops_limit - 1
15029
- ) {
14562
+ if (dsSession && ds_obj && ds_obj.loops_limit && ds_obj.loops_count < ds_obj.loops_limit - 1) {
15030
14563
  return;
15031
14564
  }
15032
14565
  _session.WORKER_OBJ.stat = null;
@@ -15068,8 +14601,7 @@ setInterval(function () {
15068
14601
  }, 1000);
15069
14602
 
15070
14603
  func.events.set_browser_changes = function (dsP, fieldsChangedP) {
15071
- if (fieldsChangedP.includes("SYS_GLOBAL_STR_BROWSER_TITLE"))
15072
- document.title = dsP.dataset_new["SYS_GLOBAL_STR_BROWSER_TITLE"];
14604
+ if (fieldsChangedP.includes('SYS_GLOBAL_STR_BROWSER_TITLE')) document.title = dsP.dataset_new['SYS_GLOBAL_STR_BROWSER_TITLE'];
15073
14605
  };
15074
14606
 
15075
14607
  func.events.execute_PENDING_OPEN_URL_EVENTS = async function () {
@@ -15078,52 +14610,29 @@ func.events.execute_PENDING_OPEN_URL_EVENTS = async function () {
15078
14610
  glb.WINDOW_LOCATION_SEARCH = url;
15079
14611
  glb.ROOT_ELEMENT_ATTRIBUTES = func.UI.utils.get_root_element_attributes();
15080
14612
 
15081
- const params_obj = func.common.getObjectFromUrl(
15082
- url,
15083
- glb.ROOT_ELEMENT_ATTRIBUTES
15084
- );
14613
+ const params_obj = func.common.getObjectFromUrl(url, glb.ROOT_ELEMENT_ATTRIBUTES);
15085
14614
  if (!params_obj.prog) {
15086
- return console.warn("prog empty");
14615
+ return console.warn('prog empty');
15087
14616
  }
15088
14617
 
15089
14618
  await func.utils.TREE_OBJ.get(SESSION_ID, params_obj.prog);
15090
- let screen_ret = await func.utils.get_screen_obj(
15091
- SESSION_ID,
15092
- params_obj.prog
15093
- );
14619
+ let screen_ret = await func.utils.get_screen_obj(SESSION_ID, params_obj.prog);
15094
14620
 
15095
14621
  if (screen_ret) {
15096
- await func.UI.screen.init(
15097
- SESSION_ID,
15098
- params_obj.prog,
15099
- null,
15100
- null,
15101
- $("#embed_" + SESSION_ID),
15102
- null,
15103
- null,
15104
- null,
15105
- null,
15106
- null,
15107
- "pendingUrlEvent_embed"
15108
- );
14622
+ await func.UI.screen.init(SESSION_ID, params_obj.prog, null, null, $('#embed_' + SESSION_ID), null, null, null, null, null, 'pendingUrlEvent_embed');
15109
14623
  } else {
15110
- console.error("Program not exist", params_obj.prog_id);
15111
- func.UI.utils.progressScreen.show(
15112
- SESSION_ID,
15113
- "Program not exist",
15114
- null,
15115
- true
15116
- );
14624
+ console.error('Program not exist', params_obj.prog_id);
14625
+ func.UI.utils.progressScreen.show(SESSION_ID, 'Program not exist', null, true);
15117
14626
  }
15118
14627
  } else {
15119
- console.warn("url empty");
14628
+ console.warn('url empty');
15120
14629
  }
15121
14630
  }
15122
14631
  };
15123
14632
  func.events.invoke = async function (event_id) {
15124
14633
  var _session = SESSION_OBJ[SESSION_ID];
15125
14634
  if (!event_id) {
15126
- console.warn("event_id Cannot be empty");
14635
+ console.warn('event_id Cannot be empty');
15127
14636
  return false;
15128
14637
  }
15129
14638
  var ds;
@@ -15132,10 +14641,7 @@ func.events.invoke = async function (event_id) {
15132
14641
  if (_.isEmpty(_view_obj.progEvents)) continue;
15133
14642
  if (ds) break;
15134
14643
  for await (const [key, val] of Object.entries(_view_obj.progEvents)) {
15135
- if (
15136
- val?.data?.type === "user_defined" &&
15137
- val.data.event_name === event_id
15138
- ) {
14644
+ if (val?.data?.type === 'user_defined' && val.data.event_name === event_id) {
15139
14645
  ds = ds_key;
15140
14646
  break;
15141
14647
  }
@@ -15143,11 +14649,11 @@ func.events.invoke = async function (event_id) {
15143
14649
  }
15144
14650
 
15145
14651
  if (!ds) {
15146
- console.warn("event_id not found");
14652
+ console.warn('event_id not found');
15147
14653
  return false;
15148
14654
  }
15149
14655
 
15150
- func.events.validate(SESSION_ID, "user_defined", ds, event_id);
14656
+ func.events.validate(SESSION_ID, 'user_defined', ds, event_id);
15151
14657
  };
15152
14658
  func.expression = {};
15153
14659