@xuda.io/runtime-bundle 1.0.286 → 1.0.287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/xuda-runtime-bundle.js +494 -1450
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +497 -1453
- package/js/xuda-runtime-slim.min.es.js +497 -1453
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +493 -1449
- package/js/xuda-worker-bundle.js +493 -1449
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -3263,15 +3263,15 @@ func.datasource.create = async function (
|
|
|
3263
3263
|
parameters_obj_inP,
|
|
3264
3264
|
static_refreshP,
|
|
3265
3265
|
worker_id,
|
|
3266
|
-
NA_eventChangesResults
|
|
3266
|
+
NA_eventChangesResults,
|
|
3267
3267
|
) {
|
|
3268
3268
|
return new Promise(async function (resolve, reject) {
|
|
3269
|
-
if (!prog_id) return reject(
|
|
3269
|
+
if (!prog_id) return reject('Program is empty');
|
|
3270
3270
|
|
|
3271
3271
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
3272
|
-
if (!_session.DS_GLB) return reject(
|
|
3272
|
+
if (!_session.DS_GLB) return reject('DS_GLB not exist');
|
|
3273
3273
|
var _prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
|
|
3274
|
-
if (!_prog_obj) return reject(
|
|
3274
|
+
if (!_prog_obj) return reject('Program not found');
|
|
3275
3275
|
|
|
3276
3276
|
var args = {
|
|
3277
3277
|
SESSION_ID,
|
|
@@ -3303,8 +3303,7 @@ func.datasource.create = async function (
|
|
|
3303
3303
|
old_dataSource_vars.SYS_STR_WIN_ID = _ds.data_system.SYS_STR_WIN_ID;
|
|
3304
3304
|
old_dataSource_vars.SYS_STR_WIN_NAME = _ds.data_system.SYS_STR_WIN_NAME;
|
|
3305
3305
|
}
|
|
3306
|
-
if (static_refreshP)
|
|
3307
|
-
old_dataSource_vars.in_parameters = _ds.in_parameters;
|
|
3306
|
+
if (static_refreshP) old_dataSource_vars.in_parameters = _ds.in_parameters;
|
|
3308
3307
|
}
|
|
3309
3308
|
const restore_old_dataSource_vars = function (dsSessionP) {
|
|
3310
3309
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
@@ -3316,26 +3315,20 @@ func.datasource.create = async function (
|
|
|
3316
3315
|
_ds.data_system.SYS_STR_WIN_NAME = old_dataSource_vars.SYS_STR_WIN_NAME;
|
|
3317
3316
|
}
|
|
3318
3317
|
|
|
3319
|
-
if (static_refreshP)
|
|
3320
|
-
_ds.in_parameters = old_dataSource_vars.in_parameters;
|
|
3318
|
+
if (static_refreshP) _ds.in_parameters = old_dataSource_vars.in_parameters;
|
|
3321
3319
|
};
|
|
3322
3320
|
|
|
3323
3321
|
var run_at = _prog_obj?.properties?.runAt;
|
|
3324
|
-
if (_session.opt.app_computing_mode ===
|
|
3325
|
-
run_at =
|
|
3322
|
+
if (_session.opt.app_computing_mode === 'main') {
|
|
3323
|
+
run_at = 'client';
|
|
3326
3324
|
}
|
|
3327
3325
|
|
|
3328
|
-
if (_prog_obj?.properties.menuType ===
|
|
3329
|
-
run_at =
|
|
3326
|
+
if (_prog_obj?.properties.menuType === 'globals') {
|
|
3327
|
+
run_at = 'client';
|
|
3330
3328
|
}
|
|
3331
3329
|
|
|
3332
|
-
if (
|
|
3333
|
-
|
|
3334
|
-
parentDataSourceNoP &&
|
|
3335
|
-
_session.DS_GLB[parentDataSourceNoP]
|
|
3336
|
-
) {
|
|
3337
|
-
if (_session.DS_GLB[parentDataSourceNoP]._run_at)
|
|
3338
|
-
run_at = _session.DS_GLB[parentDataSourceNoP].v.run_at;
|
|
3330
|
+
if (!run_at && parentDataSourceNoP && _session.DS_GLB[parentDataSourceNoP]) {
|
|
3331
|
+
if (_session.DS_GLB[parentDataSourceNoP]._run_at) run_at = _session.DS_GLB[parentDataSourceNoP].v.run_at;
|
|
3339
3332
|
}
|
|
3340
3333
|
|
|
3341
3334
|
const done = function (SESSION_ID, dsSessionP, is_serverP) {
|
|
@@ -3347,12 +3340,7 @@ func.datasource.create = async function (
|
|
|
3347
3340
|
|
|
3348
3341
|
if (!IS_DATASOURCE_REFRESH) {
|
|
3349
3342
|
if (!glb.IS_WORKER) {
|
|
3350
|
-
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP] =
|
|
3351
|
-
new func.datasource.interval(
|
|
3352
|
-
SESSION_ID,
|
|
3353
|
-
dsSessionP,
|
|
3354
|
-
"client_interval"
|
|
3355
|
-
);
|
|
3343
|
+
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP] = new func.datasource.interval(SESSION_ID, dsSessionP, 'client_interval');
|
|
3356
3344
|
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP].init();
|
|
3357
3345
|
}
|
|
3358
3346
|
}
|
|
@@ -3367,8 +3355,8 @@ func.datasource.create = async function (
|
|
|
3367
3355
|
|
|
3368
3356
|
var datasource_changes = {
|
|
3369
3357
|
[dsSessionP]: {
|
|
3370
|
-
[
|
|
3371
|
-
stat:
|
|
3358
|
+
['datasource_main']: {
|
|
3359
|
+
stat: 'idle',
|
|
3372
3360
|
stat_ts: Date.now(),
|
|
3373
3361
|
is_worker: glb.IS_WORKER,
|
|
3374
3362
|
},
|
|
@@ -3382,7 +3370,7 @@ func.datasource.create = async function (
|
|
|
3382
3370
|
let interval = setInterval(() => {
|
|
3383
3371
|
let idle_count = 0;
|
|
3384
3372
|
for (const _ds of ds_connected) {
|
|
3385
|
-
if (_ds.stat ==
|
|
3373
|
+
if (_ds.stat == 'idle') {
|
|
3386
3374
|
idle_count++;
|
|
3387
3375
|
}
|
|
3388
3376
|
}
|
|
@@ -3411,12 +3399,7 @@ func.datasource.create = async function (
|
|
|
3411
3399
|
if (jobNoP) {
|
|
3412
3400
|
}
|
|
3413
3401
|
|
|
3414
|
-
if (
|
|
3415
|
-
glb.IS_WORKER ||
|
|
3416
|
-
run_at === "client" ||
|
|
3417
|
-
is_system_client_vars ||
|
|
3418
|
-
db_driver === "pouchdb"
|
|
3419
|
-
) {
|
|
3402
|
+
if (glb.IS_WORKER || run_at === 'client' || is_system_client_vars || db_driver === 'pouchdb') {
|
|
3420
3403
|
const ret = await func.datasource.prepare(
|
|
3421
3404
|
args.SESSION_ID,
|
|
3422
3405
|
args.prog_id,
|
|
@@ -3435,7 +3418,7 @@ func.datasource.create = async function (
|
|
|
3435
3418
|
args.parameters_obj_inP,
|
|
3436
3419
|
args.static_refreshP,
|
|
3437
3420
|
run_at,
|
|
3438
|
-
worker_id
|
|
3421
|
+
worker_id,
|
|
3439
3422
|
);
|
|
3440
3423
|
return done(SESSION_ID, ret.dsSessionP);
|
|
3441
3424
|
}
|
|
@@ -3444,19 +3427,16 @@ func.datasource.create = async function (
|
|
|
3444
3427
|
var data = _.assignIn(
|
|
3445
3428
|
{
|
|
3446
3429
|
session_id: SESSION_ID,
|
|
3447
|
-
dataSourceSessionGlobal:
|
|
3448
|
-
|
|
3449
|
-
parentDataSourceNo: IS_DATASOURCE_REFRESH
|
|
3450
|
-
? _ds.parentDataSourceNo
|
|
3451
|
-
: null,
|
|
3430
|
+
dataSourceSessionGlobal: SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal,
|
|
3431
|
+
parentDataSourceNo: IS_DATASOURCE_REFRESH ? _ds.parentDataSourceNo : null,
|
|
3452
3432
|
IS_DATASOURCE_REFRESH,
|
|
3453
3433
|
},
|
|
3454
|
-
args
|
|
3434
|
+
args,
|
|
3455
3435
|
);
|
|
3456
3436
|
delete data.SESSION_ID;
|
|
3457
3437
|
|
|
3458
3438
|
const jsonP = await func.index.call_worker(SESSION_ID, {
|
|
3459
|
-
service:
|
|
3439
|
+
service: 'datasource_create',
|
|
3460
3440
|
data,
|
|
3461
3441
|
id: SESSION_OBJ[SESSION_ID].worker_id,
|
|
3462
3442
|
});
|
|
@@ -3470,43 +3450,20 @@ func.datasource.create = async function (
|
|
|
3470
3450
|
return done(SESSION_ID, jsonP.dsSession, true);
|
|
3471
3451
|
});
|
|
3472
3452
|
};
|
|
3473
|
-
func.datasource.prepare = async function (
|
|
3474
|
-
SESSION_ID,
|
|
3475
|
-
prog_id,
|
|
3476
|
-
dataSourceNoP,
|
|
3477
|
-
parentDataSourceNoP,
|
|
3478
|
-
containerIdP,
|
|
3479
|
-
rowIdP,
|
|
3480
|
-
jobNoP,
|
|
3481
|
-
calling_trigger_prop,
|
|
3482
|
-
NA_screen_param,
|
|
3483
|
-
NA_isInitP,
|
|
3484
|
-
callingSourceP,
|
|
3485
|
-
calling_jobP,
|
|
3486
|
-
NA_screen_dsP,
|
|
3487
|
-
is_panelP,
|
|
3488
|
-
parameters_obj_inP,
|
|
3489
|
-
static_refreshP,
|
|
3490
|
-
run_atP,
|
|
3491
|
-
worker_id
|
|
3492
|
-
) {
|
|
3453
|
+
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) {
|
|
3493
3454
|
const set_parameters = async function () {
|
|
3494
3455
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
3495
|
-
const get_Out_parameters = async function (
|
|
3496
|
-
fieldIdP,
|
|
3497
|
-
located_field_param_idxP,
|
|
3498
|
-
param_row_idP
|
|
3499
|
-
) {
|
|
3456
|
+
const get_Out_parameters = async function (fieldIdP, located_field_param_idxP, param_row_idP) {
|
|
3500
3457
|
var ret = parameters_obj_inP?.[fieldIdP] || fieldIdP;
|
|
3501
3458
|
|
|
3502
|
-
PARAM_OUT_INFO[prog_id +
|
|
3459
|
+
PARAM_OUT_INFO[prog_id + '_' + param_row_idP] = {
|
|
3503
3460
|
module: _ds.viewModule,
|
|
3504
|
-
action:
|
|
3505
|
-
prop:
|
|
3461
|
+
action: 'parameters',
|
|
3462
|
+
prop: 'out',
|
|
3506
3463
|
details: ret,
|
|
3507
3464
|
result: ret,
|
|
3508
3465
|
source: _ds.viewSourceDesc,
|
|
3509
|
-
type:
|
|
3466
|
+
type: 'parameters',
|
|
3510
3467
|
prog_id: prog_id,
|
|
3511
3468
|
dsSession: dataSourceSession,
|
|
3512
3469
|
fieldId: fieldIdP,
|
|
@@ -3525,34 +3482,24 @@ func.datasource.prepare = async function (
|
|
|
3525
3482
|
_ds.in_parameters = {};
|
|
3526
3483
|
_ds.out_parameters = {};
|
|
3527
3484
|
|
|
3528
|
-
for await (let [key, val] of Object.entries(
|
|
3529
|
-
screenInfo.properties?.progParams
|
|
3530
|
-
)) {
|
|
3485
|
+
for await (let [key, val] of Object.entries(screenInfo.properties?.progParams)) {
|
|
3531
3486
|
// run on parameters arr
|
|
3532
|
-
if (val.data.dir ===
|
|
3487
|
+
if (val.data.dir === 'in') {
|
|
3533
3488
|
_ds.in_parameters[val.data.parameter] = {
|
|
3534
3489
|
// value: parameters_obj_inP?.[val.data.parameter],
|
|
3535
3490
|
type: val.data.type,
|
|
3536
3491
|
};
|
|
3537
3492
|
|
|
3538
|
-
if (
|
|
3539
|
-
|
|
3540
|
-
) {
|
|
3541
|
-
_ds.in_parameters[val.data.parameter].value =
|
|
3542
|
-
parameters_obj_inP[val.data.parameter];
|
|
3543
|
-
} else if (_session.engine_mode === "live_preview") {
|
|
3544
|
-
_ds.in_parameters[val.data.parameter].value =
|
|
3545
|
-
_session?.url_params?.[val.data.parameter];
|
|
3493
|
+
if (typeof parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
|
|
3494
|
+
_ds.in_parameters[val.data.parameter].value = parameters_obj_inP[val.data.parameter];
|
|
3495
|
+
} else if (_session.engine_mode === 'live_preview') {
|
|
3496
|
+
_ds.in_parameters[val.data.parameter].value = _session?.url_params?.[val.data.parameter];
|
|
3546
3497
|
}
|
|
3547
3498
|
|
|
3548
3499
|
continue;
|
|
3549
3500
|
}
|
|
3550
|
-
if (val.data.dir ===
|
|
3551
|
-
_ds.out_parameters[val.data.parameter] = await get_Out_parameters(
|
|
3552
|
-
val.data.parameter,
|
|
3553
|
-
key,
|
|
3554
|
-
val.id
|
|
3555
|
-
);
|
|
3501
|
+
if (val.data.dir === 'out' && val.data.parameter) {
|
|
3502
|
+
_ds.out_parameters[val.data.parameter] = await get_Out_parameters(val.data.parameter, key, val.id);
|
|
3556
3503
|
}
|
|
3557
3504
|
}
|
|
3558
3505
|
|
|
@@ -3562,23 +3509,20 @@ func.datasource.prepare = async function (
|
|
|
3562
3509
|
};
|
|
3563
3510
|
const build_GLOBAL_SYS_fields = function () {
|
|
3564
3511
|
if (!_ds.data_system) _ds.data_system = {};
|
|
3565
|
-
_ds.data_system[
|
|
3566
|
-
_ds.data_system[
|
|
3567
|
-
_ds.data_system[
|
|
3568
|
-
_ds.data_system[
|
|
3512
|
+
_ds.data_system['SYS_GLOBAL_UTC'] = -new Date().getTimezoneOffset() / 60;
|
|
3513
|
+
_ds.data_system['SYS_GLOBAL_STR_APP_ID'] = APP_OBJ[_session.app_id]._id;
|
|
3514
|
+
_ds.data_system['SYS_GLOBAL_STR_SESSION_ID'] = SESSION_ID;
|
|
3515
|
+
_ds.data_system['SYS_GLOBAL_STR_LOGIN_USER_ID'] = _session.USR_OBJ._id;
|
|
3569
3516
|
|
|
3570
|
-
if (
|
|
3571
|
-
|
|
3572
|
-
PROJECT_OBJ[_session.app_id].info
|
|
3573
|
-
) {
|
|
3574
|
-
_ds.data_system["SYS_GLOBAL_OBJ_APP_INFO"] = {
|
|
3517
|
+
if (_session.engine_mode !== 'live_preview' && PROJECT_OBJ[_session.app_id].info) {
|
|
3518
|
+
_ds.data_system['SYS_GLOBAL_OBJ_APP_INFO'] = {
|
|
3575
3519
|
build: PROJECT_OBJ[_session.app_id].info.build_id,
|
|
3576
3520
|
author: PROJECT_OBJ[_session.app_id].info.author,
|
|
3577
3521
|
date: PROJECT_OBJ[_session.app_id].info.build_date,
|
|
3578
3522
|
name: APP_OBJ[_session.app_id].app_name,
|
|
3579
3523
|
};
|
|
3580
3524
|
}
|
|
3581
|
-
_ds.data_system[
|
|
3525
|
+
_ds.data_system['SYS_GLOBAL_OBJ_LOGIN_USER_INFO'] = {
|
|
3582
3526
|
id: _session.USR_OBJ._id,
|
|
3583
3527
|
user_name: _session.USR_OBJ.usr_name,
|
|
3584
3528
|
first_name: _session.USR_OBJ.usr_first_name,
|
|
@@ -3586,52 +3530,37 @@ func.datasource.prepare = async function (
|
|
|
3586
3530
|
email: _session.USR_OBJ.usr_email,
|
|
3587
3531
|
profile_picture: _session.USR_OBJ.usr_profile_picture,
|
|
3588
3532
|
};
|
|
3589
|
-
_ds.data_system[
|
|
3590
|
-
|
|
3591
|
-
_ds.data_system["SYS_GLOBAL_STR_BROWSER_TITLE"] =
|
|
3592
|
-
_session.SYS_GLOBAL_STR_BROWSER_TITLE;
|
|
3533
|
+
_ds.data_system['SYS_GLOBAL_STR_BROWSER_HASH_ID'] = _session.SYS_GLOBAL_STR_BROWSER_HASH_ID;
|
|
3534
|
+
_ds.data_system['SYS_GLOBAL_STR_BROWSER_TITLE'] = _session.SYS_GLOBAL_STR_BROWSER_TITLE;
|
|
3593
3535
|
// }
|
|
3594
|
-
_ds.data_system[
|
|
3595
|
-
_ds.data_system[
|
|
3596
|
-
_ds.data_system[
|
|
3597
|
-
_ds.data_system[
|
|
3598
|
-
_ds.data_system[
|
|
3536
|
+
_ds.data_system['SYS_GLOBAL_STR_SITE_CSS'] = {};
|
|
3537
|
+
_ds.data_system['SYS_GLOBAL_BOL_SHIFT_KEY_STATE'] = 0;
|
|
3538
|
+
_ds.data_system['SYS_GLOBAL_BOL_COMMAND_KEY_STATE'] = 0;
|
|
3539
|
+
_ds.data_system['SYS_GLOBAL_BOL_CONTROL_KEY_STATE'] = 0;
|
|
3540
|
+
_ds.data_system['SYS_GLOBAL_BOL_ALT_KEY_STATE'] = 0;
|
|
3599
3541
|
|
|
3600
|
-
_ds.data_system[
|
|
3601
|
-
_ds.data_system[
|
|
3602
|
-
_ds.data_system[
|
|
3603
|
-
_ds.data_system[
|
|
3604
|
-
_ds.data_system[
|
|
3542
|
+
_ds.data_system['SYS_GLOBAL_BOL_ONLINE'] = 0;
|
|
3543
|
+
_ds.data_system['SYS_GLOBAL_BOL_REPLICATION_STAT'] = 0;
|
|
3544
|
+
_ds.data_system['SYS_GLOBAL_BOL_AJAX_BUSY'] = 0;
|
|
3545
|
+
_ds.data_system['SYS_GLOBAL_BOL_CONNECTED'] = 1;
|
|
3546
|
+
_ds.data_system['SYS_GLOBAL_BOL_IDLE'] = 0;
|
|
3605
3547
|
|
|
3606
|
-
_ds.data_system[
|
|
3548
|
+
_ds.data_system['SYS_GLOBAL_STR_FIREBASE_TOKEN_ID'] = 0;
|
|
3607
3549
|
|
|
3608
|
-
_ds.data_system[
|
|
3609
|
-
_session.PUSH_NOTIFICATION_GRANTED;
|
|
3550
|
+
_ds.data_system['SYS_GLOBAL_BOL_PUSH_NOTIFICATION_GRANTED'] = _session.PUSH_NOTIFICATION_GRANTED;
|
|
3610
3551
|
|
|
3611
|
-
_ds.data_system[
|
|
3612
|
-
_session.SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO;
|
|
3552
|
+
_ds.data_system['SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO'] = _session.SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO;
|
|
3613
3553
|
|
|
3614
|
-
_ds.data_system[
|
|
3615
|
-
_session.SYS_GLOBAL_OBJ_CLIENT_INFO;
|
|
3554
|
+
_ds.data_system['SYS_GLOBAL_OBJ_CLIENT_INFO'] = _session.SYS_GLOBAL_OBJ_CLIENT_INFO;
|
|
3616
3555
|
};
|
|
3617
3556
|
if (!SESSION_OBJ[SESSION_ID].DS_GLB) return;
|
|
3618
3557
|
|
|
3619
3558
|
if (dataSourceNoP && !SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceNoP]) {
|
|
3620
|
-
return func.utils.debug_report(
|
|
3621
|
-
SESSION_ID,
|
|
3622
|
-
"Datasource",
|
|
3623
|
-
"Datasource not exist: " + dataSourceNoP,
|
|
3624
|
-
"E"
|
|
3625
|
-
);
|
|
3559
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Datasource not exist: ' + dataSourceNoP, 'E');
|
|
3626
3560
|
}
|
|
3627
3561
|
|
|
3628
3562
|
if (!prog_id) {
|
|
3629
|
-
return func.utils.debug_report(
|
|
3630
|
-
SESSION_ID,
|
|
3631
|
-
"Datasource",
|
|
3632
|
-
"Program is null",
|
|
3633
|
-
"E"
|
|
3634
|
-
);
|
|
3563
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Program is null', 'E');
|
|
3635
3564
|
}
|
|
3636
3565
|
|
|
3637
3566
|
const args = {
|
|
@@ -3657,18 +3586,13 @@ func.datasource.prepare = async function (
|
|
|
3657
3586
|
|
|
3658
3587
|
const init_dataSource = async function () {
|
|
3659
3588
|
const init_new_dataSource = async function () {
|
|
3660
|
-
if (
|
|
3661
|
-
!["main"].includes(SESSION_OBJ[SESSION_ID].opt.app_computing_mode) &&
|
|
3662
|
-
run_atP === "client" &&
|
|
3663
|
-
prog_id !== "system"
|
|
3664
|
-
) {
|
|
3589
|
+
if (!['main'].includes(SESSION_OBJ[SESSION_ID].opt.app_computing_mode) && run_atP === 'client' && prog_id !== 'system') {
|
|
3665
3590
|
const ret = await func.index.call_worker(SESSION_ID, {
|
|
3666
|
-
service:
|
|
3591
|
+
service: 'get_dataSourceSessionGlobal',
|
|
3667
3592
|
data: { session_id: SESSION_ID },
|
|
3668
3593
|
id: SESSION_OBJ[SESSION_ID].worker_id,
|
|
3669
3594
|
});
|
|
3670
|
-
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal =
|
|
3671
|
-
ret?.new_dataSourceSessionGlobal || 1;
|
|
3595
|
+
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal = ret?.new_dataSourceSessionGlobal || 1;
|
|
3672
3596
|
} else {
|
|
3673
3597
|
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal++;
|
|
3674
3598
|
}
|
|
@@ -3679,7 +3603,7 @@ func.datasource.prepare = async function (
|
|
|
3679
3603
|
};
|
|
3680
3604
|
const init_existing_dataSource = function () {
|
|
3681
3605
|
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceNoP];
|
|
3682
|
-
console.log(
|
|
3606
|
+
console.log('DATASOURCE_REFRESH', dataSourceNoP);
|
|
3683
3607
|
IS_DATASOURCE_REFRESH = true;
|
|
3684
3608
|
_ds.refreshed = true;
|
|
3685
3609
|
try {
|
|
@@ -3692,13 +3616,13 @@ func.datasource.prepare = async function (
|
|
|
3692
3616
|
|
|
3693
3617
|
_ds.v.old_dataSource = _.cloneDeep(_ds);
|
|
3694
3618
|
} catch (err) {
|
|
3695
|
-
console.error(
|
|
3619
|
+
console.error('function: init_existing_dataSource - error');
|
|
3696
3620
|
return;
|
|
3697
3621
|
}
|
|
3698
3622
|
dataSourceSession = dataSourceNoP;
|
|
3699
3623
|
};
|
|
3700
3624
|
|
|
3701
|
-
if (typeof dataSourceNoP ===
|
|
3625
|
+
if (typeof dataSourceNoP === 'undefined' || dataSourceNoP === null) {
|
|
3702
3626
|
await init_new_dataSource();
|
|
3703
3627
|
} else {
|
|
3704
3628
|
init_existing_dataSource();
|
|
@@ -3708,7 +3632,7 @@ func.datasource.prepare = async function (
|
|
|
3708
3632
|
};
|
|
3709
3633
|
var _ds = await init_dataSource();
|
|
3710
3634
|
|
|
3711
|
-
_ds.stat =
|
|
3635
|
+
_ds.stat = 'busy';
|
|
3712
3636
|
_ds._run_at = run_atP;
|
|
3713
3637
|
// init_v();
|
|
3714
3638
|
|
|
@@ -3720,12 +3644,7 @@ func.datasource.prepare = async function (
|
|
|
3720
3644
|
_ds.tree_obj = await func.utils.TREE_OBJ.get(SESSION_ID, prog_id);
|
|
3721
3645
|
|
|
3722
3646
|
if (!_ds.tree_obj) {
|
|
3723
|
-
return func.utils.debug_report(
|
|
3724
|
-
SESSION_ID,
|
|
3725
|
-
"Datasource",
|
|
3726
|
-
"Program not exist: " + prog_id,
|
|
3727
|
-
"E"
|
|
3728
|
-
);
|
|
3647
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Program not exist: ' + prog_id, 'E');
|
|
3729
3648
|
}
|
|
3730
3649
|
|
|
3731
3650
|
await func.datasource.set_VIEW_data(SESSION_ID, args, _ds);
|
|
@@ -3735,7 +3654,7 @@ func.datasource.prepare = async function (
|
|
|
3735
3654
|
) {
|
|
3736
3655
|
_ds.v.viewSourceDesc = callingSourceP;
|
|
3737
3656
|
}
|
|
3738
|
-
if (dataSourceSession === 0) _ds.v.viewSourceDesc =
|
|
3657
|
+
if (dataSourceSession === 0) _ds.v.viewSourceDesc = 'system startup';
|
|
3739
3658
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
3740
3659
|
|
|
3741
3660
|
const set_DS_GLB = async function () {
|
|
@@ -3761,7 +3680,7 @@ func.datasource.prepare = async function (
|
|
|
3761
3680
|
await set_DS_GLB();
|
|
3762
3681
|
|
|
3763
3682
|
if (
|
|
3764
|
-
prog_id ===
|
|
3683
|
+
prog_id === 'system' &&
|
|
3765
3684
|
!parentDataSourceNoP // do only on first time datasource 0 call
|
|
3766
3685
|
) {
|
|
3767
3686
|
build_GLOBAL_SYS_fields();
|
|
@@ -3776,18 +3695,10 @@ func.datasource.prepare = async function (
|
|
|
3776
3695
|
// INTERVALS
|
|
3777
3696
|
//======================================
|
|
3778
3697
|
|
|
3779
|
-
_ds.client_interval = func.datasource.get_event_interval_arr(
|
|
3780
|
-
SESSION_ID,
|
|
3781
|
-
dataSourceSession,
|
|
3782
|
-
"client_interval"
|
|
3783
|
-
);
|
|
3698
|
+
_ds.client_interval = func.datasource.get_event_interval_arr(SESSION_ID, dataSourceSession, 'client_interval');
|
|
3784
3699
|
|
|
3785
|
-
if (prog_id ===
|
|
3786
|
-
_ds.server_interval = func.datasource.get_event_interval_arr(
|
|
3787
|
-
SESSION_ID,
|
|
3788
|
-
dataSourceSession,
|
|
3789
|
-
"server_interval"
|
|
3790
|
-
);
|
|
3700
|
+
if (prog_id === 'system') {
|
|
3701
|
+
_ds.server_interval = func.datasource.get_event_interval_arr(SESSION_ID, dataSourceSession, 'server_interval');
|
|
3791
3702
|
}
|
|
3792
3703
|
|
|
3793
3704
|
// if (static_refreshP) {
|
|
@@ -3796,22 +3707,14 @@ func.datasource.prepare = async function (
|
|
|
3796
3707
|
// if (!static_refreshP) await set_parameters(); // do only on new datasource or refresh
|
|
3797
3708
|
|
|
3798
3709
|
// try {
|
|
3799
|
-
let ret_execute = await func.datasource.execute(
|
|
3800
|
-
SESSION_ID,
|
|
3801
|
-
dataSourceSession
|
|
3802
|
-
);
|
|
3710
|
+
let ret_execute = await func.datasource.execute(SESSION_ID, dataSourceSession);
|
|
3803
3711
|
return ret_execute;
|
|
3804
3712
|
// } catch (e) {
|
|
3805
3713
|
// console.error(e);
|
|
3806
3714
|
// }
|
|
3807
3715
|
};
|
|
3808
3716
|
|
|
3809
|
-
func.datasource.execute = async function (
|
|
3810
|
-
SESSION_ID,
|
|
3811
|
-
dataSourceSession,
|
|
3812
|
-
IS_DATASOURCE_REFRESH
|
|
3813
|
-
) {
|
|
3814
|
-
|
|
3717
|
+
func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATASOURCE_REFRESH) {
|
|
3815
3718
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
3816
3719
|
var _ds = _session.DS_GLB[dataSourceSession];
|
|
3817
3720
|
var args = _ds.args;
|
|
@@ -3820,60 +3723,32 @@ func.datasource.execute = async function (
|
|
|
3820
3723
|
let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
3821
3724
|
|
|
3822
3725
|
const callback_datasource = async function () {
|
|
3823
|
-
if (typeof IS_WORKER ===
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
if (!["main"].includes(_session.opt.app_computing_mode)) {
|
|
3726
|
+
if (typeof IS_WORKER === 'undefined' && typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined' && _ds.viewSourceProp === 'globals') {
|
|
3727
|
+
if (!['main'].includes(_session.opt.app_computing_mode)) {
|
|
3827
3728
|
await func.index.call_worker(SESSION_ID, {
|
|
3828
|
-
service:
|
|
3729
|
+
service: 'create_webworker_globals',
|
|
3829
3730
|
data: { ds_data: _ds, session_id: SESSION_ID },
|
|
3830
3731
|
});
|
|
3831
3732
|
}
|
|
3832
3733
|
}
|
|
3833
3734
|
|
|
3834
|
-
if (
|
|
3835
|
-
await func.datasource.
|
|
3836
|
-
SESSION_ID,
|
|
3837
|
-
dataSourceSession,
|
|
3838
|
-
"on_load"
|
|
3839
|
-
)
|
|
3840
|
-
) {
|
|
3841
|
-
await func.datasource.execute_view_events(
|
|
3842
|
-
SESSION_ID,
|
|
3843
|
-
dataSourceSession,
|
|
3844
|
-
"on_load"
|
|
3845
|
-
);
|
|
3735
|
+
if (await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'on_load')) {
|
|
3736
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'on_load');
|
|
3846
3737
|
}
|
|
3847
3738
|
// }
|
|
3848
|
-
return func.datasource.callback(
|
|
3849
|
-
SESSION_ID,
|
|
3850
|
-
dataSourceSession,
|
|
3851
|
-
args.dataSourceNoP,
|
|
3852
|
-
args.rowIdP,
|
|
3853
|
-
args.jobNoP,
|
|
3854
|
-
null,
|
|
3855
|
-
_ds.prog_id
|
|
3856
|
-
);
|
|
3739
|
+
return await func.datasource.callback(SESSION_ID, dataSourceSession, args.dataSourceNoP, args.rowIdP, args.jobNoP, null, _ds.prog_id);
|
|
3857
3740
|
};
|
|
3858
3741
|
|
|
3859
3742
|
const get_limit = async function () {
|
|
3860
3743
|
var ret = 0;
|
|
3861
3744
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
3862
|
-
if (tree_ret.menuType ===
|
|
3745
|
+
if (tree_ret.menuType === 'get_data') {
|
|
3863
3746
|
return 1;
|
|
3864
3747
|
}
|
|
3865
3748
|
ret = _ds.progDataSource?.dataSourceLimit;
|
|
3866
3749
|
|
|
3867
3750
|
if (prog_obj.progDataSource?.dataSourceLoopExp) {
|
|
3868
|
-
ret = (
|
|
3869
|
-
await func.expression.get(
|
|
3870
|
-
SESSION_ID,
|
|
3871
|
-
prog_obj.progDataSource.dataSourceLoopExp,
|
|
3872
|
-
dataSourceSession,
|
|
3873
|
-
"view_loop",
|
|
3874
|
-
args.rowIdP
|
|
3875
|
-
)
|
|
3876
|
-
).result;
|
|
3751
|
+
ret = (await func.expression.get(SESSION_ID, prog_obj.progDataSource.dataSourceLoopExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
3877
3752
|
}
|
|
3878
3753
|
return ret;
|
|
3879
3754
|
};
|
|
@@ -3883,24 +3758,13 @@ func.datasource.execute = async function (
|
|
|
3883
3758
|
ret = _ds.progDataSource?.dataSourceSkip;
|
|
3884
3759
|
|
|
3885
3760
|
if (prog_obj.progDataSource?.dataSourceSkipExp) {
|
|
3886
|
-
ret = (
|
|
3887
|
-
await func.expression.get(
|
|
3888
|
-
SESSION_ID,
|
|
3889
|
-
prog_obj.progDataSource.dataSourceSkipExp,
|
|
3890
|
-
dataSourceSession,
|
|
3891
|
-
"view_loop",
|
|
3892
|
-
args.rowIdP
|
|
3893
|
-
)
|
|
3894
|
-
).result;
|
|
3761
|
+
ret = (await func.expression.get(SESSION_ID, prog_obj.progDataSource.dataSourceSkipExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
3895
3762
|
}
|
|
3896
3763
|
return ret;
|
|
3897
3764
|
};
|
|
3898
3765
|
|
|
3899
3766
|
const calc_batch_loops = async () => {
|
|
3900
|
-
if (
|
|
3901
|
-
!prog_obj.progDataSource?.dataSourceType ||
|
|
3902
|
-
_ds.progDataSource.dataSourceType === "none"
|
|
3903
|
-
) {
|
|
3767
|
+
if (!prog_obj.progDataSource?.dataSourceType || _ds.progDataSource.dataSourceType === 'none') {
|
|
3904
3768
|
_ds.v.batch_loops = await get_limit();
|
|
3905
3769
|
return false;
|
|
3906
3770
|
}
|
|
@@ -3909,10 +3773,7 @@ func.datasource.execute = async function (
|
|
|
3909
3773
|
// ? await get_limit()
|
|
3910
3774
|
// : _ds?.data_feed?.rows?.length;
|
|
3911
3775
|
|
|
3912
|
-
_ds.v.batch_loops =
|
|
3913
|
-
(await get_limit()) <= _ds.v.raw_data?.rows?.length
|
|
3914
|
-
? await get_limit()
|
|
3915
|
-
: _ds.v.raw_data?.rows?.length;
|
|
3776
|
+
_ds.v.batch_loops = (await get_limit()) <= _ds.v.raw_data?.rows?.length ? await get_limit() : _ds.v.raw_data?.rows?.length;
|
|
3916
3777
|
return true;
|
|
3917
3778
|
// _ds.v.batch_loops =
|
|
3918
3779
|
// (await get_limit()) <= _ds.v?.raw_data?.rows?.length
|
|
@@ -3923,54 +3784,39 @@ func.datasource.execute = async function (
|
|
|
3923
3784
|
|
|
3924
3785
|
const render_api_output = async function () {
|
|
3925
3786
|
if (prog_obj?.scriptData?.value) {
|
|
3926
|
-
var exp = await func.expression.get(
|
|
3927
|
-
SESSION_ID,
|
|
3928
|
-
prog_obj.scriptData.value,
|
|
3929
|
-
dataSourceSession,
|
|
3930
|
-
"api_rendered_output",
|
|
3931
|
-
null, null, null, null, null, null, null, null, null, tree_obj.apiOutput
|
|
3932
|
-
);
|
|
3787
|
+
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);
|
|
3933
3788
|
|
|
3934
|
-
let output_result = exp.result
|
|
3935
|
-
if (tree_obj.apiOutput ===
|
|
3789
|
+
let output_result = exp.result;
|
|
3790
|
+
if (tree_obj.apiOutput === 'json') {
|
|
3936
3791
|
// iterate object to fix expressions
|
|
3937
3792
|
try {
|
|
3938
3793
|
// let output_result_obj = JSON5.parse(output_result)
|
|
3939
|
-
let output_result_obj = await func.expression.secure_eval(
|
|
3940
|
-
SESSION_ID,
|
|
3941
|
-
"api_rendered_output",
|
|
3942
|
-
"(" + output_result + ")",
|
|
3943
|
-
null,
|
|
3944
|
-
dataSourceSession,
|
|
3945
|
-
|
|
3946
|
-
);
|
|
3794
|
+
let output_result_obj = await func.expression.secure_eval(SESSION_ID, 'api_rendered_output', '(' + output_result + ')', null, dataSourceSession);
|
|
3947
3795
|
// for await (let [key, val] of Object.entries(output_result_obj)) {
|
|
3948
3796
|
// output_result_obj[key] = (await func.expression.get(
|
|
3949
3797
|
// SESSION_ID,
|
|
3950
3798
|
// val,
|
|
3951
3799
|
// dataSourceSession, "object_property")).result
|
|
3952
3800
|
// }
|
|
3953
|
-
output_result = JSON.stringify(output_result_obj)
|
|
3801
|
+
output_result = JSON.stringify(output_result_obj);
|
|
3954
3802
|
} catch (err) {
|
|
3955
|
-
console.error(err)
|
|
3803
|
+
console.error(err);
|
|
3956
3804
|
}
|
|
3957
|
-
|
|
3958
3805
|
}
|
|
3959
|
-
_ds.api_rendered_output +=
|
|
3960
|
-
output_result + (tree_obj.apiOutput === "json" ? "," : "");
|
|
3806
|
+
_ds.api_rendered_output += output_result + (tree_obj.apiOutput === 'json' ? ',' : '');
|
|
3961
3807
|
} else {
|
|
3962
|
-
_ds.api_rendered_output =
|
|
3808
|
+
_ds.api_rendered_output = ''; //empty
|
|
3963
3809
|
}
|
|
3964
3810
|
};
|
|
3965
3811
|
|
|
3966
3812
|
// ======================================
|
|
3967
3813
|
// COMPUTE GLOBALS
|
|
3968
3814
|
// ======================================
|
|
3969
|
-
if (_ds.prog_id ===
|
|
3815
|
+
if (_ds.prog_id === 'system') {
|
|
3970
3816
|
//TBD tree_obj.menuType === "globals"
|
|
3971
|
-
_ds.currentRecordId =
|
|
3817
|
+
_ds.currentRecordId = 'dataset';
|
|
3972
3818
|
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, {
|
|
3973
|
-
id:
|
|
3819
|
+
id: 'dataset',
|
|
3974
3820
|
value: _session.url_params,
|
|
3975
3821
|
});
|
|
3976
3822
|
|
|
@@ -3983,47 +3829,31 @@ func.datasource.execute = async function (
|
|
|
3983
3829
|
let db_adapter_module;
|
|
3984
3830
|
|
|
3985
3831
|
if (prog_obj.progDataSource?.dataSourceType) {
|
|
3986
|
-
db_adapter_module = await func.common.get_module(
|
|
3987
|
-
SESSION_ID,
|
|
3988
|
-
"xuda-datasource-db-adapter-module.mjs"
|
|
3989
|
-
);
|
|
3832
|
+
db_adapter_module = await func.common.get_module(SESSION_ID, 'xuda-datasource-db-adapter-module.mjs');
|
|
3990
3833
|
}
|
|
3991
3834
|
|
|
3992
3835
|
const get_data_from_source = async function () {
|
|
3993
3836
|
switch (prog_obj.progDataSource.dataSourceSrcType) {
|
|
3994
|
-
case
|
|
3995
|
-
const { result, error } = await func.expression.get(
|
|
3996
|
-
SESSION_ID,
|
|
3997
|
-
prog_obj.progDataSource.progDataSourceInput,
|
|
3998
|
-
dataSourceSession,
|
|
3999
|
-
"datasource select"
|
|
4000
|
-
);
|
|
3837
|
+
case 'input': {
|
|
3838
|
+
const { result, error } = await func.expression.get(SESSION_ID, prog_obj.progDataSource.progDataSourceInput, dataSourceSession, 'datasource select');
|
|
4001
3839
|
if (error) {
|
|
4002
|
-
func.utils.debug_report(
|
|
4003
|
-
SESSION_ID,
|
|
4004
|
-
"Data source",
|
|
4005
|
-
`Datasource parse error using ${prog_obj.progDataSource?.dataSourceType} input`,
|
|
4006
|
-
"E"
|
|
4007
|
-
);
|
|
3840
|
+
func.utils.debug_report(SESSION_ID, 'Data source', `Datasource parse error using ${prog_obj.progDataSource?.dataSourceType} input`, 'E');
|
|
4008
3841
|
return null;
|
|
4009
3842
|
}
|
|
4010
3843
|
|
|
4011
3844
|
return result;
|
|
4012
3845
|
break;
|
|
4013
3846
|
}
|
|
4014
|
-
case
|
|
3847
|
+
case 'url': {
|
|
4015
3848
|
let opt = {
|
|
4016
|
-
method: prog_obj.progDataSource.dataSourceMethod ||
|
|
3849
|
+
method: prog_obj.progDataSource.dataSourceMethod || 'POST',
|
|
4017
3850
|
headers: {
|
|
4018
|
-
Accept:
|
|
4019
|
-
|
|
3851
|
+
Accept: 'application/json',
|
|
3852
|
+
'Content-Type': 'application/json',
|
|
4020
3853
|
},
|
|
4021
3854
|
};
|
|
4022
3855
|
let data = {};
|
|
4023
|
-
if (
|
|
4024
|
-
prog_obj.progDataSource.dataSourceMethod == "POST" &&
|
|
4025
|
-
prog_obj.progDataSource.dataSourceParameters
|
|
4026
|
-
) {
|
|
3856
|
+
if (prog_obj.progDataSource.dataSourceMethod == 'POST' && prog_obj.progDataSource.dataSourceParameters) {
|
|
4027
3857
|
for (let val of prog_obj.progDataSource.dataSourceParameters) {
|
|
4028
3858
|
data[val.key] = val.val;
|
|
4029
3859
|
}
|
|
@@ -4031,21 +3861,11 @@ func.datasource.execute = async function (
|
|
|
4031
3861
|
opt.body = JSON.stringify(data);
|
|
4032
3862
|
}
|
|
4033
3863
|
try {
|
|
4034
|
-
const response = await fetch(
|
|
4035
|
-
"https://" + prog_obj.progDataSource.dataSourceDataUrl,
|
|
4036
|
-
opt
|
|
4037
|
-
);
|
|
3864
|
+
const response = await fetch('https://' + prog_obj.progDataSource.dataSourceDataUrl, opt);
|
|
4038
3865
|
const json = await response.json();
|
|
4039
3866
|
return json.data;
|
|
4040
3867
|
} catch (err) {
|
|
4041
|
-
func.utils.debug_report(
|
|
4042
|
-
SESSION_ID,
|
|
4043
|
-
"Data source",
|
|
4044
|
-
err.message +
|
|
4045
|
-
" https://" +
|
|
4046
|
-
prog_obj.progDataSource.dataSourceDataUrl,
|
|
4047
|
-
"E"
|
|
4048
|
-
);
|
|
3868
|
+
func.utils.debug_report(SESSION_ID, 'Data source', err.message + ' https://' + prog_obj.progDataSource.dataSourceDataUrl, 'E');
|
|
4049
3869
|
return null;
|
|
4050
3870
|
}
|
|
4051
3871
|
|
|
@@ -4065,76 +3885,37 @@ func.datasource.execute = async function (
|
|
|
4065
3885
|
_ds.data_feed.rows = [];
|
|
4066
3886
|
|
|
4067
3887
|
switch (prog_obj.progDataSource?.dataSourceType) {
|
|
4068
|
-
case
|
|
3888
|
+
case 'table':
|
|
4069
3889
|
_ds._dataSourceTableId = prog_obj.progDataSource?.dataSourceTableId; // get file id
|
|
4070
3890
|
|
|
4071
3891
|
if (prog_obj.progDataSource?.dataSourceTableIdExp) {
|
|
4072
|
-
_ds.v.dataSourceTableIdExp = await func.expression.get(
|
|
4073
|
-
SESSION_ID,
|
|
4074
|
-
prog_obj.progDataSource?.dataSourceTableIdExp,
|
|
4075
|
-
dataSourceSession,
|
|
4076
|
-
"dataSourceTableIdExp",
|
|
4077
|
-
args.rowIdP
|
|
4078
|
-
);
|
|
3892
|
+
_ds.v.dataSourceTableIdExp = await func.expression.get(SESSION_ID, prog_obj.progDataSource?.dataSourceTableIdExp, dataSourceSession, 'dataSourceTableIdExp', args.rowIdP);
|
|
4079
3893
|
if (_ds.v.dataSourceTableIdExp.result) {
|
|
4080
3894
|
_ds._dataSourceTableId = _ds.v.dataSourceTableIdExp.result;
|
|
4081
3895
|
} else {
|
|
4082
|
-
func.utils.debug_report(
|
|
4083
|
-
SESSION_ID,
|
|
4084
|
-
"get_VIEW_data",
|
|
4085
|
-
"Table Expression returned empty result",
|
|
4086
|
-
"W"
|
|
4087
|
-
);
|
|
3896
|
+
func.utils.debug_report(SESSION_ID, 'get_VIEW_data', 'Table Expression returned empty result', 'W');
|
|
4088
3897
|
}
|
|
4089
3898
|
}
|
|
4090
3899
|
|
|
4091
3900
|
if (!_ds._dataSourceTableId) {
|
|
4092
|
-
return func.utils.debug_report(
|
|
4093
|
-
SESSION_ID,
|
|
4094
|
-
"Data source",
|
|
4095
|
-
"Table cannot be empty when Db Table selected",
|
|
4096
|
-
"E"
|
|
4097
|
-
);
|
|
3901
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Table cannot be empty when Db Table selected', 'E');
|
|
4098
3902
|
}
|
|
4099
3903
|
|
|
4100
|
-
let table_ret = await func.utils.TREE_OBJ.get(
|
|
4101
|
-
SESSION_ID,
|
|
4102
|
-
_ds._dataSourceTableId
|
|
4103
|
-
);
|
|
3904
|
+
let table_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
4104
3905
|
if (!table_ret) {
|
|
4105
|
-
return func.utils.debug_report(
|
|
4106
|
-
SESSION_ID,
|
|
4107
|
-
"Data source",
|
|
4108
|
-
"Table not found: " + _ds._dataSourceTableId,
|
|
4109
|
-
"E"
|
|
4110
|
-
);
|
|
3906
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Table not found: ' + _ds._dataSourceTableId, 'E');
|
|
4111
3907
|
}
|
|
4112
3908
|
|
|
4113
|
-
await db_adapter_module.build_filter(
|
|
4114
|
-
SESSION_ID,
|
|
4115
|
-
dataSourceSession,
|
|
4116
|
-
_ds.v,
|
|
4117
|
-
_ds
|
|
4118
|
-
);
|
|
3909
|
+
await db_adapter_module.build_filter(SESSION_ID, dataSourceSession, _ds.v, _ds);
|
|
4119
3910
|
|
|
4120
3911
|
let filterModelMongo = _ds.progDataSource.filterModelMongo;
|
|
4121
3912
|
if (_ds.progDataSource.filterModelMongoFx) {
|
|
4122
|
-
let ret = await func.expression.get(
|
|
4123
|
-
SESSION_ID,
|
|
4124
|
-
_ds.progDataSource.filterModelMongoFx,
|
|
4125
|
-
dataSourceSession,
|
|
4126
|
-
"query"
|
|
4127
|
-
);
|
|
3913
|
+
let ret = await func.expression.get(SESSION_ID, _ds.progDataSource.filterModelMongoFx, dataSourceSession, 'query');
|
|
4128
3914
|
filterModelMongo = ret.result;
|
|
4129
3915
|
}
|
|
4130
3916
|
let filterModelSql = _ds.progDataSource.filterModelSql;
|
|
4131
3917
|
if (_ds.progDataSource.filterModelSqlFx) {
|
|
4132
|
-
let ret = await func.expression.get(
|
|
4133
|
-
SESSION_ID,
|
|
4134
|
-
_ds.progDataSource.filterModelSqlFx,
|
|
4135
|
-
dataSourceSession,
|
|
4136
|
-
"query"
|
|
4137
|
-
);
|
|
3918
|
+
let ret = await func.expression.get(SESSION_ID, _ds.progDataSource.filterModelSqlFx, dataSourceSession, 'query');
|
|
4138
3919
|
filterModelSql = ret.result;
|
|
4139
3920
|
}
|
|
4140
3921
|
|
|
@@ -4154,7 +3935,7 @@ func.datasource.execute = async function (
|
|
|
4154
3935
|
_ds.v.couchView,
|
|
4155
3936
|
dataSourceSession,
|
|
4156
3937
|
_ds.viewSourceDesc,
|
|
4157
|
-
|
|
3938
|
+
'datasource table',
|
|
4158
3939
|
prog_obj.progDataSource.dataSourceReduce,
|
|
4159
3940
|
await get_skip(),
|
|
4160
3941
|
(await get_limit()) || 99999999,
|
|
@@ -4163,7 +3944,7 @@ func.datasource.execute = async function (
|
|
|
4163
3944
|
_ds?.progDataSource?.sortModel,
|
|
4164
3945
|
null,
|
|
4165
3946
|
filterModel,
|
|
4166
|
-
_ds?.progDataSource?.dataSourceFilterModelType
|
|
3947
|
+
_ds?.progDataSource?.dataSourceFilterModelType,
|
|
4167
3948
|
);
|
|
4168
3949
|
if (_ds?.progDataSource?.dataSourceLimit) {
|
|
4169
3950
|
const ret_rows_found = await func.db.get_query(
|
|
@@ -4172,7 +3953,7 @@ func.datasource.execute = async function (
|
|
|
4172
3953
|
_ds.v.couchView,
|
|
4173
3954
|
dataSourceSession,
|
|
4174
3955
|
_ds.viewSourceDesc,
|
|
4175
|
-
|
|
3956
|
+
'datasource table',
|
|
4176
3957
|
prog_obj.progDataSource.dataSourceReduce,
|
|
4177
3958
|
null,
|
|
4178
3959
|
null,
|
|
@@ -4181,7 +3962,7 @@ func.datasource.execute = async function (
|
|
|
4181
3962
|
null,
|
|
4182
3963
|
null,
|
|
4183
3964
|
filterModel,
|
|
4184
|
-
_ds?.progDataSource?.dataSourceFilterModelType
|
|
3965
|
+
_ds?.progDataSource?.dataSourceFilterModelType,
|
|
4185
3966
|
);
|
|
4186
3967
|
_ds.rows_found = ret_rows_found?.rows?.[0]?.value || 0;
|
|
4187
3968
|
} else {
|
|
@@ -4189,7 +3970,7 @@ func.datasource.execute = async function (
|
|
|
4189
3970
|
}
|
|
4190
3971
|
break;
|
|
4191
3972
|
|
|
4192
|
-
case
|
|
3973
|
+
case 'array': {
|
|
4193
3974
|
let data = await get_data_from_source();
|
|
4194
3975
|
|
|
4195
3976
|
if (data === null) {
|
|
@@ -4215,7 +3996,7 @@ func.datasource.execute = async function (
|
|
|
4215
3996
|
break;
|
|
4216
3997
|
}
|
|
4217
3998
|
|
|
4218
|
-
case
|
|
3999
|
+
case 'json': {
|
|
4219
4000
|
let data = await get_data_from_source();
|
|
4220
4001
|
if (data === null) {
|
|
4221
4002
|
data = {};
|
|
@@ -4236,12 +4017,10 @@ func.datasource.execute = async function (
|
|
|
4236
4017
|
break;
|
|
4237
4018
|
}
|
|
4238
4019
|
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
case "csv":
|
|
4020
|
+
case 'csv':
|
|
4242
4021
|
let data = await get_data_from_source();
|
|
4243
4022
|
if (data === null) {
|
|
4244
|
-
data =
|
|
4023
|
+
data = '';
|
|
4245
4024
|
}
|
|
4246
4025
|
|
|
4247
4026
|
// if (!_ds.v.raw_data) {
|
|
@@ -4260,7 +4039,7 @@ func.datasource.execute = async function (
|
|
|
4260
4039
|
// }
|
|
4261
4040
|
|
|
4262
4041
|
let _KEY = 0;
|
|
4263
|
-
let arr = data.split(
|
|
4042
|
+
let arr = data.split(',');
|
|
4264
4043
|
for (const _VAL of arr) {
|
|
4265
4044
|
_ds.v.raw_data.rows.push({ id: _KEY, value: { _KEY, _VAL } });
|
|
4266
4045
|
_KEY++;
|
|
@@ -4279,24 +4058,16 @@ func.datasource.execute = async function (
|
|
|
4279
4058
|
let ret;
|
|
4280
4059
|
|
|
4281
4060
|
const get_before_record_count = async () => {
|
|
4282
|
-
return await func.datasource.get_view_events_count(
|
|
4283
|
-
SESSION_ID,
|
|
4284
|
-
dataSourceSession,
|
|
4285
|
-
"before_record"
|
|
4286
|
-
);
|
|
4061
|
+
return await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'before_record');
|
|
4287
4062
|
};
|
|
4288
4063
|
const get_after_record_count = async () => {
|
|
4289
|
-
return await func.datasource.get_view_events_count(
|
|
4290
|
-
SESSION_ID,
|
|
4291
|
-
dataSourceSession,
|
|
4292
|
-
"after_record"
|
|
4293
|
-
);
|
|
4064
|
+
return await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'after_record');
|
|
4294
4065
|
};
|
|
4295
4066
|
|
|
4296
4067
|
let _raw_data_rows = [];
|
|
4297
4068
|
switch (tree_obj.menuType) {
|
|
4298
|
-
case
|
|
4299
|
-
_ds.api_rendered_output =
|
|
4069
|
+
case 'api': {
|
|
4070
|
+
_ds.api_rendered_output = '';
|
|
4300
4071
|
let has_datasource = await calc_batch_loops();
|
|
4301
4072
|
|
|
4302
4073
|
_raw_data_rows = _ds.v.raw_data.rows || [];
|
|
@@ -4305,7 +4076,7 @@ func.datasource.execute = async function (
|
|
|
4305
4076
|
_raw_data_rows.push({ id: n, value: {} });
|
|
4306
4077
|
}
|
|
4307
4078
|
}
|
|
4308
|
-
_ds.currentRecordId =
|
|
4079
|
+
_ds.currentRecordId = 'dataset';
|
|
4309
4080
|
for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
|
|
4310
4081
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
4311
4082
|
|
|
@@ -4314,47 +4085,31 @@ func.datasource.execute = async function (
|
|
|
4314
4085
|
}
|
|
4315
4086
|
|
|
4316
4087
|
if (await get_before_record_count()) {
|
|
4317
|
-
await func.datasource.execute_view_events(
|
|
4318
|
-
SESSION_ID,
|
|
4319
|
-
dataSourceSession,
|
|
4320
|
-
"before_record"
|
|
4321
|
-
);
|
|
4088
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
4322
4089
|
}
|
|
4323
4090
|
|
|
4324
|
-
await func.datasource.render_fields_dataset(
|
|
4325
|
-
SESSION_ID,
|
|
4326
|
-
dataSourceSession,
|
|
4327
|
-
raw_data_row
|
|
4328
|
-
);
|
|
4091
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
4329
4092
|
|
|
4330
4093
|
if (await get_after_record_count()) {
|
|
4331
|
-
await func.datasource.execute_view_events(
|
|
4332
|
-
SESSION_ID,
|
|
4333
|
-
dataSourceSession,
|
|
4334
|
-
"after_record"
|
|
4335
|
-
);
|
|
4094
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
4336
4095
|
}
|
|
4337
4096
|
|
|
4338
4097
|
await render_api_output();
|
|
4339
4098
|
}
|
|
4340
4099
|
|
|
4341
|
-
if (tree_obj.apiOutput ===
|
|
4342
|
-
var str = _ds.api_rendered_output.substring(
|
|
4343
|
-
0,
|
|
4344
|
-
_ds.api_rendered_output.length - 1
|
|
4345
|
-
);
|
|
4100
|
+
if (tree_obj.apiOutput === 'json') {
|
|
4101
|
+
var str = _ds.api_rendered_output.substring(0, _ds.api_rendered_output.length - 1);
|
|
4346
4102
|
if (Number(_ds.progDataSource?.dataSourceLimit) === 1) {
|
|
4347
4103
|
_ds.api_rendered_output = str;
|
|
4348
4104
|
} else {
|
|
4349
|
-
_ds.api_rendered_output =
|
|
4105
|
+
_ds.api_rendered_output = '[' + str + ']';
|
|
4350
4106
|
}
|
|
4351
4107
|
}
|
|
4352
4108
|
|
|
4353
4109
|
break;
|
|
4354
4110
|
}
|
|
4355
4111
|
|
|
4356
|
-
case
|
|
4357
|
-
|
|
4112
|
+
case 'batch': {
|
|
4358
4113
|
let has_datasource = await calc_batch_loops();
|
|
4359
4114
|
|
|
4360
4115
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
@@ -4363,7 +4118,7 @@ func.datasource.execute = async function (
|
|
|
4363
4118
|
_raw_data_rows.push({ id: n, value: {} });
|
|
4364
4119
|
}
|
|
4365
4120
|
}
|
|
4366
|
-
_ds.currentRecordId =
|
|
4121
|
+
_ds.currentRecordId = 'dataset';
|
|
4367
4122
|
for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
|
|
4368
4123
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
4369
4124
|
|
|
@@ -4372,68 +4127,35 @@ func.datasource.execute = async function (
|
|
|
4372
4127
|
}
|
|
4373
4128
|
|
|
4374
4129
|
if (await get_before_record_count()) {
|
|
4375
|
-
await func.datasource.execute_view_events(
|
|
4376
|
-
SESSION_ID,
|
|
4377
|
-
dataSourceSession,
|
|
4378
|
-
"before_record"
|
|
4379
|
-
);
|
|
4130
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
4380
4131
|
}
|
|
4381
4132
|
|
|
4382
|
-
await func.datasource.render_fields_dataset(
|
|
4383
|
-
SESSION_ID,
|
|
4384
|
-
dataSourceSession,
|
|
4385
|
-
raw_data_row
|
|
4386
|
-
);
|
|
4133
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
4387
4134
|
|
|
4388
4135
|
if (await get_after_record_count()) {
|
|
4389
|
-
await func.datasource.execute_view_events(
|
|
4390
|
-
SESSION_ID,
|
|
4391
|
-
dataSourceSession,
|
|
4392
|
-
"after_record"
|
|
4393
|
-
);
|
|
4136
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
4394
4137
|
}
|
|
4395
4138
|
}
|
|
4396
4139
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
4397
4140
|
break;
|
|
4398
4141
|
}
|
|
4399
4142
|
|
|
4400
|
-
case
|
|
4143
|
+
case 'get_data':
|
|
4401
4144
|
if (await get_before_record_count()) {
|
|
4402
|
-
await func.datasource.execute_view_events(
|
|
4403
|
-
SESSION_ID,
|
|
4404
|
-
dataSourceSession,
|
|
4405
|
-
"before_record"
|
|
4406
|
-
);
|
|
4145
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
4407
4146
|
}
|
|
4408
4147
|
|
|
4409
|
-
ret = await db_adapter_module.process_view_dataset(
|
|
4410
|
-
SESSION_ID,
|
|
4411
|
-
dataSourceSession,
|
|
4412
|
-
_ds
|
|
4413
|
-
);
|
|
4148
|
+
ret = await db_adapter_module.process_view_dataset(SESSION_ID, dataSourceSession, _ds);
|
|
4414
4149
|
|
|
4415
4150
|
if (await get_after_record_count()) {
|
|
4416
|
-
await func.datasource.execute_view_events(
|
|
4417
|
-
SESSION_ID,
|
|
4418
|
-
dataSourceSession,
|
|
4419
|
-
"after_record"
|
|
4420
|
-
);
|
|
4151
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
4421
4152
|
}
|
|
4422
4153
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
4423
4154
|
break;
|
|
4424
4155
|
|
|
4425
|
-
case
|
|
4426
|
-
if (
|
|
4427
|
-
|
|
4428
|
-
_ds.progDataSource.dataSourceType !== "table" ||
|
|
4429
|
-
!_ds._dataSourceTableId
|
|
4430
|
-
) {
|
|
4431
|
-
return func.utils.debug_report(
|
|
4432
|
-
SESSION_ID,
|
|
4433
|
-
"Data source",
|
|
4434
|
-
"Datasource DB Table must be defined for Set Data operation",
|
|
4435
|
-
"E"
|
|
4436
|
-
);
|
|
4156
|
+
case 'set_data':
|
|
4157
|
+
if (!prog_obj.progDataSource?.dataSourceType || _ds.progDataSource.dataSourceType !== 'table' || !_ds._dataSourceTableId) {
|
|
4158
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Datasource DB Table must be defined for Set Data operation', 'E');
|
|
4437
4159
|
}
|
|
4438
4160
|
|
|
4439
4161
|
// const get_data_from_data_feed = function () {
|
|
@@ -4448,7 +4170,7 @@ func.datasource.execute = async function (
|
|
|
4448
4170
|
|
|
4449
4171
|
const find_ROWID_idx_from_raw_data_arr = function (rowId) {
|
|
4450
4172
|
if (!_raw_data_rows) {
|
|
4451
|
-
throw new Error(
|
|
4173
|
+
throw new Error('_raw_data_rows not found');
|
|
4452
4174
|
}
|
|
4453
4175
|
|
|
4454
4176
|
const index = _raw_data_rows.findIndex((item) => item.id === rowId);
|
|
@@ -4458,81 +4180,62 @@ func.datasource.execute = async function (
|
|
|
4458
4180
|
return index;
|
|
4459
4181
|
};
|
|
4460
4182
|
|
|
4461
|
-
if (tree_obj.crudMode ===
|
|
4462
|
-
_ds.set_mode =
|
|
4183
|
+
if (tree_obj.crudMode === 'U') {
|
|
4184
|
+
_ds.set_mode = 'U';
|
|
4463
4185
|
// _raw_data_rows = get_data_from_data_feed(); // _ds?.raw_data?.rows || [];
|
|
4464
4186
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
4465
4187
|
}
|
|
4466
4188
|
|
|
4467
|
-
if (tree_obj.crudMode ===
|
|
4468
|
-
_ds.set_mode =
|
|
4189
|
+
if (tree_obj.crudMode === 'D') {
|
|
4190
|
+
_ds.set_mode = 'D';
|
|
4469
4191
|
// _raw_data_rows = get_data_from_data_feed(); // _ds.raw_data?.rows || [];
|
|
4470
4192
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
4471
4193
|
}
|
|
4472
4194
|
|
|
4473
4195
|
// initiated with Update but no rows found
|
|
4474
|
-
if (
|
|
4475
|
-
|
|
4476
|
-
tree_obj.allowCreate &&
|
|
4477
|
-
!_ds?.data_feed?.rows?.length
|
|
4478
|
-
) {
|
|
4479
|
-
_ds.set_mode = "C";
|
|
4196
|
+
if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
|
|
4197
|
+
_ds.set_mode = 'C';
|
|
4480
4198
|
// _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
|
|
4481
4199
|
|
|
4482
4200
|
try {
|
|
4483
|
-
const row_idx = find_ROWID_idx_from_raw_data_arr(
|
|
4484
|
-
_raw_data_rows[row_idx] = [{ id:
|
|
4201
|
+
const row_idx = find_ROWID_idx_from_raw_data_arr('newRecord');
|
|
4202
|
+
_raw_data_rows[row_idx] = [{ id: 'newRecord', value: {} }];
|
|
4485
4203
|
} catch (error) {
|
|
4486
|
-
_raw_data_rows.push({ _ROWID:
|
|
4204
|
+
_raw_data_rows.push({ _ROWID: 'newRecord' });
|
|
4487
4205
|
}
|
|
4488
4206
|
}
|
|
4489
4207
|
|
|
4490
|
-
if (tree_obj.crudMode ===
|
|
4491
|
-
_ds.set_mode =
|
|
4208
|
+
if (tree_obj.crudMode === 'C') {
|
|
4209
|
+
_ds.set_mode = 'C';
|
|
4492
4210
|
// _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
|
|
4493
4211
|
try {
|
|
4494
|
-
const row_idx = find_ROWID_idx_from_raw_data_arr(
|
|
4495
|
-
_raw_data_rows[row_idx] = [{ id:
|
|
4212
|
+
const row_idx = find_ROWID_idx_from_raw_data_arr('newRecord');
|
|
4213
|
+
_raw_data_rows[row_idx] = [{ id: 'newRecord', value: {} }];
|
|
4496
4214
|
} catch (error) {
|
|
4497
|
-
_raw_data_rows.push({ id:
|
|
4215
|
+
_raw_data_rows.push({ id: 'newRecord', value: {} });
|
|
4498
4216
|
}
|
|
4499
4217
|
}
|
|
4500
4218
|
|
|
4501
4219
|
for await (let raw_data_row of _raw_data_rows) {
|
|
4502
4220
|
_ds.currentRecordId = raw_data_row.id;
|
|
4503
4221
|
if (await get_before_record_count()) {
|
|
4504
|
-
await func.datasource.execute_view_events(
|
|
4505
|
-
SESSION_ID,
|
|
4506
|
-
dataSourceSession,
|
|
4507
|
-
"before_record"
|
|
4508
|
-
);
|
|
4222
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
4509
4223
|
}
|
|
4510
4224
|
|
|
4511
|
-
await func.datasource.render_fields_dataset(
|
|
4512
|
-
SESSION_ID,
|
|
4513
|
-
dataSourceSession,
|
|
4514
|
-
raw_data_row
|
|
4515
|
-
);
|
|
4225
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
4516
4226
|
let data_feed_str = JSON.stringify(_ds.data_feed);
|
|
4517
4227
|
|
|
4518
4228
|
if (await get_after_record_count()) {
|
|
4519
|
-
await func.datasource.execute_view_events(
|
|
4520
|
-
SESSION_ID,
|
|
4521
|
-
dataSourceSession,
|
|
4522
|
-
"after_record"
|
|
4523
|
-
);
|
|
4229
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
4524
4230
|
}
|
|
4525
4231
|
|
|
4526
|
-
if (
|
|
4527
|
-
_ds.set_mode === "C" ||
|
|
4528
|
-
JSON.stringify(_ds.data_feed) !== data_feed_str
|
|
4529
|
-
) {
|
|
4232
|
+
if (_ds.set_mode === 'C' || JSON.stringify(_ds.data_feed) !== data_feed_str) {
|
|
4530
4233
|
const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
4531
4234
|
if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
4532
|
-
_ds.set_mode =
|
|
4235
|
+
_ds.set_mode = 'U';
|
|
4533
4236
|
}
|
|
4534
4237
|
|
|
4535
|
-
if (_ds.set_mode ===
|
|
4238
|
+
if (_ds.set_mode === 'D') {
|
|
4536
4239
|
const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
4537
4240
|
if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
4538
4241
|
}
|
|
@@ -4541,7 +4244,7 @@ func.datasource.execute = async function (
|
|
|
4541
4244
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
4542
4245
|
break;
|
|
4543
4246
|
|
|
4544
|
-
case
|
|
4247
|
+
case 'component':
|
|
4545
4248
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
4546
4249
|
_ds.rows_processed = 0;
|
|
4547
4250
|
_ds.viewRangeExp_rows_deleted = 0;
|
|
@@ -4552,49 +4255,29 @@ func.datasource.execute = async function (
|
|
|
4552
4255
|
_ds.data_feed.rows_deleted = [];
|
|
4553
4256
|
_ds.data_feed.rows_added = [];
|
|
4554
4257
|
|
|
4555
|
-
if (tree_obj.rwMode ===
|
|
4556
|
-
_ds.set_mode =
|
|
4258
|
+
if (tree_obj.rwMode === 'U') {
|
|
4259
|
+
_ds.set_mode = 'U';
|
|
4557
4260
|
} else {
|
|
4558
|
-
_ds.set_mode =
|
|
4261
|
+
_ds.set_mode = 'R';
|
|
4559
4262
|
}
|
|
4560
4263
|
|
|
4561
4264
|
const row_not_found = async function () {
|
|
4562
|
-
if (
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
) {
|
|
4566
|
-
_ds.currentRecordId = "newRecord";
|
|
4567
|
-
_ds.set_mode = "C";
|
|
4265
|
+
if (!prog_obj.progDataSource?.dataSourceType || (tree_obj.rwMode === 'U' && tree_obj.allowCreate)) {
|
|
4266
|
+
_ds.currentRecordId = 'newRecord';
|
|
4267
|
+
_ds.set_mode = 'C';
|
|
4568
4268
|
_ds.record_not_found = true;
|
|
4569
4269
|
|
|
4570
4270
|
try {
|
|
4571
|
-
const row_idx = func.common.find_ROWID_idx(
|
|
4572
|
-
_ds,
|
|
4573
|
-
_ds.currentRecordId
|
|
4574
|
-
);
|
|
4271
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
4575
4272
|
} catch (error) {
|
|
4576
|
-
await func.datasource.render_fields_form(
|
|
4577
|
-
SESSION_ID,
|
|
4578
|
-
dataSourceSession,
|
|
4579
|
-
{ id: "newRecord", value: {} }
|
|
4580
|
-
);
|
|
4273
|
+
await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, { id: 'newRecord', value: {} });
|
|
4581
4274
|
}
|
|
4582
4275
|
|
|
4583
|
-
var count = await func.datasource.get_field_init_count(
|
|
4584
|
-
SESSION_ID,
|
|
4585
|
-
dataSourceSession,
|
|
4586
|
-
"newRecord",
|
|
4587
|
-
false
|
|
4588
|
-
);
|
|
4276
|
+
var count = await func.datasource.get_field_init_count(SESSION_ID, dataSourceSession, 'newRecord', false);
|
|
4589
4277
|
if (
|
|
4590
4278
|
count > 0 // was: && !args.dataSourceNoP
|
|
4591
4279
|
) {
|
|
4592
|
-
await func.datasource.execute_field_init_events(
|
|
4593
|
-
SESSION_ID,
|
|
4594
|
-
dataSourceSession,
|
|
4595
|
-
"form",
|
|
4596
|
-
"newRecord"
|
|
4597
|
-
);
|
|
4280
|
+
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', 'newRecord');
|
|
4598
4281
|
}
|
|
4599
4282
|
}
|
|
4600
4283
|
};
|
|
@@ -4609,20 +4292,13 @@ func.datasource.execute = async function (
|
|
|
4609
4292
|
// check if locatedRecordId exist in SESSION_OBJ[SESSION_ID].DS_GLB
|
|
4610
4293
|
if (_ds.locatedRecordId) {
|
|
4611
4294
|
try {
|
|
4612
|
-
const row_idx = func.common.find_ROWID_idx(
|
|
4613
|
-
_ds,
|
|
4614
|
-
_ds.locatedRecordId
|
|
4615
|
-
);
|
|
4295
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.locatedRecordId);
|
|
4616
4296
|
} catch (error) {
|
|
4617
4297
|
delete _ds.locatedRecordId;
|
|
4618
4298
|
}
|
|
4619
4299
|
}
|
|
4620
4300
|
|
|
4621
|
-
_ds.finalRecordId = func.datasource.get_currentRecordId(
|
|
4622
|
-
SESSION_ID,
|
|
4623
|
-
dataSourceSession,
|
|
4624
|
-
true
|
|
4625
|
-
);
|
|
4301
|
+
_ds.finalRecordId = func.datasource.get_currentRecordId(SESSION_ID, dataSourceSession, true);
|
|
4626
4302
|
_ds.currentRecordId = _ds.finalRecordId;
|
|
4627
4303
|
};
|
|
4628
4304
|
|
|
@@ -4630,11 +4306,7 @@ func.datasource.execute = async function (
|
|
|
4630
4306
|
const idx = Number(key);
|
|
4631
4307
|
|
|
4632
4308
|
if (await get_before_record_count()) {
|
|
4633
|
-
await func.datasource.execute_view_events(
|
|
4634
|
-
SESSION_ID,
|
|
4635
|
-
dataSourceSession,
|
|
4636
|
-
"before_record"
|
|
4637
|
-
);
|
|
4309
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
4638
4310
|
}
|
|
4639
4311
|
|
|
4640
4312
|
// await func.datasource.run_rows_form(
|
|
@@ -4648,28 +4320,13 @@ func.datasource.execute = async function (
|
|
|
4648
4320
|
|
|
4649
4321
|
_ds.currentRecordId = raw_data_row.id; // set temporary to allow expression decoder work
|
|
4650
4322
|
|
|
4651
|
-
await func.datasource.render_fields_form(
|
|
4652
|
-
SESSION_ID,
|
|
4653
|
-
dataSourceSession,
|
|
4654
|
-
raw_data_row
|
|
4655
|
-
);
|
|
4323
|
+
await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, raw_data_row);
|
|
4656
4324
|
|
|
4657
4325
|
try {
|
|
4658
|
-
const init_count = await func.datasource.get_field_init_count(
|
|
4659
|
-
SESSION_ID,
|
|
4660
|
-
dataSourceSession,
|
|
4661
|
-
raw_data_row.id,
|
|
4662
|
-
false,
|
|
4663
|
-
_ds.oninit_triggers_to_run
|
|
4664
|
-
);
|
|
4326
|
+
const init_count = await func.datasource.get_field_init_count(SESSION_ID, dataSourceSession, raw_data_row.id, false, _ds.oninit_triggers_to_run);
|
|
4665
4327
|
|
|
4666
4328
|
if (init_count > 0) {
|
|
4667
|
-
await func.datasource.execute_field_init_events(
|
|
4668
|
-
SESSION_ID,
|
|
4669
|
-
dataSourceSession,
|
|
4670
|
-
"form",
|
|
4671
|
-
raw_data_row.id
|
|
4672
|
-
);
|
|
4329
|
+
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', raw_data_row.id);
|
|
4673
4330
|
}
|
|
4674
4331
|
} catch (err) {
|
|
4675
4332
|
console.error(err);
|
|
@@ -4678,11 +4335,7 @@ func.datasource.execute = async function (
|
|
|
4678
4335
|
/////////////////////
|
|
4679
4336
|
|
|
4680
4337
|
if (await get_after_record_count()) {
|
|
4681
|
-
await func.datasource.execute_view_events(
|
|
4682
|
-
SESSION_ID,
|
|
4683
|
-
dataSourceSession,
|
|
4684
|
-
"after_record"
|
|
4685
|
-
);
|
|
4338
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
4686
4339
|
}
|
|
4687
4340
|
}
|
|
4688
4341
|
await finish_form();
|
|
@@ -4690,82 +4343,42 @@ func.datasource.execute = async function (
|
|
|
4690
4343
|
break;
|
|
4691
4344
|
|
|
4692
4345
|
default:
|
|
4693
|
-
return func.utils.debug_report(
|
|
4694
|
-
SESSION_ID,
|
|
4695
|
-
"Data source",
|
|
4696
|
-
"Program type not defined",
|
|
4697
|
-
"E"
|
|
4698
|
-
);
|
|
4346
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Program type not defined', 'E');
|
|
4699
4347
|
}
|
|
4700
4348
|
|
|
4701
4349
|
ret = await callback_datasource();
|
|
4702
4350
|
return ret;
|
|
4703
4351
|
};
|
|
4704
4352
|
|
|
4705
|
-
func.datasource.render_fields_dataset = async function (
|
|
4706
|
-
SESSION_ID,
|
|
4707
|
-
dataSourceSession,
|
|
4708
|
-
raw_data_row
|
|
4709
|
-
) {
|
|
4353
|
+
func.datasource.render_fields_dataset = async function (SESSION_ID, dataSourceSession, raw_data_row) {
|
|
4710
4354
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
4711
4355
|
var args = _ds.args;
|
|
4712
4356
|
|
|
4713
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4714
|
-
SESSION_ID,
|
|
4715
|
-
dataSourceSession
|
|
4716
|
-
);
|
|
4357
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSourceSession);
|
|
4717
4358
|
|
|
4718
4359
|
if (!_progFields) {
|
|
4719
4360
|
return;
|
|
4720
4361
|
}
|
|
4721
4362
|
|
|
4722
4363
|
const get_value = async (field_id, value) => {
|
|
4723
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
4724
|
-
_progFields,
|
|
4725
|
-
"field_id",
|
|
4726
|
-
field_id
|
|
4727
|
-
);
|
|
4364
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
4728
4365
|
var fieldType = view_field_obj?.props?.fieldType;
|
|
4729
4366
|
let table_field_obj;
|
|
4730
|
-
if (view_field_obj.data.type ===
|
|
4367
|
+
if (view_field_obj.data.type === 'table' && field_id !== 'REDUCE_VALUE') {
|
|
4731
4368
|
if (!_ds.progDataSource?.dataSourceTableId) {
|
|
4732
|
-
return func.utils.debug_report(
|
|
4733
|
-
SESSION_ID,
|
|
4734
|
-
"Datasource",
|
|
4735
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
4736
|
-
"E"
|
|
4737
|
-
);
|
|
4369
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
4738
4370
|
}
|
|
4739
4371
|
|
|
4740
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
4741
|
-
SESSION_ID,
|
|
4742
|
-
_ds._dataSourceTableId
|
|
4743
|
-
);
|
|
4372
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
4744
4373
|
|
|
4745
4374
|
if (!table_obj) {
|
|
4746
|
-
return func.utils.debug_report(
|
|
4747
|
-
SESSION_ID,
|
|
4748
|
-
"Datasource",
|
|
4749
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
4750
|
-
"E"
|
|
4751
|
-
);
|
|
4375
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
4752
4376
|
}
|
|
4753
|
-
table_field_obj = func.common.find_item_by_key(
|
|
4754
|
-
table_obj.tableFields,
|
|
4755
|
-
"field_id",
|
|
4756
|
-
field_id
|
|
4757
|
-
);
|
|
4377
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
4758
4378
|
fieldType = table_field_obj.props?.fieldType;
|
|
4759
4379
|
}
|
|
4760
4380
|
|
|
4761
|
-
return await func.common.get_cast_val(
|
|
4762
|
-
SESSION_ID,
|
|
4763
|
-
`render fields dataset ${_ds.viewSourceDesc}`,
|
|
4764
|
-
field_id,
|
|
4765
|
-
fieldType,
|
|
4766
|
-
value,
|
|
4767
|
-
null
|
|
4768
|
-
);
|
|
4381
|
+
return await func.common.get_cast_val(SESSION_ID, `render fields dataset ${_ds.viewSourceDesc}`, field_id, fieldType, value, null);
|
|
4769
4382
|
};
|
|
4770
4383
|
|
|
4771
4384
|
if (!_ds.data_feed) {
|
|
@@ -4786,64 +4399,38 @@ func.datasource.render_fields_dataset = async function (
|
|
|
4786
4399
|
try {
|
|
4787
4400
|
var fieldId = val.data.field_id;
|
|
4788
4401
|
|
|
4789
|
-
if (val.data.type ===
|
|
4790
|
-
if (typeof raw_data_row?.value?.[fieldId] !==
|
|
4402
|
+
if (val.data.type === 'virtual' || _ds.set_mode === 'C') {
|
|
4403
|
+
if (typeof raw_data_row?.value?.[fieldId] !== 'undefined') {
|
|
4791
4404
|
// supports x=x+1
|
|
4792
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
4793
|
-
fieldId,
|
|
4794
|
-
raw_data_row.value[fieldId]
|
|
4795
|
-
);
|
|
4405
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
4796
4406
|
continue;
|
|
4797
4407
|
}
|
|
4798
4408
|
|
|
4799
4409
|
if (val.props?.propExpressions?.fieldValue) {
|
|
4800
|
-
let ret = await func.expression.get(
|
|
4801
|
-
|
|
4802
|
-
val.props?.propExpressions?.fieldValue,
|
|
4803
|
-
dataSourceSession,
|
|
4804
|
-
"update",
|
|
4805
|
-
args.rowIdP
|
|
4806
|
-
);
|
|
4807
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
4808
|
-
fieldId,
|
|
4809
|
-
ret.result
|
|
4810
|
-
);
|
|
4410
|
+
let ret = await func.expression.get(SESSION_ID, val.props?.propExpressions?.fieldValue, dataSourceSession, 'update', args.rowIdP);
|
|
4411
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, ret.result);
|
|
4811
4412
|
continue;
|
|
4812
4413
|
}
|
|
4813
4414
|
|
|
4814
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
4815
|
-
fieldId,
|
|
4816
|
-
val.props?.fieldValue
|
|
4817
|
-
);
|
|
4415
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, val.props?.fieldValue);
|
|
4818
4416
|
continue;
|
|
4819
4417
|
}
|
|
4820
|
-
if (val.data.type ===
|
|
4821
|
-
if (typeof raw_data_row.value[fieldId] ===
|
|
4822
|
-
throw
|
|
4418
|
+
if (val.data.type === 'table' || val.data.type === 'datasource') {
|
|
4419
|
+
if (typeof raw_data_row.value[fieldId] === 'undefined') {
|
|
4420
|
+
throw 'field do not exist in data: ' + fieldId;
|
|
4823
4421
|
}
|
|
4824
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
4825
|
-
fieldId,
|
|
4826
|
-
raw_data_row.value[fieldId]
|
|
4827
|
-
);
|
|
4422
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
4828
4423
|
}
|
|
4829
4424
|
} catch (err) {
|
|
4830
|
-
func.utils.debug_report(SESSION_ID,
|
|
4425
|
+
func.utils.debug_report(SESSION_ID, 'Datasource', err, 'E', null, _ds);
|
|
4831
4426
|
}
|
|
4832
4427
|
}
|
|
4833
4428
|
};
|
|
4834
4429
|
|
|
4835
|
-
func.datasource.run_events_functions = async function (
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
calling_job,
|
|
4840
|
-
async_event,
|
|
4841
|
-
event_parameters
|
|
4842
|
-
) {
|
|
4843
|
-
|
|
4844
|
-
if (typeof dataSourceSession === "undefined" || dataSourceSession === null) {
|
|
4845
|
-
console.warn(`Event ${event_id} not exist or not found`)
|
|
4846
|
-
return
|
|
4430
|
+
func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSession, event_id, calling_job, async_event, event_parameters) {
|
|
4431
|
+
if (typeof dataSourceSession === 'undefined' || dataSourceSession === null) {
|
|
4432
|
+
console.warn(`Event ${event_id} not exist or not found`);
|
|
4433
|
+
return;
|
|
4847
4434
|
}
|
|
4848
4435
|
|
|
4849
4436
|
// return new Promise(async (resolve, reject) => {
|
|
@@ -4851,123 +4438,75 @@ func.datasource.run_events_functions = async function (
|
|
|
4851
4438
|
var args = _ds.args;
|
|
4852
4439
|
// var v = _ds.v;
|
|
4853
4440
|
const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4854
|
-
let job_promises = []
|
|
4441
|
+
let job_promises = [];
|
|
4855
4442
|
if (_view_obj.progEvents) {
|
|
4856
4443
|
for await (const [key, val] of Object.entries(_view_obj.progEvents)) {
|
|
4857
|
-
if (
|
|
4858
|
-
val.data.type === "user_defined" &&
|
|
4859
|
-
val.data.event_name &&
|
|
4860
|
-
val.data.event_name === event_id
|
|
4861
|
-
) {
|
|
4444
|
+
if (val.data.type === 'user_defined' && val.data.event_name && val.data.event_name === event_id) {
|
|
4862
4445
|
const jobs = await func.events.validate(
|
|
4863
4446
|
SESSION_ID,
|
|
4864
|
-
|
|
4447
|
+
'user_defined',
|
|
4865
4448
|
dataSourceSession,
|
|
4866
4449
|
val.data.event_name,
|
|
4867
4450
|
args.callingSourceP,
|
|
4868
|
-
event_parameters// val.data.parameters
|
|
4451
|
+
event_parameters, // val.data.parameters
|
|
4869
4452
|
);
|
|
4870
4453
|
|
|
4871
|
-
if (calling_job || async_event) continue
|
|
4454
|
+
if (calling_job || async_event) continue;
|
|
4872
4455
|
|
|
4873
4456
|
for (let job_num of jobs) {
|
|
4874
|
-
job_promises.push(
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4457
|
+
job_promises.push(
|
|
4458
|
+
new Promise((resolve, reject) => {
|
|
4459
|
+
const interval = setInterval(() => {
|
|
4460
|
+
var job_index = func.events.find_job_index(SESSION_ID, job_num);
|
|
4461
|
+
if (job_index == null) {
|
|
4462
|
+
clearInterval(interval);
|
|
4463
|
+
resolve(job_num);
|
|
4464
|
+
}
|
|
4465
|
+
}, 100);
|
|
4466
|
+
}),
|
|
4467
|
+
);
|
|
4884
4468
|
}
|
|
4885
4469
|
}
|
|
4886
4470
|
}
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
4471
|
}
|
|
4891
4472
|
if (job_promises.length) {
|
|
4892
|
-
await Promise.all(job_promises)
|
|
4473
|
+
await Promise.all(job_promises);
|
|
4893
4474
|
}
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
4475
|
};
|
|
4897
4476
|
|
|
4898
|
-
func.datasource.render_fields_form = async function (
|
|
4899
|
-
SESSION_ID,
|
|
4900
|
-
dataSourceSession,
|
|
4901
|
-
raw_data_row
|
|
4902
|
-
) {
|
|
4477
|
+
func.datasource.render_fields_form = async function (SESSION_ID, dataSourceSession, raw_data_row) {
|
|
4903
4478
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
4904
4479
|
|
|
4905
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4906
|
-
SESSION_ID,
|
|
4907
|
-
dataSourceSession
|
|
4908
|
-
);
|
|
4480
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSourceSession);
|
|
4909
4481
|
|
|
4910
4482
|
if (!_progFields) {
|
|
4911
4483
|
return;
|
|
4912
4484
|
}
|
|
4913
4485
|
|
|
4914
4486
|
const get_value = async (field_id, value) => {
|
|
4915
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
4916
|
-
_progFields,
|
|
4917
|
-
"field_id",
|
|
4918
|
-
field_id
|
|
4919
|
-
);
|
|
4487
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
4920
4488
|
var fieldType = view_field_obj.props?.fieldType;
|
|
4921
4489
|
let table_field_obj;
|
|
4922
|
-
if (view_field_obj.data.type ===
|
|
4490
|
+
if (view_field_obj.data.type === 'table' && field_id !== 'REDUCE_VALUE') {
|
|
4923
4491
|
if (!_ds._dataSourceTableId) {
|
|
4924
|
-
return func.utils.debug_report(
|
|
4925
|
-
SESSION_ID,
|
|
4926
|
-
"Datasource",
|
|
4927
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
4928
|
-
"E"
|
|
4929
|
-
);
|
|
4492
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
4930
4493
|
}
|
|
4931
4494
|
|
|
4932
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
4933
|
-
SESSION_ID,
|
|
4934
|
-
_ds._dataSourceTableId
|
|
4935
|
-
);
|
|
4495
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
4936
4496
|
|
|
4937
4497
|
if (!table_obj) {
|
|
4938
|
-
return func.utils.debug_report(
|
|
4939
|
-
SESSION_ID,
|
|
4940
|
-
"Datasource",
|
|
4941
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
4942
|
-
"E"
|
|
4943
|
-
);
|
|
4498
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
4944
4499
|
}
|
|
4945
|
-
table_field_obj = func.common.find_item_by_key(
|
|
4946
|
-
table_obj.tableFields,
|
|
4947
|
-
"field_id",
|
|
4948
|
-
field_id
|
|
4949
|
-
);
|
|
4500
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
4950
4501
|
|
|
4951
4502
|
if (!table_field_obj) {
|
|
4952
|
-
return func.utils.debug_report(
|
|
4953
|
-
SESSION_ID,
|
|
4954
|
-
"Datasource",
|
|
4955
|
-
`Field Id: ${field_id} not exist in table ${table_obj.properties.menuName}`,
|
|
4956
|
-
"E"
|
|
4957
|
-
);
|
|
4503
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Field Id: ${field_id} not exist in table ${table_obj.properties.menuName}`, 'E');
|
|
4958
4504
|
}
|
|
4959
4505
|
|
|
4960
4506
|
fieldType = table_field_obj.props?.fieldType;
|
|
4961
4507
|
}
|
|
4962
4508
|
|
|
4963
|
-
return await func.common.get_cast_val(
|
|
4964
|
-
SESSION_ID,
|
|
4965
|
-
`render fields datasource ${_ds.viewSourceDesc}`,
|
|
4966
|
-
field_id,
|
|
4967
|
-
fieldType,
|
|
4968
|
-
value,
|
|
4969
|
-
null
|
|
4970
|
-
);
|
|
4509
|
+
return await func.common.get_cast_val(SESSION_ID, `render fields datasource ${_ds.viewSourceDesc}`, field_id, fieldType, value, null);
|
|
4971
4510
|
};
|
|
4972
4511
|
|
|
4973
4512
|
let row_idx;
|
|
@@ -4984,29 +4523,20 @@ func.datasource.render_fields_form = async function (
|
|
|
4984
4523
|
try {
|
|
4985
4524
|
var fieldId = val.data.field_id;
|
|
4986
4525
|
|
|
4987
|
-
if (val.data.type ===
|
|
4526
|
+
if (val.data.type === 'virtual' || raw_data_row.id === 'newRecord') {
|
|
4988
4527
|
if (glb.PROTECTED_VARS.includes(fieldId)) {
|
|
4989
4528
|
switch (fieldId) {
|
|
4990
|
-
case
|
|
4991
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
4992
|
-
fieldId,
|
|
4993
|
-
row_idx
|
|
4994
|
-
);
|
|
4529
|
+
case '_ROWNO': {
|
|
4530
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, row_idx);
|
|
4995
4531
|
continue;
|
|
4996
4532
|
}
|
|
4997
|
-
case
|
|
4998
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
4999
|
-
fieldId,
|
|
5000
|
-
raw_data_row.id
|
|
5001
|
-
);
|
|
4533
|
+
case '_ROWID': {
|
|
4534
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.id);
|
|
5002
4535
|
|
|
5003
4536
|
continue;
|
|
5004
4537
|
}
|
|
5005
|
-
case
|
|
5006
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
5007
|
-
fieldId,
|
|
5008
|
-
raw_data_row.value
|
|
5009
|
-
);
|
|
4538
|
+
case '_ROWDOC': {
|
|
4539
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value);
|
|
5010
4540
|
|
|
5011
4541
|
continue;
|
|
5012
4542
|
}
|
|
@@ -5015,39 +4545,24 @@ func.datasource.render_fields_form = async function (
|
|
|
5015
4545
|
|
|
5016
4546
|
if (val.props?.propExpressions?.fieldValue) {
|
|
5017
4547
|
// check init exp existence
|
|
5018
|
-
let ret = await func.expression.get(
|
|
5019
|
-
|
|
5020
|
-
val.props?.propExpressions?.fieldValue,
|
|
5021
|
-
dataSourceSession,
|
|
5022
|
-
"update",
|
|
5023
|
-
raw_data_row.id
|
|
5024
|
-
);
|
|
5025
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
5026
|
-
fieldId,
|
|
5027
|
-
ret.result
|
|
5028
|
-
);
|
|
4548
|
+
let ret = await func.expression.get(SESSION_ID, val.props?.propExpressions?.fieldValue, dataSourceSession, 'update', raw_data_row.id);
|
|
4549
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, ret.result);
|
|
5029
4550
|
|
|
5030
4551
|
continue;
|
|
5031
4552
|
}
|
|
5032
4553
|
|
|
5033
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
5034
|
-
fieldId,
|
|
5035
|
-
val.props?.fieldValue
|
|
5036
|
-
);
|
|
4554
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, val.props?.fieldValue);
|
|
5037
4555
|
|
|
5038
4556
|
continue;
|
|
5039
4557
|
}
|
|
5040
|
-
if (val.data.type ===
|
|
5041
|
-
if (typeof raw_data_row.value[fieldId] ===
|
|
5042
|
-
throw
|
|
4558
|
+
if (val.data.type === 'table' || val.data.type === 'datasource') {
|
|
4559
|
+
if (typeof raw_data_row.value[fieldId] === 'undefined') {
|
|
4560
|
+
throw 'field do not exist in data: ' + fieldId;
|
|
5043
4561
|
}
|
|
5044
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
5045
|
-
fieldId,
|
|
5046
|
-
raw_data_row.value[fieldId]
|
|
5047
|
-
);
|
|
4562
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
5048
4563
|
}
|
|
5049
4564
|
} catch (err) {
|
|
5050
|
-
func.utils.debug_report(SESSION_ID,
|
|
4565
|
+
func.utils.debug_report(SESSION_ID, 'Datasource', err, 'E', null, _ds);
|
|
5051
4566
|
}
|
|
5052
4567
|
}
|
|
5053
4568
|
};
|
|
@@ -5110,12 +4625,7 @@ func.datasource.render_fields_form = async function (
|
|
|
5110
4625
|
// // await form_continue();
|
|
5111
4626
|
// };
|
|
5112
4627
|
|
|
5113
|
-
func.datasource.execute_field_init_events = async function (
|
|
5114
|
-
SESSION_ID,
|
|
5115
|
-
dataSourceSession,
|
|
5116
|
-
sourceP,
|
|
5117
|
-
rowIdP
|
|
5118
|
-
) {
|
|
4628
|
+
func.datasource.execute_field_init_events = async function (SESSION_ID, dataSourceSession, sourceP, rowIdP) {
|
|
5119
4629
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5120
4630
|
var args = _ds.args;
|
|
5121
4631
|
var arr = _ds.dataSource_init_arr[rowIdP];
|
|
@@ -5125,21 +4635,11 @@ func.datasource.execute_field_init_events = async function (
|
|
|
5125
4635
|
if (!func.utils.is_onscreen_event(val.eventInfo.data.action)) {
|
|
5126
4636
|
var cond = val?.eventInfo?.data?.enabled;
|
|
5127
4637
|
var expression = undefined;
|
|
5128
|
-
if (val.eventInfo.props.condition)
|
|
5129
|
-
expression = val.eventInfo.props.condition;
|
|
4638
|
+
if (val.eventInfo.props.condition) expression = val.eventInfo.props.condition;
|
|
5130
4639
|
var expCond = {};
|
|
5131
4640
|
if (expression && !_.isEmpty(expression)) {
|
|
5132
4641
|
// check if expression exist
|
|
5133
|
-
expCond = await func.expression.get(
|
|
5134
|
-
SESSION_ID,
|
|
5135
|
-
expression,
|
|
5136
|
-
dataSourceSession,
|
|
5137
|
-
"condition",
|
|
5138
|
-
rowIdP,
|
|
5139
|
-
null,
|
|
5140
|
-
null,
|
|
5141
|
-
val.fieldId
|
|
5142
|
-
); // execute expression
|
|
4642
|
+
expCond = await func.expression.get(SESSION_ID, expression, dataSourceSession, 'condition', rowIdP, null, null, val.fieldId); // execute expression
|
|
5143
4643
|
cond = expCond.result;
|
|
5144
4644
|
expCond.conditional = true;
|
|
5145
4645
|
val.DEBUG_INFO_OBJ.result = expCond.result;
|
|
@@ -5181,20 +4681,14 @@ func.datasource.execute_field_init_events = async function (
|
|
|
5181
4681
|
null,
|
|
5182
4682
|
null,
|
|
5183
4683
|
null,
|
|
5184
|
-
ds.parentDataSourceNo
|
|
4684
|
+
ds.parentDataSourceNo,
|
|
5185
4685
|
);
|
|
5186
4686
|
}
|
|
5187
4687
|
}
|
|
5188
4688
|
}
|
|
5189
4689
|
};
|
|
5190
4690
|
|
|
5191
|
-
func.datasource.get_field_init_count = async function (
|
|
5192
|
-
SESSION_ID,
|
|
5193
|
-
dataSourceSession,
|
|
5194
|
-
rowIdP,
|
|
5195
|
-
pre_initP,
|
|
5196
|
-
oninit_triggers_to_runP
|
|
5197
|
-
) {
|
|
4691
|
+
func.datasource.get_field_init_count = async function (SESSION_ID, dataSourceSession, rowIdP, pre_initP, oninit_triggers_to_runP) {
|
|
5198
4692
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5199
4693
|
var args = _ds.args;
|
|
5200
4694
|
|
|
@@ -5210,25 +4704,15 @@ func.datasource.get_field_init_count = async function (
|
|
|
5210
4704
|
continue;
|
|
5211
4705
|
}
|
|
5212
4706
|
for await (const trigger_obj of field_obj.triggers) {
|
|
5213
|
-
if (
|
|
5214
|
-
oninit_triggers_to_runP &&
|
|
5215
|
-
!oninit_triggers_to_runP?.includes(trigger_obj.id)
|
|
5216
|
-
) {
|
|
4707
|
+
if (oninit_triggers_to_runP && !oninit_triggers_to_runP?.includes(trigger_obj.id)) {
|
|
5217
4708
|
continue;
|
|
5218
4709
|
}
|
|
5219
4710
|
if (
|
|
5220
4711
|
// trigger_obj.data.trigger === "oninit" &&
|
|
5221
|
-
[
|
|
5222
|
-
trigger_obj.data.action
|
|
5223
|
-
)
|
|
4712
|
+
['get_data', 'set_data', 'batch', 'update', 'raise_event'].includes(trigger_obj.data.action)
|
|
5224
4713
|
) {
|
|
5225
4714
|
if (!trigger_obj.data.action) {
|
|
5226
|
-
func.utils.debug_report(
|
|
5227
|
-
SESSION_ID,
|
|
5228
|
-
"_ds.get_field_init_count",
|
|
5229
|
-
`Error initiating event for field: ${fieldId} prog: ${_ds.v.viewSourceDesc} row: ${rowIdP} reason: missing action`,
|
|
5230
|
-
"E"
|
|
5231
|
-
);
|
|
4715
|
+
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');
|
|
5232
4716
|
break;
|
|
5233
4717
|
}
|
|
5234
4718
|
|
|
@@ -5262,14 +4746,14 @@ func.datasource.get_field_init_count = async function (
|
|
|
5262
4746
|
fieldId: fieldId,
|
|
5263
4747
|
rowId: rowIdP,
|
|
5264
4748
|
colId: field_obj.id,
|
|
5265
|
-
node_id: args.prog_id +
|
|
4749
|
+
node_id: args.prog_id + '_' + trigger_obj.id + '_' + field_obj.id,
|
|
5266
4750
|
fieldProp: field_obj,
|
|
5267
4751
|
DEBUG_INFO_OBJ: {
|
|
5268
4752
|
module: _ds.viewModule,
|
|
5269
|
-
action:
|
|
4753
|
+
action: 'init field event',
|
|
5270
4754
|
prop: fieldId,
|
|
5271
4755
|
source: _ds.viewSourceDesc,
|
|
5272
|
-
type:
|
|
4756
|
+
type: 'event',
|
|
5273
4757
|
prog_id: args.prog_id,
|
|
5274
4758
|
dsSession: dataSourceSession,
|
|
5275
4759
|
},
|
|
@@ -5283,19 +4767,14 @@ func.datasource.get_field_init_count = async function (
|
|
|
5283
4767
|
return ret;
|
|
5284
4768
|
};
|
|
5285
4769
|
|
|
5286
|
-
func.datasource.get_view_events_count = async function (
|
|
5287
|
-
SESSION_ID,
|
|
5288
|
-
dataSourceSession,
|
|
5289
|
-
typeP,
|
|
5290
|
-
eventIdP
|
|
5291
|
-
) {
|
|
4770
|
+
func.datasource.get_view_events_count = async function (SESSION_ID, dataSourceSession, typeP, eventIdP) {
|
|
5292
4771
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5293
4772
|
const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5294
4773
|
if (!_ds) return 0;
|
|
5295
4774
|
var args = _ds.args;
|
|
5296
4775
|
|
|
5297
4776
|
var index = typeP;
|
|
5298
|
-
if (eventIdP) index = typeP +
|
|
4777
|
+
if (eventIdP) index = typeP + '_' + eventIdP;
|
|
5299
4778
|
|
|
5300
4779
|
// client interval
|
|
5301
4780
|
if (!_ds.viewEventExec_arr) _ds.viewEventExec_arr = {};
|
|
@@ -5309,18 +4788,7 @@ func.datasource.get_view_events_count = async function (
|
|
|
5309
4788
|
if (eventIdP && event_obj.id !== eventIdP) continue; // match w ID added 03312017
|
|
5310
4789
|
|
|
5311
4790
|
if (event_obj.data.condition) {
|
|
5312
|
-
let res = await func.expression.get(
|
|
5313
|
-
SESSION_ID,
|
|
5314
|
-
event_obj.data.condition,
|
|
5315
|
-
dataSourceSession,
|
|
5316
|
-
"condition",
|
|
5317
|
-
args.rowIdP,
|
|
5318
|
-
null,
|
|
5319
|
-
null,
|
|
5320
|
-
null,
|
|
5321
|
-
null,
|
|
5322
|
-
event_obj
|
|
5323
|
-
);
|
|
4791
|
+
let res = await func.expression.get(SESSION_ID, event_obj.data.condition, dataSourceSession, 'condition', args.rowIdP, null, null, null, null, event_obj);
|
|
5324
4792
|
if (!res.result) {
|
|
5325
4793
|
continue;
|
|
5326
4794
|
}
|
|
@@ -5330,13 +4798,12 @@ func.datasource.get_view_events_count = async function (
|
|
|
5330
4798
|
for (const trigger_obj of event_obj.triggers) {
|
|
5331
4799
|
if (trigger_obj.data.enabled) {
|
|
5332
4800
|
var expression;
|
|
5333
|
-
if (trigger_obj.props.condition)
|
|
5334
|
-
expression = trigger_obj.props.condition;
|
|
4801
|
+
if (trigger_obj.props.condition) expression = trigger_obj.props.condition;
|
|
5335
4802
|
var expCond = {};
|
|
5336
4803
|
if (expression) {
|
|
5337
4804
|
expCond.conditional = true;
|
|
5338
4805
|
}
|
|
5339
|
-
func.utils.debug.log(SESSION_ID, args.prog_id +
|
|
4806
|
+
func.utils.debug.log(SESSION_ID, args.prog_id + '_' + trigger_obj.id, {
|
|
5340
4807
|
module: _ds.viewModule,
|
|
5341
4808
|
action: trigger_obj.data.action,
|
|
5342
4809
|
prop: event_obj.data.type,
|
|
@@ -5345,31 +4812,18 @@ func.datasource.get_view_events_count = async function (
|
|
|
5345
4812
|
error: expCond.error,
|
|
5346
4813
|
source: _ds.viewSourceDesc,
|
|
5347
4814
|
fields: expCond.fields,
|
|
5348
|
-
type:
|
|
4815
|
+
type: 'event',
|
|
5349
4816
|
prog_id: args.prog_id,
|
|
5350
4817
|
dsSession: dataSourceSession,
|
|
5351
4818
|
conditional: expCond.conditional,
|
|
5352
4819
|
});
|
|
5353
|
-
}
|
|
5354
|
-
if (!trigger_obj.data.action) {
|
|
5355
|
-
func.utils.debug_report(
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
);
|
|
5361
|
-
break;
|
|
5362
|
-
}
|
|
5363
|
-
if (
|
|
5364
|
-
!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) &&
|
|
5365
|
-
!trigger_obj.data.action
|
|
5366
|
-
) {
|
|
5367
|
-
func.utils.debug_report(
|
|
5368
|
-
SESSION_ID,
|
|
5369
|
-
"get_view_events_count",
|
|
5370
|
-
`Error initiating ${typeP} prog: ${_ds.v.viewSourceDesc} reason: missing reference`,
|
|
5371
|
-
"E"
|
|
5372
|
-
);
|
|
4820
|
+
}
|
|
4821
|
+
if (!trigger_obj.data.action) {
|
|
4822
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog:${_ds.v.viewSourceDesc} reason: missing action`, 'E');
|
|
4823
|
+
break;
|
|
4824
|
+
}
|
|
4825
|
+
if (!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) && !trigger_obj.data.action) {
|
|
4826
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.v.viewSourceDesc} reason: missing reference`, 'E');
|
|
5373
4827
|
break;
|
|
5374
4828
|
}
|
|
5375
4829
|
if (trigger_obj.data.enabled) {
|
|
@@ -5385,50 +4839,28 @@ func.datasource.get_view_events_count = async function (
|
|
|
5385
4839
|
}
|
|
5386
4840
|
return _ds.viewEventExec_arr[index].length;
|
|
5387
4841
|
};
|
|
5388
|
-
func.datasource.execute_view_events = async function (
|
|
5389
|
-
SESSION_ID,
|
|
5390
|
-
dataSourceSession,
|
|
5391
|
-
typeP,
|
|
5392
|
-
eventIdP
|
|
5393
|
-
) {
|
|
4842
|
+
func.datasource.execute_view_events = async function (SESSION_ID, dataSourceSession, typeP, eventIdP) {
|
|
5394
4843
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5395
4844
|
var args = _ds.args;
|
|
5396
4845
|
|
|
5397
4846
|
var i = -1;
|
|
5398
4847
|
var index = typeP;
|
|
5399
|
-
if (eventIdP) index = typeP +
|
|
4848
|
+
if (eventIdP) index = typeP + '_' + eventIdP;
|
|
5400
4849
|
var arr = _ds.viewEventExec_arr[index];
|
|
5401
4850
|
if (_.isEmpty(arr)) return;
|
|
5402
4851
|
|
|
5403
4852
|
for await (const val of arr) {
|
|
5404
|
-
if (
|
|
5405
|
-
!glb.IS_WORKER ||
|
|
5406
|
-
!func.utils.is_onscreen_event(val.eventInfo.data.action) ||
|
|
5407
|
-
(glb.IS_WORKER &&
|
|
5408
|
-
_ds.v.run_at === "server" &&
|
|
5409
|
-
!func.utils.is_onscreen_event(val.eventInfo.data.action))
|
|
5410
|
-
) {
|
|
4853
|
+
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))) {
|
|
5411
4854
|
// val.done = true;
|
|
5412
4855
|
var cond = true;
|
|
5413
4856
|
if (val.expression) {
|
|
5414
|
-
var expCond = await func.expression.get(
|
|
5415
|
-
SESSION_ID,
|
|
5416
|
-
val.expression,
|
|
5417
|
-
dataSourceSession,
|
|
5418
|
-
"condition",
|
|
5419
|
-
args.rowIdP,
|
|
5420
|
-
null,
|
|
5421
|
-
null,
|
|
5422
|
-
null,
|
|
5423
|
-
null,
|
|
5424
|
-
val.eventInfo
|
|
5425
|
-
); // execute expression
|
|
4857
|
+
var expCond = await func.expression.get(SESSION_ID, val.expression, dataSourceSession, 'condition', args.rowIdP, null, null, null, null, val.eventInfo); // execute expression
|
|
5426
4858
|
cond = expCond.result;
|
|
5427
4859
|
}
|
|
5428
4860
|
if (cond) {
|
|
5429
4861
|
var elem_params = undefined;
|
|
5430
4862
|
if (!glb.IS_WORKER) {
|
|
5431
|
-
elem_params = $(
|
|
4863
|
+
elem_params = $('#' + _ds.containerId).data('params');
|
|
5432
4864
|
}
|
|
5433
4865
|
const ret = await func.events.execute(
|
|
5434
4866
|
SESSION_ID,
|
|
@@ -5445,39 +4877,28 @@ func.datasource.execute_view_events = async function (
|
|
|
5445
4877
|
null,
|
|
5446
4878
|
dataSourceSession,
|
|
5447
4879
|
val.eventId,
|
|
5448
|
-
_ds.tree_obj.menuType +
|
|
4880
|
+
_ds.tree_obj.menuType + ' event',
|
|
5449
4881
|
true,
|
|
5450
4882
|
null,
|
|
5451
4883
|
null,
|
|
5452
4884
|
args.jobNoP,
|
|
5453
4885
|
elem_params,
|
|
5454
4886
|
null,
|
|
5455
|
-
val.eventInfo
|
|
4887
|
+
val.eventInfo,
|
|
5456
4888
|
);
|
|
5457
4889
|
}
|
|
5458
4890
|
|
|
5459
4891
|
continue;
|
|
5460
4892
|
}
|
|
5461
4893
|
// on screen event
|
|
5462
|
-
if (
|
|
5463
|
-
typeP == "before_record" ||
|
|
5464
|
-
typeP == "after_record" ||
|
|
5465
|
-
typeP == "on_load" ||
|
|
5466
|
-
typeP == "on_exit"
|
|
5467
|
-
) {
|
|
4894
|
+
if (typeP == 'before_record' || typeP == 'after_record' || typeP == 'on_load' || typeP == 'on_exit') {
|
|
5468
4895
|
_ds.v.onscreen_events_active = {
|
|
5469
4896
|
i: i,
|
|
5470
4897
|
type: typeP,
|
|
5471
4898
|
};
|
|
5472
|
-
var parent_ds_chain = func.datasource.get_parent_ds_chain(
|
|
5473
|
-
SESSION_ID,
|
|
5474
|
-
dataSourceSession
|
|
5475
|
-
);
|
|
4899
|
+
var parent_ds_chain = func.datasource.get_parent_ds_chain(SESSION_ID, dataSourceSession);
|
|
5476
4900
|
var obj = {
|
|
5477
|
-
ds_obj: func.utils.clean_returned_datasource(
|
|
5478
|
-
SESSION_ID,
|
|
5479
|
-
dataSourceSession
|
|
5480
|
-
),
|
|
4901
|
+
ds_obj: func.utils.clean_returned_datasource(SESSION_ID, dataSourceSession),
|
|
5481
4902
|
dsSessionP: dataSourceSession,
|
|
5482
4903
|
};
|
|
5483
4904
|
obj.ds_obj.parent_ds_chain = parent_ds_chain;
|
|
@@ -5488,10 +4909,7 @@ func.datasource.get_parent_ds_chain = function (SESSION_ID, dataSourceSession) {
|
|
|
5488
4909
|
var arr = [];
|
|
5489
4910
|
var drill = function (ds) {
|
|
5490
4911
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[ds]) {
|
|
5491
|
-
if (
|
|
5492
|
-
typeof SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo !==
|
|
5493
|
-
"undefined"
|
|
5494
|
-
) {
|
|
4912
|
+
if (typeof SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo !== 'undefined') {
|
|
5495
4913
|
arr.push(SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo);
|
|
5496
4914
|
drill(SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo);
|
|
5497
4915
|
}
|
|
@@ -5500,11 +4918,7 @@ func.datasource.get_parent_ds_chain = function (SESSION_ID, dataSourceSession) {
|
|
|
5500
4918
|
drill(dataSourceSession);
|
|
5501
4919
|
return arr;
|
|
5502
4920
|
};
|
|
5503
|
-
func.datasource.execute_onscreen_view_events = async function (
|
|
5504
|
-
SESSION_ID,
|
|
5505
|
-
dataSourceSession,
|
|
5506
|
-
sourceP
|
|
5507
|
-
) {
|
|
4921
|
+
func.datasource.execute_onscreen_view_events = async function (SESSION_ID, dataSourceSession, sourceP) {
|
|
5508
4922
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5509
4923
|
var args = _ds.args;
|
|
5510
4924
|
|
|
@@ -5517,13 +4931,7 @@ func.datasource.execute_onscreen_view_events = async function (
|
|
|
5517
4931
|
|
|
5518
4932
|
var cond = true;
|
|
5519
4933
|
if (evnt.expression) {
|
|
5520
|
-
var expCond = await func.expression.get(
|
|
5521
|
-
SESSION_ID,
|
|
5522
|
-
evnt.expression,
|
|
5523
|
-
dataSourceSession,
|
|
5524
|
-
"condition",
|
|
5525
|
-
args.rowIdP
|
|
5526
|
-
); // execute expression
|
|
4934
|
+
var expCond = await func.expression.get(SESSION_ID, evnt.expression, dataSourceSession, 'condition', args.rowIdP); // execute expression
|
|
5527
4935
|
cond = expCond.result;
|
|
5528
4936
|
}
|
|
5529
4937
|
if (cond) {
|
|
@@ -5542,20 +4950,16 @@ func.datasource.execute_onscreen_view_events = async function (
|
|
|
5542
4950
|
null,
|
|
5543
4951
|
dataSourceSession,
|
|
5544
4952
|
null,
|
|
5545
|
-
sourceP +
|
|
4953
|
+
sourceP + ' event',
|
|
5546
4954
|
true,
|
|
5547
4955
|
null,
|
|
5548
4956
|
null,
|
|
5549
|
-
args.jobNoP
|
|
4957
|
+
args.jobNoP,
|
|
5550
4958
|
);
|
|
5551
4959
|
}
|
|
5552
|
-
} else console.error(
|
|
4960
|
+
} else console.error('*execute_onscreen_view_events error');
|
|
5553
4961
|
};
|
|
5554
|
-
func.datasource.get_event_interval_arr = function (
|
|
5555
|
-
SESSION_ID,
|
|
5556
|
-
dataSourceSession,
|
|
5557
|
-
typeP
|
|
5558
|
-
) {
|
|
4962
|
+
func.datasource.get_event_interval_arr = function (SESSION_ID, dataSourceSession, typeP) {
|
|
5559
4963
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5560
4964
|
// var v = _ds.v;
|
|
5561
4965
|
var arr = [];
|
|
@@ -5596,19 +5000,17 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
|
|
|
5596
5000
|
Number(key) > 0 &&
|
|
5597
5001
|
(val.screenId === screenIdP ||
|
|
5598
5002
|
val.rootScreenId === screenIdP ||
|
|
5599
|
-
$(
|
|
5003
|
+
$('#' + val.screenId)
|
|
5600
5004
|
.parent()
|
|
5601
|
-
.attr(
|
|
5602
|
-
(val &&
|
|
5603
|
-
val.parentDataSourceNo &&
|
|
5604
|
-
arr.includes(val.parentDataSourceNo.toString())))
|
|
5005
|
+
.attr('id') === screenIdP ||
|
|
5006
|
+
(val && val.parentDataSourceNo && arr.includes(val.parentDataSourceNo.toString())))
|
|
5605
5007
|
) {
|
|
5606
5008
|
arr.push(key);
|
|
5607
5009
|
if (val.screenId) func.UI.utils.screen_blocker(false, val.screenId);
|
|
5608
5010
|
}
|
|
5609
5011
|
} catch (err) {
|
|
5610
|
-
console.warn(
|
|
5611
|
-
func.datasource.reset_jobs(SESSION_ID, key,
|
|
5012
|
+
console.warn('func.datasource.clean failed');
|
|
5013
|
+
func.datasource.reset_jobs(SESSION_ID, key, 'datasource.clean', err);
|
|
5612
5014
|
}
|
|
5613
5015
|
}
|
|
5614
5016
|
for (let val of arr) {
|
|
@@ -5616,27 +5018,19 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
|
|
|
5616
5018
|
}
|
|
5617
5019
|
};
|
|
5618
5020
|
func.datasource.del = function (SESSION_ID, dsP) {
|
|
5619
|
-
if (
|
|
5620
|
-
|
|
5621
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].keep_alive) ||
|
|
5622
|
-
dsP == 0
|
|
5623
|
-
)
|
|
5624
|
-
return;
|
|
5625
|
-
if (
|
|
5626
|
-
DATASOURCE_INTERVALS[SESSION_ID] &&
|
|
5627
|
-
DATASOURCE_INTERVALS[SESSION_ID][dsP]
|
|
5628
|
-
) {
|
|
5021
|
+
if ((SESSION_OBJ[SESSION_ID].DS_GLB[dsP] && SESSION_OBJ[SESSION_ID].DS_GLB[dsP].keep_alive) || dsP == 0) return;
|
|
5022
|
+
if (DATASOURCE_INTERVALS[SESSION_ID] && DATASOURCE_INTERVALS[SESSION_ID][dsP]) {
|
|
5629
5023
|
DATASOURCE_INTERVALS[SESSION_ID][dsP].clear();
|
|
5630
5024
|
}
|
|
5631
5025
|
|
|
5632
5026
|
const perform_delete = async function () {
|
|
5633
5027
|
var response = {
|
|
5634
|
-
success: function (jsonP, ajaxP) {
|
|
5028
|
+
success: function (jsonP, ajaxP) {},
|
|
5635
5029
|
error: function (status) {
|
|
5636
|
-
console.error(
|
|
5030
|
+
console.error('error datasource:' + status);
|
|
5637
5031
|
},
|
|
5638
5032
|
fail: function (status) {
|
|
5639
|
-
console.error(
|
|
5033
|
+
console.error('error datasource:' + status);
|
|
5640
5034
|
},
|
|
5641
5035
|
};
|
|
5642
5036
|
|
|
@@ -5650,14 +5044,9 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5650
5044
|
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsP];
|
|
5651
5045
|
if (_ds.worker_id) {
|
|
5652
5046
|
// if (_ds.data_xuda) console.log(dsP);
|
|
5653
|
-
if (
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
(!_session.opt.app_computing_mode ||
|
|
5657
|
-
_session.opt.app_computing_mode === "server")
|
|
5658
|
-
) {
|
|
5659
|
-
WEB_WORKER[SESSION_ID][_ds.worker_id].emit("message", {
|
|
5660
|
-
service: "close_websocket",
|
|
5047
|
+
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
|
|
5048
|
+
WEB_WORKER[SESSION_ID][_ds.worker_id].emit('message', {
|
|
5049
|
+
service: 'close_websocket',
|
|
5661
5050
|
});
|
|
5662
5051
|
} else {
|
|
5663
5052
|
WEB_WORKER[SESSION_ID][_ds.worker_id].worker.terminate();
|
|
@@ -5666,7 +5055,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5666
5055
|
delete WEB_WORKER[SESSION_ID][_ds.worker_id];
|
|
5667
5056
|
} else {
|
|
5668
5057
|
const json = await func.index.call_worker(SESSION_ID, {
|
|
5669
|
-
service:
|
|
5058
|
+
service: 'datasource_delete',
|
|
5670
5059
|
data: data,
|
|
5671
5060
|
id: _ds.worker_id,
|
|
5672
5061
|
});
|
|
@@ -5682,7 +5071,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5682
5071
|
_.forEach(SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs, function (val, key) {
|
|
5683
5072
|
if (val && val.dsSessionP == dsP) {
|
|
5684
5073
|
arr.push(key);
|
|
5685
|
-
for (const [key, val] of Object.entries($(
|
|
5074
|
+
for (const [key, val] of Object.entries($('.screen_blocker'))) {
|
|
5686
5075
|
$(val).remove();
|
|
5687
5076
|
}
|
|
5688
5077
|
}
|
|
@@ -5690,23 +5079,16 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5690
5079
|
for (let val of arr.reverse()) {
|
|
5691
5080
|
SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.splice(val, 1);
|
|
5692
5081
|
}
|
|
5693
|
-
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length)
|
|
5694
|
-
SESSION_OBJ[SESSION_ID].WORKER_OBJ.stat = null;
|
|
5082
|
+
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length) SESSION_OBJ[SESSION_ID].WORKER_OBJ.stat = null;
|
|
5695
5083
|
};
|
|
5696
5084
|
if (!glb.IS_WORKER) {
|
|
5697
5085
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsP]) {
|
|
5698
|
-
delete SCREEN_BLOCKER_OBJ[
|
|
5699
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].screenId +
|
|
5700
|
-
"_" +
|
|
5701
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].callingScreenId
|
|
5702
|
-
];
|
|
5086
|
+
delete SCREEN_BLOCKER_OBJ[SESSION_OBJ[SESSION_ID].DS_GLB[dsP].screenId + '_' + SESSION_OBJ[SESSION_ID].DS_GLB[dsP].callingScreenId];
|
|
5703
5087
|
|
|
5704
5088
|
delete_pending_jobs();
|
|
5705
5089
|
}
|
|
5706
|
-
if ($(SESSION_OBJ[SESSION_ID].root_element).find(
|
|
5707
|
-
var ds_obj = $(SESSION_OBJ[SESSION_ID].root_element)
|
|
5708
|
-
.find("xu-nav")
|
|
5709
|
-
?.data()?.xuData.nav_params;
|
|
5090
|
+
if ($(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav').length) {
|
|
5091
|
+
var ds_obj = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav')?.data()?.xuData.nav_params;
|
|
5710
5092
|
if (ds_obj) {
|
|
5711
5093
|
delete ds_obj[dsP];
|
|
5712
5094
|
}
|
|
@@ -5714,86 +5096,63 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
5714
5096
|
}
|
|
5715
5097
|
perform_delete();
|
|
5716
5098
|
};
|
|
5717
|
-
func.datasource.update = async function (
|
|
5718
|
-
SESSION_ID,
|
|
5719
|
-
datasource_changes,
|
|
5720
|
-
update_local_scope_only,
|
|
5721
|
-
avoid_refresh
|
|
5722
|
-
) {
|
|
5099
|
+
func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
5723
5100
|
return new Promise(async (resolve, reject) => {
|
|
5724
5101
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5725
5102
|
|
|
5726
|
-
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !==
|
|
5727
|
-
update_local_scope_only = true
|
|
5103
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
5104
|
+
update_local_scope_only = true;
|
|
5728
5105
|
}
|
|
5729
5106
|
|
|
5730
|
-
if (typeof glb.GLOBAL_VARS ===
|
|
5731
|
-
glb.GLOBAL_VARS = (
|
|
5732
|
-
await func.common.get_module(
|
|
5733
|
-
SESSION_ID,
|
|
5734
|
-
"xuda-system-globals-module.mjs"
|
|
5735
|
-
)
|
|
5736
|
-
).system_globals;
|
|
5107
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
5108
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
5737
5109
|
}
|
|
5738
5110
|
|
|
5739
5111
|
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
5740
|
-
|
|
5741
5112
|
// iterate child ds
|
|
5742
5113
|
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5743
5114
|
if (parent_ds !== null) {
|
|
5744
|
-
if (_ds.parentDataSourceNo != parent_ds) continue
|
|
5115
|
+
if (_ds.parentDataSourceNo != parent_ds) continue;
|
|
5745
5116
|
} else {
|
|
5746
|
-
if (dsSession != dsNo) continue
|
|
5117
|
+
if (dsSession != dsNo) continue;
|
|
5747
5118
|
}
|
|
5748
5119
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5749
|
-
if (tree_ret.menuType ===
|
|
5120
|
+
if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
|
|
5750
5121
|
// check if field has fieldComputed property
|
|
5751
|
-
const _progFields = await func.datasource.get_progFields(
|
|
5752
|
-
SESSION_ID,
|
|
5753
|
-
dsSession
|
|
5754
|
-
);
|
|
5122
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
|
|
5755
5123
|
// find if field is computed
|
|
5756
|
-
let fieldComputed_propExpressions, fieldComputed_id
|
|
5124
|
+
let fieldComputed_propExpressions, fieldComputed_id;
|
|
5757
5125
|
for await (const val of _progFields) {
|
|
5758
|
-
|
|
5759
5126
|
const fieldId = val.data.field_id;
|
|
5760
5127
|
|
|
5761
5128
|
// if (fieldId !== field_id) continue
|
|
5762
|
-
if (val.data.type !==
|
|
5129
|
+
if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
|
|
5763
5130
|
|
|
5764
|
-
const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
5131
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue;
|
|
5765
5132
|
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
5766
|
-
fieldComputed_propExpressions = _propExpressions
|
|
5767
|
-
fieldComputed_id = fieldId
|
|
5133
|
+
fieldComputed_propExpressions = _propExpressions;
|
|
5134
|
+
fieldComputed_id = fieldId;
|
|
5768
5135
|
}
|
|
5769
5136
|
}
|
|
5770
5137
|
|
|
5771
|
-
if (!fieldComputed_id) return
|
|
5772
|
-
|
|
5138
|
+
if (!fieldComputed_id) return;
|
|
5773
5139
|
|
|
5774
5140
|
// iterate ds rows
|
|
5775
5141
|
for (const row of _ds.data_feed?.rows || []) {
|
|
5776
5142
|
// iterate row fields
|
|
5777
5143
|
for (const [key, val] of Object.entries(row)) {
|
|
5778
|
-
if (key !== fieldComputed_id) continue
|
|
5144
|
+
if (key !== fieldComputed_id) continue;
|
|
5779
5145
|
try {
|
|
5780
|
-
|
|
5781
|
-
let ret = await func.expression.get(
|
|
5782
|
-
SESSION_ID,
|
|
5783
|
-
fieldComputed_propExpressions,
|
|
5784
|
-
dsNo,
|
|
5785
|
-
"update",
|
|
5786
|
-
row._ROWID
|
|
5787
|
-
);
|
|
5146
|
+
let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
|
|
5788
5147
|
|
|
5789
5148
|
const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
|
|
5790
5149
|
if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
|
|
5791
5150
|
_ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
|
|
5792
5151
|
if (!fields_changed.includes(fieldComputed_id)) {
|
|
5793
|
-
fields_changed.push(fieldComputed_id)
|
|
5152
|
+
fields_changed.push(fieldComputed_id);
|
|
5794
5153
|
}
|
|
5795
5154
|
if (!datasource_changed.includes(dsSession)) {
|
|
5796
|
-
datasource_changed.push(dsSession)
|
|
5155
|
+
datasource_changed.push(dsSession);
|
|
5797
5156
|
}
|
|
5798
5157
|
}
|
|
5799
5158
|
} catch (err) {
|
|
@@ -5802,19 +5161,16 @@ func.datasource.update = async function (
|
|
|
5802
5161
|
}
|
|
5803
5162
|
}
|
|
5804
5163
|
}
|
|
5805
|
-
await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
5164
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
|
|
5806
5165
|
}
|
|
5807
|
-
|
|
5808
|
-
}
|
|
5166
|
+
};
|
|
5809
5167
|
|
|
5810
5168
|
var fields_changed = [];
|
|
5811
5169
|
var datasource_changed = [];
|
|
5812
|
-
let client_datasource_changes = {}
|
|
5813
|
-
let server_datasource_changes = {}
|
|
5170
|
+
let client_datasource_changes = {};
|
|
5171
|
+
let server_datasource_changes = {};
|
|
5814
5172
|
// iterate changes datasource
|
|
5815
|
-
for await (const [dataSource, row_data] of Object.entries(
|
|
5816
|
-
datasource_changes
|
|
5817
|
-
)) {
|
|
5173
|
+
for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
|
|
5818
5174
|
var _ds = _session.DS_GLB[dataSource];
|
|
5819
5175
|
if (!_ds) {
|
|
5820
5176
|
continue;
|
|
@@ -5824,12 +5180,12 @@ func.datasource.update = async function (
|
|
|
5824
5180
|
// iterate changes fields
|
|
5825
5181
|
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
5826
5182
|
// mechanism to make update directly on the datasource object
|
|
5827
|
-
if (record_id ===
|
|
5183
|
+
if (record_id === 'datasource_main') {
|
|
5828
5184
|
_.set(_ds, field_id, value);
|
|
5829
5185
|
continue;
|
|
5830
5186
|
}
|
|
5831
5187
|
|
|
5832
|
-
if (typeof fields_data ===
|
|
5188
|
+
if (typeof fields_data === 'object') {
|
|
5833
5189
|
if (glb.GLOBAL_VARS[field_id]) {
|
|
5834
5190
|
_ds.data_system[field_id] = value;
|
|
5835
5191
|
|
|
@@ -5839,42 +5195,33 @@ func.datasource.update = async function (
|
|
|
5839
5195
|
try {
|
|
5840
5196
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5841
5197
|
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
5842
|
-
await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
5198
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
5843
5199
|
|
|
5844
5200
|
if (!update_local_scope_only) {
|
|
5845
5201
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5846
5202
|
if (glb.IS_WORKER) {
|
|
5847
5203
|
// RUN AT SERVER
|
|
5848
|
-
if (tree_ret.menuType ===
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
dataSource
|
|
5853
|
-
);
|
|
5854
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
5855
|
-
_progFields,
|
|
5856
|
-
"field_id",
|
|
5857
|
-
field_id
|
|
5858
|
-
);
|
|
5859
|
-
if (!view_field_obj?.data?.serverField && record_id !== "data_system") {
|
|
5204
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5205
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5206
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5207
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5860
5208
|
if (!client_datasource_changes[dataSource]) {
|
|
5861
|
-
client_datasource_changes[dataSource] = {}
|
|
5209
|
+
client_datasource_changes[dataSource] = {};
|
|
5862
5210
|
}
|
|
5863
5211
|
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5864
|
-
client_datasource_changes[dataSource][record_id] = {}
|
|
5212
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
5865
5213
|
}
|
|
5866
5214
|
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5867
5215
|
}
|
|
5868
|
-
|
|
5869
5216
|
}
|
|
5870
5217
|
} else {
|
|
5871
5218
|
// RUN AT CLIENT
|
|
5872
|
-
if ((tree_ret.menuType ===
|
|
5219
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5873
5220
|
if (!server_datasource_changes[dataSource]) {
|
|
5874
|
-
server_datasource_changes[dataSource] = {}
|
|
5221
|
+
server_datasource_changes[dataSource] = {};
|
|
5875
5222
|
}
|
|
5876
5223
|
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5877
|
-
server_datasource_changes[dataSource][record_id] = {}
|
|
5224
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
5878
5225
|
}
|
|
5879
5226
|
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5880
5227
|
}
|
|
@@ -5894,14 +5241,10 @@ func.datasource.update = async function (
|
|
|
5894
5241
|
if (!_ds.data_feed.rows_changed) {
|
|
5895
5242
|
_ds.data_feed.rows_changed = [];
|
|
5896
5243
|
}
|
|
5897
|
-
if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
} else if (fields_data === "set") {
|
|
5244
|
+
if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
|
|
5245
|
+
} else if (fields_data === 'set') {
|
|
5901
5246
|
_ds.currentRecordId = record_id;
|
|
5902
5247
|
}
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
5248
|
}
|
|
5906
5249
|
// if (!_ds.data_feed.rows_changed) {
|
|
5907
5250
|
// _ds.data_feed.rows_changed = [];
|
|
@@ -5909,30 +5252,16 @@ func.datasource.update = async function (
|
|
|
5909
5252
|
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
5910
5253
|
// _ds.data_feed.rows_changed.push(record_id);
|
|
5911
5254
|
}
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
5255
|
}
|
|
5918
5256
|
|
|
5919
5257
|
if (glb.IS_WORKER) {
|
|
5920
|
-
|
|
5921
5258
|
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
5922
|
-
func.utils.post_back_to_client(
|
|
5923
|
-
SESSION_ID,
|
|
5924
|
-
"update_client_eventChangesResults_from_worker",
|
|
5925
|
-
_session.worker_id,
|
|
5926
|
-
client_datasource_changes
|
|
5927
|
-
);
|
|
5928
|
-
|
|
5259
|
+
func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
|
|
5929
5260
|
}
|
|
5930
|
-
|
|
5931
5261
|
} else {
|
|
5932
5262
|
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
5933
|
-
|
|
5934
5263
|
const ret = await func.index.call_worker(SESSION_ID, {
|
|
5935
|
-
service:
|
|
5264
|
+
service: 'update_datasource_changes_from_client',
|
|
5936
5265
|
data: {
|
|
5937
5266
|
session_id: SESSION_ID,
|
|
5938
5267
|
datasource_changes: server_datasource_changes,
|
|
@@ -5947,16 +5276,14 @@ func.datasource.update = async function (
|
|
|
5947
5276
|
SESSION_ID,
|
|
5948
5277
|
fields_changed,
|
|
5949
5278
|
null,
|
|
5950
|
-
datasource_changed[0] // refresh the current datasource only
|
|
5279
|
+
datasource_changed[0], // refresh the current datasource only
|
|
5951
5280
|
);
|
|
5952
5281
|
}
|
|
5953
5282
|
}
|
|
5954
5283
|
resolve();
|
|
5955
5284
|
});
|
|
5956
|
-
|
|
5957
5285
|
};
|
|
5958
5286
|
|
|
5959
|
-
|
|
5960
5287
|
// func.datasource.update = async function (
|
|
5961
5288
|
// SESSION_ID,
|
|
5962
5289
|
// datasource_changes,
|
|
@@ -6042,8 +5369,6 @@ func.datasource.update = async function (
|
|
|
6042
5369
|
// }
|
|
6043
5370
|
// debugger
|
|
6044
5371
|
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
5372
|
// }
|
|
6048
5373
|
|
|
6049
5374
|
// var fields_changed = [];
|
|
@@ -6082,8 +5407,6 @@ func.datasource.update = async function (
|
|
|
6082
5407
|
// console.error(err);
|
|
6083
5408
|
// }
|
|
6084
5409
|
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
5410
|
// if (!fields_changed.includes(field_id)) {
|
|
6088
5411
|
// fields_changed.push(field_id);
|
|
6089
5412
|
// }
|
|
@@ -6127,14 +5450,12 @@ func.datasource.update = async function (
|
|
|
6127
5450
|
// _ds.data_feed.rows_changed.push(record_id);
|
|
6128
5451
|
// }
|
|
6129
5452
|
|
|
6130
|
-
|
|
6131
5453
|
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
6132
5454
|
|
|
6133
5455
|
// if (!update_local_scope_only) {
|
|
6134
5456
|
// if (glb.IS_WORKER) {
|
|
6135
5457
|
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
6136
5458
|
|
|
6137
|
-
|
|
6138
5459
|
// if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
6139
5460
|
// continue;
|
|
6140
5461
|
// }
|
|
@@ -6191,55 +5512,53 @@ func.datasource.update = async function (
|
|
|
6191
5512
|
// });
|
|
6192
5513
|
// };
|
|
6193
5514
|
|
|
6194
|
-
func.datasource.callback = function (
|
|
6195
|
-
SESSION_ID,
|
|
6196
|
-
dsSessionP,
|
|
6197
|
-
na,
|
|
6198
|
-
rowIdP,
|
|
6199
|
-
jobNoP,
|
|
6200
|
-
NA_callingDataSourceP,
|
|
6201
|
-
NA_isInitP,
|
|
6202
|
-
nodeIdP
|
|
6203
|
-
) {
|
|
5515
|
+
func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, jobNoP, NA_callingDataSourceP, NA_isInitP, nodeIdP) {
|
|
6204
5516
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
6205
5517
|
var _ds = _session.DS_GLB[dsSessionP];
|
|
6206
5518
|
|
|
6207
5519
|
try {
|
|
6208
|
-
const row_idx = func.common.find_ROWID_idx(_ds,
|
|
5520
|
+
const row_idx = func.common.find_ROWID_idx(_ds, 'dataset');
|
|
6209
5521
|
|
|
6210
5522
|
if (_ds.PARAM_OUT_INFO) {
|
|
6211
5523
|
// write log for out params
|
|
6212
5524
|
for (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
6213
|
-
if (
|
|
6214
|
-
typeof _ds?.data_feed?.rows?.[row_idx]?.[val.fieldId] === "undefined"
|
|
6215
|
-
) {
|
|
5525
|
+
if (typeof _ds?.data_feed?.rows?.[row_idx]?.[val.fieldId] === 'undefined') {
|
|
6216
5526
|
// func.utils.debug.log(SESSION_ID, key, val);
|
|
6217
|
-
func.utils.alerts.invoke(
|
|
6218
|
-
SESSION_ID,
|
|
6219
|
-
"system_msg",
|
|
6220
|
-
"SYS_MSG_0310",
|
|
6221
|
-
val.fieldId,
|
|
6222
|
-
dsSessionP
|
|
6223
|
-
);
|
|
5527
|
+
func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0310', val.fieldId, dsSessionP);
|
|
6224
5528
|
break;
|
|
6225
5529
|
}
|
|
6226
5530
|
val.result = _ds.data_feed.rows[row_idx][val.fieldId];
|
|
6227
5531
|
}
|
|
6228
5532
|
}
|
|
5533
|
+
|
|
5534
|
+
if (_ds?.progDataSource?.datasetOutputField) {
|
|
5535
|
+
let datasource_changes = {};
|
|
5536
|
+
|
|
5537
|
+
let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
|
|
5538
|
+
if (!datasource_changes[_ds.dsSession]) {
|
|
5539
|
+
datasource_changes[_ds.dsSession] = {};
|
|
5540
|
+
}
|
|
5541
|
+
if (!datasource_changes[_ds.dsSession][_ds.currentRecordId]) {
|
|
5542
|
+
datasource_changes[_ds.dsSession][_ds.currentRecordId] = {};
|
|
5543
|
+
|
|
5544
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][_ds?.progDataSource?.datasetOutputField] = _ds?.data_feed?.rows || [];
|
|
5545
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
6229
5548
|
} catch (err) {
|
|
6230
5549
|
// console.error(err);
|
|
6231
5550
|
}
|
|
6232
5551
|
|
|
6233
5552
|
func.utils.debug.log(SESSION_ID, nodeIdP, {
|
|
6234
5553
|
module: _ds.viewModule,
|
|
6235
|
-
action:
|
|
5554
|
+
action: 'close',
|
|
6236
5555
|
source: _ds.viewSourceDesc,
|
|
6237
|
-
type:
|
|
5556
|
+
type: 'adapter',
|
|
6238
5557
|
prog_id: _ds.prog_id,
|
|
6239
5558
|
dsSession: dsSessionP,
|
|
6240
|
-
prop: _ds.log_prop +
|
|
5559
|
+
prop: _ds.log_prop + ' ' + 'adapter',
|
|
6241
5560
|
});
|
|
6242
|
-
if (!glb.IS_WORKER) $(_session.root_element).css(
|
|
5561
|
+
if (!glb.IS_WORKER) $(_session.root_element).css('cursor', 'default');
|
|
6243
5562
|
|
|
6244
5563
|
if (_ds.prog_id) {
|
|
6245
5564
|
let _ds = _session.DS_GLB[dsSessionP];
|
|
@@ -6247,19 +5566,17 @@ func.datasource.callback = function (
|
|
|
6247
5566
|
func.utils.debug.watch(
|
|
6248
5567
|
SESSION_ID,
|
|
6249
5568
|
_ds.prog_id,
|
|
6250
|
-
|
|
5569
|
+
'program',
|
|
6251
5570
|
{
|
|
6252
5571
|
in_parameters: _ds.in_parameters,
|
|
6253
5572
|
out_parameters: _ds.out_parameters,
|
|
6254
5573
|
data_feed: _ds.data_feed,
|
|
6255
5574
|
},
|
|
6256
|
-
_ds.tree_obj.menuType
|
|
5575
|
+
_ds.tree_obj.menuType,
|
|
6257
5576
|
);
|
|
6258
5577
|
}
|
|
6259
5578
|
delete _ds.old_dataSource;
|
|
6260
5579
|
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
5580
|
return {
|
|
6264
5581
|
SESSION_ID,
|
|
6265
5582
|
dsSessionP,
|
|
@@ -6269,28 +5586,14 @@ func.datasource.callback = function (
|
|
|
6269
5586
|
calling_jobP: _ds.calling_jobP,
|
|
6270
5587
|
};
|
|
6271
5588
|
};
|
|
6272
|
-
func.datasource.validate_viewRange = async function (
|
|
6273
|
-
SESSION_ID,
|
|
6274
|
-
viewRangeExpP,
|
|
6275
|
-
dsSessionP,
|
|
6276
|
-
rowIdP,
|
|
6277
|
-
sourceP
|
|
6278
|
-
) {
|
|
5589
|
+
func.datasource.validate_viewRange = async function (SESSION_ID, viewRangeExpP, dsSessionP, rowIdP, sourceP) {
|
|
6279
5590
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
6280
5591
|
if (viewRangeExpP && _ds) {
|
|
6281
|
-
var ret = func.expression.remove_quotes(
|
|
6282
|
-
await func.expression.get(
|
|
6283
|
-
SESSION_ID,
|
|
6284
|
-
viewRangeExpP,
|
|
6285
|
-
dsSessionP,
|
|
6286
|
-
"range",
|
|
6287
|
-
rowIdP
|
|
6288
|
-
)
|
|
6289
|
-
);
|
|
5592
|
+
var ret = func.expression.remove_quotes(await func.expression.get(SESSION_ID, viewRangeExpP, dsSessionP, 'range', rowIdP));
|
|
6290
5593
|
ret.result = func.expression.remove_quotes(ret.result);
|
|
6291
5594
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
6292
5595
|
module: _ds.viewModule,
|
|
6293
|
-
action:
|
|
5596
|
+
action: 'range Exp',
|
|
6294
5597
|
prop: sourceP,
|
|
6295
5598
|
details: viewRangeExpP,
|
|
6296
5599
|
result: ret.result,
|
|
@@ -6313,27 +5616,13 @@ func.datasource.validate_viewRange = async function (
|
|
|
6313
5616
|
return ret.result;
|
|
6314
5617
|
} else return false;
|
|
6315
5618
|
};
|
|
6316
|
-
func.datasource.validate_viewLocate = async function (
|
|
6317
|
-
SESSION_ID,
|
|
6318
|
-
viewLocateExpP,
|
|
6319
|
-
dsSessionP,
|
|
6320
|
-
rowIdP,
|
|
6321
|
-
sourceP
|
|
6322
|
-
) {
|
|
5619
|
+
func.datasource.validate_viewLocate = async function (SESSION_ID, viewLocateExpP, dsSessionP, rowIdP, sourceP) {
|
|
6323
5620
|
if (viewLocateExpP && _ds) {
|
|
6324
|
-
var ret = func.expression.remove_quotes(
|
|
6325
|
-
await func.expression.get(
|
|
6326
|
-
SESSION_ID,
|
|
6327
|
-
viewLocateExpP,
|
|
6328
|
-
dsSessionP,
|
|
6329
|
-
"locate",
|
|
6330
|
-
rowIdP
|
|
6331
|
-
)
|
|
6332
|
-
);
|
|
5621
|
+
var ret = func.expression.remove_quotes(await func.expression.get(SESSION_ID, viewLocateExpP, dsSessionP, 'locate', rowIdP));
|
|
6333
5622
|
ret.result = func.expression.remove_quotes(ret.result);
|
|
6334
5623
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
6335
5624
|
module: _ds.viewModule,
|
|
6336
|
-
action:
|
|
5625
|
+
action: 'locate Exp',
|
|
6337
5626
|
prop: sourceP,
|
|
6338
5627
|
details: viewLocateExpP,
|
|
6339
5628
|
result: ret.result,
|
|
@@ -6348,12 +5637,7 @@ func.datasource.validate_viewLocate = async function (
|
|
|
6348
5637
|
} else return false;
|
|
6349
5638
|
};
|
|
6350
5639
|
|
|
6351
|
-
func.datasource.get_viewFields_for_update_function = function (
|
|
6352
|
-
SESSION_ID,
|
|
6353
|
-
calling_trigger_prop,
|
|
6354
|
-
na,
|
|
6355
|
-
dsSessionP
|
|
6356
|
-
) {
|
|
5640
|
+
func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calling_trigger_prop, na, dsSessionP) {
|
|
6357
5641
|
var viewFields = [];
|
|
6358
5642
|
|
|
6359
5643
|
var exp = calling_trigger_prop?.data?.name?.value;
|
|
@@ -6362,7 +5646,7 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
6362
5646
|
}
|
|
6363
5647
|
try {
|
|
6364
5648
|
// parse json
|
|
6365
|
-
var json = JSON5.parse(exp.replace(/\n/gi,
|
|
5649
|
+
var json = JSON5.parse(exp.replace(/\n/gi, ''));
|
|
6366
5650
|
for (const [key, val] of Object.entries(json)) {
|
|
6367
5651
|
let id = key.substr(1, key.length - 1);
|
|
6368
5652
|
if (!id) continue;
|
|
@@ -6376,13 +5660,12 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
6376
5660
|
if (!exp) {
|
|
6377
5661
|
return;
|
|
6378
5662
|
}
|
|
6379
|
-
if (exp.substr(exp.length - 1, 1) ===
|
|
6380
|
-
exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
5663
|
+
if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
6381
5664
|
var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
|
|
6382
5665
|
if (exp_arr?.length) {
|
|
6383
5666
|
for (let val of exp_arr) {
|
|
6384
5667
|
// run view fields
|
|
6385
|
-
var pos = val.indexOf(
|
|
5668
|
+
var pos = val.indexOf(':');
|
|
6386
5669
|
var seg = [val.substring(0, pos), val.substring(pos + 1)];
|
|
6387
5670
|
if (seg && seg.length === 2) {
|
|
6388
5671
|
let id = seg[0].substr(1, seg[0].length);
|
|
@@ -6395,14 +5678,14 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
6395
5678
|
} else {
|
|
6396
5679
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
6397
5680
|
module: _ds.viewModule,
|
|
6398
|
-
action:
|
|
6399
|
-
prop:
|
|
5681
|
+
action: 'set',
|
|
5682
|
+
prop: 'parse update exp',
|
|
6400
5683
|
details: exp,
|
|
6401
|
-
result:
|
|
6402
|
-
error:
|
|
5684
|
+
result: '',
|
|
5685
|
+
error: 'Invalid json; too many segments',
|
|
6403
5686
|
source: _ds.viewSourceDesc,
|
|
6404
|
-
json:
|
|
6405
|
-
fields:
|
|
5687
|
+
json: '',
|
|
5688
|
+
fields: '',
|
|
6406
5689
|
dsSession: dsSessionP,
|
|
6407
5690
|
});
|
|
6408
5691
|
}
|
|
@@ -6412,74 +5695,36 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
6412
5695
|
return viewFields;
|
|
6413
5696
|
}
|
|
6414
5697
|
};
|
|
6415
|
-
func.datasource.get_value = async function (
|
|
6416
|
-
SESSION_ID,
|
|
6417
|
-
fieldIdP,
|
|
6418
|
-
dsSessionP,
|
|
6419
|
-
rowIdP,
|
|
6420
|
-
org_dsSessionP
|
|
6421
|
-
) {
|
|
5698
|
+
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
6422
5699
|
const return_value = async (field_id, value) => {
|
|
6423
|
-
const _progFields = await func.datasource.get_progFields(
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
);
|
|
6427
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
6428
|
-
_progFields,
|
|
6429
|
-
"field_id",
|
|
6430
|
-
field_id
|
|
6431
|
-
);
|
|
6432
|
-
var fieldType = view_field_obj?.props?.fieldType || "string";
|
|
5700
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
5701
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5702
|
+
var fieldType = view_field_obj?.props?.fieldType || 'string';
|
|
6433
5703
|
var fieldProp = view_field_obj?.props;
|
|
6434
5704
|
let table_field_obj;
|
|
6435
|
-
if (view_field_obj?.data?.type ===
|
|
5705
|
+
if (view_field_obj?.data?.type === 'table') {
|
|
6436
5706
|
if (!_ds._dataSourceTableId) {
|
|
6437
|
-
return func.utils.debug_report(
|
|
6438
|
-
SESSION_ID,
|
|
6439
|
-
"Datasource",
|
|
6440
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
6441
|
-
"E"
|
|
6442
|
-
);
|
|
5707
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
6443
5708
|
}
|
|
6444
5709
|
|
|
6445
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
6446
|
-
SESSION_ID,
|
|
6447
|
-
_ds._dataSourceTableId
|
|
6448
|
-
);
|
|
5710
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
6449
5711
|
|
|
6450
5712
|
if (!table_obj) {
|
|
6451
|
-
return func.utils.debug_report(
|
|
6452
|
-
SESSION_ID,
|
|
6453
|
-
"Datasource",
|
|
6454
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
6455
|
-
"E"
|
|
6456
|
-
);
|
|
5713
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
6457
5714
|
}
|
|
6458
|
-
table_field_obj = func.common.find_item_by_key(
|
|
6459
|
-
table_obj.tableFields,
|
|
6460
|
-
"field_id",
|
|
6461
|
-
field_id
|
|
6462
|
-
);
|
|
5715
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
6463
5716
|
fieldType = table_field_obj.props?.fieldType;
|
|
6464
5717
|
fieldProp = table_field_obj.props;
|
|
6465
5718
|
}
|
|
6466
5719
|
|
|
6467
5720
|
let ret = {
|
|
6468
|
-
value: await func.common.get_cast_val(
|
|
6469
|
-
SESSION_ID,
|
|
6470
|
-
`datasource get value ${_ds.tree_obj.menuName}`,
|
|
6471
|
-
fieldIdP,
|
|
6472
|
-
fieldType,
|
|
6473
|
-
value,
|
|
6474
|
-
null
|
|
6475
|
-
),
|
|
5721
|
+
value: await func.common.get_cast_val(SESSION_ID, `datasource get value ${_ds.tree_obj.menuName}`, fieldIdP, fieldType, value, null),
|
|
6476
5722
|
type: fieldType,
|
|
6477
5723
|
prop: fieldProp,
|
|
6478
5724
|
};
|
|
6479
5725
|
|
|
6480
|
-
if (ret.value && typeof ret.value ===
|
|
6481
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
6482
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
5726
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
5727
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
6483
5728
|
}
|
|
6484
5729
|
|
|
6485
5730
|
return {
|
|
@@ -6487,12 +5732,12 @@ func.datasource.get_value = async function (
|
|
|
6487
5732
|
dsSessionP,
|
|
6488
5733
|
fieldIdP: field_id,
|
|
6489
5734
|
currentRecordId: _ds.currentRecordId,
|
|
6490
|
-
found: typeof value !==
|
|
5735
|
+
found: typeof value !== 'undefined',
|
|
6491
5736
|
};
|
|
6492
5737
|
};
|
|
6493
5738
|
const return_dynamic_value = async (field_id, value) => {
|
|
6494
5739
|
let view_field_obj = _ds.dynamic_fields[field_id];
|
|
6495
|
-
var fieldType = view_field_obj?.props?.fieldType ||
|
|
5740
|
+
var fieldType = view_field_obj?.props?.fieldType || 'string';
|
|
6496
5741
|
var fieldProp = view_field_obj?.props;
|
|
6497
5742
|
|
|
6498
5743
|
let ret = {
|
|
@@ -6501,9 +5746,8 @@ func.datasource.get_value = async function (
|
|
|
6501
5746
|
prop: fieldProp,
|
|
6502
5747
|
};
|
|
6503
5748
|
|
|
6504
|
-
if (ret.value && typeof ret.value ===
|
|
6505
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
6506
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
5749
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
5750
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
6507
5751
|
}
|
|
6508
5752
|
|
|
6509
5753
|
return {
|
|
@@ -6511,26 +5755,18 @@ func.datasource.get_value = async function (
|
|
|
6511
5755
|
dsSessionP,
|
|
6512
5756
|
fieldIdP: field_id,
|
|
6513
5757
|
currentRecordId: _ds.currentRecordId,
|
|
6514
|
-
found: typeof value !==
|
|
5758
|
+
found: typeof value !== 'undefined',
|
|
6515
5759
|
};
|
|
6516
5760
|
};
|
|
6517
5761
|
const return_value_parameters = async (field_id, value) => {
|
|
6518
5762
|
let ret = {
|
|
6519
|
-
value: await func.common.get_cast_val(
|
|
6520
|
-
SESSION_ID,
|
|
6521
|
-
"datasource get value",
|
|
6522
|
-
fieldIdP,
|
|
6523
|
-
value.type,
|
|
6524
|
-
value.value,
|
|
6525
|
-
null
|
|
6526
|
-
),
|
|
5763
|
+
value: await func.common.get_cast_val(SESSION_ID, 'datasource get value', fieldIdP, value.type, value.value, null),
|
|
6527
5764
|
type: value.type,
|
|
6528
5765
|
prop: null,
|
|
6529
5766
|
};
|
|
6530
5767
|
|
|
6531
|
-
if (ret.value && typeof ret.value ===
|
|
6532
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
6533
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
5768
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
5769
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
6534
5770
|
// if (/"/.test(ret.value) && ret.value.indexOf("\\") === -1)
|
|
6535
5771
|
// ret.value = ret.value.replace(/"/g, '\\"');
|
|
6536
5772
|
}
|
|
@@ -6540,7 +5776,7 @@ func.datasource.get_value = async function (
|
|
|
6540
5776
|
dsSessionP,
|
|
6541
5777
|
fieldIdP: field_id,
|
|
6542
5778
|
currentRecordId: _ds.currentRecordId,
|
|
6543
|
-
found: typeof value !==
|
|
5779
|
+
found: typeof value !== 'undefined',
|
|
6544
5780
|
};
|
|
6545
5781
|
};
|
|
6546
5782
|
const return_value_system = async (field_id, value) => {
|
|
@@ -6548,14 +5784,7 @@ func.datasource.get_value = async function (
|
|
|
6548
5784
|
let fieldProp = null;
|
|
6549
5785
|
|
|
6550
5786
|
let ret = {
|
|
6551
|
-
value: await func.common.get_cast_val(
|
|
6552
|
-
SESSION_ID,
|
|
6553
|
-
`datasource get value ${_ds.tree_obj.menuName}`,
|
|
6554
|
-
field_id,
|
|
6555
|
-
fieldType,
|
|
6556
|
-
value,
|
|
6557
|
-
null
|
|
6558
|
-
),
|
|
5787
|
+
value: await func.common.get_cast_val(SESSION_ID, `datasource get value ${_ds.tree_obj.menuName}`, field_id, fieldType, value, null),
|
|
6559
5788
|
type: fieldType,
|
|
6560
5789
|
prop: fieldProp,
|
|
6561
5790
|
};
|
|
@@ -6565,52 +5794,35 @@ func.datasource.get_value = async function (
|
|
|
6565
5794
|
dsSessionP,
|
|
6566
5795
|
fieldIdP: field_id,
|
|
6567
5796
|
currentRecordId: _ds.currentRecordId,
|
|
6568
|
-
found: typeof value !==
|
|
5797
|
+
found: typeof value !== 'undefined',
|
|
6569
5798
|
};
|
|
6570
5799
|
};
|
|
6571
5800
|
const search_in_parameters = async (field_id) => {
|
|
6572
|
-
if (typeof _ds?.in_parameters?.[field_id]?.value !==
|
|
6573
|
-
let ret = await return_value_parameters(
|
|
6574
|
-
field_id,
|
|
6575
|
-
_ds.in_parameters[field_id]
|
|
6576
|
-
);
|
|
5801
|
+
if (typeof _ds?.in_parameters?.[field_id]?.value !== 'undefined') {
|
|
5802
|
+
let ret = await return_value_parameters(field_id, _ds.in_parameters[field_id]);
|
|
6577
5803
|
return ret;
|
|
6578
5804
|
}
|
|
6579
5805
|
|
|
6580
|
-
if (typeof _ds.parentDataSourceNo !==
|
|
5806
|
+
if (typeof _ds.parentDataSourceNo !== 'undefined') {
|
|
6581
5807
|
var org_dsSession = org_dsSessionP;
|
|
6582
5808
|
if (!org_dsSessionP) org_dsSession = dsSessionP;
|
|
6583
|
-
if (recordId && recordId !==
|
|
5809
|
+
if (recordId && recordId !== 'newRecord') org_dsSession = null;
|
|
6584
5810
|
|
|
6585
|
-
return await func.datasource.get_value(
|
|
6586
|
-
SESSION_ID,
|
|
6587
|
-
fieldIdP,
|
|
6588
|
-
_ds.parentDataSourceNo,
|
|
6589
|
-
recordId,
|
|
6590
|
-
org_dsSession
|
|
6591
|
-
);
|
|
5811
|
+
return await func.datasource.get_value(SESSION_ID, fieldIdP, _ds.parentDataSourceNo, recordId, org_dsSession);
|
|
6592
5812
|
}
|
|
6593
5813
|
|
|
6594
5814
|
return await return_value(field_id);
|
|
6595
5815
|
};
|
|
6596
5816
|
|
|
6597
|
-
if (typeof glb.GLOBAL_VARS ===
|
|
6598
|
-
glb.GLOBAL_VARS = (
|
|
6599
|
-
await func.common.get_module(SESSION_ID, "xuda-system-globals-module.mjs")
|
|
6600
|
-
).system_globals;
|
|
5817
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
5818
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
6601
5819
|
}
|
|
6602
5820
|
|
|
6603
5821
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
6604
5822
|
if (!_ds) {
|
|
6605
5823
|
if (dsSessionP > 0) {
|
|
6606
5824
|
// let prev_ds = dsSessionP - 1;
|
|
6607
|
-
return await func.datasource.get_value(
|
|
6608
|
-
SESSION_ID,
|
|
6609
|
-
fieldIdP,
|
|
6610
|
-
dsSessionP - 1,
|
|
6611
|
-
rowIdP,
|
|
6612
|
-
org_dsSessionP
|
|
6613
|
-
);
|
|
5825
|
+
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
6614
5826
|
}
|
|
6615
5827
|
return await return_value(fieldIdP);
|
|
6616
5828
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
@@ -6626,8 +5838,8 @@ func.datasource.get_value = async function (
|
|
|
6626
5838
|
}
|
|
6627
5839
|
|
|
6628
5840
|
if (dsSessionP > 0) {
|
|
6629
|
-
_ds.data_system[
|
|
6630
|
-
_ds.data_system[
|
|
5841
|
+
_ds.data_system['SYS_STR_ACTIVE_ROW_ID'] = _ds.currentRecordId;
|
|
5842
|
+
_ds.data_system['SYS_STR_PROG_DS_SESSION'] = dsSessionP;
|
|
6631
5843
|
}
|
|
6632
5844
|
|
|
6633
5845
|
// set system time
|
|
@@ -6638,19 +5850,15 @@ func.datasource.get_value = async function (
|
|
|
6638
5850
|
if (!_ds_0.data_system) {
|
|
6639
5851
|
_ds_0.data_system = {};
|
|
6640
5852
|
}
|
|
6641
|
-
const ts = await func.utils.get_dateTime(SESSION_ID,
|
|
5853
|
+
const ts = await func.utils.get_dateTime(SESSION_ID, 'SYS_DATE_VALUE');
|
|
6642
5854
|
for (const val of glb.SYS_DATE_ARR) {
|
|
6643
|
-
_ds_0.data_system[val] = await func.utils.get_dateTime(
|
|
6644
|
-
SESSION_ID,
|
|
6645
|
-
val,
|
|
6646
|
-
ts
|
|
6647
|
-
);
|
|
5855
|
+
_ds_0.data_system[val] = await func.utils.get_dateTime(SESSION_ID, val, ts);
|
|
6648
5856
|
}
|
|
6649
5857
|
}
|
|
6650
5858
|
}
|
|
6651
5859
|
|
|
6652
5860
|
// await func.datasource.set_system_vars(SESSION_ID, dsSessionP);
|
|
6653
|
-
if (typeof _ds?.data_system?.[fieldIdP] !==
|
|
5861
|
+
if (typeof _ds?.data_system?.[fieldIdP] !== 'undefined') {
|
|
6654
5862
|
return await return_value_system(fieldIdP, _ds?.data_system?.[fieldIdP]);
|
|
6655
5863
|
}
|
|
6656
5864
|
return await search_in_parameters(fieldIdP);
|
|
@@ -6673,28 +5881,20 @@ func.datasource.get_value = async function (
|
|
|
6673
5881
|
|
|
6674
5882
|
var _field_id = fieldIdP;
|
|
6675
5883
|
|
|
6676
|
-
if (fieldIdP.substr(0, 1) ===
|
|
5884
|
+
if (fieldIdP.substr(0, 1) === '_') {
|
|
6677
5885
|
if (_ds.alias) _field_id = _ds.alias[fieldIdP];
|
|
6678
5886
|
}
|
|
6679
5887
|
|
|
6680
5888
|
if (!org_dsSessionP && recordId) {
|
|
6681
5889
|
try {
|
|
6682
5890
|
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
6683
|
-
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !==
|
|
6684
|
-
if (
|
|
6685
|
-
|
|
6686
|
-
) {
|
|
6687
|
-
return await return_value(
|
|
6688
|
-
_field_id,
|
|
6689
|
-
_ds.data_feed.rows[row_idx][_field_id]
|
|
6690
|
-
);
|
|
5891
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== 'undefined') {
|
|
5892
|
+
if (Object.keys(_ds.data_feed?.rows?.[row_idx] || {})?.includes(_field_id)) {
|
|
5893
|
+
return await return_value(_field_id, _ds.data_feed.rows[row_idx][_field_id]);
|
|
6691
5894
|
}
|
|
6692
5895
|
|
|
6693
5896
|
if (Object.keys(_ds?.dynamic_fields || {})?.includes(_field_id)) {
|
|
6694
|
-
return await return_dynamic_value(
|
|
6695
|
-
_field_id,
|
|
6696
|
-
_ds.dynamic_fields[_field_id]
|
|
6697
|
-
);
|
|
5897
|
+
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
6698
5898
|
}
|
|
6699
5899
|
}
|
|
6700
5900
|
} catch (err) {
|
|
@@ -6705,26 +5905,19 @@ func.datasource.get_value = async function (
|
|
|
6705
5905
|
try {
|
|
6706
5906
|
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
6707
5907
|
|
|
6708
|
-
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !==
|
|
6709
|
-
return await return_value(
|
|
6710
|
-
_field_id,
|
|
6711
|
-
_ds.data_feed.rows[row_idx][_field_id]
|
|
6712
|
-
);
|
|
5908
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== 'undefined') {
|
|
5909
|
+
return await return_value(_field_id, _ds.data_feed.rows[row_idx][_field_id]);
|
|
6713
5910
|
}
|
|
6714
|
-
} catch (error) {
|
|
5911
|
+
} catch (error) {}
|
|
6715
5912
|
|
|
6716
|
-
if (typeof _ds?.dynamic_fields?.[_field_id] !==
|
|
5913
|
+
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
6717
5914
|
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
6718
5915
|
}
|
|
6719
5916
|
|
|
6720
5917
|
return await search_in_parameters(fieldIdP);
|
|
6721
5918
|
};
|
|
6722
5919
|
|
|
6723
|
-
func.datasource.find_event_dataSource = async function (
|
|
6724
|
-
SESSION_ID,
|
|
6725
|
-
eventIdP,
|
|
6726
|
-
dsSessionP
|
|
6727
|
-
) {
|
|
5920
|
+
func.datasource.find_event_dataSource = async function (SESSION_ID, eventIdP, dsSessionP) {
|
|
6728
5921
|
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
6729
5922
|
var ret;
|
|
6730
5923
|
//============================
|
|
@@ -6732,14 +5925,10 @@ func.datasource.find_event_dataSource = async function (
|
|
|
6732
5925
|
//============================
|
|
6733
5926
|
if (_ds?.prog_id) {
|
|
6734
5927
|
let view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
6735
|
-
if (
|
|
6736
|
-
view_ret?.progEvents &&
|
|
6737
|
-
func.common.find_item_by_key(view_ret.progEvents, "event_name", eventIdP)
|
|
6738
|
-
) {
|
|
5928
|
+
if (view_ret?.progEvents && func.common.find_item_by_key(view_ret.progEvents, 'event_name', eventIdP)) {
|
|
6739
5929
|
ret = dsSessionP;
|
|
6740
|
-
if (_ds.callingSource ===
|
|
6741
|
-
if (_ds.callingSource ===
|
|
6742
|
-
ret = dsSessionP;
|
|
5930
|
+
if (_ds.callingSource === 'system') ret = 0;
|
|
5931
|
+
if (_ds.callingSource === 'program' || !_ds.callingSource) ret = dsSessionP;
|
|
6743
5932
|
// >>> found value
|
|
6744
5933
|
return ret;
|
|
6745
5934
|
}
|
|
@@ -6748,46 +5937,24 @@ func.datasource.find_event_dataSource = async function (
|
|
|
6748
5937
|
//=======================================
|
|
6749
5938
|
// continue Search in parent datasource
|
|
6750
5939
|
//=======================================
|
|
6751
|
-
if (
|
|
6752
|
-
_ds
|
|
6753
|
-
_ds.parentDataSourceNo &&
|
|
6754
|
-
Number(_ds.parentDataSourceNo) > 0 &&
|
|
6755
|
-
Number(_ds.parentDataSourceNo) < dsSessionP
|
|
6756
|
-
) {
|
|
6757
|
-
return await func.datasource.find_event_dataSource(
|
|
6758
|
-
SESSION_ID,
|
|
6759
|
-
eventIdP,
|
|
6760
|
-
_ds.parentDataSourceNo
|
|
6761
|
-
);
|
|
5940
|
+
if (_ds && _ds.parentDataSourceNo && Number(_ds.parentDataSourceNo) > 0 && Number(_ds.parentDataSourceNo) < dsSessionP) {
|
|
5941
|
+
return await func.datasource.find_event_dataSource(SESSION_ID, eventIdP, _ds.parentDataSourceNo);
|
|
6762
5942
|
} else {
|
|
6763
5943
|
//========================================
|
|
6764
5944
|
// continue Search in global system
|
|
6765
5945
|
//=========================================
|
|
6766
|
-
if (!ret)
|
|
6767
|
-
return await func.datasource.find_event_dataSource(
|
|
6768
|
-
SESSION_ID,
|
|
6769
|
-
eventIdP,
|
|
6770
|
-
0
|
|
6771
|
-
);
|
|
5946
|
+
if (!ret) return await func.datasource.find_event_dataSource(SESSION_ID, eventIdP, 0);
|
|
6772
5947
|
}
|
|
6773
5948
|
}
|
|
6774
5949
|
};
|
|
6775
5950
|
func.datasource.reset_jobs = function (SESSION_ID, dsSessionP, sourceP, errP) {
|
|
6776
|
-
for (const [key, val] of Object.entries(
|
|
6777
|
-
SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs
|
|
6778
|
-
)) {
|
|
5951
|
+
for (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs)) {
|
|
6779
5952
|
if (val.dsSessionP === dsSessionP) {
|
|
6780
5953
|
func.events.delete_job(SESSION_ID, val.job_num);
|
|
6781
5954
|
break;
|
|
6782
5955
|
}
|
|
6783
5956
|
}
|
|
6784
|
-
func.utils.debug_report(
|
|
6785
|
-
SESSION_ID,
|
|
6786
|
-
sourceP + "Missing datasource: " + dsSessionP,
|
|
6787
|
-
errP,
|
|
6788
|
-
"W",
|
|
6789
|
-
null
|
|
6790
|
-
);
|
|
5957
|
+
func.utils.debug_report(SESSION_ID, sourceP + 'Missing datasource: ' + dsSessionP, errP, 'W', null);
|
|
6791
5958
|
};
|
|
6792
5959
|
// func.datasource.set_system_vars = async function (SESSION_ID, dsSessionP) {
|
|
6793
5960
|
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
@@ -6831,13 +5998,9 @@ func.datasource.reset_jobs = function (SESSION_ID, dsSessionP, sourceP, errP) {
|
|
|
6831
5998
|
// _ds_0.data_system[val] = await func.utils.get_dateTime(SESSION_ID, val, ts);
|
|
6832
5999
|
// }
|
|
6833
6000
|
// };
|
|
6834
|
-
func.datasource.get_currentRecordId = function (
|
|
6835
|
-
SESSION_ID,
|
|
6836
|
-
dsSessionP,
|
|
6837
|
-
from_datasourceP
|
|
6838
|
-
) {
|
|
6001
|
+
func.datasource.get_currentRecordId = function (SESSION_ID, dsSessionP, from_datasourceP) {
|
|
6839
6002
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
6840
|
-
if (_ds._dataSourceTableId !==
|
|
6003
|
+
if (_ds._dataSourceTableId !== '') {
|
|
6841
6004
|
var firstRecordId = _ds.firstRecordId; // returns the value of the fist row
|
|
6842
6005
|
var currentRecordId = _ds.currentRecordId; // record id that exist on ds after entering the form
|
|
6843
6006
|
var locatedRecordId = _ds.locatedRecordId; // record id located by ds
|
|
@@ -6847,7 +6010,7 @@ func.datasource.get_currentRecordId = function (
|
|
|
6847
6010
|
// set first row when no rec located
|
|
6848
6011
|
else currentRecordId = locatedRecordId; // set with located row
|
|
6849
6012
|
}
|
|
6850
|
-
} else currentRecordId =
|
|
6013
|
+
} else currentRecordId = 'newRecord'; // create mode
|
|
6851
6014
|
return currentRecordId;
|
|
6852
6015
|
};
|
|
6853
6016
|
func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
@@ -6874,34 +6037,19 @@ func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
|
6874
6037
|
interval.push(
|
|
6875
6038
|
setInterval(async function () {
|
|
6876
6039
|
if (!SESSION_OBJ[SESSION_ID]) return;
|
|
6877
|
-
var event_count = await func.datasource.get_view_events_count(
|
|
6878
|
-
SESSION_ID,
|
|
6879
|
-
dsSessionP,
|
|
6880
|
-
typeP,
|
|
6881
|
-
event_id
|
|
6882
|
-
);
|
|
6040
|
+
var event_count = await func.datasource.get_view_events_count(SESSION_ID, dsSessionP, typeP, event_id);
|
|
6883
6041
|
if (!event_count) {
|
|
6884
6042
|
fx.clear();
|
|
6885
6043
|
return;
|
|
6886
6044
|
}
|
|
6887
|
-
var event_condition = await func.expression.get(
|
|
6888
|
-
SESSION_ID,
|
|
6889
|
-
condition,
|
|
6890
|
-
dsSessionP,
|
|
6891
|
-
"condition"
|
|
6892
|
-
); // execute condition;
|
|
6045
|
+
var event_condition = await func.expression.get(SESSION_ID, condition, dsSessionP, 'condition'); // execute condition;
|
|
6893
6046
|
if (condition && !event_condition.result) return;
|
|
6894
6047
|
|
|
6895
|
-
const e = await func.datasource.execute_view_events(
|
|
6896
|
-
SESSION_ID,
|
|
6897
|
-
dsSessionP,
|
|
6898
|
-
typeP,
|
|
6899
|
-
event_id
|
|
6900
|
-
);
|
|
6048
|
+
const e = await func.datasource.execute_view_events(SESSION_ID, dsSessionP, typeP, event_id);
|
|
6901
6049
|
// for (const [key, val] of Object.entries(e)) {
|
|
6902
6050
|
// val.done = false;
|
|
6903
6051
|
// }
|
|
6904
|
-
}, Number(interval_rate) * 1000)
|
|
6052
|
+
}, Number(interval_rate) * 1000),
|
|
6905
6053
|
);
|
|
6906
6054
|
}
|
|
6907
6055
|
} else {
|
|
@@ -6910,8 +6058,7 @@ func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
|
6910
6058
|
}
|
|
6911
6059
|
},
|
|
6912
6060
|
clear: function () {
|
|
6913
|
-
if (DATASOURCE_INTERVALS[session_id])
|
|
6914
|
-
delete DATASOURCE_INTERVALS[session_id][dsSessionP];
|
|
6061
|
+
if (DATASOURCE_INTERVALS[session_id]) delete DATASOURCE_INTERVALS[session_id][dsSessionP];
|
|
6915
6062
|
for (const [key, val] of Object.entries(interval)) {
|
|
6916
6063
|
clearInterval(val);
|
|
6917
6064
|
}
|
|
@@ -6924,12 +6071,8 @@ func.datasource.server_cron = function (session_id) {
|
|
|
6924
6071
|
var jobs = [];
|
|
6925
6072
|
// var ds = SESSION_OBJ[SESSION_ID].DS_GLB[0];
|
|
6926
6073
|
// var v = ds.v;
|
|
6927
|
-
var arr = func.datasource.get_event_interval_arr(
|
|
6928
|
-
|
|
6929
|
-
0,
|
|
6930
|
-
"server_cron"
|
|
6931
|
-
);
|
|
6932
|
-
const schedule = require("node-schedule");
|
|
6074
|
+
var arr = func.datasource.get_event_interval_arr(SESSION_ID, 0, 'server_cron');
|
|
6075
|
+
const schedule = require('node-schedule');
|
|
6933
6076
|
|
|
6934
6077
|
if (!arr.length) {
|
|
6935
6078
|
return jobs;
|
|
@@ -6942,75 +6085,43 @@ func.datasource.server_cron = function (session_id) {
|
|
|
6942
6085
|
jobs.push(
|
|
6943
6086
|
schedule.scheduleJob(cron_prop, async function () {
|
|
6944
6087
|
if (!SESSION_OBJ[SESSION_ID]) return;
|
|
6945
|
-
var event_count = await func.datasource.get_view_events_count(
|
|
6946
|
-
SESSION_ID,
|
|
6947
|
-
0,
|
|
6948
|
-
"server_cron",
|
|
6949
|
-
event_id
|
|
6950
|
-
);
|
|
6088
|
+
var event_count = await func.datasource.get_view_events_count(SESSION_ID, 0, 'server_cron', event_id);
|
|
6951
6089
|
if (!event_count) {
|
|
6952
6090
|
fx.clear();
|
|
6953
6091
|
return;
|
|
6954
6092
|
}
|
|
6955
|
-
var event_condition = await func.expression.get(
|
|
6956
|
-
SESSION_ID,
|
|
6957
|
-
condition,
|
|
6958
|
-
0,
|
|
6959
|
-
"condition"
|
|
6960
|
-
); // execute condition;
|
|
6093
|
+
var event_condition = await func.expression.get(SESSION_ID, condition, 0, 'condition'); // execute condition;
|
|
6961
6094
|
if (condition && !event_condition.result) return;
|
|
6962
6095
|
if (event_count) {
|
|
6963
|
-
const e = await func.datasource.execute_view_events(
|
|
6964
|
-
SESSION_ID,
|
|
6965
|
-
0,
|
|
6966
|
-
"server_cron",
|
|
6967
|
-
event_id
|
|
6968
|
-
);
|
|
6096
|
+
const e = await func.datasource.execute_view_events(SESSION_ID, 0, 'server_cron', event_id);
|
|
6969
6097
|
// for (const [key, val] of Object.entries(e)) {
|
|
6970
6098
|
// val.done = false;
|
|
6971
6099
|
// }
|
|
6972
6100
|
}
|
|
6973
|
-
})
|
|
6101
|
+
}),
|
|
6974
6102
|
);
|
|
6975
6103
|
}
|
|
6976
6104
|
|
|
6977
6105
|
return jobs;
|
|
6978
6106
|
};
|
|
6979
|
-
func.datasource.get_viewLoops = async function (
|
|
6980
|
-
SESSION_ID,
|
|
6981
|
-
dataSourceSession,
|
|
6982
|
-
data,
|
|
6983
|
-
batch_source,
|
|
6984
|
-
default_limit
|
|
6985
|
-
) {
|
|
6107
|
+
func.datasource.get_viewLoops = async function (SESSION_ID, dataSourceSession, data, batch_source, default_limit) {
|
|
6986
6108
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
6987
6109
|
var args = _ds.args;
|
|
6988
6110
|
// var v = _ds.v;
|
|
6989
6111
|
var ret = default_limit;
|
|
6990
6112
|
|
|
6991
|
-
if (batch_source ===
|
|
6992
|
-
if (batch_source ===
|
|
6993
|
-
if (batch_source ===
|
|
6113
|
+
if (batch_source === 'db_data') ret = _.size(data.rows);
|
|
6114
|
+
if (batch_source === 'array' || batch_source === 'csv') ret = data.length;
|
|
6115
|
+
if (batch_source === 'json') ret = Object.keys(data).length;
|
|
6994
6116
|
if (_ds.progDataSource?.dataSourceLimit) {
|
|
6995
|
-
if (
|
|
6996
|
-
batch_source !== "no_data" &&
|
|
6997
|
-
Number(_ds.progDataSource?.dataSourceLimit) < ret
|
|
6998
|
-
) {
|
|
6117
|
+
if (batch_source !== 'no_data' && Number(_ds.progDataSource?.dataSourceLimit) < ret) {
|
|
6999
6118
|
ret = Number(_ds.progDataSource.dataSourceLimit);
|
|
7000
6119
|
}
|
|
7001
6120
|
if (!batch_source) ret = Number(_ds.progDataSource.dataSourceLimit);
|
|
7002
6121
|
}
|
|
7003
6122
|
if (prog_obj.progDataSource?.dataSourceLoopExp) {
|
|
7004
|
-
var n = (
|
|
7005
|
-
|
|
7006
|
-
SESSION_ID,
|
|
7007
|
-
_ds.v.viewLoopsExp,
|
|
7008
|
-
dataSourceSession,
|
|
7009
|
-
"view_loop",
|
|
7010
|
-
args.rowIdP
|
|
7011
|
-
)
|
|
7012
|
-
).result;
|
|
7013
|
-
if (batch_source !== "no_data" && n < ret) ret = n;
|
|
6123
|
+
var n = (await func.expression.get(SESSION_ID, _ds.v.viewLoopsExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
6124
|
+
if (batch_source !== 'no_data' && n < ret) ret = n;
|
|
7014
6125
|
if (!batch_source) ret = n;
|
|
7015
6126
|
}
|
|
7016
6127
|
return ret;
|
|
@@ -7022,13 +6133,11 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
7022
6133
|
segTo: [],
|
|
7023
6134
|
segLocateFrom: [],
|
|
7024
6135
|
segLocateTo: [],
|
|
7025
|
-
viewModule:
|
|
6136
|
+
viewModule: 'adapter',
|
|
7026
6137
|
};
|
|
7027
6138
|
_ds.viewEventExec_arr = {};
|
|
7028
6139
|
|
|
7029
|
-
var view = _.cloneDeep(
|
|
7030
|
-
await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id)
|
|
7031
|
-
);
|
|
6140
|
+
var view = _.cloneDeep(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
|
|
7032
6141
|
|
|
7033
6142
|
_ds.v.dataSourceSrcType = view.dataSourceSrcType;
|
|
7034
6143
|
|
|
@@ -7044,7 +6153,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
7044
6153
|
}
|
|
7045
6154
|
|
|
7046
6155
|
if (glb.FUNCTION_NODES_ARR.includes(tree_ret.menuType)) {
|
|
7047
|
-
_ds.v.viewModule =
|
|
6156
|
+
_ds.v.viewModule = 'function';
|
|
7048
6157
|
}
|
|
7049
6158
|
_ds.v.viewSourceProp = tree_ret.menuType;
|
|
7050
6159
|
if (view.progEvents) _ds.v.progEvents = view.progEvents;
|
|
@@ -7058,15 +6167,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
7058
6167
|
}
|
|
7059
6168
|
};
|
|
7060
6169
|
|
|
7061
|
-
func.datasource.get_cast_val = async function (
|
|
7062
|
-
SESSION_ID,
|
|
7063
|
-
source,
|
|
7064
|
-
dsSession,
|
|
7065
|
-
valP,
|
|
7066
|
-
typeP,
|
|
7067
|
-
req,
|
|
7068
|
-
error
|
|
7069
|
-
) {
|
|
6170
|
+
func.datasource.get_cast_val = async function (SESSION_ID, source, dsSession, valP, typeP, req, error) {
|
|
7070
6171
|
var prog_id, prog_name;
|
|
7071
6172
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
7072
6173
|
var _ds = _session.DS_GLB[dsSession];
|
|
@@ -7074,73 +6175,39 @@ func.datasource.get_cast_val = async function (
|
|
|
7074
6175
|
prog_id = _ds.prog_id;
|
|
7075
6176
|
prog_name = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id).menuName;
|
|
7076
6177
|
|
|
7077
|
-
const prog_info = prog_id ? ` (prog: ${prog_id} ${prog_name})` :
|
|
6178
|
+
const prog_info = prog_id ? ` (prog: ${prog_id} ${prog_name})` : '';
|
|
7078
6179
|
|
|
7079
6180
|
const report_conversion_error = function (res) {
|
|
7080
6181
|
var msg = `error converting from ${valP} to ${typeP}`;
|
|
7081
6182
|
if (error) {
|
|
7082
|
-
return func.utils.debug_report(SESSION_ID, msg,
|
|
6183
|
+
return func.utils.debug_report(SESSION_ID, msg, '', 'W');
|
|
7083
6184
|
}
|
|
7084
|
-
func.utils.debug_report(
|
|
7085
|
-
SESSION_ID,
|
|
7086
|
-
msg + " " + _.capitalize(source) + prog_info,
|
|
7087
|
-
"",
|
|
7088
|
-
"E"
|
|
7089
|
-
);
|
|
6185
|
+
func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'E');
|
|
7090
6186
|
};
|
|
7091
6187
|
const report_conversion_warn = function (res) {
|
|
7092
6188
|
var msg = `type mismatch auto conversion from value ${valP} to ${typeP}`;
|
|
7093
|
-
func.utils.debug_report(
|
|
7094
|
-
SESSION_ID,
|
|
7095
|
-
msg + " " + _.capitalize(source) + prog_info,
|
|
7096
|
-
"",
|
|
7097
|
-
"W"
|
|
7098
|
-
);
|
|
6189
|
+
func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'W');
|
|
7099
6190
|
};
|
|
7100
6191
|
// var ret = valP;
|
|
7101
6192
|
if (error) {
|
|
7102
6193
|
return report_conversion_error();
|
|
7103
6194
|
}
|
|
7104
6195
|
|
|
7105
|
-
const module = await func.common.get_module(
|
|
7106
|
-
|
|
7107
|
-
"xuda-get-cast-util-module.mjs"
|
|
7108
|
-
);
|
|
7109
|
-
return module.cast(
|
|
7110
|
-
typeP,
|
|
7111
|
-
valP,
|
|
7112
|
-
report_conversion_error,
|
|
7113
|
-
report_conversion_warn
|
|
7114
|
-
);
|
|
6196
|
+
const module = await func.common.get_module(SESSION_ID, 'xuda-get-cast-util-module.mjs');
|
|
6197
|
+
return module.cast(typeP, valP, report_conversion_error, report_conversion_warn);
|
|
7115
6198
|
};
|
|
7116
|
-
func.datasource.get_field_init_triggers_to_run = function (
|
|
7117
|
-
SESSION_ID,
|
|
7118
|
-
dataSourceSession,
|
|
7119
|
-
pre_init_fieldsP
|
|
7120
|
-
) {
|
|
6199
|
+
func.datasource.get_field_init_triggers_to_run = function (SESSION_ID, dataSourceSession, pre_init_fieldsP) {
|
|
7121
6200
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
7122
6201
|
if (!_ds) return;
|
|
7123
6202
|
|
|
7124
6203
|
return []; // inactive 021617
|
|
7125
6204
|
}; // inactive temporary, design to execute init triggers when querying large datasets
|
|
7126
|
-
func.datasource.get_pre_init_fields = function (
|
|
7127
|
-
SESSION_ID,
|
|
7128
|
-
dsSessionP,
|
|
7129
|
-
viewRangeExpP,
|
|
7130
|
-
viewSortExpP,
|
|
7131
|
-
viewGroupByExpP,
|
|
7132
|
-
viewLocateExpP
|
|
7133
|
-
) {
|
|
6205
|
+
func.datasource.get_pre_init_fields = function (SESSION_ID, dsSessionP, viewRangeExpP, viewSortExpP, viewGroupByExpP, viewLocateExpP) {
|
|
7134
6206
|
var ret = [];
|
|
7135
6207
|
return; // inactive 021617
|
|
7136
6208
|
}; // temporary inactive, init preformed on the first round
|
|
7137
6209
|
|
|
7138
|
-
func.datasource.add_dynamic_field_to_ds = function (
|
|
7139
|
-
SESSION_ID,
|
|
7140
|
-
dsSessionP,
|
|
7141
|
-
key,
|
|
7142
|
-
val
|
|
7143
|
-
) {
|
|
6210
|
+
func.datasource.add_dynamic_field_to_ds = function (SESSION_ID, dsSessionP, key, val) {
|
|
7144
6211
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
7145
6212
|
if (!_ds.dynamic_fields) {
|
|
7146
6213
|
_ds.dynamic_fields = {};
|
|
@@ -7156,11 +6223,11 @@ func.datasource.add_dynamic_field_to_ds = function (
|
|
|
7156
6223
|
_ds.dynamic_fields[key] = {
|
|
7157
6224
|
id: crypto.randomUUID(),
|
|
7158
6225
|
data: {
|
|
7159
|
-
type:
|
|
6226
|
+
type: 'virtual',
|
|
7160
6227
|
field_id: key,
|
|
7161
6228
|
},
|
|
7162
6229
|
props: {
|
|
7163
|
-
fieldType: typeof
|
|
6230
|
+
fieldType: typeof val !== 'undefined' ? toType(val) : 'string',
|
|
7164
6231
|
},
|
|
7165
6232
|
value: val,
|
|
7166
6233
|
};
|
|
@@ -7171,11 +6238,7 @@ func.datasource.get_progFields = async function (SESSION_ID, dsSessionP) {
|
|
|
7171
6238
|
const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
7172
6239
|
return _view_obj.progFields;
|
|
7173
6240
|
};
|
|
7174
|
-
func.datasource.update_changes_for_out_parameter = async function (
|
|
7175
|
-
SESSION_ID,
|
|
7176
|
-
dsSessionP,
|
|
7177
|
-
calling_dsP
|
|
7178
|
-
) {
|
|
6241
|
+
func.datasource.update_changes_for_out_parameter = async function (SESSION_ID, dsSessionP, calling_dsP) {
|
|
7179
6242
|
let _session = SESSION_OBJ[SESSION_ID];
|
|
7180
6243
|
let _ds = _session.DS_GLB[dsSessionP];
|
|
7181
6244
|
const _calling_ds = _session.DS_GLB[calling_dsP];
|
|
@@ -7183,7 +6246,7 @@ func.datasource.update_changes_for_out_parameter = async function (
|
|
|
7183
6246
|
if (_ds.PARAM_OUT_INFO) {
|
|
7184
6247
|
let data = {};
|
|
7185
6248
|
for await (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
7186
|
-
if (val.prop ===
|
|
6249
|
+
if (val.prop === 'out') {
|
|
7187
6250
|
try {
|
|
7188
6251
|
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
7189
6252
|
data[val.details] = _ds.data_feed.rows[row_idx][val.fieldId];
|
|
@@ -7205,50 +6268,31 @@ func.datasource.set_outputField = async function (SESSION_ID, dsSessionP, result
|
|
|
7205
6268
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
7206
6269
|
// let _ds = _session.DS_GLB[dsSessionP];
|
|
7207
6270
|
|
|
7208
|
-
|
|
7209
|
-
const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSessionP, args, "outputField")
|
|
7210
|
-
|
|
6271
|
+
const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSessionP, args, 'outputField');
|
|
7211
6272
|
|
|
7212
6273
|
if (output_field) {
|
|
7213
6274
|
let datasource_changes = {};
|
|
7214
6275
|
|
|
7215
|
-
let ret_get_value = await func.datasource.get_value(
|
|
7216
|
-
SESSION_ID,
|
|
7217
|
-
output_field,
|
|
7218
|
-
dsSessionP
|
|
7219
|
-
);
|
|
6276
|
+
let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
|
|
7220
6277
|
if (ret_get_value.found) {
|
|
7221
6278
|
let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
|
|
7222
6279
|
if (!datasource_changes[_ds.dsSession]) {
|
|
7223
6280
|
datasource_changes[_ds.dsSession] = {};
|
|
7224
6281
|
}
|
|
7225
|
-
if (
|
|
7226
|
-
|
|
7227
|
-
) {
|
|
7228
|
-
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
|
|
7229
|
-
{};
|
|
6282
|
+
if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
|
|
6283
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
|
|
7230
6284
|
}
|
|
7231
|
-
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
|
|
7232
|
-
output_field
|
|
7233
|
-
] = result;
|
|
6285
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = result;
|
|
7234
6286
|
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
7235
6287
|
}
|
|
7236
6288
|
}
|
|
7237
|
-
|
|
7238
|
-
}
|
|
6289
|
+
};
|
|
7239
6290
|
|
|
7240
6291
|
func.datasource.get_args_property_value = async function (SESSION_ID, dsSession, args, prop_name) {
|
|
7241
6292
|
let _prop = args?.calling_trigger_prop?.data?.name;
|
|
7242
6293
|
let _value = _prop[prop_name];
|
|
7243
6294
|
if (_prop?.[`xu-exp:${prop_name}`]) {
|
|
7244
|
-
_value = (
|
|
7245
|
-
await func.expression.get(
|
|
7246
|
-
SESSION_ID,
|
|
7247
|
-
_prop[`xu-exp:${prop_name}`],
|
|
7248
|
-
dsSession,
|
|
7249
|
-
`${prop_name} expression`
|
|
7250
|
-
)
|
|
7251
|
-
).result;
|
|
6295
|
+
_value = (await func.expression.get(SESSION_ID, _prop[`xu-exp:${prop_name}`], dsSession, `${prop_name} expression`)).result;
|
|
7252
6296
|
}
|
|
7253
6297
|
|
|
7254
6298
|
return _value;
|