@xuda.io/runtime-bundle 1.0.286 → 1.0.287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/xuda-runtime-bundle.js +494 -1450
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +497 -1453
- package/js/xuda-runtime-slim.min.es.js +497 -1453
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +493 -1449
- package/js/xuda-worker-bundle.js +493 -1449
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -28517,15 +28517,15 @@ func.datasource.create = async function (
|
|
|
28517
28517
|
parameters_obj_inP,
|
|
28518
28518
|
static_refreshP,
|
|
28519
28519
|
worker_id,
|
|
28520
|
-
NA_eventChangesResults
|
|
28520
|
+
NA_eventChangesResults,
|
|
28521
28521
|
) {
|
|
28522
28522
|
return new Promise(async function (resolve, reject) {
|
|
28523
|
-
if (!prog_id) return reject(
|
|
28523
|
+
if (!prog_id) return reject('Program is empty');
|
|
28524
28524
|
|
|
28525
28525
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
28526
|
-
if (!_session.DS_GLB) return reject(
|
|
28526
|
+
if (!_session.DS_GLB) return reject('DS_GLB not exist');
|
|
28527
28527
|
var _prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
|
|
28528
|
-
if (!_prog_obj) return reject(
|
|
28528
|
+
if (!_prog_obj) return reject('Program not found');
|
|
28529
28529
|
|
|
28530
28530
|
var args = {
|
|
28531
28531
|
SESSION_ID,
|
|
@@ -28557,8 +28557,7 @@ func.datasource.create = async function (
|
|
|
28557
28557
|
old_dataSource_vars.SYS_STR_WIN_ID = _ds.data_system.SYS_STR_WIN_ID;
|
|
28558
28558
|
old_dataSource_vars.SYS_STR_WIN_NAME = _ds.data_system.SYS_STR_WIN_NAME;
|
|
28559
28559
|
}
|
|
28560
|
-
if (static_refreshP)
|
|
28561
|
-
old_dataSource_vars.in_parameters = _ds.in_parameters;
|
|
28560
|
+
if (static_refreshP) old_dataSource_vars.in_parameters = _ds.in_parameters;
|
|
28562
28561
|
}
|
|
28563
28562
|
const restore_old_dataSource_vars = function (dsSessionP) {
|
|
28564
28563
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
@@ -28570,26 +28569,20 @@ func.datasource.create = async function (
|
|
|
28570
28569
|
_ds.data_system.SYS_STR_WIN_NAME = old_dataSource_vars.SYS_STR_WIN_NAME;
|
|
28571
28570
|
}
|
|
28572
28571
|
|
|
28573
|
-
if (static_refreshP)
|
|
28574
|
-
_ds.in_parameters = old_dataSource_vars.in_parameters;
|
|
28572
|
+
if (static_refreshP) _ds.in_parameters = old_dataSource_vars.in_parameters;
|
|
28575
28573
|
};
|
|
28576
28574
|
|
|
28577
28575
|
var run_at = _prog_obj?.properties?.runAt;
|
|
28578
|
-
if (_session.opt.app_computing_mode ===
|
|
28579
|
-
run_at =
|
|
28576
|
+
if (_session.opt.app_computing_mode === 'main') {
|
|
28577
|
+
run_at = 'client';
|
|
28580
28578
|
}
|
|
28581
28579
|
|
|
28582
|
-
if (_prog_obj?.properties.menuType ===
|
|
28583
|
-
run_at =
|
|
28580
|
+
if (_prog_obj?.properties.menuType === 'globals') {
|
|
28581
|
+
run_at = 'client';
|
|
28584
28582
|
}
|
|
28585
28583
|
|
|
28586
|
-
if (
|
|
28587
|
-
|
|
28588
|
-
parentDataSourceNoP &&
|
|
28589
|
-
_session.DS_GLB[parentDataSourceNoP]
|
|
28590
|
-
) {
|
|
28591
|
-
if (_session.DS_GLB[parentDataSourceNoP]._run_at)
|
|
28592
|
-
run_at = _session.DS_GLB[parentDataSourceNoP].v.run_at;
|
|
28584
|
+
if (!run_at && parentDataSourceNoP && _session.DS_GLB[parentDataSourceNoP]) {
|
|
28585
|
+
if (_session.DS_GLB[parentDataSourceNoP]._run_at) run_at = _session.DS_GLB[parentDataSourceNoP].v.run_at;
|
|
28593
28586
|
}
|
|
28594
28587
|
|
|
28595
28588
|
const done = function (SESSION_ID, dsSessionP, is_serverP) {
|
|
@@ -28601,12 +28594,7 @@ func.datasource.create = async function (
|
|
|
28601
28594
|
|
|
28602
28595
|
if (!IS_DATASOURCE_REFRESH) {
|
|
28603
28596
|
if (!glb.IS_WORKER) {
|
|
28604
|
-
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP] =
|
|
28605
|
-
new func.datasource.interval(
|
|
28606
|
-
SESSION_ID,
|
|
28607
|
-
dsSessionP,
|
|
28608
|
-
"client_interval"
|
|
28609
|
-
);
|
|
28597
|
+
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP] = new func.datasource.interval(SESSION_ID, dsSessionP, 'client_interval');
|
|
28610
28598
|
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP].init();
|
|
28611
28599
|
}
|
|
28612
28600
|
}
|
|
@@ -28621,8 +28609,8 @@ func.datasource.create = async function (
|
|
|
28621
28609
|
|
|
28622
28610
|
var datasource_changes = {
|
|
28623
28611
|
[dsSessionP]: {
|
|
28624
|
-
[
|
|
28625
|
-
stat:
|
|
28612
|
+
['datasource_main']: {
|
|
28613
|
+
stat: 'idle',
|
|
28626
28614
|
stat_ts: Date.now(),
|
|
28627
28615
|
is_worker: glb.IS_WORKER,
|
|
28628
28616
|
},
|
|
@@ -28636,7 +28624,7 @@ func.datasource.create = async function (
|
|
|
28636
28624
|
let interval = setInterval(() => {
|
|
28637
28625
|
let idle_count = 0;
|
|
28638
28626
|
for (const _ds of ds_connected) {
|
|
28639
|
-
if (_ds.stat ==
|
|
28627
|
+
if (_ds.stat == 'idle') {
|
|
28640
28628
|
idle_count++;
|
|
28641
28629
|
}
|
|
28642
28630
|
}
|
|
@@ -28665,12 +28653,7 @@ func.datasource.create = async function (
|
|
|
28665
28653
|
if (jobNoP) {
|
|
28666
28654
|
}
|
|
28667
28655
|
|
|
28668
|
-
if (
|
|
28669
|
-
glb.IS_WORKER ||
|
|
28670
|
-
run_at === "client" ||
|
|
28671
|
-
is_system_client_vars ||
|
|
28672
|
-
db_driver === "pouchdb"
|
|
28673
|
-
) {
|
|
28656
|
+
if (glb.IS_WORKER || run_at === 'client' || is_system_client_vars || db_driver === 'pouchdb') {
|
|
28674
28657
|
const ret = await func.datasource.prepare(
|
|
28675
28658
|
args.SESSION_ID,
|
|
28676
28659
|
args.prog_id,
|
|
@@ -28689,7 +28672,7 @@ func.datasource.create = async function (
|
|
|
28689
28672
|
args.parameters_obj_inP,
|
|
28690
28673
|
args.static_refreshP,
|
|
28691
28674
|
run_at,
|
|
28692
|
-
worker_id
|
|
28675
|
+
worker_id,
|
|
28693
28676
|
);
|
|
28694
28677
|
return done(SESSION_ID, ret.dsSessionP);
|
|
28695
28678
|
}
|
|
@@ -28698,19 +28681,16 @@ func.datasource.create = async function (
|
|
|
28698
28681
|
var data = _.assignIn(
|
|
28699
28682
|
{
|
|
28700
28683
|
session_id: SESSION_ID,
|
|
28701
|
-
dataSourceSessionGlobal:
|
|
28702
|
-
|
|
28703
|
-
parentDataSourceNo: IS_DATASOURCE_REFRESH
|
|
28704
|
-
? _ds.parentDataSourceNo
|
|
28705
|
-
: null,
|
|
28684
|
+
dataSourceSessionGlobal: SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal,
|
|
28685
|
+
parentDataSourceNo: IS_DATASOURCE_REFRESH ? _ds.parentDataSourceNo : null,
|
|
28706
28686
|
IS_DATASOURCE_REFRESH,
|
|
28707
28687
|
},
|
|
28708
|
-
args
|
|
28688
|
+
args,
|
|
28709
28689
|
);
|
|
28710
28690
|
delete data.SESSION_ID;
|
|
28711
28691
|
|
|
28712
28692
|
const jsonP = await func.index.call_worker(SESSION_ID, {
|
|
28713
|
-
service:
|
|
28693
|
+
service: 'datasource_create',
|
|
28714
28694
|
data,
|
|
28715
28695
|
id: SESSION_OBJ[SESSION_ID].worker_id,
|
|
28716
28696
|
});
|
|
@@ -28724,43 +28704,20 @@ func.datasource.create = async function (
|
|
|
28724
28704
|
return done(SESSION_ID, jsonP.dsSession, true);
|
|
28725
28705
|
});
|
|
28726
28706
|
};
|
|
28727
|
-
func.datasource.prepare = async function (
|
|
28728
|
-
SESSION_ID,
|
|
28729
|
-
prog_id,
|
|
28730
|
-
dataSourceNoP,
|
|
28731
|
-
parentDataSourceNoP,
|
|
28732
|
-
containerIdP,
|
|
28733
|
-
rowIdP,
|
|
28734
|
-
jobNoP,
|
|
28735
|
-
calling_trigger_prop,
|
|
28736
|
-
NA_screen_param,
|
|
28737
|
-
NA_isInitP,
|
|
28738
|
-
callingSourceP,
|
|
28739
|
-
calling_jobP,
|
|
28740
|
-
NA_screen_dsP,
|
|
28741
|
-
is_panelP,
|
|
28742
|
-
parameters_obj_inP,
|
|
28743
|
-
static_refreshP,
|
|
28744
|
-
run_atP,
|
|
28745
|
-
worker_id
|
|
28746
|
-
) {
|
|
28707
|
+
func.datasource.prepare = async function (SESSION_ID, prog_id, dataSourceNoP, parentDataSourceNoP, containerIdP, rowIdP, jobNoP, calling_trigger_prop, NA_screen_param, NA_isInitP, callingSourceP, calling_jobP, NA_screen_dsP, is_panelP, parameters_obj_inP, static_refreshP, run_atP, worker_id) {
|
|
28747
28708
|
const set_parameters = async function () {
|
|
28748
28709
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
28749
|
-
const get_Out_parameters = async function (
|
|
28750
|
-
fieldIdP,
|
|
28751
|
-
located_field_param_idxP,
|
|
28752
|
-
param_row_idP
|
|
28753
|
-
) {
|
|
28710
|
+
const get_Out_parameters = async function (fieldIdP, located_field_param_idxP, param_row_idP) {
|
|
28754
28711
|
var ret = parameters_obj_inP?.[fieldIdP] || fieldIdP;
|
|
28755
28712
|
|
|
28756
|
-
PARAM_OUT_INFO[prog_id +
|
|
28713
|
+
PARAM_OUT_INFO[prog_id + '_' + param_row_idP] = {
|
|
28757
28714
|
module: _ds.viewModule,
|
|
28758
|
-
action:
|
|
28759
|
-
prop:
|
|
28715
|
+
action: 'parameters',
|
|
28716
|
+
prop: 'out',
|
|
28760
28717
|
details: ret,
|
|
28761
28718
|
result: ret,
|
|
28762
28719
|
source: _ds.viewSourceDesc,
|
|
28763
|
-
type:
|
|
28720
|
+
type: 'parameters',
|
|
28764
28721
|
prog_id: prog_id,
|
|
28765
28722
|
dsSession: dataSourceSession,
|
|
28766
28723
|
fieldId: fieldIdP,
|
|
@@ -28779,34 +28736,24 @@ func.datasource.prepare = async function (
|
|
|
28779
28736
|
_ds.in_parameters = {};
|
|
28780
28737
|
_ds.out_parameters = {};
|
|
28781
28738
|
|
|
28782
|
-
for await (let [key, val] of Object.entries(
|
|
28783
|
-
screenInfo.properties?.progParams
|
|
28784
|
-
)) {
|
|
28739
|
+
for await (let [key, val] of Object.entries(screenInfo.properties?.progParams)) {
|
|
28785
28740
|
// run on parameters arr
|
|
28786
|
-
if (val.data.dir ===
|
|
28741
|
+
if (val.data.dir === 'in') {
|
|
28787
28742
|
_ds.in_parameters[val.data.parameter] = {
|
|
28788
28743
|
// value: parameters_obj_inP?.[val.data.parameter],
|
|
28789
28744
|
type: val.data.type,
|
|
28790
28745
|
};
|
|
28791
28746
|
|
|
28792
|
-
if (
|
|
28793
|
-
|
|
28794
|
-
) {
|
|
28795
|
-
_ds.in_parameters[val.data.parameter].value =
|
|
28796
|
-
parameters_obj_inP[val.data.parameter];
|
|
28797
|
-
} else if (_session.engine_mode === "live_preview") {
|
|
28798
|
-
_ds.in_parameters[val.data.parameter].value =
|
|
28799
|
-
_session?.url_params?.[val.data.parameter];
|
|
28747
|
+
if (typeof parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
|
|
28748
|
+
_ds.in_parameters[val.data.parameter].value = parameters_obj_inP[val.data.parameter];
|
|
28749
|
+
} else if (_session.engine_mode === 'live_preview') {
|
|
28750
|
+
_ds.in_parameters[val.data.parameter].value = _session?.url_params?.[val.data.parameter];
|
|
28800
28751
|
}
|
|
28801
28752
|
|
|
28802
28753
|
continue;
|
|
28803
28754
|
}
|
|
28804
|
-
if (val.data.dir ===
|
|
28805
|
-
_ds.out_parameters[val.data.parameter] = await get_Out_parameters(
|
|
28806
|
-
val.data.parameter,
|
|
28807
|
-
key,
|
|
28808
|
-
val.id
|
|
28809
|
-
);
|
|
28755
|
+
if (val.data.dir === 'out' && val.data.parameter) {
|
|
28756
|
+
_ds.out_parameters[val.data.parameter] = await get_Out_parameters(val.data.parameter, key, val.id);
|
|
28810
28757
|
}
|
|
28811
28758
|
}
|
|
28812
28759
|
|
|
@@ -28816,23 +28763,20 @@ func.datasource.prepare = async function (
|
|
|
28816
28763
|
};
|
|
28817
28764
|
const build_GLOBAL_SYS_fields = function () {
|
|
28818
28765
|
if (!_ds.data_system) _ds.data_system = {};
|
|
28819
|
-
_ds.data_system[
|
|
28820
|
-
_ds.data_system[
|
|
28821
|
-
_ds.data_system[
|
|
28822
|
-
_ds.data_system[
|
|
28766
|
+
_ds.data_system['SYS_GLOBAL_UTC'] = -new Date().getTimezoneOffset() / 60;
|
|
28767
|
+
_ds.data_system['SYS_GLOBAL_STR_APP_ID'] = APP_OBJ[_session.app_id]._id;
|
|
28768
|
+
_ds.data_system['SYS_GLOBAL_STR_SESSION_ID'] = SESSION_ID;
|
|
28769
|
+
_ds.data_system['SYS_GLOBAL_STR_LOGIN_USER_ID'] = _session.USR_OBJ._id;
|
|
28823
28770
|
|
|
28824
|
-
if (
|
|
28825
|
-
|
|
28826
|
-
PROJECT_OBJ[_session.app_id].info
|
|
28827
|
-
) {
|
|
28828
|
-
_ds.data_system["SYS_GLOBAL_OBJ_APP_INFO"] = {
|
|
28771
|
+
if (_session.engine_mode !== 'live_preview' && PROJECT_OBJ[_session.app_id].info) {
|
|
28772
|
+
_ds.data_system['SYS_GLOBAL_OBJ_APP_INFO'] = {
|
|
28829
28773
|
build: PROJECT_OBJ[_session.app_id].info.build_id,
|
|
28830
28774
|
author: PROJECT_OBJ[_session.app_id].info.author,
|
|
28831
28775
|
date: PROJECT_OBJ[_session.app_id].info.build_date,
|
|
28832
28776
|
name: APP_OBJ[_session.app_id].app_name,
|
|
28833
28777
|
};
|
|
28834
28778
|
}
|
|
28835
|
-
_ds.data_system[
|
|
28779
|
+
_ds.data_system['SYS_GLOBAL_OBJ_LOGIN_USER_INFO'] = {
|
|
28836
28780
|
id: _session.USR_OBJ._id,
|
|
28837
28781
|
user_name: _session.USR_OBJ.usr_name,
|
|
28838
28782
|
first_name: _session.USR_OBJ.usr_first_name,
|
|
@@ -28840,52 +28784,37 @@ func.datasource.prepare = async function (
|
|
|
28840
28784
|
email: _session.USR_OBJ.usr_email,
|
|
28841
28785
|
profile_picture: _session.USR_OBJ.usr_profile_picture,
|
|
28842
28786
|
};
|
|
28843
|
-
_ds.data_system[
|
|
28844
|
-
|
|
28845
|
-
_ds.data_system["SYS_GLOBAL_STR_BROWSER_TITLE"] =
|
|
28846
|
-
_session.SYS_GLOBAL_STR_BROWSER_TITLE;
|
|
28787
|
+
_ds.data_system['SYS_GLOBAL_STR_BROWSER_HASH_ID'] = _session.SYS_GLOBAL_STR_BROWSER_HASH_ID;
|
|
28788
|
+
_ds.data_system['SYS_GLOBAL_STR_BROWSER_TITLE'] = _session.SYS_GLOBAL_STR_BROWSER_TITLE;
|
|
28847
28789
|
// }
|
|
28848
|
-
_ds.data_system[
|
|
28849
|
-
_ds.data_system[
|
|
28850
|
-
_ds.data_system[
|
|
28851
|
-
_ds.data_system[
|
|
28852
|
-
_ds.data_system[
|
|
28790
|
+
_ds.data_system['SYS_GLOBAL_STR_SITE_CSS'] = {};
|
|
28791
|
+
_ds.data_system['SYS_GLOBAL_BOL_SHIFT_KEY_STATE'] = 0;
|
|
28792
|
+
_ds.data_system['SYS_GLOBAL_BOL_COMMAND_KEY_STATE'] = 0;
|
|
28793
|
+
_ds.data_system['SYS_GLOBAL_BOL_CONTROL_KEY_STATE'] = 0;
|
|
28794
|
+
_ds.data_system['SYS_GLOBAL_BOL_ALT_KEY_STATE'] = 0;
|
|
28853
28795
|
|
|
28854
|
-
_ds.data_system[
|
|
28855
|
-
_ds.data_system[
|
|
28856
|
-
_ds.data_system[
|
|
28857
|
-
_ds.data_system[
|
|
28858
|
-
_ds.data_system[
|
|
28796
|
+
_ds.data_system['SYS_GLOBAL_BOL_ONLINE'] = 0;
|
|
28797
|
+
_ds.data_system['SYS_GLOBAL_BOL_REPLICATION_STAT'] = 0;
|
|
28798
|
+
_ds.data_system['SYS_GLOBAL_BOL_AJAX_BUSY'] = 0;
|
|
28799
|
+
_ds.data_system['SYS_GLOBAL_BOL_CONNECTED'] = 1;
|
|
28800
|
+
_ds.data_system['SYS_GLOBAL_BOL_IDLE'] = 0;
|
|
28859
28801
|
|
|
28860
|
-
_ds.data_system[
|
|
28802
|
+
_ds.data_system['SYS_GLOBAL_STR_FIREBASE_TOKEN_ID'] = 0;
|
|
28861
28803
|
|
|
28862
|
-
_ds.data_system[
|
|
28863
|
-
_session.PUSH_NOTIFICATION_GRANTED;
|
|
28804
|
+
_ds.data_system['SYS_GLOBAL_BOL_PUSH_NOTIFICATION_GRANTED'] = _session.PUSH_NOTIFICATION_GRANTED;
|
|
28864
28805
|
|
|
28865
|
-
_ds.data_system[
|
|
28866
|
-
_session.SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO;
|
|
28806
|
+
_ds.data_system['SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO'] = _session.SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO;
|
|
28867
28807
|
|
|
28868
|
-
_ds.data_system[
|
|
28869
|
-
_session.SYS_GLOBAL_OBJ_CLIENT_INFO;
|
|
28808
|
+
_ds.data_system['SYS_GLOBAL_OBJ_CLIENT_INFO'] = _session.SYS_GLOBAL_OBJ_CLIENT_INFO;
|
|
28870
28809
|
};
|
|
28871
28810
|
if (!SESSION_OBJ[SESSION_ID].DS_GLB) return;
|
|
28872
28811
|
|
|
28873
28812
|
if (dataSourceNoP && !SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceNoP]) {
|
|
28874
|
-
return func.utils.debug_report(
|
|
28875
|
-
SESSION_ID,
|
|
28876
|
-
"Datasource",
|
|
28877
|
-
"Datasource not exist: " + dataSourceNoP,
|
|
28878
|
-
"E"
|
|
28879
|
-
);
|
|
28813
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Datasource not exist: ' + dataSourceNoP, 'E');
|
|
28880
28814
|
}
|
|
28881
28815
|
|
|
28882
28816
|
if (!prog_id) {
|
|
28883
|
-
return func.utils.debug_report(
|
|
28884
|
-
SESSION_ID,
|
|
28885
|
-
"Datasource",
|
|
28886
|
-
"Program is null",
|
|
28887
|
-
"E"
|
|
28888
|
-
);
|
|
28817
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Program is null', 'E');
|
|
28889
28818
|
}
|
|
28890
28819
|
|
|
28891
28820
|
const args = {
|
|
@@ -28911,18 +28840,13 @@ func.datasource.prepare = async function (
|
|
|
28911
28840
|
|
|
28912
28841
|
const init_dataSource = async function () {
|
|
28913
28842
|
const init_new_dataSource = async function () {
|
|
28914
|
-
if (
|
|
28915
|
-
!["main"].includes(SESSION_OBJ[SESSION_ID].opt.app_computing_mode) &&
|
|
28916
|
-
run_atP === "client" &&
|
|
28917
|
-
prog_id !== "system"
|
|
28918
|
-
) {
|
|
28843
|
+
if (!['main'].includes(SESSION_OBJ[SESSION_ID].opt.app_computing_mode) && run_atP === 'client' && prog_id !== 'system') {
|
|
28919
28844
|
const ret = await func.index.call_worker(SESSION_ID, {
|
|
28920
|
-
service:
|
|
28845
|
+
service: 'get_dataSourceSessionGlobal',
|
|
28921
28846
|
data: { session_id: SESSION_ID },
|
|
28922
28847
|
id: SESSION_OBJ[SESSION_ID].worker_id,
|
|
28923
28848
|
});
|
|
28924
|
-
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal =
|
|
28925
|
-
ret?.new_dataSourceSessionGlobal || 1;
|
|
28849
|
+
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal = ret?.new_dataSourceSessionGlobal || 1;
|
|
28926
28850
|
} else {
|
|
28927
28851
|
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal++;
|
|
28928
28852
|
}
|
|
@@ -28933,7 +28857,7 @@ func.datasource.prepare = async function (
|
|
|
28933
28857
|
};
|
|
28934
28858
|
const init_existing_dataSource = function () {
|
|
28935
28859
|
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceNoP];
|
|
28936
|
-
console.log(
|
|
28860
|
+
console.log('DATASOURCE_REFRESH', dataSourceNoP);
|
|
28937
28861
|
IS_DATASOURCE_REFRESH = true;
|
|
28938
28862
|
_ds.refreshed = true;
|
|
28939
28863
|
try {
|
|
@@ -28946,13 +28870,13 @@ func.datasource.prepare = async function (
|
|
|
28946
28870
|
|
|
28947
28871
|
_ds.v.old_dataSource = _.cloneDeep(_ds);
|
|
28948
28872
|
} catch (err) {
|
|
28949
|
-
console.error(
|
|
28873
|
+
console.error('function: init_existing_dataSource - error');
|
|
28950
28874
|
return;
|
|
28951
28875
|
}
|
|
28952
28876
|
dataSourceSession = dataSourceNoP;
|
|
28953
28877
|
};
|
|
28954
28878
|
|
|
28955
|
-
if (typeof dataSourceNoP ===
|
|
28879
|
+
if (typeof dataSourceNoP === 'undefined' || dataSourceNoP === null) {
|
|
28956
28880
|
await init_new_dataSource();
|
|
28957
28881
|
} else {
|
|
28958
28882
|
init_existing_dataSource();
|
|
@@ -28962,7 +28886,7 @@ func.datasource.prepare = async function (
|
|
|
28962
28886
|
};
|
|
28963
28887
|
var _ds = await init_dataSource();
|
|
28964
28888
|
|
|
28965
|
-
_ds.stat =
|
|
28889
|
+
_ds.stat = 'busy';
|
|
28966
28890
|
_ds._run_at = run_atP;
|
|
28967
28891
|
// init_v();
|
|
28968
28892
|
|
|
@@ -28974,12 +28898,7 @@ func.datasource.prepare = async function (
|
|
|
28974
28898
|
_ds.tree_obj = await func.utils.TREE_OBJ.get(SESSION_ID, prog_id);
|
|
28975
28899
|
|
|
28976
28900
|
if (!_ds.tree_obj) {
|
|
28977
|
-
return func.utils.debug_report(
|
|
28978
|
-
SESSION_ID,
|
|
28979
|
-
"Datasource",
|
|
28980
|
-
"Program not exist: " + prog_id,
|
|
28981
|
-
"E"
|
|
28982
|
-
);
|
|
28901
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Program not exist: ' + prog_id, 'E');
|
|
28983
28902
|
}
|
|
28984
28903
|
|
|
28985
28904
|
await func.datasource.set_VIEW_data(SESSION_ID, args, _ds);
|
|
@@ -28989,7 +28908,7 @@ func.datasource.prepare = async function (
|
|
|
28989
28908
|
) {
|
|
28990
28909
|
_ds.v.viewSourceDesc = callingSourceP;
|
|
28991
28910
|
}
|
|
28992
|
-
if (dataSourceSession === 0) _ds.v.viewSourceDesc =
|
|
28911
|
+
if (dataSourceSession === 0) _ds.v.viewSourceDesc = 'system startup';
|
|
28993
28912
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
28994
28913
|
|
|
28995
28914
|
const set_DS_GLB = async function () {
|
|
@@ -29015,7 +28934,7 @@ func.datasource.prepare = async function (
|
|
|
29015
28934
|
await set_DS_GLB();
|
|
29016
28935
|
|
|
29017
28936
|
if (
|
|
29018
|
-
prog_id ===
|
|
28937
|
+
prog_id === 'system' &&
|
|
29019
28938
|
!parentDataSourceNoP // do only on first time datasource 0 call
|
|
29020
28939
|
) {
|
|
29021
28940
|
build_GLOBAL_SYS_fields();
|
|
@@ -29030,18 +28949,10 @@ func.datasource.prepare = async function (
|
|
|
29030
28949
|
// INTERVALS
|
|
29031
28950
|
//======================================
|
|
29032
28951
|
|
|
29033
|
-
_ds.client_interval = func.datasource.get_event_interval_arr(
|
|
29034
|
-
SESSION_ID,
|
|
29035
|
-
dataSourceSession,
|
|
29036
|
-
"client_interval"
|
|
29037
|
-
);
|
|
28952
|
+
_ds.client_interval = func.datasource.get_event_interval_arr(SESSION_ID, dataSourceSession, 'client_interval');
|
|
29038
28953
|
|
|
29039
|
-
if (prog_id ===
|
|
29040
|
-
_ds.server_interval = func.datasource.get_event_interval_arr(
|
|
29041
|
-
SESSION_ID,
|
|
29042
|
-
dataSourceSession,
|
|
29043
|
-
"server_interval"
|
|
29044
|
-
);
|
|
28954
|
+
if (prog_id === 'system') {
|
|
28955
|
+
_ds.server_interval = func.datasource.get_event_interval_arr(SESSION_ID, dataSourceSession, 'server_interval');
|
|
29045
28956
|
}
|
|
29046
28957
|
|
|
29047
28958
|
// if (static_refreshP) {
|
|
@@ -29050,22 +28961,14 @@ func.datasource.prepare = async function (
|
|
|
29050
28961
|
// if (!static_refreshP) await set_parameters(); // do only on new datasource or refresh
|
|
29051
28962
|
|
|
29052
28963
|
// try {
|
|
29053
|
-
let ret_execute = await func.datasource.execute(
|
|
29054
|
-
SESSION_ID,
|
|
29055
|
-
dataSourceSession
|
|
29056
|
-
);
|
|
28964
|
+
let ret_execute = await func.datasource.execute(SESSION_ID, dataSourceSession);
|
|
29057
28965
|
return ret_execute;
|
|
29058
28966
|
// } catch (e) {
|
|
29059
28967
|
// console.error(e);
|
|
29060
28968
|
// }
|
|
29061
28969
|
};
|
|
29062
28970
|
|
|
29063
|
-
func.datasource.execute = async function (
|
|
29064
|
-
SESSION_ID,
|
|
29065
|
-
dataSourceSession,
|
|
29066
|
-
IS_DATASOURCE_REFRESH
|
|
29067
|
-
) {
|
|
29068
|
-
|
|
28971
|
+
func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATASOURCE_REFRESH) {
|
|
29069
28972
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
29070
28973
|
var _ds = _session.DS_GLB[dataSourceSession];
|
|
29071
28974
|
var args = _ds.args;
|
|
@@ -29074,60 +28977,32 @@ func.datasource.execute = async function (
|
|
|
29074
28977
|
let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
29075
28978
|
|
|
29076
28979
|
const callback_datasource = async function () {
|
|
29077
|
-
if (typeof IS_WORKER ===
|
|
29078
|
-
|
|
29079
|
-
|
|
29080
|
-
if (!["main"].includes(_session.opt.app_computing_mode)) {
|
|
28980
|
+
if (typeof IS_WORKER === 'undefined' && typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined' && _ds.viewSourceProp === 'globals') {
|
|
28981
|
+
if (!['main'].includes(_session.opt.app_computing_mode)) {
|
|
29081
28982
|
await func.index.call_worker(SESSION_ID, {
|
|
29082
|
-
service:
|
|
28983
|
+
service: 'create_webworker_globals',
|
|
29083
28984
|
data: { ds_data: _ds, session_id: SESSION_ID },
|
|
29084
28985
|
});
|
|
29085
28986
|
}
|
|
29086
28987
|
}
|
|
29087
28988
|
|
|
29088
|
-
if (
|
|
29089
|
-
await func.datasource.
|
|
29090
|
-
SESSION_ID,
|
|
29091
|
-
dataSourceSession,
|
|
29092
|
-
"on_load"
|
|
29093
|
-
)
|
|
29094
|
-
) {
|
|
29095
|
-
await func.datasource.execute_view_events(
|
|
29096
|
-
SESSION_ID,
|
|
29097
|
-
dataSourceSession,
|
|
29098
|
-
"on_load"
|
|
29099
|
-
);
|
|
28989
|
+
if (await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'on_load')) {
|
|
28990
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'on_load');
|
|
29100
28991
|
}
|
|
29101
28992
|
// }
|
|
29102
|
-
return func.datasource.callback(
|
|
29103
|
-
SESSION_ID,
|
|
29104
|
-
dataSourceSession,
|
|
29105
|
-
args.dataSourceNoP,
|
|
29106
|
-
args.rowIdP,
|
|
29107
|
-
args.jobNoP,
|
|
29108
|
-
null,
|
|
29109
|
-
_ds.prog_id
|
|
29110
|
-
);
|
|
28993
|
+
return await func.datasource.callback(SESSION_ID, dataSourceSession, args.dataSourceNoP, args.rowIdP, args.jobNoP, null, _ds.prog_id);
|
|
29111
28994
|
};
|
|
29112
28995
|
|
|
29113
28996
|
const get_limit = async function () {
|
|
29114
28997
|
var ret = 0;
|
|
29115
28998
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
29116
|
-
if (tree_ret.menuType ===
|
|
28999
|
+
if (tree_ret.menuType === 'get_data') {
|
|
29117
29000
|
return 1;
|
|
29118
29001
|
}
|
|
29119
29002
|
ret = _ds.progDataSource?.dataSourceLimit;
|
|
29120
29003
|
|
|
29121
29004
|
if (prog_obj.progDataSource?.dataSourceLoopExp) {
|
|
29122
|
-
ret = (
|
|
29123
|
-
await func.expression.get(
|
|
29124
|
-
SESSION_ID,
|
|
29125
|
-
prog_obj.progDataSource.dataSourceLoopExp,
|
|
29126
|
-
dataSourceSession,
|
|
29127
|
-
"view_loop",
|
|
29128
|
-
args.rowIdP
|
|
29129
|
-
)
|
|
29130
|
-
).result;
|
|
29005
|
+
ret = (await func.expression.get(SESSION_ID, prog_obj.progDataSource.dataSourceLoopExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
29131
29006
|
}
|
|
29132
29007
|
return ret;
|
|
29133
29008
|
};
|
|
@@ -29137,24 +29012,13 @@ func.datasource.execute = async function (
|
|
|
29137
29012
|
ret = _ds.progDataSource?.dataSourceSkip;
|
|
29138
29013
|
|
|
29139
29014
|
if (prog_obj.progDataSource?.dataSourceSkipExp) {
|
|
29140
|
-
ret = (
|
|
29141
|
-
await func.expression.get(
|
|
29142
|
-
SESSION_ID,
|
|
29143
|
-
prog_obj.progDataSource.dataSourceSkipExp,
|
|
29144
|
-
dataSourceSession,
|
|
29145
|
-
"view_loop",
|
|
29146
|
-
args.rowIdP
|
|
29147
|
-
)
|
|
29148
|
-
).result;
|
|
29015
|
+
ret = (await func.expression.get(SESSION_ID, prog_obj.progDataSource.dataSourceSkipExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
29149
29016
|
}
|
|
29150
29017
|
return ret;
|
|
29151
29018
|
};
|
|
29152
29019
|
|
|
29153
29020
|
const calc_batch_loops = async () => {
|
|
29154
|
-
if (
|
|
29155
|
-
!prog_obj.progDataSource?.dataSourceType ||
|
|
29156
|
-
_ds.progDataSource.dataSourceType === "none"
|
|
29157
|
-
) {
|
|
29021
|
+
if (!prog_obj.progDataSource?.dataSourceType || _ds.progDataSource.dataSourceType === 'none') {
|
|
29158
29022
|
_ds.v.batch_loops = await get_limit();
|
|
29159
29023
|
return false;
|
|
29160
29024
|
}
|
|
@@ -29163,10 +29027,7 @@ func.datasource.execute = async function (
|
|
|
29163
29027
|
// ? await get_limit()
|
|
29164
29028
|
// : _ds?.data_feed?.rows?.length;
|
|
29165
29029
|
|
|
29166
|
-
_ds.v.batch_loops =
|
|
29167
|
-
(await get_limit()) <= _ds.v.raw_data?.rows?.length
|
|
29168
|
-
? await get_limit()
|
|
29169
|
-
: _ds.v.raw_data?.rows?.length;
|
|
29030
|
+
_ds.v.batch_loops = (await get_limit()) <= _ds.v.raw_data?.rows?.length ? await get_limit() : _ds.v.raw_data?.rows?.length;
|
|
29170
29031
|
return true;
|
|
29171
29032
|
// _ds.v.batch_loops =
|
|
29172
29033
|
// (await get_limit()) <= _ds.v?.raw_data?.rows?.length
|
|
@@ -29177,54 +29038,39 @@ func.datasource.execute = async function (
|
|
|
29177
29038
|
|
|
29178
29039
|
const render_api_output = async function () {
|
|
29179
29040
|
if (prog_obj?.scriptData?.value) {
|
|
29180
|
-
var exp = await func.expression.get(
|
|
29181
|
-
SESSION_ID,
|
|
29182
|
-
prog_obj.scriptData.value,
|
|
29183
|
-
dataSourceSession,
|
|
29184
|
-
"api_rendered_output",
|
|
29185
|
-
null, null, null, null, null, null, null, null, null, tree_obj.apiOutput
|
|
29186
|
-
);
|
|
29041
|
+
var exp = await func.expression.get(SESSION_ID, prog_obj.scriptData.value, dataSourceSession, 'api_rendered_output', null, null, null, null, null, null, null, null, null, tree_obj.apiOutput);
|
|
29187
29042
|
|
|
29188
|
-
let output_result = exp.result
|
|
29189
|
-
if (tree_obj.apiOutput ===
|
|
29043
|
+
let output_result = exp.result;
|
|
29044
|
+
if (tree_obj.apiOutput === 'json') {
|
|
29190
29045
|
// iterate object to fix expressions
|
|
29191
29046
|
try {
|
|
29192
29047
|
// let output_result_obj = JSON5.parse(output_result)
|
|
29193
|
-
let output_result_obj = await func.expression.secure_eval(
|
|
29194
|
-
SESSION_ID,
|
|
29195
|
-
"api_rendered_output",
|
|
29196
|
-
"(" + output_result + ")",
|
|
29197
|
-
null,
|
|
29198
|
-
dataSourceSession,
|
|
29199
|
-
|
|
29200
|
-
);
|
|
29048
|
+
let output_result_obj = await func.expression.secure_eval(SESSION_ID, 'api_rendered_output', '(' + output_result + ')', null, dataSourceSession);
|
|
29201
29049
|
// for await (let [key, val] of Object.entries(output_result_obj)) {
|
|
29202
29050
|
// output_result_obj[key] = (await func.expression.get(
|
|
29203
29051
|
// SESSION_ID,
|
|
29204
29052
|
// val,
|
|
29205
29053
|
// dataSourceSession, "object_property")).result
|
|
29206
29054
|
// }
|
|
29207
|
-
output_result = JSON.stringify(output_result_obj)
|
|
29055
|
+
output_result = JSON.stringify(output_result_obj);
|
|
29208
29056
|
} catch (err) {
|
|
29209
|
-
console.error(err)
|
|
29057
|
+
console.error(err);
|
|
29210
29058
|
}
|
|
29211
|
-
|
|
29212
29059
|
}
|
|
29213
|
-
_ds.api_rendered_output +=
|
|
29214
|
-
output_result + (tree_obj.apiOutput === "json" ? "," : "");
|
|
29060
|
+
_ds.api_rendered_output += output_result + (tree_obj.apiOutput === 'json' ? ',' : '');
|
|
29215
29061
|
} else {
|
|
29216
|
-
_ds.api_rendered_output =
|
|
29062
|
+
_ds.api_rendered_output = ''; //empty
|
|
29217
29063
|
}
|
|
29218
29064
|
};
|
|
29219
29065
|
|
|
29220
29066
|
// ======================================
|
|
29221
29067
|
// COMPUTE GLOBALS
|
|
29222
29068
|
// ======================================
|
|
29223
|
-
if (_ds.prog_id ===
|
|
29069
|
+
if (_ds.prog_id === 'system') {
|
|
29224
29070
|
//TBD tree_obj.menuType === "globals"
|
|
29225
|
-
_ds.currentRecordId =
|
|
29071
|
+
_ds.currentRecordId = 'dataset';
|
|
29226
29072
|
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, {
|
|
29227
|
-
id:
|
|
29073
|
+
id: 'dataset',
|
|
29228
29074
|
value: _session.url_params,
|
|
29229
29075
|
});
|
|
29230
29076
|
|
|
@@ -29237,47 +29083,31 @@ func.datasource.execute = async function (
|
|
|
29237
29083
|
let db_adapter_module;
|
|
29238
29084
|
|
|
29239
29085
|
if (prog_obj.progDataSource?.dataSourceType) {
|
|
29240
|
-
db_adapter_module = await func.common.get_module(
|
|
29241
|
-
SESSION_ID,
|
|
29242
|
-
"xuda-datasource-db-adapter-module.mjs"
|
|
29243
|
-
);
|
|
29086
|
+
db_adapter_module = await func.common.get_module(SESSION_ID, 'xuda-datasource-db-adapter-module.mjs');
|
|
29244
29087
|
}
|
|
29245
29088
|
|
|
29246
29089
|
const get_data_from_source = async function () {
|
|
29247
29090
|
switch (prog_obj.progDataSource.dataSourceSrcType) {
|
|
29248
|
-
case
|
|
29249
|
-
const { result, error } = await func.expression.get(
|
|
29250
|
-
SESSION_ID,
|
|
29251
|
-
prog_obj.progDataSource.progDataSourceInput,
|
|
29252
|
-
dataSourceSession,
|
|
29253
|
-
"datasource select"
|
|
29254
|
-
);
|
|
29091
|
+
case 'input': {
|
|
29092
|
+
const { result, error } = await func.expression.get(SESSION_ID, prog_obj.progDataSource.progDataSourceInput, dataSourceSession, 'datasource select');
|
|
29255
29093
|
if (error) {
|
|
29256
|
-
func.utils.debug_report(
|
|
29257
|
-
SESSION_ID,
|
|
29258
|
-
"Data source",
|
|
29259
|
-
`Datasource parse error using ${prog_obj.progDataSource?.dataSourceType} input`,
|
|
29260
|
-
"E"
|
|
29261
|
-
);
|
|
29094
|
+
func.utils.debug_report(SESSION_ID, 'Data source', `Datasource parse error using ${prog_obj.progDataSource?.dataSourceType} input`, 'E');
|
|
29262
29095
|
return null;
|
|
29263
29096
|
}
|
|
29264
29097
|
|
|
29265
29098
|
return result;
|
|
29266
29099
|
break;
|
|
29267
29100
|
}
|
|
29268
|
-
case
|
|
29101
|
+
case 'url': {
|
|
29269
29102
|
let opt = {
|
|
29270
|
-
method: prog_obj.progDataSource.dataSourceMethod ||
|
|
29103
|
+
method: prog_obj.progDataSource.dataSourceMethod || 'POST',
|
|
29271
29104
|
headers: {
|
|
29272
|
-
Accept:
|
|
29273
|
-
|
|
29105
|
+
Accept: 'application/json',
|
|
29106
|
+
'Content-Type': 'application/json',
|
|
29274
29107
|
},
|
|
29275
29108
|
};
|
|
29276
29109
|
let data = {};
|
|
29277
|
-
if (
|
|
29278
|
-
prog_obj.progDataSource.dataSourceMethod == "POST" &&
|
|
29279
|
-
prog_obj.progDataSource.dataSourceParameters
|
|
29280
|
-
) {
|
|
29110
|
+
if (prog_obj.progDataSource.dataSourceMethod == 'POST' && prog_obj.progDataSource.dataSourceParameters) {
|
|
29281
29111
|
for (let val of prog_obj.progDataSource.dataSourceParameters) {
|
|
29282
29112
|
data[val.key] = val.val;
|
|
29283
29113
|
}
|
|
@@ -29285,21 +29115,11 @@ func.datasource.execute = async function (
|
|
|
29285
29115
|
opt.body = JSON.stringify(data);
|
|
29286
29116
|
}
|
|
29287
29117
|
try {
|
|
29288
|
-
const response = await fetch(
|
|
29289
|
-
"https://" + prog_obj.progDataSource.dataSourceDataUrl,
|
|
29290
|
-
opt
|
|
29291
|
-
);
|
|
29118
|
+
const response = await fetch('https://' + prog_obj.progDataSource.dataSourceDataUrl, opt);
|
|
29292
29119
|
const json = await response.json();
|
|
29293
29120
|
return json.data;
|
|
29294
29121
|
} catch (err) {
|
|
29295
|
-
func.utils.debug_report(
|
|
29296
|
-
SESSION_ID,
|
|
29297
|
-
"Data source",
|
|
29298
|
-
err.message +
|
|
29299
|
-
" https://" +
|
|
29300
|
-
prog_obj.progDataSource.dataSourceDataUrl,
|
|
29301
|
-
"E"
|
|
29302
|
-
);
|
|
29122
|
+
func.utils.debug_report(SESSION_ID, 'Data source', err.message + ' https://' + prog_obj.progDataSource.dataSourceDataUrl, 'E');
|
|
29303
29123
|
return null;
|
|
29304
29124
|
}
|
|
29305
29125
|
|
|
@@ -29319,76 +29139,37 @@ func.datasource.execute = async function (
|
|
|
29319
29139
|
_ds.data_feed.rows = [];
|
|
29320
29140
|
|
|
29321
29141
|
switch (prog_obj.progDataSource?.dataSourceType) {
|
|
29322
|
-
case
|
|
29142
|
+
case 'table':
|
|
29323
29143
|
_ds._dataSourceTableId = prog_obj.progDataSource?.dataSourceTableId; // get file id
|
|
29324
29144
|
|
|
29325
29145
|
if (prog_obj.progDataSource?.dataSourceTableIdExp) {
|
|
29326
|
-
_ds.v.dataSourceTableIdExp = await func.expression.get(
|
|
29327
|
-
SESSION_ID,
|
|
29328
|
-
prog_obj.progDataSource?.dataSourceTableIdExp,
|
|
29329
|
-
dataSourceSession,
|
|
29330
|
-
"dataSourceTableIdExp",
|
|
29331
|
-
args.rowIdP
|
|
29332
|
-
);
|
|
29146
|
+
_ds.v.dataSourceTableIdExp = await func.expression.get(SESSION_ID, prog_obj.progDataSource?.dataSourceTableIdExp, dataSourceSession, 'dataSourceTableIdExp', args.rowIdP);
|
|
29333
29147
|
if (_ds.v.dataSourceTableIdExp.result) {
|
|
29334
29148
|
_ds._dataSourceTableId = _ds.v.dataSourceTableIdExp.result;
|
|
29335
29149
|
} else {
|
|
29336
|
-
func.utils.debug_report(
|
|
29337
|
-
SESSION_ID,
|
|
29338
|
-
"get_VIEW_data",
|
|
29339
|
-
"Table Expression returned empty result",
|
|
29340
|
-
"W"
|
|
29341
|
-
);
|
|
29150
|
+
func.utils.debug_report(SESSION_ID, 'get_VIEW_data', 'Table Expression returned empty result', 'W');
|
|
29342
29151
|
}
|
|
29343
29152
|
}
|
|
29344
29153
|
|
|
29345
29154
|
if (!_ds._dataSourceTableId) {
|
|
29346
|
-
return func.utils.debug_report(
|
|
29347
|
-
SESSION_ID,
|
|
29348
|
-
"Data source",
|
|
29349
|
-
"Table cannot be empty when Db Table selected",
|
|
29350
|
-
"E"
|
|
29351
|
-
);
|
|
29155
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Table cannot be empty when Db Table selected', 'E');
|
|
29352
29156
|
}
|
|
29353
29157
|
|
|
29354
|
-
let table_ret = await func.utils.TREE_OBJ.get(
|
|
29355
|
-
SESSION_ID,
|
|
29356
|
-
_ds._dataSourceTableId
|
|
29357
|
-
);
|
|
29158
|
+
let table_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
29358
29159
|
if (!table_ret) {
|
|
29359
|
-
return func.utils.debug_report(
|
|
29360
|
-
SESSION_ID,
|
|
29361
|
-
"Data source",
|
|
29362
|
-
"Table not found: " + _ds._dataSourceTableId,
|
|
29363
|
-
"E"
|
|
29364
|
-
);
|
|
29160
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Table not found: ' + _ds._dataSourceTableId, 'E');
|
|
29365
29161
|
}
|
|
29366
29162
|
|
|
29367
|
-
await db_adapter_module.build_filter(
|
|
29368
|
-
SESSION_ID,
|
|
29369
|
-
dataSourceSession,
|
|
29370
|
-
_ds.v,
|
|
29371
|
-
_ds
|
|
29372
|
-
);
|
|
29163
|
+
await db_adapter_module.build_filter(SESSION_ID, dataSourceSession, _ds.v, _ds);
|
|
29373
29164
|
|
|
29374
29165
|
let filterModelMongo = _ds.progDataSource.filterModelMongo;
|
|
29375
29166
|
if (_ds.progDataSource.filterModelMongoFx) {
|
|
29376
|
-
let ret = await func.expression.get(
|
|
29377
|
-
SESSION_ID,
|
|
29378
|
-
_ds.progDataSource.filterModelMongoFx,
|
|
29379
|
-
dataSourceSession,
|
|
29380
|
-
"query"
|
|
29381
|
-
);
|
|
29167
|
+
let ret = await func.expression.get(SESSION_ID, _ds.progDataSource.filterModelMongoFx, dataSourceSession, 'query');
|
|
29382
29168
|
filterModelMongo = ret.result;
|
|
29383
29169
|
}
|
|
29384
29170
|
let filterModelSql = _ds.progDataSource.filterModelSql;
|
|
29385
29171
|
if (_ds.progDataSource.filterModelSqlFx) {
|
|
29386
|
-
let ret = await func.expression.get(
|
|
29387
|
-
SESSION_ID,
|
|
29388
|
-
_ds.progDataSource.filterModelSqlFx,
|
|
29389
|
-
dataSourceSession,
|
|
29390
|
-
"query"
|
|
29391
|
-
);
|
|
29172
|
+
let ret = await func.expression.get(SESSION_ID, _ds.progDataSource.filterModelSqlFx, dataSourceSession, 'query');
|
|
29392
29173
|
filterModelSql = ret.result;
|
|
29393
29174
|
}
|
|
29394
29175
|
|
|
@@ -29408,7 +29189,7 @@ func.datasource.execute = async function (
|
|
|
29408
29189
|
_ds.v.couchView,
|
|
29409
29190
|
dataSourceSession,
|
|
29410
29191
|
_ds.viewSourceDesc,
|
|
29411
|
-
|
|
29192
|
+
'datasource table',
|
|
29412
29193
|
prog_obj.progDataSource.dataSourceReduce,
|
|
29413
29194
|
await get_skip(),
|
|
29414
29195
|
(await get_limit()) || 99999999,
|
|
@@ -29417,7 +29198,7 @@ func.datasource.execute = async function (
|
|
|
29417
29198
|
_ds?.progDataSource?.sortModel,
|
|
29418
29199
|
null,
|
|
29419
29200
|
filterModel,
|
|
29420
|
-
_ds?.progDataSource?.dataSourceFilterModelType
|
|
29201
|
+
_ds?.progDataSource?.dataSourceFilterModelType,
|
|
29421
29202
|
);
|
|
29422
29203
|
if (_ds?.progDataSource?.dataSourceLimit) {
|
|
29423
29204
|
const ret_rows_found = await func.db.get_query(
|
|
@@ -29426,7 +29207,7 @@ func.datasource.execute = async function (
|
|
|
29426
29207
|
_ds.v.couchView,
|
|
29427
29208
|
dataSourceSession,
|
|
29428
29209
|
_ds.viewSourceDesc,
|
|
29429
|
-
|
|
29210
|
+
'datasource table',
|
|
29430
29211
|
prog_obj.progDataSource.dataSourceReduce,
|
|
29431
29212
|
null,
|
|
29432
29213
|
null,
|
|
@@ -29435,7 +29216,7 @@ func.datasource.execute = async function (
|
|
|
29435
29216
|
null,
|
|
29436
29217
|
null,
|
|
29437
29218
|
filterModel,
|
|
29438
|
-
_ds?.progDataSource?.dataSourceFilterModelType
|
|
29219
|
+
_ds?.progDataSource?.dataSourceFilterModelType,
|
|
29439
29220
|
);
|
|
29440
29221
|
_ds.rows_found = ret_rows_found?.rows?.[0]?.value || 0;
|
|
29441
29222
|
} else {
|
|
@@ -29443,7 +29224,7 @@ func.datasource.execute = async function (
|
|
|
29443
29224
|
}
|
|
29444
29225
|
break;
|
|
29445
29226
|
|
|
29446
|
-
case
|
|
29227
|
+
case 'array': {
|
|
29447
29228
|
let data = await get_data_from_source();
|
|
29448
29229
|
|
|
29449
29230
|
if (data === null) {
|
|
@@ -29469,7 +29250,7 @@ func.datasource.execute = async function (
|
|
|
29469
29250
|
break;
|
|
29470
29251
|
}
|
|
29471
29252
|
|
|
29472
|
-
case
|
|
29253
|
+
case 'json': {
|
|
29473
29254
|
let data = await get_data_from_source();
|
|
29474
29255
|
if (data === null) {
|
|
29475
29256
|
data = {};
|
|
@@ -29490,12 +29271,10 @@ func.datasource.execute = async function (
|
|
|
29490
29271
|
break;
|
|
29491
29272
|
}
|
|
29492
29273
|
|
|
29493
|
-
|
|
29494
|
-
|
|
29495
|
-
case "csv":
|
|
29274
|
+
case 'csv':
|
|
29496
29275
|
let data = await get_data_from_source();
|
|
29497
29276
|
if (data === null) {
|
|
29498
|
-
data =
|
|
29277
|
+
data = '';
|
|
29499
29278
|
}
|
|
29500
29279
|
|
|
29501
29280
|
// if (!_ds.v.raw_data) {
|
|
@@ -29514,7 +29293,7 @@ func.datasource.execute = async function (
|
|
|
29514
29293
|
// }
|
|
29515
29294
|
|
|
29516
29295
|
let _KEY = 0;
|
|
29517
|
-
let arr = data.split(
|
|
29296
|
+
let arr = data.split(',');
|
|
29518
29297
|
for (const _VAL of arr) {
|
|
29519
29298
|
_ds.v.raw_data.rows.push({ id: _KEY, value: { _KEY, _VAL } });
|
|
29520
29299
|
_KEY++;
|
|
@@ -29533,24 +29312,16 @@ func.datasource.execute = async function (
|
|
|
29533
29312
|
let ret;
|
|
29534
29313
|
|
|
29535
29314
|
const get_before_record_count = async () => {
|
|
29536
|
-
return await func.datasource.get_view_events_count(
|
|
29537
|
-
SESSION_ID,
|
|
29538
|
-
dataSourceSession,
|
|
29539
|
-
"before_record"
|
|
29540
|
-
);
|
|
29315
|
+
return await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'before_record');
|
|
29541
29316
|
};
|
|
29542
29317
|
const get_after_record_count = async () => {
|
|
29543
|
-
return await func.datasource.get_view_events_count(
|
|
29544
|
-
SESSION_ID,
|
|
29545
|
-
dataSourceSession,
|
|
29546
|
-
"after_record"
|
|
29547
|
-
);
|
|
29318
|
+
return await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'after_record');
|
|
29548
29319
|
};
|
|
29549
29320
|
|
|
29550
29321
|
let _raw_data_rows = [];
|
|
29551
29322
|
switch (tree_obj.menuType) {
|
|
29552
|
-
case
|
|
29553
|
-
_ds.api_rendered_output =
|
|
29323
|
+
case 'api': {
|
|
29324
|
+
_ds.api_rendered_output = '';
|
|
29554
29325
|
let has_datasource = await calc_batch_loops();
|
|
29555
29326
|
|
|
29556
29327
|
_raw_data_rows = _ds.v.raw_data.rows || [];
|
|
@@ -29559,7 +29330,7 @@ func.datasource.execute = async function (
|
|
|
29559
29330
|
_raw_data_rows.push({ id: n, value: {} });
|
|
29560
29331
|
}
|
|
29561
29332
|
}
|
|
29562
|
-
_ds.currentRecordId =
|
|
29333
|
+
_ds.currentRecordId = 'dataset';
|
|
29563
29334
|
for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
|
|
29564
29335
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
29565
29336
|
|
|
@@ -29568,47 +29339,31 @@ func.datasource.execute = async function (
|
|
|
29568
29339
|
}
|
|
29569
29340
|
|
|
29570
29341
|
if (await get_before_record_count()) {
|
|
29571
|
-
await func.datasource.execute_view_events(
|
|
29572
|
-
SESSION_ID,
|
|
29573
|
-
dataSourceSession,
|
|
29574
|
-
"before_record"
|
|
29575
|
-
);
|
|
29342
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
29576
29343
|
}
|
|
29577
29344
|
|
|
29578
|
-
await func.datasource.render_fields_dataset(
|
|
29579
|
-
SESSION_ID,
|
|
29580
|
-
dataSourceSession,
|
|
29581
|
-
raw_data_row
|
|
29582
|
-
);
|
|
29345
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
29583
29346
|
|
|
29584
29347
|
if (await get_after_record_count()) {
|
|
29585
|
-
await func.datasource.execute_view_events(
|
|
29586
|
-
SESSION_ID,
|
|
29587
|
-
dataSourceSession,
|
|
29588
|
-
"after_record"
|
|
29589
|
-
);
|
|
29348
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
29590
29349
|
}
|
|
29591
29350
|
|
|
29592
29351
|
await render_api_output();
|
|
29593
29352
|
}
|
|
29594
29353
|
|
|
29595
|
-
if (tree_obj.apiOutput ===
|
|
29596
|
-
var str = _ds.api_rendered_output.substring(
|
|
29597
|
-
0,
|
|
29598
|
-
_ds.api_rendered_output.length - 1
|
|
29599
|
-
);
|
|
29354
|
+
if (tree_obj.apiOutput === 'json') {
|
|
29355
|
+
var str = _ds.api_rendered_output.substring(0, _ds.api_rendered_output.length - 1);
|
|
29600
29356
|
if (Number(_ds.progDataSource?.dataSourceLimit) === 1) {
|
|
29601
29357
|
_ds.api_rendered_output = str;
|
|
29602
29358
|
} else {
|
|
29603
|
-
_ds.api_rendered_output =
|
|
29359
|
+
_ds.api_rendered_output = '[' + str + ']';
|
|
29604
29360
|
}
|
|
29605
29361
|
}
|
|
29606
29362
|
|
|
29607
29363
|
break;
|
|
29608
29364
|
}
|
|
29609
29365
|
|
|
29610
|
-
case
|
|
29611
|
-
|
|
29366
|
+
case 'batch': {
|
|
29612
29367
|
let has_datasource = await calc_batch_loops();
|
|
29613
29368
|
|
|
29614
29369
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
@@ -29617,7 +29372,7 @@ func.datasource.execute = async function (
|
|
|
29617
29372
|
_raw_data_rows.push({ id: n, value: {} });
|
|
29618
29373
|
}
|
|
29619
29374
|
}
|
|
29620
|
-
_ds.currentRecordId =
|
|
29375
|
+
_ds.currentRecordId = 'dataset';
|
|
29621
29376
|
for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
|
|
29622
29377
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
29623
29378
|
|
|
@@ -29626,68 +29381,35 @@ func.datasource.execute = async function (
|
|
|
29626
29381
|
}
|
|
29627
29382
|
|
|
29628
29383
|
if (await get_before_record_count()) {
|
|
29629
|
-
await func.datasource.execute_view_events(
|
|
29630
|
-
SESSION_ID,
|
|
29631
|
-
dataSourceSession,
|
|
29632
|
-
"before_record"
|
|
29633
|
-
);
|
|
29384
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
29634
29385
|
}
|
|
29635
29386
|
|
|
29636
|
-
await func.datasource.render_fields_dataset(
|
|
29637
|
-
SESSION_ID,
|
|
29638
|
-
dataSourceSession,
|
|
29639
|
-
raw_data_row
|
|
29640
|
-
);
|
|
29387
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
29641
29388
|
|
|
29642
29389
|
if (await get_after_record_count()) {
|
|
29643
|
-
await func.datasource.execute_view_events(
|
|
29644
|
-
SESSION_ID,
|
|
29645
|
-
dataSourceSession,
|
|
29646
|
-
"after_record"
|
|
29647
|
-
);
|
|
29390
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
29648
29391
|
}
|
|
29649
29392
|
}
|
|
29650
29393
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
29651
29394
|
break;
|
|
29652
29395
|
}
|
|
29653
29396
|
|
|
29654
|
-
case
|
|
29397
|
+
case 'get_data':
|
|
29655
29398
|
if (await get_before_record_count()) {
|
|
29656
|
-
await func.datasource.execute_view_events(
|
|
29657
|
-
SESSION_ID,
|
|
29658
|
-
dataSourceSession,
|
|
29659
|
-
"before_record"
|
|
29660
|
-
);
|
|
29399
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
29661
29400
|
}
|
|
29662
29401
|
|
|
29663
|
-
ret = await db_adapter_module.process_view_dataset(
|
|
29664
|
-
SESSION_ID,
|
|
29665
|
-
dataSourceSession,
|
|
29666
|
-
_ds
|
|
29667
|
-
);
|
|
29402
|
+
ret = await db_adapter_module.process_view_dataset(SESSION_ID, dataSourceSession, _ds);
|
|
29668
29403
|
|
|
29669
29404
|
if (await get_after_record_count()) {
|
|
29670
|
-
await func.datasource.execute_view_events(
|
|
29671
|
-
SESSION_ID,
|
|
29672
|
-
dataSourceSession,
|
|
29673
|
-
"after_record"
|
|
29674
|
-
);
|
|
29405
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
29675
29406
|
}
|
|
29676
29407
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
29677
29408
|
break;
|
|
29678
29409
|
|
|
29679
|
-
case
|
|
29680
|
-
if (
|
|
29681
|
-
|
|
29682
|
-
_ds.progDataSource.dataSourceType !== "table" ||
|
|
29683
|
-
!_ds._dataSourceTableId
|
|
29684
|
-
) {
|
|
29685
|
-
return func.utils.debug_report(
|
|
29686
|
-
SESSION_ID,
|
|
29687
|
-
"Data source",
|
|
29688
|
-
"Datasource DB Table must be defined for Set Data operation",
|
|
29689
|
-
"E"
|
|
29690
|
-
);
|
|
29410
|
+
case 'set_data':
|
|
29411
|
+
if (!prog_obj.progDataSource?.dataSourceType || _ds.progDataSource.dataSourceType !== 'table' || !_ds._dataSourceTableId) {
|
|
29412
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Datasource DB Table must be defined for Set Data operation', 'E');
|
|
29691
29413
|
}
|
|
29692
29414
|
|
|
29693
29415
|
// const get_data_from_data_feed = function () {
|
|
@@ -29702,7 +29424,7 @@ func.datasource.execute = async function (
|
|
|
29702
29424
|
|
|
29703
29425
|
const find_ROWID_idx_from_raw_data_arr = function (rowId) {
|
|
29704
29426
|
if (!_raw_data_rows) {
|
|
29705
|
-
throw new Error(
|
|
29427
|
+
throw new Error('_raw_data_rows not found');
|
|
29706
29428
|
}
|
|
29707
29429
|
|
|
29708
29430
|
const index = _raw_data_rows.findIndex((item) => item.id === rowId);
|
|
@@ -29712,81 +29434,62 @@ func.datasource.execute = async function (
|
|
|
29712
29434
|
return index;
|
|
29713
29435
|
};
|
|
29714
29436
|
|
|
29715
|
-
if (tree_obj.crudMode ===
|
|
29716
|
-
_ds.set_mode =
|
|
29437
|
+
if (tree_obj.crudMode === 'U') {
|
|
29438
|
+
_ds.set_mode = 'U';
|
|
29717
29439
|
// _raw_data_rows = get_data_from_data_feed(); // _ds?.raw_data?.rows || [];
|
|
29718
29440
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
29719
29441
|
}
|
|
29720
29442
|
|
|
29721
|
-
if (tree_obj.crudMode ===
|
|
29722
|
-
_ds.set_mode =
|
|
29443
|
+
if (tree_obj.crudMode === 'D') {
|
|
29444
|
+
_ds.set_mode = 'D';
|
|
29723
29445
|
// _raw_data_rows = get_data_from_data_feed(); // _ds.raw_data?.rows || [];
|
|
29724
29446
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
29725
29447
|
}
|
|
29726
29448
|
|
|
29727
29449
|
// initiated with Update but no rows found
|
|
29728
|
-
if (
|
|
29729
|
-
|
|
29730
|
-
tree_obj.allowCreate &&
|
|
29731
|
-
!_ds?.data_feed?.rows?.length
|
|
29732
|
-
) {
|
|
29733
|
-
_ds.set_mode = "C";
|
|
29450
|
+
if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
|
|
29451
|
+
_ds.set_mode = 'C';
|
|
29734
29452
|
// _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
|
|
29735
29453
|
|
|
29736
29454
|
try {
|
|
29737
|
-
const row_idx = find_ROWID_idx_from_raw_data_arr(
|
|
29738
|
-
_raw_data_rows[row_idx] = [{ id:
|
|
29455
|
+
const row_idx = find_ROWID_idx_from_raw_data_arr('newRecord');
|
|
29456
|
+
_raw_data_rows[row_idx] = [{ id: 'newRecord', value: {} }];
|
|
29739
29457
|
} catch (error) {
|
|
29740
|
-
_raw_data_rows.push({ _ROWID:
|
|
29458
|
+
_raw_data_rows.push({ _ROWID: 'newRecord' });
|
|
29741
29459
|
}
|
|
29742
29460
|
}
|
|
29743
29461
|
|
|
29744
|
-
if (tree_obj.crudMode ===
|
|
29745
|
-
_ds.set_mode =
|
|
29462
|
+
if (tree_obj.crudMode === 'C') {
|
|
29463
|
+
_ds.set_mode = 'C';
|
|
29746
29464
|
// _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
|
|
29747
29465
|
try {
|
|
29748
|
-
const row_idx = find_ROWID_idx_from_raw_data_arr(
|
|
29749
|
-
_raw_data_rows[row_idx] = [{ id:
|
|
29466
|
+
const row_idx = find_ROWID_idx_from_raw_data_arr('newRecord');
|
|
29467
|
+
_raw_data_rows[row_idx] = [{ id: 'newRecord', value: {} }];
|
|
29750
29468
|
} catch (error) {
|
|
29751
|
-
_raw_data_rows.push({ id:
|
|
29469
|
+
_raw_data_rows.push({ id: 'newRecord', value: {} });
|
|
29752
29470
|
}
|
|
29753
29471
|
}
|
|
29754
29472
|
|
|
29755
29473
|
for await (let raw_data_row of _raw_data_rows) {
|
|
29756
29474
|
_ds.currentRecordId = raw_data_row.id;
|
|
29757
29475
|
if (await get_before_record_count()) {
|
|
29758
|
-
await func.datasource.execute_view_events(
|
|
29759
|
-
SESSION_ID,
|
|
29760
|
-
dataSourceSession,
|
|
29761
|
-
"before_record"
|
|
29762
|
-
);
|
|
29476
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
29763
29477
|
}
|
|
29764
29478
|
|
|
29765
|
-
await func.datasource.render_fields_dataset(
|
|
29766
|
-
SESSION_ID,
|
|
29767
|
-
dataSourceSession,
|
|
29768
|
-
raw_data_row
|
|
29769
|
-
);
|
|
29479
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
29770
29480
|
let data_feed_str = JSON.stringify(_ds.data_feed);
|
|
29771
29481
|
|
|
29772
29482
|
if (await get_after_record_count()) {
|
|
29773
|
-
await func.datasource.execute_view_events(
|
|
29774
|
-
SESSION_ID,
|
|
29775
|
-
dataSourceSession,
|
|
29776
|
-
"after_record"
|
|
29777
|
-
);
|
|
29483
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
29778
29484
|
}
|
|
29779
29485
|
|
|
29780
|
-
if (
|
|
29781
|
-
_ds.set_mode === "C" ||
|
|
29782
|
-
JSON.stringify(_ds.data_feed) !== data_feed_str
|
|
29783
|
-
) {
|
|
29486
|
+
if (_ds.set_mode === 'C' || JSON.stringify(_ds.data_feed) !== data_feed_str) {
|
|
29784
29487
|
const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
29785
29488
|
if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
29786
|
-
_ds.set_mode =
|
|
29489
|
+
_ds.set_mode = 'U';
|
|
29787
29490
|
}
|
|
29788
29491
|
|
|
29789
|
-
if (_ds.set_mode ===
|
|
29492
|
+
if (_ds.set_mode === 'D') {
|
|
29790
29493
|
const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
29791
29494
|
if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
29792
29495
|
}
|
|
@@ -29795,7 +29498,7 @@ func.datasource.execute = async function (
|
|
|
29795
29498
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
29796
29499
|
break;
|
|
29797
29500
|
|
|
29798
|
-
case
|
|
29501
|
+
case 'component':
|
|
29799
29502
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
29800
29503
|
_ds.rows_processed = 0;
|
|
29801
29504
|
_ds.viewRangeExp_rows_deleted = 0;
|
|
@@ -29806,49 +29509,29 @@ func.datasource.execute = async function (
|
|
|
29806
29509
|
_ds.data_feed.rows_deleted = [];
|
|
29807
29510
|
_ds.data_feed.rows_added = [];
|
|
29808
29511
|
|
|
29809
|
-
if (tree_obj.rwMode ===
|
|
29810
|
-
_ds.set_mode =
|
|
29512
|
+
if (tree_obj.rwMode === 'U') {
|
|
29513
|
+
_ds.set_mode = 'U';
|
|
29811
29514
|
} else {
|
|
29812
|
-
_ds.set_mode =
|
|
29515
|
+
_ds.set_mode = 'R';
|
|
29813
29516
|
}
|
|
29814
29517
|
|
|
29815
29518
|
const row_not_found = async function () {
|
|
29816
|
-
if (
|
|
29817
|
-
|
|
29818
|
-
|
|
29819
|
-
) {
|
|
29820
|
-
_ds.currentRecordId = "newRecord";
|
|
29821
|
-
_ds.set_mode = "C";
|
|
29519
|
+
if (!prog_obj.progDataSource?.dataSourceType || (tree_obj.rwMode === 'U' && tree_obj.allowCreate)) {
|
|
29520
|
+
_ds.currentRecordId = 'newRecord';
|
|
29521
|
+
_ds.set_mode = 'C';
|
|
29822
29522
|
_ds.record_not_found = true;
|
|
29823
29523
|
|
|
29824
29524
|
try {
|
|
29825
|
-
const row_idx = func.common.find_ROWID_idx(
|
|
29826
|
-
_ds,
|
|
29827
|
-
_ds.currentRecordId
|
|
29828
|
-
);
|
|
29525
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
29829
29526
|
} catch (error) {
|
|
29830
|
-
await func.datasource.render_fields_form(
|
|
29831
|
-
SESSION_ID,
|
|
29832
|
-
dataSourceSession,
|
|
29833
|
-
{ id: "newRecord", value: {} }
|
|
29834
|
-
);
|
|
29527
|
+
await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, { id: 'newRecord', value: {} });
|
|
29835
29528
|
}
|
|
29836
29529
|
|
|
29837
|
-
var count = await func.datasource.get_field_init_count(
|
|
29838
|
-
SESSION_ID,
|
|
29839
|
-
dataSourceSession,
|
|
29840
|
-
"newRecord",
|
|
29841
|
-
false
|
|
29842
|
-
);
|
|
29530
|
+
var count = await func.datasource.get_field_init_count(SESSION_ID, dataSourceSession, 'newRecord', false);
|
|
29843
29531
|
if (
|
|
29844
29532
|
count > 0 // was: && !args.dataSourceNoP
|
|
29845
29533
|
) {
|
|
29846
|
-
await func.datasource.execute_field_init_events(
|
|
29847
|
-
SESSION_ID,
|
|
29848
|
-
dataSourceSession,
|
|
29849
|
-
"form",
|
|
29850
|
-
"newRecord"
|
|
29851
|
-
);
|
|
29534
|
+
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', 'newRecord');
|
|
29852
29535
|
}
|
|
29853
29536
|
}
|
|
29854
29537
|
};
|
|
@@ -29863,20 +29546,13 @@ func.datasource.execute = async function (
|
|
|
29863
29546
|
// check if locatedRecordId exist in SESSION_OBJ[SESSION_ID].DS_GLB
|
|
29864
29547
|
if (_ds.locatedRecordId) {
|
|
29865
29548
|
try {
|
|
29866
|
-
const row_idx = func.common.find_ROWID_idx(
|
|
29867
|
-
_ds,
|
|
29868
|
-
_ds.locatedRecordId
|
|
29869
|
-
);
|
|
29549
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.locatedRecordId);
|
|
29870
29550
|
} catch (error) {
|
|
29871
29551
|
delete _ds.locatedRecordId;
|
|
29872
29552
|
}
|
|
29873
29553
|
}
|
|
29874
29554
|
|
|
29875
|
-
_ds.finalRecordId = func.datasource.get_currentRecordId(
|
|
29876
|
-
SESSION_ID,
|
|
29877
|
-
dataSourceSession,
|
|
29878
|
-
true
|
|
29879
|
-
);
|
|
29555
|
+
_ds.finalRecordId = func.datasource.get_currentRecordId(SESSION_ID, dataSourceSession, true);
|
|
29880
29556
|
_ds.currentRecordId = _ds.finalRecordId;
|
|
29881
29557
|
};
|
|
29882
29558
|
|
|
@@ -29884,11 +29560,7 @@ func.datasource.execute = async function (
|
|
|
29884
29560
|
const idx = Number(key);
|
|
29885
29561
|
|
|
29886
29562
|
if (await get_before_record_count()) {
|
|
29887
|
-
await func.datasource.execute_view_events(
|
|
29888
|
-
SESSION_ID,
|
|
29889
|
-
dataSourceSession,
|
|
29890
|
-
"before_record"
|
|
29891
|
-
);
|
|
29563
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
29892
29564
|
}
|
|
29893
29565
|
|
|
29894
29566
|
// await func.datasource.run_rows_form(
|
|
@@ -29902,28 +29574,13 @@ func.datasource.execute = async function (
|
|
|
29902
29574
|
|
|
29903
29575
|
_ds.currentRecordId = raw_data_row.id; // set temporary to allow expression decoder work
|
|
29904
29576
|
|
|
29905
|
-
await func.datasource.render_fields_form(
|
|
29906
|
-
SESSION_ID,
|
|
29907
|
-
dataSourceSession,
|
|
29908
|
-
raw_data_row
|
|
29909
|
-
);
|
|
29577
|
+
await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, raw_data_row);
|
|
29910
29578
|
|
|
29911
29579
|
try {
|
|
29912
|
-
const init_count = await func.datasource.get_field_init_count(
|
|
29913
|
-
SESSION_ID,
|
|
29914
|
-
dataSourceSession,
|
|
29915
|
-
raw_data_row.id,
|
|
29916
|
-
false,
|
|
29917
|
-
_ds.oninit_triggers_to_run
|
|
29918
|
-
);
|
|
29580
|
+
const init_count = await func.datasource.get_field_init_count(SESSION_ID, dataSourceSession, raw_data_row.id, false, _ds.oninit_triggers_to_run);
|
|
29919
29581
|
|
|
29920
29582
|
if (init_count > 0) {
|
|
29921
|
-
await func.datasource.execute_field_init_events(
|
|
29922
|
-
SESSION_ID,
|
|
29923
|
-
dataSourceSession,
|
|
29924
|
-
"form",
|
|
29925
|
-
raw_data_row.id
|
|
29926
|
-
);
|
|
29583
|
+
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', raw_data_row.id);
|
|
29927
29584
|
}
|
|
29928
29585
|
} catch (err) {
|
|
29929
29586
|
console.error(err);
|
|
@@ -29932,11 +29589,7 @@ func.datasource.execute = async function (
|
|
|
29932
29589
|
/////////////////////
|
|
29933
29590
|
|
|
29934
29591
|
if (await get_after_record_count()) {
|
|
29935
|
-
await func.datasource.execute_view_events(
|
|
29936
|
-
SESSION_ID,
|
|
29937
|
-
dataSourceSession,
|
|
29938
|
-
"after_record"
|
|
29939
|
-
);
|
|
29592
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
29940
29593
|
}
|
|
29941
29594
|
}
|
|
29942
29595
|
await finish_form();
|
|
@@ -29944,82 +29597,42 @@ func.datasource.execute = async function (
|
|
|
29944
29597
|
break;
|
|
29945
29598
|
|
|
29946
29599
|
default:
|
|
29947
|
-
return func.utils.debug_report(
|
|
29948
|
-
SESSION_ID,
|
|
29949
|
-
"Data source",
|
|
29950
|
-
"Program type not defined",
|
|
29951
|
-
"E"
|
|
29952
|
-
);
|
|
29600
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Program type not defined', 'E');
|
|
29953
29601
|
}
|
|
29954
29602
|
|
|
29955
29603
|
ret = await callback_datasource();
|
|
29956
29604
|
return ret;
|
|
29957
29605
|
};
|
|
29958
29606
|
|
|
29959
|
-
func.datasource.render_fields_dataset = async function (
|
|
29960
|
-
SESSION_ID,
|
|
29961
|
-
dataSourceSession,
|
|
29962
|
-
raw_data_row
|
|
29963
|
-
) {
|
|
29607
|
+
func.datasource.render_fields_dataset = async function (SESSION_ID, dataSourceSession, raw_data_row) {
|
|
29964
29608
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
29965
29609
|
var args = _ds.args;
|
|
29966
29610
|
|
|
29967
|
-
const _progFields = await func.datasource.get_progFields(
|
|
29968
|
-
SESSION_ID,
|
|
29969
|
-
dataSourceSession
|
|
29970
|
-
);
|
|
29611
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSourceSession);
|
|
29971
29612
|
|
|
29972
29613
|
if (!_progFields) {
|
|
29973
29614
|
return;
|
|
29974
29615
|
}
|
|
29975
29616
|
|
|
29976
29617
|
const get_value = async (field_id, value) => {
|
|
29977
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
29978
|
-
_progFields,
|
|
29979
|
-
"field_id",
|
|
29980
|
-
field_id
|
|
29981
|
-
);
|
|
29618
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
29982
29619
|
var fieldType = view_field_obj?.props?.fieldType;
|
|
29983
29620
|
let table_field_obj;
|
|
29984
|
-
if (view_field_obj.data.type ===
|
|
29621
|
+
if (view_field_obj.data.type === 'table' && field_id !== 'REDUCE_VALUE') {
|
|
29985
29622
|
if (!_ds.progDataSource?.dataSourceTableId) {
|
|
29986
|
-
return func.utils.debug_report(
|
|
29987
|
-
SESSION_ID,
|
|
29988
|
-
"Datasource",
|
|
29989
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
29990
|
-
"E"
|
|
29991
|
-
);
|
|
29623
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
29992
29624
|
}
|
|
29993
29625
|
|
|
29994
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
29995
|
-
SESSION_ID,
|
|
29996
|
-
_ds._dataSourceTableId
|
|
29997
|
-
);
|
|
29626
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
29998
29627
|
|
|
29999
29628
|
if (!table_obj) {
|
|
30000
|
-
return func.utils.debug_report(
|
|
30001
|
-
SESSION_ID,
|
|
30002
|
-
"Datasource",
|
|
30003
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
30004
|
-
"E"
|
|
30005
|
-
);
|
|
29629
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
30006
29630
|
}
|
|
30007
|
-
table_field_obj = func.common.find_item_by_key(
|
|
30008
|
-
table_obj.tableFields,
|
|
30009
|
-
"field_id",
|
|
30010
|
-
field_id
|
|
30011
|
-
);
|
|
29631
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
30012
29632
|
fieldType = table_field_obj.props?.fieldType;
|
|
30013
29633
|
}
|
|
30014
29634
|
|
|
30015
|
-
return await func.common.get_cast_val(
|
|
30016
|
-
SESSION_ID,
|
|
30017
|
-
`render fields dataset ${_ds.viewSourceDesc}`,
|
|
30018
|
-
field_id,
|
|
30019
|
-
fieldType,
|
|
30020
|
-
value,
|
|
30021
|
-
null
|
|
30022
|
-
);
|
|
29635
|
+
return await func.common.get_cast_val(SESSION_ID, `render fields dataset ${_ds.viewSourceDesc}`, field_id, fieldType, value, null);
|
|
30023
29636
|
};
|
|
30024
29637
|
|
|
30025
29638
|
if (!_ds.data_feed) {
|
|
@@ -30040,64 +29653,38 @@ func.datasource.render_fields_dataset = async function (
|
|
|
30040
29653
|
try {
|
|
30041
29654
|
var fieldId = val.data.field_id;
|
|
30042
29655
|
|
|
30043
|
-
if (val.data.type ===
|
|
30044
|
-
if (typeof raw_data_row?.value?.[fieldId] !==
|
|
29656
|
+
if (val.data.type === 'virtual' || _ds.set_mode === 'C') {
|
|
29657
|
+
if (typeof raw_data_row?.value?.[fieldId] !== 'undefined') {
|
|
30045
29658
|
// supports x=x+1
|
|
30046
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30047
|
-
fieldId,
|
|
30048
|
-
raw_data_row.value[fieldId]
|
|
30049
|
-
);
|
|
29659
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
30050
29660
|
continue;
|
|
30051
29661
|
}
|
|
30052
29662
|
|
|
30053
29663
|
if (val.props?.propExpressions?.fieldValue) {
|
|
30054
|
-
let ret = await func.expression.get(
|
|
30055
|
-
|
|
30056
|
-
val.props?.propExpressions?.fieldValue,
|
|
30057
|
-
dataSourceSession,
|
|
30058
|
-
"update",
|
|
30059
|
-
args.rowIdP
|
|
30060
|
-
);
|
|
30061
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30062
|
-
fieldId,
|
|
30063
|
-
ret.result
|
|
30064
|
-
);
|
|
29664
|
+
let ret = await func.expression.get(SESSION_ID, val.props?.propExpressions?.fieldValue, dataSourceSession, 'update', args.rowIdP);
|
|
29665
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, ret.result);
|
|
30065
29666
|
continue;
|
|
30066
29667
|
}
|
|
30067
29668
|
|
|
30068
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30069
|
-
fieldId,
|
|
30070
|
-
val.props?.fieldValue
|
|
30071
|
-
);
|
|
29669
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, val.props?.fieldValue);
|
|
30072
29670
|
continue;
|
|
30073
29671
|
}
|
|
30074
|
-
if (val.data.type ===
|
|
30075
|
-
if (typeof raw_data_row.value[fieldId] ===
|
|
30076
|
-
throw
|
|
29672
|
+
if (val.data.type === 'table' || val.data.type === 'datasource') {
|
|
29673
|
+
if (typeof raw_data_row.value[fieldId] === 'undefined') {
|
|
29674
|
+
throw 'field do not exist in data: ' + fieldId;
|
|
30077
29675
|
}
|
|
30078
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30079
|
-
fieldId,
|
|
30080
|
-
raw_data_row.value[fieldId]
|
|
30081
|
-
);
|
|
29676
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
30082
29677
|
}
|
|
30083
29678
|
} catch (err) {
|
|
30084
|
-
func.utils.debug_report(SESSION_ID,
|
|
29679
|
+
func.utils.debug_report(SESSION_ID, 'Datasource', err, 'E', null, _ds);
|
|
30085
29680
|
}
|
|
30086
29681
|
}
|
|
30087
29682
|
};
|
|
30088
29683
|
|
|
30089
|
-
func.datasource.run_events_functions = async function (
|
|
30090
|
-
|
|
30091
|
-
|
|
30092
|
-
|
|
30093
|
-
calling_job,
|
|
30094
|
-
async_event,
|
|
30095
|
-
event_parameters
|
|
30096
|
-
) {
|
|
30097
|
-
|
|
30098
|
-
if (typeof dataSourceSession === "undefined" || dataSourceSession === null) {
|
|
30099
|
-
console.warn(`Event ${event_id} not exist or not found`)
|
|
30100
|
-
return
|
|
29684
|
+
func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSession, event_id, calling_job, async_event, event_parameters) {
|
|
29685
|
+
if (typeof dataSourceSession === 'undefined' || dataSourceSession === null) {
|
|
29686
|
+
console.warn(`Event ${event_id} not exist or not found`);
|
|
29687
|
+
return;
|
|
30101
29688
|
}
|
|
30102
29689
|
|
|
30103
29690
|
// return new Promise(async (resolve, reject) => {
|
|
@@ -30105,123 +29692,75 @@ func.datasource.run_events_functions = async function (
|
|
|
30105
29692
|
var args = _ds.args;
|
|
30106
29693
|
// var v = _ds.v;
|
|
30107
29694
|
const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
30108
|
-
let job_promises = []
|
|
29695
|
+
let job_promises = [];
|
|
30109
29696
|
if (_view_obj.progEvents) {
|
|
30110
29697
|
for await (const [key, val] of Object.entries(_view_obj.progEvents)) {
|
|
30111
|
-
if (
|
|
30112
|
-
val.data.type === "user_defined" &&
|
|
30113
|
-
val.data.event_name &&
|
|
30114
|
-
val.data.event_name === event_id
|
|
30115
|
-
) {
|
|
29698
|
+
if (val.data.type === 'user_defined' && val.data.event_name && val.data.event_name === event_id) {
|
|
30116
29699
|
const jobs = await func.events.validate(
|
|
30117
29700
|
SESSION_ID,
|
|
30118
|
-
|
|
29701
|
+
'user_defined',
|
|
30119
29702
|
dataSourceSession,
|
|
30120
29703
|
val.data.event_name,
|
|
30121
29704
|
args.callingSourceP,
|
|
30122
|
-
event_parameters// val.data.parameters
|
|
29705
|
+
event_parameters, // val.data.parameters
|
|
30123
29706
|
);
|
|
30124
29707
|
|
|
30125
|
-
if (calling_job || async_event) continue
|
|
29708
|
+
if (calling_job || async_event) continue;
|
|
30126
29709
|
|
|
30127
29710
|
for (let job_num of jobs) {
|
|
30128
|
-
job_promises.push(
|
|
30129
|
-
|
|
30130
|
-
|
|
30131
|
-
|
|
30132
|
-
|
|
30133
|
-
|
|
30134
|
-
|
|
30135
|
-
|
|
30136
|
-
|
|
30137
|
-
|
|
29711
|
+
job_promises.push(
|
|
29712
|
+
new Promise((resolve, reject) => {
|
|
29713
|
+
const interval = setInterval(() => {
|
|
29714
|
+
var job_index = func.events.find_job_index(SESSION_ID, job_num);
|
|
29715
|
+
if (job_index == null) {
|
|
29716
|
+
clearInterval(interval);
|
|
29717
|
+
resolve(job_num);
|
|
29718
|
+
}
|
|
29719
|
+
}, 100);
|
|
29720
|
+
}),
|
|
29721
|
+
);
|
|
30138
29722
|
}
|
|
30139
29723
|
}
|
|
30140
29724
|
}
|
|
30141
|
-
|
|
30142
|
-
|
|
30143
|
-
|
|
30144
29725
|
}
|
|
30145
29726
|
if (job_promises.length) {
|
|
30146
|
-
await Promise.all(job_promises)
|
|
29727
|
+
await Promise.all(job_promises);
|
|
30147
29728
|
}
|
|
30148
|
-
|
|
30149
|
-
|
|
30150
29729
|
};
|
|
30151
29730
|
|
|
30152
|
-
func.datasource.render_fields_form = async function (
|
|
30153
|
-
SESSION_ID,
|
|
30154
|
-
dataSourceSession,
|
|
30155
|
-
raw_data_row
|
|
30156
|
-
) {
|
|
29731
|
+
func.datasource.render_fields_form = async function (SESSION_ID, dataSourceSession, raw_data_row) {
|
|
30157
29732
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30158
29733
|
|
|
30159
|
-
const _progFields = await func.datasource.get_progFields(
|
|
30160
|
-
SESSION_ID,
|
|
30161
|
-
dataSourceSession
|
|
30162
|
-
);
|
|
29734
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSourceSession);
|
|
30163
29735
|
|
|
30164
29736
|
if (!_progFields) {
|
|
30165
29737
|
return;
|
|
30166
29738
|
}
|
|
30167
29739
|
|
|
30168
29740
|
const get_value = async (field_id, value) => {
|
|
30169
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
30170
|
-
_progFields,
|
|
30171
|
-
"field_id",
|
|
30172
|
-
field_id
|
|
30173
|
-
);
|
|
29741
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
30174
29742
|
var fieldType = view_field_obj.props?.fieldType;
|
|
30175
29743
|
let table_field_obj;
|
|
30176
|
-
if (view_field_obj.data.type ===
|
|
29744
|
+
if (view_field_obj.data.type === 'table' && field_id !== 'REDUCE_VALUE') {
|
|
30177
29745
|
if (!_ds._dataSourceTableId) {
|
|
30178
|
-
return func.utils.debug_report(
|
|
30179
|
-
SESSION_ID,
|
|
30180
|
-
"Datasource",
|
|
30181
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
30182
|
-
"E"
|
|
30183
|
-
);
|
|
29746
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
30184
29747
|
}
|
|
30185
29748
|
|
|
30186
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
30187
|
-
SESSION_ID,
|
|
30188
|
-
_ds._dataSourceTableId
|
|
30189
|
-
);
|
|
29749
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
30190
29750
|
|
|
30191
29751
|
if (!table_obj) {
|
|
30192
|
-
return func.utils.debug_report(
|
|
30193
|
-
SESSION_ID,
|
|
30194
|
-
"Datasource",
|
|
30195
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
30196
|
-
"E"
|
|
30197
|
-
);
|
|
29752
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
30198
29753
|
}
|
|
30199
|
-
table_field_obj = func.common.find_item_by_key(
|
|
30200
|
-
table_obj.tableFields,
|
|
30201
|
-
"field_id",
|
|
30202
|
-
field_id
|
|
30203
|
-
);
|
|
29754
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
30204
29755
|
|
|
30205
29756
|
if (!table_field_obj) {
|
|
30206
|
-
return func.utils.debug_report(
|
|
30207
|
-
SESSION_ID,
|
|
30208
|
-
"Datasource",
|
|
30209
|
-
`Field Id: ${field_id} not exist in table ${table_obj.properties.menuName}`,
|
|
30210
|
-
"E"
|
|
30211
|
-
);
|
|
29757
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Field Id: ${field_id} not exist in table ${table_obj.properties.menuName}`, 'E');
|
|
30212
29758
|
}
|
|
30213
29759
|
|
|
30214
29760
|
fieldType = table_field_obj.props?.fieldType;
|
|
30215
29761
|
}
|
|
30216
29762
|
|
|
30217
|
-
return await func.common.get_cast_val(
|
|
30218
|
-
SESSION_ID,
|
|
30219
|
-
`render fields datasource ${_ds.viewSourceDesc}`,
|
|
30220
|
-
field_id,
|
|
30221
|
-
fieldType,
|
|
30222
|
-
value,
|
|
30223
|
-
null
|
|
30224
|
-
);
|
|
29763
|
+
return await func.common.get_cast_val(SESSION_ID, `render fields datasource ${_ds.viewSourceDesc}`, field_id, fieldType, value, null);
|
|
30225
29764
|
};
|
|
30226
29765
|
|
|
30227
29766
|
let row_idx;
|
|
@@ -30238,29 +29777,20 @@ func.datasource.render_fields_form = async function (
|
|
|
30238
29777
|
try {
|
|
30239
29778
|
var fieldId = val.data.field_id;
|
|
30240
29779
|
|
|
30241
|
-
if (val.data.type ===
|
|
29780
|
+
if (val.data.type === 'virtual' || raw_data_row.id === 'newRecord') {
|
|
30242
29781
|
if (glb.PROTECTED_VARS.includes(fieldId)) {
|
|
30243
29782
|
switch (fieldId) {
|
|
30244
|
-
case
|
|
30245
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30246
|
-
fieldId,
|
|
30247
|
-
row_idx
|
|
30248
|
-
);
|
|
29783
|
+
case '_ROWNO': {
|
|
29784
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, row_idx);
|
|
30249
29785
|
continue;
|
|
30250
29786
|
}
|
|
30251
|
-
case
|
|
30252
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30253
|
-
fieldId,
|
|
30254
|
-
raw_data_row.id
|
|
30255
|
-
);
|
|
29787
|
+
case '_ROWID': {
|
|
29788
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.id);
|
|
30256
29789
|
|
|
30257
29790
|
continue;
|
|
30258
29791
|
}
|
|
30259
|
-
case
|
|
30260
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30261
|
-
fieldId,
|
|
30262
|
-
raw_data_row.value
|
|
30263
|
-
);
|
|
29792
|
+
case '_ROWDOC': {
|
|
29793
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value);
|
|
30264
29794
|
|
|
30265
29795
|
continue;
|
|
30266
29796
|
}
|
|
@@ -30269,39 +29799,24 @@ func.datasource.render_fields_form = async function (
|
|
|
30269
29799
|
|
|
30270
29800
|
if (val.props?.propExpressions?.fieldValue) {
|
|
30271
29801
|
// check init exp existence
|
|
30272
|
-
let ret = await func.expression.get(
|
|
30273
|
-
|
|
30274
|
-
val.props?.propExpressions?.fieldValue,
|
|
30275
|
-
dataSourceSession,
|
|
30276
|
-
"update",
|
|
30277
|
-
raw_data_row.id
|
|
30278
|
-
);
|
|
30279
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30280
|
-
fieldId,
|
|
30281
|
-
ret.result
|
|
30282
|
-
);
|
|
29802
|
+
let ret = await func.expression.get(SESSION_ID, val.props?.propExpressions?.fieldValue, dataSourceSession, 'update', raw_data_row.id);
|
|
29803
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, ret.result);
|
|
30283
29804
|
|
|
30284
29805
|
continue;
|
|
30285
29806
|
}
|
|
30286
29807
|
|
|
30287
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30288
|
-
fieldId,
|
|
30289
|
-
val.props?.fieldValue
|
|
30290
|
-
);
|
|
29808
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, val.props?.fieldValue);
|
|
30291
29809
|
|
|
30292
29810
|
continue;
|
|
30293
29811
|
}
|
|
30294
|
-
if (val.data.type ===
|
|
30295
|
-
if (typeof raw_data_row.value[fieldId] ===
|
|
30296
|
-
throw
|
|
29812
|
+
if (val.data.type === 'table' || val.data.type === 'datasource') {
|
|
29813
|
+
if (typeof raw_data_row.value[fieldId] === 'undefined') {
|
|
29814
|
+
throw 'field do not exist in data: ' + fieldId;
|
|
30297
29815
|
}
|
|
30298
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
30299
|
-
fieldId,
|
|
30300
|
-
raw_data_row.value[fieldId]
|
|
30301
|
-
);
|
|
29816
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
30302
29817
|
}
|
|
30303
29818
|
} catch (err) {
|
|
30304
|
-
func.utils.debug_report(SESSION_ID,
|
|
29819
|
+
func.utils.debug_report(SESSION_ID, 'Datasource', err, 'E', null, _ds);
|
|
30305
29820
|
}
|
|
30306
29821
|
}
|
|
30307
29822
|
};
|
|
@@ -30364,12 +29879,7 @@ func.datasource.render_fields_form = async function (
|
|
|
30364
29879
|
// // await form_continue();
|
|
30365
29880
|
// };
|
|
30366
29881
|
|
|
30367
|
-
func.datasource.execute_field_init_events = async function (
|
|
30368
|
-
SESSION_ID,
|
|
30369
|
-
dataSourceSession,
|
|
30370
|
-
sourceP,
|
|
30371
|
-
rowIdP
|
|
30372
|
-
) {
|
|
29882
|
+
func.datasource.execute_field_init_events = async function (SESSION_ID, dataSourceSession, sourceP, rowIdP) {
|
|
30373
29883
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30374
29884
|
var args = _ds.args;
|
|
30375
29885
|
var arr = _ds.dataSource_init_arr[rowIdP];
|
|
@@ -30379,21 +29889,11 @@ func.datasource.execute_field_init_events = async function (
|
|
|
30379
29889
|
if (!func.utils.is_onscreen_event(val.eventInfo.data.action)) {
|
|
30380
29890
|
var cond = val?.eventInfo?.data?.enabled;
|
|
30381
29891
|
var expression = undefined;
|
|
30382
|
-
if (val.eventInfo.props.condition)
|
|
30383
|
-
expression = val.eventInfo.props.condition;
|
|
29892
|
+
if (val.eventInfo.props.condition) expression = val.eventInfo.props.condition;
|
|
30384
29893
|
var expCond = {};
|
|
30385
29894
|
if (expression && !_.isEmpty(expression)) {
|
|
30386
29895
|
// check if expression exist
|
|
30387
|
-
expCond = await func.expression.get(
|
|
30388
|
-
SESSION_ID,
|
|
30389
|
-
expression,
|
|
30390
|
-
dataSourceSession,
|
|
30391
|
-
"condition",
|
|
30392
|
-
rowIdP,
|
|
30393
|
-
null,
|
|
30394
|
-
null,
|
|
30395
|
-
val.fieldId
|
|
30396
|
-
); // execute expression
|
|
29896
|
+
expCond = await func.expression.get(SESSION_ID, expression, dataSourceSession, 'condition', rowIdP, null, null, val.fieldId); // execute expression
|
|
30397
29897
|
cond = expCond.result;
|
|
30398
29898
|
expCond.conditional = true;
|
|
30399
29899
|
val.DEBUG_INFO_OBJ.result = expCond.result;
|
|
@@ -30435,20 +29935,14 @@ func.datasource.execute_field_init_events = async function (
|
|
|
30435
29935
|
null,
|
|
30436
29936
|
null,
|
|
30437
29937
|
null,
|
|
30438
|
-
ds.parentDataSourceNo
|
|
29938
|
+
ds.parentDataSourceNo,
|
|
30439
29939
|
);
|
|
30440
29940
|
}
|
|
30441
29941
|
}
|
|
30442
29942
|
}
|
|
30443
29943
|
};
|
|
30444
29944
|
|
|
30445
|
-
func.datasource.get_field_init_count = async function (
|
|
30446
|
-
SESSION_ID,
|
|
30447
|
-
dataSourceSession,
|
|
30448
|
-
rowIdP,
|
|
30449
|
-
pre_initP,
|
|
30450
|
-
oninit_triggers_to_runP
|
|
30451
|
-
) {
|
|
29945
|
+
func.datasource.get_field_init_count = async function (SESSION_ID, dataSourceSession, rowIdP, pre_initP, oninit_triggers_to_runP) {
|
|
30452
29946
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30453
29947
|
var args = _ds.args;
|
|
30454
29948
|
|
|
@@ -30464,25 +29958,15 @@ func.datasource.get_field_init_count = async function (
|
|
|
30464
29958
|
continue;
|
|
30465
29959
|
}
|
|
30466
29960
|
for await (const trigger_obj of field_obj.triggers) {
|
|
30467
|
-
if (
|
|
30468
|
-
oninit_triggers_to_runP &&
|
|
30469
|
-
!oninit_triggers_to_runP?.includes(trigger_obj.id)
|
|
30470
|
-
) {
|
|
29961
|
+
if (oninit_triggers_to_runP && !oninit_triggers_to_runP?.includes(trigger_obj.id)) {
|
|
30471
29962
|
continue;
|
|
30472
29963
|
}
|
|
30473
29964
|
if (
|
|
30474
29965
|
// trigger_obj.data.trigger === "oninit" &&
|
|
30475
|
-
[
|
|
30476
|
-
trigger_obj.data.action
|
|
30477
|
-
)
|
|
29966
|
+
['get_data', 'set_data', 'batch', 'update', 'raise_event'].includes(trigger_obj.data.action)
|
|
30478
29967
|
) {
|
|
30479
29968
|
if (!trigger_obj.data.action) {
|
|
30480
|
-
func.utils.debug_report(
|
|
30481
|
-
SESSION_ID,
|
|
30482
|
-
"_ds.get_field_init_count",
|
|
30483
|
-
`Error initiating event for field: ${fieldId} prog: ${_ds.v.viewSourceDesc} row: ${rowIdP} reason: missing action`,
|
|
30484
|
-
"E"
|
|
30485
|
-
);
|
|
29969
|
+
func.utils.debug_report(SESSION_ID, '_ds.get_field_init_count', `Error initiating event for field: ${fieldId} prog: ${_ds.v.viewSourceDesc} row: ${rowIdP} reason: missing action`, 'E');
|
|
30486
29970
|
break;
|
|
30487
29971
|
}
|
|
30488
29972
|
|
|
@@ -30516,14 +30000,14 @@ func.datasource.get_field_init_count = async function (
|
|
|
30516
30000
|
fieldId: fieldId,
|
|
30517
30001
|
rowId: rowIdP,
|
|
30518
30002
|
colId: field_obj.id,
|
|
30519
|
-
node_id: args.prog_id +
|
|
30003
|
+
node_id: args.prog_id + '_' + trigger_obj.id + '_' + field_obj.id,
|
|
30520
30004
|
fieldProp: field_obj,
|
|
30521
30005
|
DEBUG_INFO_OBJ: {
|
|
30522
30006
|
module: _ds.viewModule,
|
|
30523
|
-
action:
|
|
30007
|
+
action: 'init field event',
|
|
30524
30008
|
prop: fieldId,
|
|
30525
30009
|
source: _ds.viewSourceDesc,
|
|
30526
|
-
type:
|
|
30010
|
+
type: 'event',
|
|
30527
30011
|
prog_id: args.prog_id,
|
|
30528
30012
|
dsSession: dataSourceSession,
|
|
30529
30013
|
},
|
|
@@ -30537,19 +30021,14 @@ func.datasource.get_field_init_count = async function (
|
|
|
30537
30021
|
return ret;
|
|
30538
30022
|
};
|
|
30539
30023
|
|
|
30540
|
-
func.datasource.get_view_events_count = async function (
|
|
30541
|
-
SESSION_ID,
|
|
30542
|
-
dataSourceSession,
|
|
30543
|
-
typeP,
|
|
30544
|
-
eventIdP
|
|
30545
|
-
) {
|
|
30024
|
+
func.datasource.get_view_events_count = async function (SESSION_ID, dataSourceSession, typeP, eventIdP) {
|
|
30546
30025
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30547
30026
|
const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
30548
30027
|
if (!_ds) return 0;
|
|
30549
30028
|
var args = _ds.args;
|
|
30550
30029
|
|
|
30551
30030
|
var index = typeP;
|
|
30552
|
-
if (eventIdP) index = typeP +
|
|
30031
|
+
if (eventIdP) index = typeP + '_' + eventIdP;
|
|
30553
30032
|
|
|
30554
30033
|
// client interval
|
|
30555
30034
|
if (!_ds.viewEventExec_arr) _ds.viewEventExec_arr = {};
|
|
@@ -30563,18 +30042,7 @@ func.datasource.get_view_events_count = async function (
|
|
|
30563
30042
|
if (eventIdP && event_obj.id !== eventIdP) continue; // match w ID added 03312017
|
|
30564
30043
|
|
|
30565
30044
|
if (event_obj.data.condition) {
|
|
30566
|
-
let res = await func.expression.get(
|
|
30567
|
-
SESSION_ID,
|
|
30568
|
-
event_obj.data.condition,
|
|
30569
|
-
dataSourceSession,
|
|
30570
|
-
"condition",
|
|
30571
|
-
args.rowIdP,
|
|
30572
|
-
null,
|
|
30573
|
-
null,
|
|
30574
|
-
null,
|
|
30575
|
-
null,
|
|
30576
|
-
event_obj
|
|
30577
|
-
);
|
|
30045
|
+
let res = await func.expression.get(SESSION_ID, event_obj.data.condition, dataSourceSession, 'condition', args.rowIdP, null, null, null, null, event_obj);
|
|
30578
30046
|
if (!res.result) {
|
|
30579
30047
|
continue;
|
|
30580
30048
|
}
|
|
@@ -30584,13 +30052,12 @@ func.datasource.get_view_events_count = async function (
|
|
|
30584
30052
|
for (const trigger_obj of event_obj.triggers) {
|
|
30585
30053
|
if (trigger_obj.data.enabled) {
|
|
30586
30054
|
var expression;
|
|
30587
|
-
if (trigger_obj.props.condition)
|
|
30588
|
-
expression = trigger_obj.props.condition;
|
|
30055
|
+
if (trigger_obj.props.condition) expression = trigger_obj.props.condition;
|
|
30589
30056
|
var expCond = {};
|
|
30590
30057
|
if (expression) {
|
|
30591
30058
|
expCond.conditional = true;
|
|
30592
30059
|
}
|
|
30593
|
-
func.utils.debug.log(SESSION_ID, args.prog_id +
|
|
30060
|
+
func.utils.debug.log(SESSION_ID, args.prog_id + '_' + trigger_obj.id, {
|
|
30594
30061
|
module: _ds.viewModule,
|
|
30595
30062
|
action: trigger_obj.data.action,
|
|
30596
30063
|
prop: event_obj.data.type,
|
|
@@ -30599,31 +30066,18 @@ func.datasource.get_view_events_count = async function (
|
|
|
30599
30066
|
error: expCond.error,
|
|
30600
30067
|
source: _ds.viewSourceDesc,
|
|
30601
30068
|
fields: expCond.fields,
|
|
30602
|
-
type:
|
|
30069
|
+
type: 'event',
|
|
30603
30070
|
prog_id: args.prog_id,
|
|
30604
30071
|
dsSession: dataSourceSession,
|
|
30605
30072
|
conditional: expCond.conditional,
|
|
30606
30073
|
});
|
|
30607
30074
|
}
|
|
30608
30075
|
if (!trigger_obj.data.action) {
|
|
30609
|
-
func.utils.debug_report(
|
|
30610
|
-
SESSION_ID,
|
|
30611
|
-
"get_view_events_count",
|
|
30612
|
-
`Error initiating ${typeP} prog:${_ds.v.viewSourceDesc} reason: missing action`,
|
|
30613
|
-
"E"
|
|
30614
|
-
);
|
|
30076
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog:${_ds.v.viewSourceDesc} reason: missing action`, 'E');
|
|
30615
30077
|
break;
|
|
30616
|
-
}
|
|
30617
|
-
if (
|
|
30618
|
-
|
|
30619
|
-
!trigger_obj.data.action
|
|
30620
|
-
) {
|
|
30621
|
-
func.utils.debug_report(
|
|
30622
|
-
SESSION_ID,
|
|
30623
|
-
"get_view_events_count",
|
|
30624
|
-
`Error initiating ${typeP} prog: ${_ds.v.viewSourceDesc} reason: missing reference`,
|
|
30625
|
-
"E"
|
|
30626
|
-
);
|
|
30078
|
+
}
|
|
30079
|
+
if (!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) && !trigger_obj.data.action) {
|
|
30080
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.v.viewSourceDesc} reason: missing reference`, 'E');
|
|
30627
30081
|
break;
|
|
30628
30082
|
}
|
|
30629
30083
|
if (trigger_obj.data.enabled) {
|
|
@@ -30639,50 +30093,28 @@ func.datasource.get_view_events_count = async function (
|
|
|
30639
30093
|
}
|
|
30640
30094
|
return _ds.viewEventExec_arr[index].length;
|
|
30641
30095
|
};
|
|
30642
|
-
func.datasource.execute_view_events = async function (
|
|
30643
|
-
SESSION_ID,
|
|
30644
|
-
dataSourceSession,
|
|
30645
|
-
typeP,
|
|
30646
|
-
eventIdP
|
|
30647
|
-
) {
|
|
30096
|
+
func.datasource.execute_view_events = async function (SESSION_ID, dataSourceSession, typeP, eventIdP) {
|
|
30648
30097
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30649
30098
|
var args = _ds.args;
|
|
30650
30099
|
|
|
30651
30100
|
var i = -1;
|
|
30652
30101
|
var index = typeP;
|
|
30653
|
-
if (eventIdP) index = typeP +
|
|
30102
|
+
if (eventIdP) index = typeP + '_' + eventIdP;
|
|
30654
30103
|
var arr = _ds.viewEventExec_arr[index];
|
|
30655
30104
|
if (_.isEmpty(arr)) return;
|
|
30656
30105
|
|
|
30657
30106
|
for await (const val of arr) {
|
|
30658
|
-
if (
|
|
30659
|
-
!glb.IS_WORKER ||
|
|
30660
|
-
!func.utils.is_onscreen_event(val.eventInfo.data.action) ||
|
|
30661
|
-
(glb.IS_WORKER &&
|
|
30662
|
-
_ds.v.run_at === "server" &&
|
|
30663
|
-
!func.utils.is_onscreen_event(val.eventInfo.data.action))
|
|
30664
|
-
) {
|
|
30107
|
+
if (!glb.IS_WORKER || !func.utils.is_onscreen_event(val.eventInfo.data.action) || (glb.IS_WORKER && _ds.v.run_at === 'server' && !func.utils.is_onscreen_event(val.eventInfo.data.action))) {
|
|
30665
30108
|
// val.done = true;
|
|
30666
30109
|
var cond = true;
|
|
30667
30110
|
if (val.expression) {
|
|
30668
|
-
var expCond = await func.expression.get(
|
|
30669
|
-
SESSION_ID,
|
|
30670
|
-
val.expression,
|
|
30671
|
-
dataSourceSession,
|
|
30672
|
-
"condition",
|
|
30673
|
-
args.rowIdP,
|
|
30674
|
-
null,
|
|
30675
|
-
null,
|
|
30676
|
-
null,
|
|
30677
|
-
null,
|
|
30678
|
-
val.eventInfo
|
|
30679
|
-
); // execute expression
|
|
30111
|
+
var expCond = await func.expression.get(SESSION_ID, val.expression, dataSourceSession, 'condition', args.rowIdP, null, null, null, null, val.eventInfo); // execute expression
|
|
30680
30112
|
cond = expCond.result;
|
|
30681
30113
|
}
|
|
30682
30114
|
if (cond) {
|
|
30683
30115
|
var elem_params = undefined;
|
|
30684
30116
|
if (!glb.IS_WORKER) {
|
|
30685
|
-
elem_params = $(
|
|
30117
|
+
elem_params = $('#' + _ds.containerId).data('params');
|
|
30686
30118
|
}
|
|
30687
30119
|
const ret = await func.events.execute(
|
|
30688
30120
|
SESSION_ID,
|
|
@@ -30699,39 +30131,28 @@ func.datasource.execute_view_events = async function (
|
|
|
30699
30131
|
null,
|
|
30700
30132
|
dataSourceSession,
|
|
30701
30133
|
val.eventId,
|
|
30702
|
-
_ds.tree_obj.menuType +
|
|
30134
|
+
_ds.tree_obj.menuType + ' event',
|
|
30703
30135
|
true,
|
|
30704
30136
|
null,
|
|
30705
30137
|
null,
|
|
30706
30138
|
args.jobNoP,
|
|
30707
30139
|
elem_params,
|
|
30708
30140
|
null,
|
|
30709
|
-
val.eventInfo
|
|
30141
|
+
val.eventInfo,
|
|
30710
30142
|
);
|
|
30711
30143
|
}
|
|
30712
30144
|
|
|
30713
30145
|
continue;
|
|
30714
30146
|
}
|
|
30715
30147
|
// on screen event
|
|
30716
|
-
if (
|
|
30717
|
-
typeP == "before_record" ||
|
|
30718
|
-
typeP == "after_record" ||
|
|
30719
|
-
typeP == "on_load" ||
|
|
30720
|
-
typeP == "on_exit"
|
|
30721
|
-
) {
|
|
30148
|
+
if (typeP == 'before_record' || typeP == 'after_record' || typeP == 'on_load' || typeP == 'on_exit') {
|
|
30722
30149
|
_ds.v.onscreen_events_active = {
|
|
30723
30150
|
i: i,
|
|
30724
30151
|
type: typeP,
|
|
30725
30152
|
};
|
|
30726
|
-
var parent_ds_chain = func.datasource.get_parent_ds_chain(
|
|
30727
|
-
SESSION_ID,
|
|
30728
|
-
dataSourceSession
|
|
30729
|
-
);
|
|
30153
|
+
var parent_ds_chain = func.datasource.get_parent_ds_chain(SESSION_ID, dataSourceSession);
|
|
30730
30154
|
var obj = {
|
|
30731
|
-
ds_obj: func.utils.clean_returned_datasource(
|
|
30732
|
-
SESSION_ID,
|
|
30733
|
-
dataSourceSession
|
|
30734
|
-
),
|
|
30155
|
+
ds_obj: func.utils.clean_returned_datasource(SESSION_ID, dataSourceSession),
|
|
30735
30156
|
dsSessionP: dataSourceSession,
|
|
30736
30157
|
};
|
|
30737
30158
|
obj.ds_obj.parent_ds_chain = parent_ds_chain;
|
|
@@ -30742,10 +30163,7 @@ func.datasource.get_parent_ds_chain = function (SESSION_ID, dataSourceSession) {
|
|
|
30742
30163
|
var arr = [];
|
|
30743
30164
|
var drill = function (ds) {
|
|
30744
30165
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[ds]) {
|
|
30745
|
-
if (
|
|
30746
|
-
typeof SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo !==
|
|
30747
|
-
"undefined"
|
|
30748
|
-
) {
|
|
30166
|
+
if (typeof SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo !== 'undefined') {
|
|
30749
30167
|
arr.push(SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo);
|
|
30750
30168
|
drill(SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo);
|
|
30751
30169
|
}
|
|
@@ -30754,11 +30172,7 @@ func.datasource.get_parent_ds_chain = function (SESSION_ID, dataSourceSession) {
|
|
|
30754
30172
|
drill(dataSourceSession);
|
|
30755
30173
|
return arr;
|
|
30756
30174
|
};
|
|
30757
|
-
func.datasource.execute_onscreen_view_events = async function (
|
|
30758
|
-
SESSION_ID,
|
|
30759
|
-
dataSourceSession,
|
|
30760
|
-
sourceP
|
|
30761
|
-
) {
|
|
30175
|
+
func.datasource.execute_onscreen_view_events = async function (SESSION_ID, dataSourceSession, sourceP) {
|
|
30762
30176
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30763
30177
|
var args = _ds.args;
|
|
30764
30178
|
|
|
@@ -30771,13 +30185,7 @@ func.datasource.execute_onscreen_view_events = async function (
|
|
|
30771
30185
|
|
|
30772
30186
|
var cond = true;
|
|
30773
30187
|
if (evnt.expression) {
|
|
30774
|
-
var expCond = await func.expression.get(
|
|
30775
|
-
SESSION_ID,
|
|
30776
|
-
evnt.expression,
|
|
30777
|
-
dataSourceSession,
|
|
30778
|
-
"condition",
|
|
30779
|
-
args.rowIdP
|
|
30780
|
-
); // execute expression
|
|
30188
|
+
var expCond = await func.expression.get(SESSION_ID, evnt.expression, dataSourceSession, 'condition', args.rowIdP); // execute expression
|
|
30781
30189
|
cond = expCond.result;
|
|
30782
30190
|
}
|
|
30783
30191
|
if (cond) {
|
|
@@ -30796,20 +30204,16 @@ func.datasource.execute_onscreen_view_events = async function (
|
|
|
30796
30204
|
null,
|
|
30797
30205
|
dataSourceSession,
|
|
30798
30206
|
null,
|
|
30799
|
-
sourceP +
|
|
30207
|
+
sourceP + ' event',
|
|
30800
30208
|
true,
|
|
30801
30209
|
null,
|
|
30802
30210
|
null,
|
|
30803
|
-
args.jobNoP
|
|
30211
|
+
args.jobNoP,
|
|
30804
30212
|
);
|
|
30805
30213
|
}
|
|
30806
|
-
} else console.error(
|
|
30214
|
+
} else console.error('*execute_onscreen_view_events error');
|
|
30807
30215
|
};
|
|
30808
|
-
func.datasource.get_event_interval_arr = function (
|
|
30809
|
-
SESSION_ID,
|
|
30810
|
-
dataSourceSession,
|
|
30811
|
-
typeP
|
|
30812
|
-
) {
|
|
30216
|
+
func.datasource.get_event_interval_arr = function (SESSION_ID, dataSourceSession, typeP) {
|
|
30813
30217
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
30814
30218
|
// var v = _ds.v;
|
|
30815
30219
|
var arr = [];
|
|
@@ -30850,19 +30254,17 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
|
|
|
30850
30254
|
Number(key) > 0 &&
|
|
30851
30255
|
(val.screenId === screenIdP ||
|
|
30852
30256
|
val.rootScreenId === screenIdP ||
|
|
30853
|
-
$(
|
|
30257
|
+
$('#' + val.screenId)
|
|
30854
30258
|
.parent()
|
|
30855
|
-
.attr(
|
|
30856
|
-
(val &&
|
|
30857
|
-
val.parentDataSourceNo &&
|
|
30858
|
-
arr.includes(val.parentDataSourceNo.toString())))
|
|
30259
|
+
.attr('id') === screenIdP ||
|
|
30260
|
+
(val && val.parentDataSourceNo && arr.includes(val.parentDataSourceNo.toString())))
|
|
30859
30261
|
) {
|
|
30860
30262
|
arr.push(key);
|
|
30861
30263
|
if (val.screenId) func.UI.utils.screen_blocker(false, val.screenId);
|
|
30862
30264
|
}
|
|
30863
30265
|
} catch (err) {
|
|
30864
|
-
console.warn(
|
|
30865
|
-
func.datasource.reset_jobs(SESSION_ID, key,
|
|
30266
|
+
console.warn('func.datasource.clean failed');
|
|
30267
|
+
func.datasource.reset_jobs(SESSION_ID, key, 'datasource.clean', err);
|
|
30866
30268
|
}
|
|
30867
30269
|
}
|
|
30868
30270
|
for (let val of arr) {
|
|
@@ -30870,27 +30272,19 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
|
|
|
30870
30272
|
}
|
|
30871
30273
|
};
|
|
30872
30274
|
func.datasource.del = function (SESSION_ID, dsP) {
|
|
30873
|
-
if (
|
|
30874
|
-
|
|
30875
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].keep_alive) ||
|
|
30876
|
-
dsP == 0
|
|
30877
|
-
)
|
|
30878
|
-
return;
|
|
30879
|
-
if (
|
|
30880
|
-
DATASOURCE_INTERVALS[SESSION_ID] &&
|
|
30881
|
-
DATASOURCE_INTERVALS[SESSION_ID][dsP]
|
|
30882
|
-
) {
|
|
30275
|
+
if ((SESSION_OBJ[SESSION_ID].DS_GLB[dsP] && SESSION_OBJ[SESSION_ID].DS_GLB[dsP].keep_alive) || dsP == 0) return;
|
|
30276
|
+
if (DATASOURCE_INTERVALS[SESSION_ID] && DATASOURCE_INTERVALS[SESSION_ID][dsP]) {
|
|
30883
30277
|
DATASOURCE_INTERVALS[SESSION_ID][dsP].clear();
|
|
30884
30278
|
}
|
|
30885
30279
|
|
|
30886
30280
|
const perform_delete = async function () {
|
|
30887
30281
|
var response = {
|
|
30888
|
-
success: function (jsonP, ajaxP) {
|
|
30282
|
+
success: function (jsonP, ajaxP) {},
|
|
30889
30283
|
error: function (status) {
|
|
30890
|
-
console.error(
|
|
30284
|
+
console.error('error datasource:' + status);
|
|
30891
30285
|
},
|
|
30892
30286
|
fail: function (status) {
|
|
30893
|
-
console.error(
|
|
30287
|
+
console.error('error datasource:' + status);
|
|
30894
30288
|
},
|
|
30895
30289
|
};
|
|
30896
30290
|
|
|
@@ -30904,14 +30298,9 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
30904
30298
|
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsP];
|
|
30905
30299
|
if (_ds.worker_id) {
|
|
30906
30300
|
// if (_ds.data_xuda) console.log(dsP);
|
|
30907
|
-
if (
|
|
30908
|
-
|
|
30909
|
-
|
|
30910
|
-
(!_session.opt.app_computing_mode ||
|
|
30911
|
-
_session.opt.app_computing_mode === "server")
|
|
30912
|
-
) {
|
|
30913
|
-
WEB_WORKER[SESSION_ID][_ds.worker_id].emit("message", {
|
|
30914
|
-
service: "close_websocket",
|
|
30301
|
+
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
|
|
30302
|
+
WEB_WORKER[SESSION_ID][_ds.worker_id].emit('message', {
|
|
30303
|
+
service: 'close_websocket',
|
|
30915
30304
|
});
|
|
30916
30305
|
} else {
|
|
30917
30306
|
WEB_WORKER[SESSION_ID][_ds.worker_id].worker.terminate();
|
|
@@ -30920,7 +30309,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
30920
30309
|
delete WEB_WORKER[SESSION_ID][_ds.worker_id];
|
|
30921
30310
|
} else {
|
|
30922
30311
|
const json = await func.index.call_worker(SESSION_ID, {
|
|
30923
|
-
service:
|
|
30312
|
+
service: 'datasource_delete',
|
|
30924
30313
|
data: data,
|
|
30925
30314
|
id: _ds.worker_id,
|
|
30926
30315
|
});
|
|
@@ -30936,7 +30325,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
30936
30325
|
_.forEach(SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs, function (val, key) {
|
|
30937
30326
|
if (val && val.dsSessionP == dsP) {
|
|
30938
30327
|
arr.push(key);
|
|
30939
|
-
for (const [key, val] of Object.entries($(
|
|
30328
|
+
for (const [key, val] of Object.entries($('.screen_blocker'))) {
|
|
30940
30329
|
$(val).remove();
|
|
30941
30330
|
}
|
|
30942
30331
|
}
|
|
@@ -30944,23 +30333,16 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
30944
30333
|
for (let val of arr.reverse()) {
|
|
30945
30334
|
SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.splice(val, 1);
|
|
30946
30335
|
}
|
|
30947
|
-
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length)
|
|
30948
|
-
SESSION_OBJ[SESSION_ID].WORKER_OBJ.stat = null;
|
|
30336
|
+
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length) SESSION_OBJ[SESSION_ID].WORKER_OBJ.stat = null;
|
|
30949
30337
|
};
|
|
30950
30338
|
if (!glb.IS_WORKER) {
|
|
30951
30339
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsP]) {
|
|
30952
|
-
delete SCREEN_BLOCKER_OBJ[
|
|
30953
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].screenId +
|
|
30954
|
-
"_" +
|
|
30955
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].callingScreenId
|
|
30956
|
-
];
|
|
30340
|
+
delete SCREEN_BLOCKER_OBJ[SESSION_OBJ[SESSION_ID].DS_GLB[dsP].screenId + '_' + SESSION_OBJ[SESSION_ID].DS_GLB[dsP].callingScreenId];
|
|
30957
30341
|
|
|
30958
30342
|
delete_pending_jobs();
|
|
30959
30343
|
}
|
|
30960
|
-
if ($(SESSION_OBJ[SESSION_ID].root_element).find(
|
|
30961
|
-
var ds_obj = $(SESSION_OBJ[SESSION_ID].root_element)
|
|
30962
|
-
.find("xu-nav")
|
|
30963
|
-
?.data()?.xuData.nav_params;
|
|
30344
|
+
if ($(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav').length) {
|
|
30345
|
+
var ds_obj = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav')?.data()?.xuData.nav_params;
|
|
30964
30346
|
if (ds_obj) {
|
|
30965
30347
|
delete ds_obj[dsP];
|
|
30966
30348
|
}
|
|
@@ -30968,86 +30350,63 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
30968
30350
|
}
|
|
30969
30351
|
perform_delete();
|
|
30970
30352
|
};
|
|
30971
|
-
func.datasource.update = async function (
|
|
30972
|
-
SESSION_ID,
|
|
30973
|
-
datasource_changes,
|
|
30974
|
-
update_local_scope_only,
|
|
30975
|
-
avoid_refresh
|
|
30976
|
-
) {
|
|
30353
|
+
func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
30977
30354
|
return new Promise(async (resolve, reject) => {
|
|
30978
30355
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
30979
30356
|
|
|
30980
|
-
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !==
|
|
30981
|
-
update_local_scope_only = true
|
|
30357
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
30358
|
+
update_local_scope_only = true;
|
|
30982
30359
|
}
|
|
30983
30360
|
|
|
30984
|
-
if (typeof glb.GLOBAL_VARS ===
|
|
30985
|
-
glb.GLOBAL_VARS = (
|
|
30986
|
-
await func.common.get_module(
|
|
30987
|
-
SESSION_ID,
|
|
30988
|
-
"xuda-system-globals-module.mjs"
|
|
30989
|
-
)
|
|
30990
|
-
).system_globals;
|
|
30361
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
30362
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
30991
30363
|
}
|
|
30992
30364
|
|
|
30993
30365
|
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
30994
|
-
|
|
30995
30366
|
// iterate child ds
|
|
30996
30367
|
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
30997
30368
|
if (parent_ds !== null) {
|
|
30998
|
-
if (_ds.parentDataSourceNo != parent_ds) continue
|
|
30369
|
+
if (_ds.parentDataSourceNo != parent_ds) continue;
|
|
30999
30370
|
} else {
|
|
31000
|
-
if (dsSession != dsNo) continue
|
|
30371
|
+
if (dsSession != dsNo) continue;
|
|
31001
30372
|
}
|
|
31002
30373
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
31003
|
-
if (tree_ret.menuType ===
|
|
30374
|
+
if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
|
|
31004
30375
|
// check if field has fieldComputed property
|
|
31005
|
-
const _progFields = await func.datasource.get_progFields(
|
|
31006
|
-
SESSION_ID,
|
|
31007
|
-
dsSession
|
|
31008
|
-
);
|
|
30376
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
|
|
31009
30377
|
// find if field is computed
|
|
31010
|
-
let fieldComputed_propExpressions, fieldComputed_id
|
|
30378
|
+
let fieldComputed_propExpressions, fieldComputed_id;
|
|
31011
30379
|
for await (const val of _progFields) {
|
|
31012
|
-
|
|
31013
30380
|
const fieldId = val.data.field_id;
|
|
31014
30381
|
|
|
31015
30382
|
// if (fieldId !== field_id) continue
|
|
31016
|
-
if (val.data.type !==
|
|
30383
|
+
if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
|
|
31017
30384
|
|
|
31018
|
-
const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
30385
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue;
|
|
31019
30386
|
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
31020
|
-
fieldComputed_propExpressions = _propExpressions
|
|
31021
|
-
fieldComputed_id = fieldId
|
|
30387
|
+
fieldComputed_propExpressions = _propExpressions;
|
|
30388
|
+
fieldComputed_id = fieldId;
|
|
31022
30389
|
}
|
|
31023
30390
|
}
|
|
31024
30391
|
|
|
31025
|
-
if (!fieldComputed_id) return
|
|
31026
|
-
|
|
30392
|
+
if (!fieldComputed_id) return;
|
|
31027
30393
|
|
|
31028
30394
|
// iterate ds rows
|
|
31029
30395
|
for (const row of _ds.data_feed?.rows || []) {
|
|
31030
30396
|
// iterate row fields
|
|
31031
30397
|
for (const [key, val] of Object.entries(row)) {
|
|
31032
|
-
if (key !== fieldComputed_id) continue
|
|
30398
|
+
if (key !== fieldComputed_id) continue;
|
|
31033
30399
|
try {
|
|
31034
|
-
|
|
31035
|
-
let ret = await func.expression.get(
|
|
31036
|
-
SESSION_ID,
|
|
31037
|
-
fieldComputed_propExpressions,
|
|
31038
|
-
dsNo,
|
|
31039
|
-
"update",
|
|
31040
|
-
row._ROWID
|
|
31041
|
-
);
|
|
30400
|
+
let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
|
|
31042
30401
|
|
|
31043
30402
|
const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
|
|
31044
30403
|
if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
|
|
31045
30404
|
_ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
|
|
31046
30405
|
if (!fields_changed.includes(fieldComputed_id)) {
|
|
31047
|
-
fields_changed.push(fieldComputed_id)
|
|
30406
|
+
fields_changed.push(fieldComputed_id);
|
|
31048
30407
|
}
|
|
31049
30408
|
if (!datasource_changed.includes(dsSession)) {
|
|
31050
|
-
datasource_changed.push(dsSession)
|
|
30409
|
+
datasource_changed.push(dsSession);
|
|
31051
30410
|
}
|
|
31052
30411
|
}
|
|
31053
30412
|
} catch (err) {
|
|
@@ -31056,19 +30415,16 @@ func.datasource.update = async function (
|
|
|
31056
30415
|
}
|
|
31057
30416
|
}
|
|
31058
30417
|
}
|
|
31059
|
-
await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
30418
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
|
|
31060
30419
|
}
|
|
31061
|
-
|
|
31062
|
-
}
|
|
30420
|
+
};
|
|
31063
30421
|
|
|
31064
30422
|
var fields_changed = [];
|
|
31065
30423
|
var datasource_changed = [];
|
|
31066
|
-
let client_datasource_changes = {}
|
|
31067
|
-
let server_datasource_changes = {}
|
|
30424
|
+
let client_datasource_changes = {};
|
|
30425
|
+
let server_datasource_changes = {};
|
|
31068
30426
|
// iterate changes datasource
|
|
31069
|
-
for await (const [dataSource, row_data] of Object.entries(
|
|
31070
|
-
datasource_changes
|
|
31071
|
-
)) {
|
|
30427
|
+
for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
|
|
31072
30428
|
var _ds = _session.DS_GLB[dataSource];
|
|
31073
30429
|
if (!_ds) {
|
|
31074
30430
|
continue;
|
|
@@ -31078,12 +30434,12 @@ func.datasource.update = async function (
|
|
|
31078
30434
|
// iterate changes fields
|
|
31079
30435
|
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
31080
30436
|
// mechanism to make update directly on the datasource object
|
|
31081
|
-
if (record_id ===
|
|
30437
|
+
if (record_id === 'datasource_main') {
|
|
31082
30438
|
_.set(_ds, field_id, value);
|
|
31083
30439
|
continue;
|
|
31084
30440
|
}
|
|
31085
30441
|
|
|
31086
|
-
if (typeof fields_data ===
|
|
30442
|
+
if (typeof fields_data === 'object') {
|
|
31087
30443
|
if (glb.GLOBAL_VARS[field_id]) {
|
|
31088
30444
|
_ds.data_system[field_id] = value;
|
|
31089
30445
|
|
|
@@ -31093,42 +30449,33 @@ func.datasource.update = async function (
|
|
|
31093
30449
|
try {
|
|
31094
30450
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
31095
30451
|
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
31096
|
-
await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
30452
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
31097
30453
|
|
|
31098
30454
|
if (!update_local_scope_only) {
|
|
31099
30455
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
31100
30456
|
if (glb.IS_WORKER) {
|
|
31101
30457
|
// RUN AT SERVER
|
|
31102
|
-
if (tree_ret.menuType ===
|
|
31103
|
-
|
|
31104
|
-
|
|
31105
|
-
|
|
31106
|
-
dataSource
|
|
31107
|
-
);
|
|
31108
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
31109
|
-
_progFields,
|
|
31110
|
-
"field_id",
|
|
31111
|
-
field_id
|
|
31112
|
-
);
|
|
31113
|
-
if (!view_field_obj?.data?.serverField && record_id !== "data_system") {
|
|
30458
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
30459
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
30460
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
30461
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
31114
30462
|
if (!client_datasource_changes[dataSource]) {
|
|
31115
|
-
client_datasource_changes[dataSource] = {}
|
|
30463
|
+
client_datasource_changes[dataSource] = {};
|
|
31116
30464
|
}
|
|
31117
30465
|
if (!client_datasource_changes[dataSource][record_id]) {
|
|
31118
|
-
client_datasource_changes[dataSource][record_id] = {}
|
|
30466
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
31119
30467
|
}
|
|
31120
30468
|
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
31121
30469
|
}
|
|
31122
|
-
|
|
31123
30470
|
}
|
|
31124
30471
|
} else {
|
|
31125
30472
|
// RUN AT CLIENT
|
|
31126
|
-
if ((tree_ret.menuType ===
|
|
30473
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
31127
30474
|
if (!server_datasource_changes[dataSource]) {
|
|
31128
|
-
server_datasource_changes[dataSource] = {}
|
|
30475
|
+
server_datasource_changes[dataSource] = {};
|
|
31129
30476
|
}
|
|
31130
30477
|
if (!server_datasource_changes[dataSource][record_id]) {
|
|
31131
|
-
server_datasource_changes[dataSource][record_id] = {}
|
|
30478
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
31132
30479
|
}
|
|
31133
30480
|
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
31134
30481
|
}
|
|
@@ -31148,14 +30495,10 @@ func.datasource.update = async function (
|
|
|
31148
30495
|
if (!_ds.data_feed.rows_changed) {
|
|
31149
30496
|
_ds.data_feed.rows_changed = [];
|
|
31150
30497
|
}
|
|
31151
|
-
if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
31152
|
-
|
|
31153
|
-
|
|
31154
|
-
} else if (fields_data === "set") {
|
|
30498
|
+
if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
|
|
30499
|
+
} else if (fields_data === 'set') {
|
|
31155
30500
|
_ds.currentRecordId = record_id;
|
|
31156
30501
|
}
|
|
31157
|
-
|
|
31158
|
-
|
|
31159
30502
|
}
|
|
31160
30503
|
// if (!_ds.data_feed.rows_changed) {
|
|
31161
30504
|
// _ds.data_feed.rows_changed = [];
|
|
@@ -31163,30 +30506,16 @@ func.datasource.update = async function (
|
|
|
31163
30506
|
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
31164
30507
|
// _ds.data_feed.rows_changed.push(record_id);
|
|
31165
30508
|
}
|
|
31166
|
-
|
|
31167
|
-
|
|
31168
|
-
|
|
31169
|
-
|
|
31170
|
-
|
|
31171
30509
|
}
|
|
31172
30510
|
|
|
31173
30511
|
if (glb.IS_WORKER) {
|
|
31174
|
-
|
|
31175
30512
|
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
31176
|
-
func.utils.post_back_to_client(
|
|
31177
|
-
SESSION_ID,
|
|
31178
|
-
"update_client_eventChangesResults_from_worker",
|
|
31179
|
-
_session.worker_id,
|
|
31180
|
-
client_datasource_changes
|
|
31181
|
-
);
|
|
31182
|
-
|
|
30513
|
+
func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
|
|
31183
30514
|
}
|
|
31184
|
-
|
|
31185
30515
|
} else {
|
|
31186
30516
|
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
31187
|
-
|
|
31188
30517
|
const ret = await func.index.call_worker(SESSION_ID, {
|
|
31189
|
-
service:
|
|
30518
|
+
service: 'update_datasource_changes_from_client',
|
|
31190
30519
|
data: {
|
|
31191
30520
|
session_id: SESSION_ID,
|
|
31192
30521
|
datasource_changes: server_datasource_changes,
|
|
@@ -31201,16 +30530,14 @@ func.datasource.update = async function (
|
|
|
31201
30530
|
SESSION_ID,
|
|
31202
30531
|
fields_changed,
|
|
31203
30532
|
null,
|
|
31204
|
-
datasource_changed[0] // refresh the current datasource only
|
|
30533
|
+
datasource_changed[0], // refresh the current datasource only
|
|
31205
30534
|
);
|
|
31206
30535
|
}
|
|
31207
30536
|
}
|
|
31208
30537
|
resolve();
|
|
31209
30538
|
});
|
|
31210
|
-
|
|
31211
30539
|
};
|
|
31212
30540
|
|
|
31213
|
-
|
|
31214
30541
|
// func.datasource.update = async function (
|
|
31215
30542
|
// SESSION_ID,
|
|
31216
30543
|
// datasource_changes,
|
|
@@ -31296,8 +30623,6 @@ func.datasource.update = async function (
|
|
|
31296
30623
|
// }
|
|
31297
30624
|
// debugger
|
|
31298
30625
|
|
|
31299
|
-
|
|
31300
|
-
|
|
31301
30626
|
// }
|
|
31302
30627
|
|
|
31303
30628
|
// var fields_changed = [];
|
|
@@ -31336,8 +30661,6 @@ func.datasource.update = async function (
|
|
|
31336
30661
|
// console.error(err);
|
|
31337
30662
|
// }
|
|
31338
30663
|
|
|
31339
|
-
|
|
31340
|
-
|
|
31341
30664
|
// if (!fields_changed.includes(field_id)) {
|
|
31342
30665
|
// fields_changed.push(field_id);
|
|
31343
30666
|
// }
|
|
@@ -31381,14 +30704,12 @@ func.datasource.update = async function (
|
|
|
31381
30704
|
// _ds.data_feed.rows_changed.push(record_id);
|
|
31382
30705
|
// }
|
|
31383
30706
|
|
|
31384
|
-
|
|
31385
30707
|
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
31386
30708
|
|
|
31387
30709
|
// if (!update_local_scope_only) {
|
|
31388
30710
|
// if (glb.IS_WORKER) {
|
|
31389
30711
|
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
31390
30712
|
|
|
31391
|
-
|
|
31392
30713
|
// if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
31393
30714
|
// continue;
|
|
31394
30715
|
// }
|
|
@@ -31445,55 +30766,53 @@ func.datasource.update = async function (
|
|
|
31445
30766
|
// });
|
|
31446
30767
|
// };
|
|
31447
30768
|
|
|
31448
|
-
func.datasource.callback = function (
|
|
31449
|
-
SESSION_ID,
|
|
31450
|
-
dsSessionP,
|
|
31451
|
-
na,
|
|
31452
|
-
rowIdP,
|
|
31453
|
-
jobNoP,
|
|
31454
|
-
NA_callingDataSourceP,
|
|
31455
|
-
NA_isInitP,
|
|
31456
|
-
nodeIdP
|
|
31457
|
-
) {
|
|
30769
|
+
func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, jobNoP, NA_callingDataSourceP, NA_isInitP, nodeIdP) {
|
|
31458
30770
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
31459
30771
|
var _ds = _session.DS_GLB[dsSessionP];
|
|
31460
30772
|
|
|
31461
30773
|
try {
|
|
31462
|
-
const row_idx = func.common.find_ROWID_idx(_ds,
|
|
30774
|
+
const row_idx = func.common.find_ROWID_idx(_ds, 'dataset');
|
|
31463
30775
|
|
|
31464
30776
|
if (_ds.PARAM_OUT_INFO) {
|
|
31465
30777
|
// write log for out params
|
|
31466
30778
|
for (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
31467
|
-
if (
|
|
31468
|
-
typeof _ds?.data_feed?.rows?.[row_idx]?.[val.fieldId] === "undefined"
|
|
31469
|
-
) {
|
|
30779
|
+
if (typeof _ds?.data_feed?.rows?.[row_idx]?.[val.fieldId] === 'undefined') {
|
|
31470
30780
|
// func.utils.debug.log(SESSION_ID, key, val);
|
|
31471
|
-
func.utils.alerts.invoke(
|
|
31472
|
-
SESSION_ID,
|
|
31473
|
-
"system_msg",
|
|
31474
|
-
"SYS_MSG_0310",
|
|
31475
|
-
val.fieldId,
|
|
31476
|
-
dsSessionP
|
|
31477
|
-
);
|
|
30781
|
+
func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0310', val.fieldId, dsSessionP);
|
|
31478
30782
|
break;
|
|
31479
30783
|
}
|
|
31480
30784
|
val.result = _ds.data_feed.rows[row_idx][val.fieldId];
|
|
31481
30785
|
}
|
|
31482
30786
|
}
|
|
30787
|
+
|
|
30788
|
+
if (_ds?.progDataSource?.datasetOutputField) {
|
|
30789
|
+
let datasource_changes = {};
|
|
30790
|
+
|
|
30791
|
+
let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
|
|
30792
|
+
if (!datasource_changes[_ds.dsSession]) {
|
|
30793
|
+
datasource_changes[_ds.dsSession] = {};
|
|
30794
|
+
}
|
|
30795
|
+
if (!datasource_changes[_ds.dsSession][_ds.currentRecordId]) {
|
|
30796
|
+
datasource_changes[_ds.dsSession][_ds.currentRecordId] = {};
|
|
30797
|
+
|
|
30798
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][_ds?.progDataSource?.datasetOutputField] = _ds?.data_feed?.rows || [];
|
|
30799
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
30800
|
+
}
|
|
30801
|
+
}
|
|
31483
30802
|
} catch (err) {
|
|
31484
30803
|
// console.error(err);
|
|
31485
30804
|
}
|
|
31486
30805
|
|
|
31487
30806
|
func.utils.debug.log(SESSION_ID, nodeIdP, {
|
|
31488
30807
|
module: _ds.viewModule,
|
|
31489
|
-
action:
|
|
30808
|
+
action: 'close',
|
|
31490
30809
|
source: _ds.viewSourceDesc,
|
|
31491
|
-
type:
|
|
30810
|
+
type: 'adapter',
|
|
31492
30811
|
prog_id: _ds.prog_id,
|
|
31493
30812
|
dsSession: dsSessionP,
|
|
31494
|
-
prop: _ds.log_prop +
|
|
30813
|
+
prop: _ds.log_prop + ' ' + 'adapter',
|
|
31495
30814
|
});
|
|
31496
|
-
if (!glb.IS_WORKER) $(_session.root_element).css(
|
|
30815
|
+
if (!glb.IS_WORKER) $(_session.root_element).css('cursor', 'default');
|
|
31497
30816
|
|
|
31498
30817
|
if (_ds.prog_id) {
|
|
31499
30818
|
let _ds = _session.DS_GLB[dsSessionP];
|
|
@@ -31501,19 +30820,17 @@ func.datasource.callback = function (
|
|
|
31501
30820
|
func.utils.debug.watch(
|
|
31502
30821
|
SESSION_ID,
|
|
31503
30822
|
_ds.prog_id,
|
|
31504
|
-
|
|
30823
|
+
'program',
|
|
31505
30824
|
{
|
|
31506
30825
|
in_parameters: _ds.in_parameters,
|
|
31507
30826
|
out_parameters: _ds.out_parameters,
|
|
31508
30827
|
data_feed: _ds.data_feed,
|
|
31509
30828
|
},
|
|
31510
|
-
_ds.tree_obj.menuType
|
|
30829
|
+
_ds.tree_obj.menuType,
|
|
31511
30830
|
);
|
|
31512
30831
|
}
|
|
31513
30832
|
delete _ds.old_dataSource;
|
|
31514
30833
|
|
|
31515
|
-
|
|
31516
|
-
|
|
31517
30834
|
return {
|
|
31518
30835
|
SESSION_ID,
|
|
31519
30836
|
dsSessionP,
|
|
@@ -31523,28 +30840,14 @@ func.datasource.callback = function (
|
|
|
31523
30840
|
calling_jobP: _ds.calling_jobP,
|
|
31524
30841
|
};
|
|
31525
30842
|
};
|
|
31526
|
-
func.datasource.validate_viewRange = async function (
|
|
31527
|
-
SESSION_ID,
|
|
31528
|
-
viewRangeExpP,
|
|
31529
|
-
dsSessionP,
|
|
31530
|
-
rowIdP,
|
|
31531
|
-
sourceP
|
|
31532
|
-
) {
|
|
30843
|
+
func.datasource.validate_viewRange = async function (SESSION_ID, viewRangeExpP, dsSessionP, rowIdP, sourceP) {
|
|
31533
30844
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
31534
30845
|
if (viewRangeExpP && _ds) {
|
|
31535
|
-
var ret = func.expression.remove_quotes(
|
|
31536
|
-
await func.expression.get(
|
|
31537
|
-
SESSION_ID,
|
|
31538
|
-
viewRangeExpP,
|
|
31539
|
-
dsSessionP,
|
|
31540
|
-
"range",
|
|
31541
|
-
rowIdP
|
|
31542
|
-
)
|
|
31543
|
-
);
|
|
30846
|
+
var ret = func.expression.remove_quotes(await func.expression.get(SESSION_ID, viewRangeExpP, dsSessionP, 'range', rowIdP));
|
|
31544
30847
|
ret.result = func.expression.remove_quotes(ret.result);
|
|
31545
30848
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
31546
30849
|
module: _ds.viewModule,
|
|
31547
|
-
action:
|
|
30850
|
+
action: 'range Exp',
|
|
31548
30851
|
prop: sourceP,
|
|
31549
30852
|
details: viewRangeExpP,
|
|
31550
30853
|
result: ret.result,
|
|
@@ -31567,27 +30870,13 @@ func.datasource.validate_viewRange = async function (
|
|
|
31567
30870
|
return ret.result;
|
|
31568
30871
|
} else return false;
|
|
31569
30872
|
};
|
|
31570
|
-
func.datasource.validate_viewLocate = async function (
|
|
31571
|
-
SESSION_ID,
|
|
31572
|
-
viewLocateExpP,
|
|
31573
|
-
dsSessionP,
|
|
31574
|
-
rowIdP,
|
|
31575
|
-
sourceP
|
|
31576
|
-
) {
|
|
30873
|
+
func.datasource.validate_viewLocate = async function (SESSION_ID, viewLocateExpP, dsSessionP, rowIdP, sourceP) {
|
|
31577
30874
|
if (viewLocateExpP && _ds) {
|
|
31578
|
-
var ret = func.expression.remove_quotes(
|
|
31579
|
-
await func.expression.get(
|
|
31580
|
-
SESSION_ID,
|
|
31581
|
-
viewLocateExpP,
|
|
31582
|
-
dsSessionP,
|
|
31583
|
-
"locate",
|
|
31584
|
-
rowIdP
|
|
31585
|
-
)
|
|
31586
|
-
);
|
|
30875
|
+
var ret = func.expression.remove_quotes(await func.expression.get(SESSION_ID, viewLocateExpP, dsSessionP, 'locate', rowIdP));
|
|
31587
30876
|
ret.result = func.expression.remove_quotes(ret.result);
|
|
31588
30877
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
31589
30878
|
module: _ds.viewModule,
|
|
31590
|
-
action:
|
|
30879
|
+
action: 'locate Exp',
|
|
31591
30880
|
prop: sourceP,
|
|
31592
30881
|
details: viewLocateExpP,
|
|
31593
30882
|
result: ret.result,
|
|
@@ -31602,12 +30891,7 @@ func.datasource.validate_viewLocate = async function (
|
|
|
31602
30891
|
} else return false;
|
|
31603
30892
|
};
|
|
31604
30893
|
|
|
31605
|
-
func.datasource.get_viewFields_for_update_function = function (
|
|
31606
|
-
SESSION_ID,
|
|
31607
|
-
calling_trigger_prop,
|
|
31608
|
-
na,
|
|
31609
|
-
dsSessionP
|
|
31610
|
-
) {
|
|
30894
|
+
func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calling_trigger_prop, na, dsSessionP) {
|
|
31611
30895
|
var viewFields = [];
|
|
31612
30896
|
|
|
31613
30897
|
var exp = calling_trigger_prop?.data?.name?.value;
|
|
@@ -31616,7 +30900,7 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
31616
30900
|
}
|
|
31617
30901
|
try {
|
|
31618
30902
|
// parse json
|
|
31619
|
-
var json = JSON5.parse(exp.replace(/\n/gi,
|
|
30903
|
+
var json = JSON5.parse(exp.replace(/\n/gi, ''));
|
|
31620
30904
|
for (const [key, val] of Object.entries(json)) {
|
|
31621
30905
|
let id = key.substr(1, key.length - 1);
|
|
31622
30906
|
if (!id) continue;
|
|
@@ -31630,13 +30914,12 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
31630
30914
|
if (!exp) {
|
|
31631
30915
|
return;
|
|
31632
30916
|
}
|
|
31633
|
-
if (exp.substr(exp.length - 1, 1) ===
|
|
31634
|
-
exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
30917
|
+
if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
31635
30918
|
var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
|
|
31636
30919
|
if (exp_arr?.length) {
|
|
31637
30920
|
for (let val of exp_arr) {
|
|
31638
30921
|
// run view fields
|
|
31639
|
-
var pos = val.indexOf(
|
|
30922
|
+
var pos = val.indexOf(':');
|
|
31640
30923
|
var seg = [val.substring(0, pos), val.substring(pos + 1)];
|
|
31641
30924
|
if (seg && seg.length === 2) {
|
|
31642
30925
|
let id = seg[0].substr(1, seg[0].length);
|
|
@@ -31649,14 +30932,14 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
31649
30932
|
} else {
|
|
31650
30933
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
31651
30934
|
module: _ds.viewModule,
|
|
31652
|
-
action:
|
|
31653
|
-
prop:
|
|
30935
|
+
action: 'set',
|
|
30936
|
+
prop: 'parse update exp',
|
|
31654
30937
|
details: exp,
|
|
31655
|
-
result:
|
|
31656
|
-
error:
|
|
30938
|
+
result: '',
|
|
30939
|
+
error: 'Invalid json; too many segments',
|
|
31657
30940
|
source: _ds.viewSourceDesc,
|
|
31658
|
-
json:
|
|
31659
|
-
fields:
|
|
30941
|
+
json: '',
|
|
30942
|
+
fields: '',
|
|
31660
30943
|
dsSession: dsSessionP,
|
|
31661
30944
|
});
|
|
31662
30945
|
}
|
|
@@ -31666,74 +30949,36 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
31666
30949
|
return viewFields;
|
|
31667
30950
|
}
|
|
31668
30951
|
};
|
|
31669
|
-
func.datasource.get_value = async function (
|
|
31670
|
-
SESSION_ID,
|
|
31671
|
-
fieldIdP,
|
|
31672
|
-
dsSessionP,
|
|
31673
|
-
rowIdP,
|
|
31674
|
-
org_dsSessionP
|
|
31675
|
-
) {
|
|
30952
|
+
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
31676
30953
|
const return_value = async (field_id, value) => {
|
|
31677
|
-
const _progFields = await func.datasource.get_progFields(
|
|
31678
|
-
|
|
31679
|
-
|
|
31680
|
-
);
|
|
31681
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
31682
|
-
_progFields,
|
|
31683
|
-
"field_id",
|
|
31684
|
-
field_id
|
|
31685
|
-
);
|
|
31686
|
-
var fieldType = view_field_obj?.props?.fieldType || "string";
|
|
30954
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
30955
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
30956
|
+
var fieldType = view_field_obj?.props?.fieldType || 'string';
|
|
31687
30957
|
var fieldProp = view_field_obj?.props;
|
|
31688
30958
|
let table_field_obj;
|
|
31689
|
-
if (view_field_obj?.data?.type ===
|
|
30959
|
+
if (view_field_obj?.data?.type === 'table') {
|
|
31690
30960
|
if (!_ds._dataSourceTableId) {
|
|
31691
|
-
return func.utils.debug_report(
|
|
31692
|
-
SESSION_ID,
|
|
31693
|
-
"Datasource",
|
|
31694
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
31695
|
-
"E"
|
|
31696
|
-
);
|
|
30961
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
31697
30962
|
}
|
|
31698
30963
|
|
|
31699
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
31700
|
-
SESSION_ID,
|
|
31701
|
-
_ds._dataSourceTableId
|
|
31702
|
-
);
|
|
30964
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
31703
30965
|
|
|
31704
30966
|
if (!table_obj) {
|
|
31705
|
-
return func.utils.debug_report(
|
|
31706
|
-
SESSION_ID,
|
|
31707
|
-
"Datasource",
|
|
31708
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
31709
|
-
"E"
|
|
31710
|
-
);
|
|
30967
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
31711
30968
|
}
|
|
31712
|
-
table_field_obj = func.common.find_item_by_key(
|
|
31713
|
-
table_obj.tableFields,
|
|
31714
|
-
"field_id",
|
|
31715
|
-
field_id
|
|
31716
|
-
);
|
|
30969
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
31717
30970
|
fieldType = table_field_obj.props?.fieldType;
|
|
31718
30971
|
fieldProp = table_field_obj.props;
|
|
31719
30972
|
}
|
|
31720
30973
|
|
|
31721
30974
|
let ret = {
|
|
31722
|
-
value: await func.common.get_cast_val(
|
|
31723
|
-
SESSION_ID,
|
|
31724
|
-
`datasource get value ${_ds.tree_obj.menuName}`,
|
|
31725
|
-
fieldIdP,
|
|
31726
|
-
fieldType,
|
|
31727
|
-
value,
|
|
31728
|
-
null
|
|
31729
|
-
),
|
|
30975
|
+
value: await func.common.get_cast_val(SESSION_ID, `datasource get value ${_ds.tree_obj.menuName}`, fieldIdP, fieldType, value, null),
|
|
31730
30976
|
type: fieldType,
|
|
31731
30977
|
prop: fieldProp,
|
|
31732
30978
|
};
|
|
31733
30979
|
|
|
31734
|
-
if (ret.value && typeof ret.value ===
|
|
31735
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
31736
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
30980
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
30981
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
31737
30982
|
}
|
|
31738
30983
|
|
|
31739
30984
|
return {
|
|
@@ -31741,12 +30986,12 @@ func.datasource.get_value = async function (
|
|
|
31741
30986
|
dsSessionP,
|
|
31742
30987
|
fieldIdP: field_id,
|
|
31743
30988
|
currentRecordId: _ds.currentRecordId,
|
|
31744
|
-
found: typeof value !==
|
|
30989
|
+
found: typeof value !== 'undefined',
|
|
31745
30990
|
};
|
|
31746
30991
|
};
|
|
31747
30992
|
const return_dynamic_value = async (field_id, value) => {
|
|
31748
30993
|
let view_field_obj = _ds.dynamic_fields[field_id];
|
|
31749
|
-
var fieldType = view_field_obj?.props?.fieldType ||
|
|
30994
|
+
var fieldType = view_field_obj?.props?.fieldType || 'string';
|
|
31750
30995
|
var fieldProp = view_field_obj?.props;
|
|
31751
30996
|
|
|
31752
30997
|
let ret = {
|
|
@@ -31755,9 +31000,8 @@ func.datasource.get_value = async function (
|
|
|
31755
31000
|
prop: fieldProp,
|
|
31756
31001
|
};
|
|
31757
31002
|
|
|
31758
|
-
if (ret.value && typeof ret.value ===
|
|
31759
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
31760
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
31003
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
31004
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
31761
31005
|
}
|
|
31762
31006
|
|
|
31763
31007
|
return {
|
|
@@ -31765,26 +31009,18 @@ func.datasource.get_value = async function (
|
|
|
31765
31009
|
dsSessionP,
|
|
31766
31010
|
fieldIdP: field_id,
|
|
31767
31011
|
currentRecordId: _ds.currentRecordId,
|
|
31768
|
-
found: typeof value !==
|
|
31012
|
+
found: typeof value !== 'undefined',
|
|
31769
31013
|
};
|
|
31770
31014
|
};
|
|
31771
31015
|
const return_value_parameters = async (field_id, value) => {
|
|
31772
31016
|
let ret = {
|
|
31773
|
-
value: await func.common.get_cast_val(
|
|
31774
|
-
SESSION_ID,
|
|
31775
|
-
"datasource get value",
|
|
31776
|
-
fieldIdP,
|
|
31777
|
-
value.type,
|
|
31778
|
-
value.value,
|
|
31779
|
-
null
|
|
31780
|
-
),
|
|
31017
|
+
value: await func.common.get_cast_val(SESSION_ID, 'datasource get value', fieldIdP, value.type, value.value, null),
|
|
31781
31018
|
type: value.type,
|
|
31782
31019
|
prop: null,
|
|
31783
31020
|
};
|
|
31784
31021
|
|
|
31785
|
-
if (ret.value && typeof ret.value ===
|
|
31786
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
31787
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
31022
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
31023
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
31788
31024
|
// if (/"/.test(ret.value) && ret.value.indexOf("\\") === -1)
|
|
31789
31025
|
// ret.value = ret.value.replace(/"/g, '\\"');
|
|
31790
31026
|
}
|
|
@@ -31794,7 +31030,7 @@ func.datasource.get_value = async function (
|
|
|
31794
31030
|
dsSessionP,
|
|
31795
31031
|
fieldIdP: field_id,
|
|
31796
31032
|
currentRecordId: _ds.currentRecordId,
|
|
31797
|
-
found: typeof value !==
|
|
31033
|
+
found: typeof value !== 'undefined',
|
|
31798
31034
|
};
|
|
31799
31035
|
};
|
|
31800
31036
|
const return_value_system = async (field_id, value) => {
|
|
@@ -31802,14 +31038,7 @@ func.datasource.get_value = async function (
|
|
|
31802
31038
|
let fieldProp = null;
|
|
31803
31039
|
|
|
31804
31040
|
let ret = {
|
|
31805
|
-
value: await func.common.get_cast_val(
|
|
31806
|
-
SESSION_ID,
|
|
31807
|
-
`datasource get value ${_ds.tree_obj.menuName}`,
|
|
31808
|
-
field_id,
|
|
31809
|
-
fieldType,
|
|
31810
|
-
value,
|
|
31811
|
-
null
|
|
31812
|
-
),
|
|
31041
|
+
value: await func.common.get_cast_val(SESSION_ID, `datasource get value ${_ds.tree_obj.menuName}`, field_id, fieldType, value, null),
|
|
31813
31042
|
type: fieldType,
|
|
31814
31043
|
prop: fieldProp,
|
|
31815
31044
|
};
|
|
@@ -31819,52 +31048,35 @@ func.datasource.get_value = async function (
|
|
|
31819
31048
|
dsSessionP,
|
|
31820
31049
|
fieldIdP: field_id,
|
|
31821
31050
|
currentRecordId: _ds.currentRecordId,
|
|
31822
|
-
found: typeof value !==
|
|
31051
|
+
found: typeof value !== 'undefined',
|
|
31823
31052
|
};
|
|
31824
31053
|
};
|
|
31825
31054
|
const search_in_parameters = async (field_id) => {
|
|
31826
|
-
if (typeof _ds?.in_parameters?.[field_id]?.value !==
|
|
31827
|
-
let ret = await return_value_parameters(
|
|
31828
|
-
field_id,
|
|
31829
|
-
_ds.in_parameters[field_id]
|
|
31830
|
-
);
|
|
31055
|
+
if (typeof _ds?.in_parameters?.[field_id]?.value !== 'undefined') {
|
|
31056
|
+
let ret = await return_value_parameters(field_id, _ds.in_parameters[field_id]);
|
|
31831
31057
|
return ret;
|
|
31832
31058
|
}
|
|
31833
31059
|
|
|
31834
|
-
if (typeof _ds.parentDataSourceNo !==
|
|
31060
|
+
if (typeof _ds.parentDataSourceNo !== 'undefined') {
|
|
31835
31061
|
var org_dsSession = org_dsSessionP;
|
|
31836
31062
|
if (!org_dsSessionP) org_dsSession = dsSessionP;
|
|
31837
|
-
if (recordId && recordId !==
|
|
31063
|
+
if (recordId && recordId !== 'newRecord') org_dsSession = null;
|
|
31838
31064
|
|
|
31839
|
-
return await func.datasource.get_value(
|
|
31840
|
-
SESSION_ID,
|
|
31841
|
-
fieldIdP,
|
|
31842
|
-
_ds.parentDataSourceNo,
|
|
31843
|
-
recordId,
|
|
31844
|
-
org_dsSession
|
|
31845
|
-
);
|
|
31065
|
+
return await func.datasource.get_value(SESSION_ID, fieldIdP, _ds.parentDataSourceNo, recordId, org_dsSession);
|
|
31846
31066
|
}
|
|
31847
31067
|
|
|
31848
31068
|
return await return_value(field_id);
|
|
31849
31069
|
};
|
|
31850
31070
|
|
|
31851
|
-
if (typeof glb.GLOBAL_VARS ===
|
|
31852
|
-
glb.GLOBAL_VARS = (
|
|
31853
|
-
await func.common.get_module(SESSION_ID, "xuda-system-globals-module.mjs")
|
|
31854
|
-
).system_globals;
|
|
31071
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
31072
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
31855
31073
|
}
|
|
31856
31074
|
|
|
31857
31075
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
31858
31076
|
if (!_ds) {
|
|
31859
31077
|
if (dsSessionP > 0) {
|
|
31860
31078
|
// let prev_ds = dsSessionP - 1;
|
|
31861
|
-
return await func.datasource.get_value(
|
|
31862
|
-
SESSION_ID,
|
|
31863
|
-
fieldIdP,
|
|
31864
|
-
dsSessionP - 1,
|
|
31865
|
-
rowIdP,
|
|
31866
|
-
org_dsSessionP
|
|
31867
|
-
);
|
|
31079
|
+
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
31868
31080
|
}
|
|
31869
31081
|
return await return_value(fieldIdP);
|
|
31870
31082
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
@@ -31880,8 +31092,8 @@ func.datasource.get_value = async function (
|
|
|
31880
31092
|
}
|
|
31881
31093
|
|
|
31882
31094
|
if (dsSessionP > 0) {
|
|
31883
|
-
_ds.data_system[
|
|
31884
|
-
_ds.data_system[
|
|
31095
|
+
_ds.data_system['SYS_STR_ACTIVE_ROW_ID'] = _ds.currentRecordId;
|
|
31096
|
+
_ds.data_system['SYS_STR_PROG_DS_SESSION'] = dsSessionP;
|
|
31885
31097
|
}
|
|
31886
31098
|
|
|
31887
31099
|
// set system time
|
|
@@ -31892,19 +31104,15 @@ func.datasource.get_value = async function (
|
|
|
31892
31104
|
if (!_ds_0.data_system) {
|
|
31893
31105
|
_ds_0.data_system = {};
|
|
31894
31106
|
}
|
|
31895
|
-
const ts = await func.utils.get_dateTime(SESSION_ID,
|
|
31107
|
+
const ts = await func.utils.get_dateTime(SESSION_ID, 'SYS_DATE_VALUE');
|
|
31896
31108
|
for (const val of glb.SYS_DATE_ARR) {
|
|
31897
|
-
_ds_0.data_system[val] = await func.utils.get_dateTime(
|
|
31898
|
-
SESSION_ID,
|
|
31899
|
-
val,
|
|
31900
|
-
ts
|
|
31901
|
-
);
|
|
31109
|
+
_ds_0.data_system[val] = await func.utils.get_dateTime(SESSION_ID, val, ts);
|
|
31902
31110
|
}
|
|
31903
31111
|
}
|
|
31904
31112
|
}
|
|
31905
31113
|
|
|
31906
31114
|
// await func.datasource.set_system_vars(SESSION_ID, dsSessionP);
|
|
31907
|
-
if (typeof _ds?.data_system?.[fieldIdP] !==
|
|
31115
|
+
if (typeof _ds?.data_system?.[fieldIdP] !== 'undefined') {
|
|
31908
31116
|
return await return_value_system(fieldIdP, _ds?.data_system?.[fieldIdP]);
|
|
31909
31117
|
}
|
|
31910
31118
|
return await search_in_parameters(fieldIdP);
|
|
@@ -31927,28 +31135,20 @@ func.datasource.get_value = async function (
|
|
|
31927
31135
|
|
|
31928
31136
|
var _field_id = fieldIdP;
|
|
31929
31137
|
|
|
31930
|
-
if (fieldIdP.substr(0, 1) ===
|
|
31138
|
+
if (fieldIdP.substr(0, 1) === '_') {
|
|
31931
31139
|
if (_ds.alias) _field_id = _ds.alias[fieldIdP];
|
|
31932
31140
|
}
|
|
31933
31141
|
|
|
31934
31142
|
if (!org_dsSessionP && recordId) {
|
|
31935
31143
|
try {
|
|
31936
31144
|
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
31937
|
-
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !==
|
|
31938
|
-
if (
|
|
31939
|
-
|
|
31940
|
-
) {
|
|
31941
|
-
return await return_value(
|
|
31942
|
-
_field_id,
|
|
31943
|
-
_ds.data_feed.rows[row_idx][_field_id]
|
|
31944
|
-
);
|
|
31145
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== 'undefined') {
|
|
31146
|
+
if (Object.keys(_ds.data_feed?.rows?.[row_idx] || {})?.includes(_field_id)) {
|
|
31147
|
+
return await return_value(_field_id, _ds.data_feed.rows[row_idx][_field_id]);
|
|
31945
31148
|
}
|
|
31946
31149
|
|
|
31947
31150
|
if (Object.keys(_ds?.dynamic_fields || {})?.includes(_field_id)) {
|
|
31948
|
-
return await return_dynamic_value(
|
|
31949
|
-
_field_id,
|
|
31950
|
-
_ds.dynamic_fields[_field_id]
|
|
31951
|
-
);
|
|
31151
|
+
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
31952
31152
|
}
|
|
31953
31153
|
}
|
|
31954
31154
|
} catch (err) {
|
|
@@ -31959,26 +31159,19 @@ func.datasource.get_value = async function (
|
|
|
31959
31159
|
try {
|
|
31960
31160
|
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
31961
31161
|
|
|
31962
|
-
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !==
|
|
31963
|
-
return await return_value(
|
|
31964
|
-
_field_id,
|
|
31965
|
-
_ds.data_feed.rows[row_idx][_field_id]
|
|
31966
|
-
);
|
|
31162
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== 'undefined') {
|
|
31163
|
+
return await return_value(_field_id, _ds.data_feed.rows[row_idx][_field_id]);
|
|
31967
31164
|
}
|
|
31968
|
-
} catch (error) {
|
|
31165
|
+
} catch (error) {}
|
|
31969
31166
|
|
|
31970
|
-
if (typeof _ds?.dynamic_fields?.[_field_id] !==
|
|
31167
|
+
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
31971
31168
|
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
31972
31169
|
}
|
|
31973
31170
|
|
|
31974
31171
|
return await search_in_parameters(fieldIdP);
|
|
31975
31172
|
};
|
|
31976
31173
|
|
|
31977
|
-
func.datasource.find_event_dataSource = async function (
|
|
31978
|
-
SESSION_ID,
|
|
31979
|
-
eventIdP,
|
|
31980
|
-
dsSessionP
|
|
31981
|
-
) {
|
|
31174
|
+
func.datasource.find_event_dataSource = async function (SESSION_ID, eventIdP, dsSessionP) {
|
|
31982
31175
|
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
31983
31176
|
var ret;
|
|
31984
31177
|
//============================
|
|
@@ -31986,14 +31179,10 @@ func.datasource.find_event_dataSource = async function (
|
|
|
31986
31179
|
//============================
|
|
31987
31180
|
if (_ds?.prog_id) {
|
|
31988
31181
|
let view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
31989
|
-
if (
|
|
31990
|
-
view_ret?.progEvents &&
|
|
31991
|
-
func.common.find_item_by_key(view_ret.progEvents, "event_name", eventIdP)
|
|
31992
|
-
) {
|
|
31182
|
+
if (view_ret?.progEvents && func.common.find_item_by_key(view_ret.progEvents, 'event_name', eventIdP)) {
|
|
31993
31183
|
ret = dsSessionP;
|
|
31994
|
-
if (_ds.callingSource ===
|
|
31995
|
-
if (_ds.callingSource ===
|
|
31996
|
-
ret = dsSessionP;
|
|
31184
|
+
if (_ds.callingSource === 'system') ret = 0;
|
|
31185
|
+
if (_ds.callingSource === 'program' || !_ds.callingSource) ret = dsSessionP;
|
|
31997
31186
|
// >>> found value
|
|
31998
31187
|
return ret;
|
|
31999
31188
|
}
|
|
@@ -32002,46 +31191,24 @@ func.datasource.find_event_dataSource = async function (
|
|
|
32002
31191
|
//=======================================
|
|
32003
31192
|
// continue Search in parent datasource
|
|
32004
31193
|
//=======================================
|
|
32005
|
-
if (
|
|
32006
|
-
_ds
|
|
32007
|
-
_ds.parentDataSourceNo &&
|
|
32008
|
-
Number(_ds.parentDataSourceNo) > 0 &&
|
|
32009
|
-
Number(_ds.parentDataSourceNo) < dsSessionP
|
|
32010
|
-
) {
|
|
32011
|
-
return await func.datasource.find_event_dataSource(
|
|
32012
|
-
SESSION_ID,
|
|
32013
|
-
eventIdP,
|
|
32014
|
-
_ds.parentDataSourceNo
|
|
32015
|
-
);
|
|
31194
|
+
if (_ds && _ds.parentDataSourceNo && Number(_ds.parentDataSourceNo) > 0 && Number(_ds.parentDataSourceNo) < dsSessionP) {
|
|
31195
|
+
return await func.datasource.find_event_dataSource(SESSION_ID, eventIdP, _ds.parentDataSourceNo);
|
|
32016
31196
|
} else {
|
|
32017
31197
|
//========================================
|
|
32018
31198
|
// continue Search in global system
|
|
32019
31199
|
//=========================================
|
|
32020
|
-
if (!ret)
|
|
32021
|
-
return await func.datasource.find_event_dataSource(
|
|
32022
|
-
SESSION_ID,
|
|
32023
|
-
eventIdP,
|
|
32024
|
-
0
|
|
32025
|
-
);
|
|
31200
|
+
if (!ret) return await func.datasource.find_event_dataSource(SESSION_ID, eventIdP, 0);
|
|
32026
31201
|
}
|
|
32027
31202
|
}
|
|
32028
31203
|
};
|
|
32029
31204
|
func.datasource.reset_jobs = function (SESSION_ID, dsSessionP, sourceP, errP) {
|
|
32030
|
-
for (const [key, val] of Object.entries(
|
|
32031
|
-
SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs
|
|
32032
|
-
)) {
|
|
31205
|
+
for (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs)) {
|
|
32033
31206
|
if (val.dsSessionP === dsSessionP) {
|
|
32034
31207
|
func.events.delete_job(SESSION_ID, val.job_num);
|
|
32035
31208
|
break;
|
|
32036
31209
|
}
|
|
32037
31210
|
}
|
|
32038
|
-
func.utils.debug_report(
|
|
32039
|
-
SESSION_ID,
|
|
32040
|
-
sourceP + "Missing datasource: " + dsSessionP,
|
|
32041
|
-
errP,
|
|
32042
|
-
"W",
|
|
32043
|
-
null
|
|
32044
|
-
);
|
|
31211
|
+
func.utils.debug_report(SESSION_ID, sourceP + 'Missing datasource: ' + dsSessionP, errP, 'W', null);
|
|
32045
31212
|
};
|
|
32046
31213
|
// func.datasource.set_system_vars = async function (SESSION_ID, dsSessionP) {
|
|
32047
31214
|
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
@@ -32085,13 +31252,9 @@ func.datasource.reset_jobs = function (SESSION_ID, dsSessionP, sourceP, errP) {
|
|
|
32085
31252
|
// _ds_0.data_system[val] = await func.utils.get_dateTime(SESSION_ID, val, ts);
|
|
32086
31253
|
// }
|
|
32087
31254
|
// };
|
|
32088
|
-
func.datasource.get_currentRecordId = function (
|
|
32089
|
-
SESSION_ID,
|
|
32090
|
-
dsSessionP,
|
|
32091
|
-
from_datasourceP
|
|
32092
|
-
) {
|
|
31255
|
+
func.datasource.get_currentRecordId = function (SESSION_ID, dsSessionP, from_datasourceP) {
|
|
32093
31256
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
32094
|
-
if (_ds._dataSourceTableId !==
|
|
31257
|
+
if (_ds._dataSourceTableId !== '') {
|
|
32095
31258
|
var firstRecordId = _ds.firstRecordId; // returns the value of the fist row
|
|
32096
31259
|
var currentRecordId = _ds.currentRecordId; // record id that exist on ds after entering the form
|
|
32097
31260
|
var locatedRecordId = _ds.locatedRecordId; // record id located by ds
|
|
@@ -32101,7 +31264,7 @@ func.datasource.get_currentRecordId = function (
|
|
|
32101
31264
|
// set first row when no rec located
|
|
32102
31265
|
else currentRecordId = locatedRecordId; // set with located row
|
|
32103
31266
|
}
|
|
32104
|
-
} else currentRecordId =
|
|
31267
|
+
} else currentRecordId = 'newRecord'; // create mode
|
|
32105
31268
|
return currentRecordId;
|
|
32106
31269
|
};
|
|
32107
31270
|
func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
@@ -32128,34 +31291,19 @@ func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
|
32128
31291
|
interval.push(
|
|
32129
31292
|
setInterval(async function () {
|
|
32130
31293
|
if (!SESSION_OBJ[SESSION_ID]) return;
|
|
32131
|
-
var event_count = await func.datasource.get_view_events_count(
|
|
32132
|
-
SESSION_ID,
|
|
32133
|
-
dsSessionP,
|
|
32134
|
-
typeP,
|
|
32135
|
-
event_id
|
|
32136
|
-
);
|
|
31294
|
+
var event_count = await func.datasource.get_view_events_count(SESSION_ID, dsSessionP, typeP, event_id);
|
|
32137
31295
|
if (!event_count) {
|
|
32138
31296
|
fx.clear();
|
|
32139
31297
|
return;
|
|
32140
31298
|
}
|
|
32141
|
-
var event_condition = await func.expression.get(
|
|
32142
|
-
SESSION_ID,
|
|
32143
|
-
condition,
|
|
32144
|
-
dsSessionP,
|
|
32145
|
-
"condition"
|
|
32146
|
-
); // execute condition;
|
|
31299
|
+
var event_condition = await func.expression.get(SESSION_ID, condition, dsSessionP, 'condition'); // execute condition;
|
|
32147
31300
|
if (condition && !event_condition.result) return;
|
|
32148
31301
|
|
|
32149
|
-
const e = await func.datasource.execute_view_events(
|
|
32150
|
-
SESSION_ID,
|
|
32151
|
-
dsSessionP,
|
|
32152
|
-
typeP,
|
|
32153
|
-
event_id
|
|
32154
|
-
);
|
|
31302
|
+
const e = await func.datasource.execute_view_events(SESSION_ID, dsSessionP, typeP, event_id);
|
|
32155
31303
|
// for (const [key, val] of Object.entries(e)) {
|
|
32156
31304
|
// val.done = false;
|
|
32157
31305
|
// }
|
|
32158
|
-
}, Number(interval_rate) * 1000)
|
|
31306
|
+
}, Number(interval_rate) * 1000),
|
|
32159
31307
|
);
|
|
32160
31308
|
}
|
|
32161
31309
|
} else {
|
|
@@ -32164,8 +31312,7 @@ func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
|
32164
31312
|
}
|
|
32165
31313
|
},
|
|
32166
31314
|
clear: function () {
|
|
32167
|
-
if (DATASOURCE_INTERVALS[session_id])
|
|
32168
|
-
delete DATASOURCE_INTERVALS[session_id][dsSessionP];
|
|
31315
|
+
if (DATASOURCE_INTERVALS[session_id]) delete DATASOURCE_INTERVALS[session_id][dsSessionP];
|
|
32169
31316
|
for (const [key, val] of Object.entries(interval)) {
|
|
32170
31317
|
clearInterval(val);
|
|
32171
31318
|
}
|
|
@@ -32178,12 +31325,8 @@ func.datasource.server_cron = function (session_id) {
|
|
|
32178
31325
|
var jobs = [];
|
|
32179
31326
|
// var ds = SESSION_OBJ[SESSION_ID].DS_GLB[0];
|
|
32180
31327
|
// var v = ds.v;
|
|
32181
|
-
var arr = func.datasource.get_event_interval_arr(
|
|
32182
|
-
|
|
32183
|
-
0,
|
|
32184
|
-
"server_cron"
|
|
32185
|
-
);
|
|
32186
|
-
const schedule = require("node-schedule");
|
|
31328
|
+
var arr = func.datasource.get_event_interval_arr(SESSION_ID, 0, 'server_cron');
|
|
31329
|
+
const schedule = require('node-schedule');
|
|
32187
31330
|
|
|
32188
31331
|
if (!arr.length) {
|
|
32189
31332
|
return jobs;
|
|
@@ -32196,75 +31339,43 @@ func.datasource.server_cron = function (session_id) {
|
|
|
32196
31339
|
jobs.push(
|
|
32197
31340
|
schedule.scheduleJob(cron_prop, async function () {
|
|
32198
31341
|
if (!SESSION_OBJ[SESSION_ID]) return;
|
|
32199
|
-
var event_count = await func.datasource.get_view_events_count(
|
|
32200
|
-
SESSION_ID,
|
|
32201
|
-
0,
|
|
32202
|
-
"server_cron",
|
|
32203
|
-
event_id
|
|
32204
|
-
);
|
|
31342
|
+
var event_count = await func.datasource.get_view_events_count(SESSION_ID, 0, 'server_cron', event_id);
|
|
32205
31343
|
if (!event_count) {
|
|
32206
31344
|
fx.clear();
|
|
32207
31345
|
return;
|
|
32208
31346
|
}
|
|
32209
|
-
var event_condition = await func.expression.get(
|
|
32210
|
-
SESSION_ID,
|
|
32211
|
-
condition,
|
|
32212
|
-
0,
|
|
32213
|
-
"condition"
|
|
32214
|
-
); // execute condition;
|
|
31347
|
+
var event_condition = await func.expression.get(SESSION_ID, condition, 0, 'condition'); // execute condition;
|
|
32215
31348
|
if (condition && !event_condition.result) return;
|
|
32216
31349
|
if (event_count) {
|
|
32217
|
-
const e = await func.datasource.execute_view_events(
|
|
32218
|
-
SESSION_ID,
|
|
32219
|
-
0,
|
|
32220
|
-
"server_cron",
|
|
32221
|
-
event_id
|
|
32222
|
-
);
|
|
31350
|
+
const e = await func.datasource.execute_view_events(SESSION_ID, 0, 'server_cron', event_id);
|
|
32223
31351
|
// for (const [key, val] of Object.entries(e)) {
|
|
32224
31352
|
// val.done = false;
|
|
32225
31353
|
// }
|
|
32226
31354
|
}
|
|
32227
|
-
})
|
|
31355
|
+
}),
|
|
32228
31356
|
);
|
|
32229
31357
|
}
|
|
32230
31358
|
|
|
32231
31359
|
return jobs;
|
|
32232
31360
|
};
|
|
32233
|
-
func.datasource.get_viewLoops = async function (
|
|
32234
|
-
SESSION_ID,
|
|
32235
|
-
dataSourceSession,
|
|
32236
|
-
data,
|
|
32237
|
-
batch_source,
|
|
32238
|
-
default_limit
|
|
32239
|
-
) {
|
|
31361
|
+
func.datasource.get_viewLoops = async function (SESSION_ID, dataSourceSession, data, batch_source, default_limit) {
|
|
32240
31362
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
32241
31363
|
var args = _ds.args;
|
|
32242
31364
|
// var v = _ds.v;
|
|
32243
31365
|
var ret = default_limit;
|
|
32244
31366
|
|
|
32245
|
-
if (batch_source ===
|
|
32246
|
-
if (batch_source ===
|
|
32247
|
-
if (batch_source ===
|
|
31367
|
+
if (batch_source === 'db_data') ret = _.size(data.rows);
|
|
31368
|
+
if (batch_source === 'array' || batch_source === 'csv') ret = data.length;
|
|
31369
|
+
if (batch_source === 'json') ret = Object.keys(data).length;
|
|
32248
31370
|
if (_ds.progDataSource?.dataSourceLimit) {
|
|
32249
|
-
if (
|
|
32250
|
-
batch_source !== "no_data" &&
|
|
32251
|
-
Number(_ds.progDataSource?.dataSourceLimit) < ret
|
|
32252
|
-
) {
|
|
31371
|
+
if (batch_source !== 'no_data' && Number(_ds.progDataSource?.dataSourceLimit) < ret) {
|
|
32253
31372
|
ret = Number(_ds.progDataSource.dataSourceLimit);
|
|
32254
31373
|
}
|
|
32255
31374
|
if (!batch_source) ret = Number(_ds.progDataSource.dataSourceLimit);
|
|
32256
31375
|
}
|
|
32257
31376
|
if (prog_obj.progDataSource?.dataSourceLoopExp) {
|
|
32258
|
-
var n = (
|
|
32259
|
-
|
|
32260
|
-
SESSION_ID,
|
|
32261
|
-
_ds.v.viewLoopsExp,
|
|
32262
|
-
dataSourceSession,
|
|
32263
|
-
"view_loop",
|
|
32264
|
-
args.rowIdP
|
|
32265
|
-
)
|
|
32266
|
-
).result;
|
|
32267
|
-
if (batch_source !== "no_data" && n < ret) ret = n;
|
|
31377
|
+
var n = (await func.expression.get(SESSION_ID, _ds.v.viewLoopsExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
31378
|
+
if (batch_source !== 'no_data' && n < ret) ret = n;
|
|
32268
31379
|
if (!batch_source) ret = n;
|
|
32269
31380
|
}
|
|
32270
31381
|
return ret;
|
|
@@ -32276,13 +31387,11 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
32276
31387
|
segTo: [],
|
|
32277
31388
|
segLocateFrom: [],
|
|
32278
31389
|
segLocateTo: [],
|
|
32279
|
-
viewModule:
|
|
31390
|
+
viewModule: 'adapter',
|
|
32280
31391
|
};
|
|
32281
31392
|
_ds.viewEventExec_arr = {};
|
|
32282
31393
|
|
|
32283
|
-
var view = _.cloneDeep(
|
|
32284
|
-
await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id)
|
|
32285
|
-
);
|
|
31394
|
+
var view = _.cloneDeep(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
|
|
32286
31395
|
|
|
32287
31396
|
_ds.v.dataSourceSrcType = view.dataSourceSrcType;
|
|
32288
31397
|
|
|
@@ -32298,7 +31407,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
32298
31407
|
}
|
|
32299
31408
|
|
|
32300
31409
|
if (glb.FUNCTION_NODES_ARR.includes(tree_ret.menuType)) {
|
|
32301
|
-
_ds.v.viewModule =
|
|
31410
|
+
_ds.v.viewModule = 'function';
|
|
32302
31411
|
}
|
|
32303
31412
|
_ds.v.viewSourceProp = tree_ret.menuType;
|
|
32304
31413
|
if (view.progEvents) _ds.v.progEvents = view.progEvents;
|
|
@@ -32312,15 +31421,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
32312
31421
|
}
|
|
32313
31422
|
};
|
|
32314
31423
|
|
|
32315
|
-
func.datasource.get_cast_val = async function (
|
|
32316
|
-
SESSION_ID,
|
|
32317
|
-
source,
|
|
32318
|
-
dsSession,
|
|
32319
|
-
valP,
|
|
32320
|
-
typeP,
|
|
32321
|
-
req,
|
|
32322
|
-
error
|
|
32323
|
-
) {
|
|
31424
|
+
func.datasource.get_cast_val = async function (SESSION_ID, source, dsSession, valP, typeP, req, error) {
|
|
32324
31425
|
var prog_id, prog_name;
|
|
32325
31426
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
32326
31427
|
var _ds = _session.DS_GLB[dsSession];
|
|
@@ -32328,73 +31429,39 @@ func.datasource.get_cast_val = async function (
|
|
|
32328
31429
|
prog_id = _ds.prog_id;
|
|
32329
31430
|
prog_name = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id).menuName;
|
|
32330
31431
|
|
|
32331
|
-
const prog_info = prog_id ? ` (prog: ${prog_id} ${prog_name})` :
|
|
31432
|
+
const prog_info = prog_id ? ` (prog: ${prog_id} ${prog_name})` : '';
|
|
32332
31433
|
|
|
32333
31434
|
const report_conversion_error = function (res) {
|
|
32334
31435
|
var msg = `error converting from ${valP} to ${typeP}`;
|
|
32335
31436
|
if (error) {
|
|
32336
|
-
return func.utils.debug_report(SESSION_ID, msg,
|
|
31437
|
+
return func.utils.debug_report(SESSION_ID, msg, '', 'W');
|
|
32337
31438
|
}
|
|
32338
|
-
func.utils.debug_report(
|
|
32339
|
-
SESSION_ID,
|
|
32340
|
-
msg + " " + _.capitalize(source) + prog_info,
|
|
32341
|
-
"",
|
|
32342
|
-
"E"
|
|
32343
|
-
);
|
|
31439
|
+
func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'E');
|
|
32344
31440
|
};
|
|
32345
31441
|
const report_conversion_warn = function (res) {
|
|
32346
31442
|
var msg = `type mismatch auto conversion from value ${valP} to ${typeP}`;
|
|
32347
|
-
func.utils.debug_report(
|
|
32348
|
-
SESSION_ID,
|
|
32349
|
-
msg + " " + _.capitalize(source) + prog_info,
|
|
32350
|
-
"",
|
|
32351
|
-
"W"
|
|
32352
|
-
);
|
|
31443
|
+
func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'W');
|
|
32353
31444
|
};
|
|
32354
31445
|
// var ret = valP;
|
|
32355
31446
|
if (error) {
|
|
32356
31447
|
return report_conversion_error();
|
|
32357
31448
|
}
|
|
32358
31449
|
|
|
32359
|
-
const module = await func.common.get_module(
|
|
32360
|
-
|
|
32361
|
-
"xuda-get-cast-util-module.mjs"
|
|
32362
|
-
);
|
|
32363
|
-
return module.cast(
|
|
32364
|
-
typeP,
|
|
32365
|
-
valP,
|
|
32366
|
-
report_conversion_error,
|
|
32367
|
-
report_conversion_warn
|
|
32368
|
-
);
|
|
31450
|
+
const module = await func.common.get_module(SESSION_ID, 'xuda-get-cast-util-module.mjs');
|
|
31451
|
+
return module.cast(typeP, valP, report_conversion_error, report_conversion_warn);
|
|
32369
31452
|
};
|
|
32370
|
-
func.datasource.get_field_init_triggers_to_run = function (
|
|
32371
|
-
SESSION_ID,
|
|
32372
|
-
dataSourceSession,
|
|
32373
|
-
pre_init_fieldsP
|
|
32374
|
-
) {
|
|
31453
|
+
func.datasource.get_field_init_triggers_to_run = function (SESSION_ID, dataSourceSession, pre_init_fieldsP) {
|
|
32375
31454
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
32376
31455
|
if (!_ds) return;
|
|
32377
31456
|
|
|
32378
31457
|
return []; // inactive 021617
|
|
32379
31458
|
}; // inactive temporary, design to execute init triggers when querying large datasets
|
|
32380
|
-
func.datasource.get_pre_init_fields = function (
|
|
32381
|
-
SESSION_ID,
|
|
32382
|
-
dsSessionP,
|
|
32383
|
-
viewRangeExpP,
|
|
32384
|
-
viewSortExpP,
|
|
32385
|
-
viewGroupByExpP,
|
|
32386
|
-
viewLocateExpP
|
|
32387
|
-
) {
|
|
31459
|
+
func.datasource.get_pre_init_fields = function (SESSION_ID, dsSessionP, viewRangeExpP, viewSortExpP, viewGroupByExpP, viewLocateExpP) {
|
|
32388
31460
|
var ret = [];
|
|
32389
31461
|
return; // inactive 021617
|
|
32390
31462
|
}; // temporary inactive, init preformed on the first round
|
|
32391
31463
|
|
|
32392
|
-
func.datasource.add_dynamic_field_to_ds = function (
|
|
32393
|
-
SESSION_ID,
|
|
32394
|
-
dsSessionP,
|
|
32395
|
-
key,
|
|
32396
|
-
val
|
|
32397
|
-
) {
|
|
31464
|
+
func.datasource.add_dynamic_field_to_ds = function (SESSION_ID, dsSessionP, key, val) {
|
|
32398
31465
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
32399
31466
|
if (!_ds.dynamic_fields) {
|
|
32400
31467
|
_ds.dynamic_fields = {};
|
|
@@ -32410,11 +31477,11 @@ func.datasource.add_dynamic_field_to_ds = function (
|
|
|
32410
31477
|
_ds.dynamic_fields[key] = {
|
|
32411
31478
|
id: crypto.randomUUID(),
|
|
32412
31479
|
data: {
|
|
32413
|
-
type:
|
|
31480
|
+
type: 'virtual',
|
|
32414
31481
|
field_id: key,
|
|
32415
31482
|
},
|
|
32416
31483
|
props: {
|
|
32417
|
-
fieldType: typeof
|
|
31484
|
+
fieldType: typeof val !== 'undefined' ? toType(val) : 'string',
|
|
32418
31485
|
},
|
|
32419
31486
|
value: val,
|
|
32420
31487
|
};
|
|
@@ -32425,11 +31492,7 @@ func.datasource.get_progFields = async function (SESSION_ID, dsSessionP) {
|
|
|
32425
31492
|
const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
32426
31493
|
return _view_obj.progFields;
|
|
32427
31494
|
};
|
|
32428
|
-
func.datasource.update_changes_for_out_parameter = async function (
|
|
32429
|
-
SESSION_ID,
|
|
32430
|
-
dsSessionP,
|
|
32431
|
-
calling_dsP
|
|
32432
|
-
) {
|
|
31495
|
+
func.datasource.update_changes_for_out_parameter = async function (SESSION_ID, dsSessionP, calling_dsP) {
|
|
32433
31496
|
let _session = SESSION_OBJ[SESSION_ID];
|
|
32434
31497
|
let _ds = _session.DS_GLB[dsSessionP];
|
|
32435
31498
|
const _calling_ds = _session.DS_GLB[calling_dsP];
|
|
@@ -32437,7 +31500,7 @@ func.datasource.update_changes_for_out_parameter = async function (
|
|
|
32437
31500
|
if (_ds.PARAM_OUT_INFO) {
|
|
32438
31501
|
let data = {};
|
|
32439
31502
|
for await (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
32440
|
-
if (val.prop ===
|
|
31503
|
+
if (val.prop === 'out') {
|
|
32441
31504
|
try {
|
|
32442
31505
|
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
32443
31506
|
data[val.details] = _ds.data_feed.rows[row_idx][val.fieldId];
|
|
@@ -32459,50 +31522,31 @@ func.datasource.set_outputField = async function (SESSION_ID, dsSessionP, result
|
|
|
32459
31522
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
32460
31523
|
// let _ds = _session.DS_GLB[dsSessionP];
|
|
32461
31524
|
|
|
32462
|
-
|
|
32463
|
-
const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSessionP, args, "outputField")
|
|
32464
|
-
|
|
31525
|
+
const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSessionP, args, 'outputField');
|
|
32465
31526
|
|
|
32466
31527
|
if (output_field) {
|
|
32467
31528
|
let datasource_changes = {};
|
|
32468
31529
|
|
|
32469
|
-
let ret_get_value = await func.datasource.get_value(
|
|
32470
|
-
SESSION_ID,
|
|
32471
|
-
output_field,
|
|
32472
|
-
dsSessionP
|
|
32473
|
-
);
|
|
31530
|
+
let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
|
|
32474
31531
|
if (ret_get_value.found) {
|
|
32475
31532
|
let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
|
|
32476
31533
|
if (!datasource_changes[_ds.dsSession]) {
|
|
32477
31534
|
datasource_changes[_ds.dsSession] = {};
|
|
32478
31535
|
}
|
|
32479
|
-
if (
|
|
32480
|
-
|
|
32481
|
-
) {
|
|
32482
|
-
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
|
|
32483
|
-
{};
|
|
31536
|
+
if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
|
|
31537
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
|
|
32484
31538
|
}
|
|
32485
|
-
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
|
|
32486
|
-
output_field
|
|
32487
|
-
] = result;
|
|
31539
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = result;
|
|
32488
31540
|
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
32489
31541
|
}
|
|
32490
31542
|
}
|
|
32491
|
-
|
|
32492
|
-
}
|
|
31543
|
+
};
|
|
32493
31544
|
|
|
32494
31545
|
func.datasource.get_args_property_value = async function (SESSION_ID, dsSession, args, prop_name) {
|
|
32495
31546
|
let _prop = args?.calling_trigger_prop?.data?.name;
|
|
32496
31547
|
let _value = _prop[prop_name];
|
|
32497
31548
|
if (_prop?.[`xu-exp:${prop_name}`]) {
|
|
32498
|
-
_value = (
|
|
32499
|
-
await func.expression.get(
|
|
32500
|
-
SESSION_ID,
|
|
32501
|
-
_prop[`xu-exp:${prop_name}`],
|
|
32502
|
-
dsSession,
|
|
32503
|
-
`${prop_name} expression`
|
|
32504
|
-
)
|
|
32505
|
-
).result;
|
|
31549
|
+
_value = (await func.expression.get(SESSION_ID, _prop[`xu-exp:${prop_name}`], dsSession, `${prop_name} expression`)).result;
|
|
32506
31550
|
}
|
|
32507
31551
|
|
|
32508
31552
|
return _value;
|