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