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