@xuda.io/xuda-worker-bundle-min 1.3.816 → 1.3.818
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/index.js +800 -194
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,9 +25,9 @@ glb.PROTECTED_VARS = [
|
|
|
25
25
|
"_THIS",
|
|
26
26
|
"_FOR_KEY",
|
|
27
27
|
"_FOR_VAL",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
28
|
+
"_ROWNO",
|
|
29
|
+
"_ROWID",
|
|
30
|
+
"_ROWDOC",
|
|
31
31
|
"_KEY",
|
|
32
32
|
"_VAL",
|
|
33
33
|
];
|
|
@@ -43,7 +43,22 @@ func.common.find_item_by_key_root = function (arr, key, val) {
|
|
|
43
43
|
return e[key] === val;
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
+
func.common.find_ROWID_idx = function (_ds, rowId) {
|
|
47
|
+
if (!_ds?.data_feed?.rows) {
|
|
48
|
+
throw new Error("data_feed not found");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Find the index of the object with the given _ROWID
|
|
52
|
+
const index = _ds.data_feed.rows.findIndex((item) => item._ROWID === rowId);
|
|
53
|
+
|
|
54
|
+
// If the index is -1, the ROWID was not found, so throw an error
|
|
55
|
+
if (index === -1) {
|
|
56
|
+
throw new Error(`ROWID "${rowId}" not found`);
|
|
57
|
+
}
|
|
46
58
|
|
|
59
|
+
// Return the found index
|
|
60
|
+
return index;
|
|
61
|
+
};
|
|
47
62
|
func.common.input_mask = async function (
|
|
48
63
|
actionP,
|
|
49
64
|
valP,
|
|
@@ -1930,7 +1945,7 @@ func.datasource.prepare = async function (
|
|
|
1930
1945
|
|
|
1931
1946
|
delete _ds.v.old_dataSource; // to eliminate parse error
|
|
1932
1947
|
delete _ds.rows_found;
|
|
1933
|
-
_ds.raw_data = {};
|
|
1948
|
+
// _ds.raw_data = {};
|
|
1934
1949
|
_ds.data_feed = {};
|
|
1935
1950
|
|
|
1936
1951
|
_ds.v.old_dataSource = _.cloneDeep(_ds);
|
|
@@ -2137,10 +2152,15 @@ func.datasource.execute = async function (
|
|
|
2137
2152
|
return false;
|
|
2138
2153
|
}
|
|
2139
2154
|
_ds.v.batch_loops =
|
|
2140
|
-
(await get_limit()) <= _ds.
|
|
2155
|
+
(await get_limit()) <= _ds.data_feed?.rows?.length
|
|
2141
2156
|
? await get_limit()
|
|
2142
|
-
: _ds
|
|
2157
|
+
: _ds?.data_feed?.rows?.length;
|
|
2143
2158
|
return true;
|
|
2159
|
+
// _ds.v.batch_loops =
|
|
2160
|
+
// (await get_limit()) <= _ds.v?.raw_data?.rows?.length
|
|
2161
|
+
// ? await get_limit()
|
|
2162
|
+
// : _ds.v?.raw_data?.rows?.length;
|
|
2163
|
+
// return true;
|
|
2144
2164
|
};
|
|
2145
2165
|
|
|
2146
2166
|
const render_api_output = async function () {
|
|
@@ -2314,7 +2334,8 @@ func.datasource.execute = async function (
|
|
|
2314
2334
|
filterModelUserMongo: _ds.progDataSource.filterModelUserMongo,
|
|
2315
2335
|
filterModelUserSql: _ds.progDataSource.filterModelUserSql,
|
|
2316
2336
|
};
|
|
2317
|
-
|
|
2337
|
+
|
|
2338
|
+
_ds.data_feed = await func.db.get_query(
|
|
2318
2339
|
SESSION_ID,
|
|
2319
2340
|
_ds._dataSourceTableId,
|
|
2320
2341
|
_ds.v.couchView,
|
|
@@ -2331,6 +2352,23 @@ func.datasource.execute = async function (
|
|
|
2331
2352
|
filterModel
|
|
2332
2353
|
);
|
|
2333
2354
|
|
|
2355
|
+
// _ds.v.raw_data = await func.db.get_query(
|
|
2356
|
+
// SESSION_ID,
|
|
2357
|
+
// _ds._dataSourceTableId,
|
|
2358
|
+
// _ds.v.couchView,
|
|
2359
|
+
// dataSourceSession,
|
|
2360
|
+
// _ds.viewSourceDesc,
|
|
2361
|
+
// "datasource table",
|
|
2362
|
+
// prog_obj.progDataSource.dataSourceReduce,
|
|
2363
|
+
// await get_skip(),
|
|
2364
|
+
// (await get_limit()) || 99999999,
|
|
2365
|
+
// null,
|
|
2366
|
+
// null,
|
|
2367
|
+
// _ds?.progDataSource?.sortModel,
|
|
2368
|
+
// null,
|
|
2369
|
+
// filterModel
|
|
2370
|
+
// );
|
|
2371
|
+
|
|
2334
2372
|
const ret_rows_found = await func.db.get_query(
|
|
2335
2373
|
SESSION_ID,
|
|
2336
2374
|
_ds._dataSourceTableId,
|
|
@@ -2358,14 +2396,19 @@ func.datasource.execute = async function (
|
|
|
2358
2396
|
data = [];
|
|
2359
2397
|
}
|
|
2360
2398
|
|
|
2361
|
-
if (!_ds.v.raw_data) {
|
|
2362
|
-
_ds.v.raw_data = { rows: [] };
|
|
2363
|
-
}
|
|
2364
2399
|
let _KEY = 0;
|
|
2365
2400
|
for (const _VAL of data) {
|
|
2366
|
-
_ds.
|
|
2401
|
+
_ds.data_feed.rows[_KEY] = { _KEY, _VAL };
|
|
2367
2402
|
_KEY++;
|
|
2368
2403
|
}
|
|
2404
|
+
// if (!_ds.v.raw_data) {
|
|
2405
|
+
// _ds.v.raw_data = { rows: [] };
|
|
2406
|
+
// }
|
|
2407
|
+
// let _KEY = 0;
|
|
2408
|
+
// for (const _VAL of data) {
|
|
2409
|
+
// _ds.v.raw_data.rows[_KEY] = { id: _KEY, value: { _KEY, _VAL } };
|
|
2410
|
+
// _KEY++;
|
|
2411
|
+
// }
|
|
2369
2412
|
break;
|
|
2370
2413
|
}
|
|
2371
2414
|
|
|
@@ -2375,13 +2418,16 @@ func.datasource.execute = async function (
|
|
|
2375
2418
|
data = {};
|
|
2376
2419
|
}
|
|
2377
2420
|
|
|
2378
|
-
if (!_ds.v.raw_data) {
|
|
2379
|
-
_ds.v.raw_data = { rows: [] };
|
|
2380
|
-
}
|
|
2381
|
-
|
|
2382
2421
|
for (let [_KEY, _VAL] of Object.keys(data)) {
|
|
2383
|
-
_ds.
|
|
2422
|
+
_ds.data_feed.rows[_KEY] = { _KEY, _VAL };
|
|
2384
2423
|
}
|
|
2424
|
+
// if (!_ds.v.raw_data) {
|
|
2425
|
+
// _ds.v.raw_data = { rows: [] };
|
|
2426
|
+
// }
|
|
2427
|
+
|
|
2428
|
+
// for (let [_KEY, _VAL] of Object.keys(data)) {
|
|
2429
|
+
// _ds.v.raw_data.rows[_KEY] = { id: _KEY, value: { _KEY, _VAL } };
|
|
2430
|
+
// }
|
|
2385
2431
|
|
|
2386
2432
|
break;
|
|
2387
2433
|
}
|
|
@@ -2399,9 +2445,19 @@ func.datasource.execute = async function (
|
|
|
2399
2445
|
let _KEY = 0;
|
|
2400
2446
|
let arr = data.split(",");
|
|
2401
2447
|
for (const _VAL of arr) {
|
|
2402
|
-
_ds.
|
|
2448
|
+
_ds.data_feed.rows[_KEY] = { _KEY, _VAL };
|
|
2403
2449
|
_KEY++;
|
|
2404
2450
|
}
|
|
2451
|
+
// if (!_ds.v.raw_data) {
|
|
2452
|
+
// _ds.v.raw_data = { rows: [] };
|
|
2453
|
+
// }
|
|
2454
|
+
|
|
2455
|
+
// let _KEY = 0;
|
|
2456
|
+
// let arr = data.split(",");
|
|
2457
|
+
// for (const _VAL of arr) {
|
|
2458
|
+
// _ds.v.raw_data.rows[_KEY] = { id: _KEY, value: { _KEY, _VAL } };
|
|
2459
|
+
// _KEY++;
|
|
2460
|
+
// }
|
|
2405
2461
|
|
|
2406
2462
|
break;
|
|
2407
2463
|
|
|
@@ -2435,10 +2491,10 @@ func.datasource.execute = async function (
|
|
|
2435
2491
|
_ds.api_rendered_output = "";
|
|
2436
2492
|
let has_datasource = await calc_batch_loops();
|
|
2437
2493
|
|
|
2438
|
-
data_arr = _ds.
|
|
2494
|
+
data_arr = _ds.data_feed.rows || [];
|
|
2439
2495
|
if (!has_datasource) {
|
|
2440
2496
|
for (n = 0; n < _ds.v.batch_loops; n++) {
|
|
2441
|
-
data_arr.push({});
|
|
2497
|
+
data_arr.push({ _ROWID: n });
|
|
2442
2498
|
}
|
|
2443
2499
|
}
|
|
2444
2500
|
_ds.currentRecordId = "dataset";
|
|
@@ -2446,9 +2502,7 @@ func.datasource.execute = async function (
|
|
|
2446
2502
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
2447
2503
|
|
|
2448
2504
|
if (!has_datasource) {
|
|
2449
|
-
val
|
|
2450
|
-
value: {},
|
|
2451
|
-
};
|
|
2505
|
+
val = _ds?.data_feed?.rows?.[key] || { _ROWID: key };
|
|
2452
2506
|
}
|
|
2453
2507
|
|
|
2454
2508
|
if (await get_before_record_count()) {
|
|
@@ -2494,10 +2548,10 @@ func.datasource.execute = async function (
|
|
|
2494
2548
|
case "batch": {
|
|
2495
2549
|
let has_datasource = await calc_batch_loops();
|
|
2496
2550
|
|
|
2497
|
-
data_arr = _ds
|
|
2551
|
+
data_arr = _ds?.data_feed?.rows || [];
|
|
2498
2552
|
if (!has_datasource) {
|
|
2499
2553
|
for (n = 0; n < _ds.v.batch_loops; n++) {
|
|
2500
|
-
data_arr.push({});
|
|
2554
|
+
data_arr.push({ _ROWID: n });
|
|
2501
2555
|
}
|
|
2502
2556
|
}
|
|
2503
2557
|
_ds.currentRecordId = "dataset";
|
|
@@ -2505,9 +2559,7 @@ func.datasource.execute = async function (
|
|
|
2505
2559
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
2506
2560
|
|
|
2507
2561
|
if (!has_datasource) {
|
|
2508
|
-
val.value = _ds?.data_feed?.rows?.[
|
|
2509
|
-
value: {},
|
|
2510
|
-
};
|
|
2562
|
+
val.value = _ds?.data_feed?.rows?.[key] || { _ROWID: key };
|
|
2511
2563
|
}
|
|
2512
2564
|
|
|
2513
2565
|
if (await get_before_record_count()) {
|
|
@@ -2579,27 +2631,28 @@ func.datasource.execute = async function (
|
|
|
2579
2631
|
|
|
2580
2632
|
if (tree_obj.crudMode === "U") {
|
|
2581
2633
|
_ds.set_mode = "U";
|
|
2582
|
-
data_arr = _ds
|
|
2634
|
+
data_arr = _ds?.data_feed?.rows || [];
|
|
2583
2635
|
}
|
|
2584
2636
|
|
|
2585
2637
|
if (tree_obj.crudMode === "D") {
|
|
2586
2638
|
_ds.set_mode = "D";
|
|
2587
|
-
data_arr = _ds.
|
|
2639
|
+
data_arr = _ds.data_feed?.rows || [];
|
|
2588
2640
|
}
|
|
2589
2641
|
|
|
2642
|
+
const newRecord = 999999;
|
|
2590
2643
|
// initiated with Update but no rows found
|
|
2591
2644
|
if (
|
|
2592
2645
|
tree_obj.crudMode === "U" &&
|
|
2593
2646
|
tree_obj.allowCreate &&
|
|
2594
|
-
!_ds
|
|
2647
|
+
!_ds?.data_feed?.rows?.length
|
|
2595
2648
|
) {
|
|
2596
2649
|
_ds.set_mode = "C";
|
|
2597
|
-
data_arr = [{
|
|
2650
|
+
data_arr = [{ _ROWID: newRecord }];
|
|
2598
2651
|
}
|
|
2599
2652
|
|
|
2600
2653
|
if (tree_obj.crudMode === "C") {
|
|
2601
2654
|
_ds.set_mode = "C";
|
|
2602
|
-
data_arr = [{
|
|
2655
|
+
data_arr = [{ _ROWID: newRecord }];
|
|
2603
2656
|
}
|
|
2604
2657
|
|
|
2605
2658
|
for await (let val of data_arr) {
|
|
@@ -2663,14 +2716,16 @@ func.datasource.execute = async function (
|
|
|
2663
2716
|
_ds.set_mode = "C";
|
|
2664
2717
|
_ds.record_not_found = true;
|
|
2665
2718
|
|
|
2666
|
-
|
|
2719
|
+
const newRecord = 999999;
|
|
2720
|
+
|
|
2721
|
+
if (_.isEmpty(_ds.data_feed.rows[newRecord])) {
|
|
2667
2722
|
await func.datasource.render_fields_form(
|
|
2668
2723
|
SESSION_ID,
|
|
2669
2724
|
dataSourceSession,
|
|
2670
|
-
{ id: "newRecord", value: {} },
|
|
2671
|
-
null,
|
|
2672
|
-
false,
|
|
2673
|
-
"newRecord"
|
|
2725
|
+
{ _ROWID: newRecord } // { id: "newRecord", value: {} },
|
|
2726
|
+
// null,
|
|
2727
|
+
// false,
|
|
2728
|
+
// "newRecord"
|
|
2674
2729
|
);
|
|
2675
2730
|
}
|
|
2676
2731
|
var count = await func.datasource.get_field_init_count(
|
|
@@ -2700,14 +2755,25 @@ func.datasource.execute = async function (
|
|
|
2700
2755
|
|
|
2701
2756
|
const finish_form = async function () {
|
|
2702
2757
|
// check if locatedRecordId exist in SESSION_OBJ[SESSION_ID].DS_GLB
|
|
2703
|
-
if (
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2758
|
+
if (_ds.locatedRecordId) {
|
|
2759
|
+
try {
|
|
2760
|
+
const row_idx = func.common.find_ROWID_idx(
|
|
2761
|
+
_ds,
|
|
2762
|
+
_ds.locatedRecordId
|
|
2763
|
+
);
|
|
2764
|
+
} catch (error) {
|
|
2765
|
+
delete _ds.locatedRecordId;
|
|
2766
|
+
}
|
|
2708
2767
|
}
|
|
2709
2768
|
|
|
2710
|
-
|
|
2769
|
+
// if (
|
|
2770
|
+
// _ds.locatedRecordId &&
|
|
2771
|
+
// typeof _ds.data_feed.rows[row_idx] === "undefined"
|
|
2772
|
+
// ) {
|
|
2773
|
+
// delete _ds.locatedRecordId;
|
|
2774
|
+
// }
|
|
2775
|
+
|
|
2776
|
+
// db_adapter_module.sort_data(SESSION_ID, dataSourceSession, "form");
|
|
2711
2777
|
|
|
2712
2778
|
_ds.finalRecordId = func.datasource.get_currentRecordId(
|
|
2713
2779
|
SESSION_ID,
|
|
@@ -2731,7 +2797,7 @@ func.datasource.execute = async function (
|
|
|
2731
2797
|
// return await callback_datasource();
|
|
2732
2798
|
};
|
|
2733
2799
|
|
|
2734
|
-
for await (const [key, val] of Object.entries(_ds.
|
|
2800
|
+
for await (const [key, val] of Object.entries(_ds.data_feed.rows)) {
|
|
2735
2801
|
if (await get_before_record_count()) {
|
|
2736
2802
|
await func.datasource.execute_view_events(
|
|
2737
2803
|
SESSION_ID,
|
|
@@ -2772,6 +2838,361 @@ func.datasource.execute = async function (
|
|
|
2772
2838
|
"E"
|
|
2773
2839
|
);
|
|
2774
2840
|
}
|
|
2841
|
+
// switch (tree_obj.menuType) {
|
|
2842
|
+
// case "api": {
|
|
2843
|
+
// _ds.api_rendered_output = "";
|
|
2844
|
+
// let has_datasource = await calc_batch_loops();
|
|
2845
|
+
|
|
2846
|
+
// data_arr = _ds.v?.raw_data?.rows || [];
|
|
2847
|
+
// if (!has_datasource) {
|
|
2848
|
+
// for (n = 0; n < _ds.v.batch_loops; n++) {
|
|
2849
|
+
// data_arr.push({});
|
|
2850
|
+
// }
|
|
2851
|
+
// }
|
|
2852
|
+
// _ds.currentRecordId = "dataset";
|
|
2853
|
+
// for await (let [key, val] of Object.entries(data_arr)) {
|
|
2854
|
+
// if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
2855
|
+
|
|
2856
|
+
// if (!has_datasource) {
|
|
2857
|
+
// val.value = _ds?.data_feed?.rows?.[_ds.currentRecordId] || {
|
|
2858
|
+
// value: {},
|
|
2859
|
+
// };
|
|
2860
|
+
// }
|
|
2861
|
+
|
|
2862
|
+
// if (await get_before_record_count()) {
|
|
2863
|
+
// await func.datasource.execute_view_events(
|
|
2864
|
+
// SESSION_ID,
|
|
2865
|
+
// dataSourceSession,
|
|
2866
|
+
// "before_record"
|
|
2867
|
+
// );
|
|
2868
|
+
// }
|
|
2869
|
+
|
|
2870
|
+
// await func.datasource.render_fields_dataset(
|
|
2871
|
+
// SESSION_ID,
|
|
2872
|
+
// dataSourceSession,
|
|
2873
|
+
// val
|
|
2874
|
+
// );
|
|
2875
|
+
|
|
2876
|
+
// if (await get_after_record_count()) {
|
|
2877
|
+
// await func.datasource.execute_view_events(
|
|
2878
|
+
// SESSION_ID,
|
|
2879
|
+
// dataSourceSession,
|
|
2880
|
+
// "after_record"
|
|
2881
|
+
// );
|
|
2882
|
+
// }
|
|
2883
|
+
|
|
2884
|
+
// await render_api_output();
|
|
2885
|
+
// }
|
|
2886
|
+
|
|
2887
|
+
// if (tree_obj.apiOutput === "json") {
|
|
2888
|
+
// var str = _ds.api_rendered_output.substring(
|
|
2889
|
+
// 0,
|
|
2890
|
+
// _ds.api_rendered_output.length - 1
|
|
2891
|
+
// );
|
|
2892
|
+
// if (Number(_ds.progDataSource?.dataSourceLimit) === 1) {
|
|
2893
|
+
// _ds.api_rendered_output = str;
|
|
2894
|
+
// } else {
|
|
2895
|
+
// _ds.api_rendered_output = "[" + str + "]";
|
|
2896
|
+
// }
|
|
2897
|
+
// }
|
|
2898
|
+
|
|
2899
|
+
// break;
|
|
2900
|
+
// }
|
|
2901
|
+
|
|
2902
|
+
// case "batch": {
|
|
2903
|
+
// let has_datasource = await calc_batch_loops();
|
|
2904
|
+
|
|
2905
|
+
// data_arr = _ds.v?.raw_data?.rows || [];
|
|
2906
|
+
// if (!has_datasource) {
|
|
2907
|
+
// for (n = 0; n < _ds.v.batch_loops; n++) {
|
|
2908
|
+
// data_arr.push({});
|
|
2909
|
+
// }
|
|
2910
|
+
// }
|
|
2911
|
+
// _ds.currentRecordId = "dataset";
|
|
2912
|
+
// for await (let [key, val] of Object.entries(data_arr)) {
|
|
2913
|
+
// if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
2914
|
+
|
|
2915
|
+
// if (!has_datasource) {
|
|
2916
|
+
// val.value = _ds?.data_feed?.rows?.[_ds.currentRecordId] || {
|
|
2917
|
+
// value: {},
|
|
2918
|
+
// };
|
|
2919
|
+
// }
|
|
2920
|
+
|
|
2921
|
+
// if (await get_before_record_count()) {
|
|
2922
|
+
// await func.datasource.execute_view_events(
|
|
2923
|
+
// SESSION_ID,
|
|
2924
|
+
// dataSourceSession,
|
|
2925
|
+
// "before_record"
|
|
2926
|
+
// );
|
|
2927
|
+
// }
|
|
2928
|
+
|
|
2929
|
+
// await func.datasource.render_fields_dataset(
|
|
2930
|
+
// SESSION_ID,
|
|
2931
|
+
// dataSourceSession,
|
|
2932
|
+
// val
|
|
2933
|
+
// );
|
|
2934
|
+
|
|
2935
|
+
// if (await get_after_record_count()) {
|
|
2936
|
+
// await func.datasource.execute_view_events(
|
|
2937
|
+
// SESSION_ID,
|
|
2938
|
+
// dataSourceSession,
|
|
2939
|
+
// "after_record"
|
|
2940
|
+
// );
|
|
2941
|
+
// }
|
|
2942
|
+
// }
|
|
2943
|
+
|
|
2944
|
+
// break;
|
|
2945
|
+
// }
|
|
2946
|
+
|
|
2947
|
+
// case "get_data":
|
|
2948
|
+
// if (await get_before_record_count()) {
|
|
2949
|
+
// await func.datasource.execute_view_events(
|
|
2950
|
+
// SESSION_ID,
|
|
2951
|
+
// dataSourceSession,
|
|
2952
|
+
// "before_record"
|
|
2953
|
+
// );
|
|
2954
|
+
// }
|
|
2955
|
+
|
|
2956
|
+
// ret = await db_adapter_module.process_view_dataset(
|
|
2957
|
+
// SESSION_ID,
|
|
2958
|
+
// dataSourceSession,
|
|
2959
|
+
// _ds.v,
|
|
2960
|
+
// _ds
|
|
2961
|
+
// // json1
|
|
2962
|
+
// );
|
|
2963
|
+
|
|
2964
|
+
// if (await get_after_record_count()) {
|
|
2965
|
+
// await func.datasource.execute_view_events(
|
|
2966
|
+
// SESSION_ID,
|
|
2967
|
+
// dataSourceSession,
|
|
2968
|
+
// "after_record"
|
|
2969
|
+
// );
|
|
2970
|
+
// }
|
|
2971
|
+
|
|
2972
|
+
// break;
|
|
2973
|
+
|
|
2974
|
+
// case "set_data":
|
|
2975
|
+
// if (
|
|
2976
|
+
// !prog_obj.progDataSource?.dataSourceType ||
|
|
2977
|
+
// _ds.progDataSource.dataSourceType !== "table" ||
|
|
2978
|
+
// !_ds._dataSourceTableId
|
|
2979
|
+
// ) {
|
|
2980
|
+
// return func.utils.debug_report(
|
|
2981
|
+
// SESSION_ID,
|
|
2982
|
+
// "Data source",
|
|
2983
|
+
// "Datasource DB Table must be defined for Set Data operation",
|
|
2984
|
+
// "E"
|
|
2985
|
+
// );
|
|
2986
|
+
// }
|
|
2987
|
+
|
|
2988
|
+
// if (tree_obj.crudMode === "U") {
|
|
2989
|
+
// _ds.set_mode = "U";
|
|
2990
|
+
// data_arr = _ds.v?.raw_data?.rows || [];
|
|
2991
|
+
// }
|
|
2992
|
+
|
|
2993
|
+
// if (tree_obj.crudMode === "D") {
|
|
2994
|
+
// _ds.set_mode = "D";
|
|
2995
|
+
// data_arr = _ds.v?.raw_data?.rows || [];
|
|
2996
|
+
// }
|
|
2997
|
+
|
|
2998
|
+
// // initiated with Update but no rows found
|
|
2999
|
+
// if (
|
|
3000
|
+
// tree_obj.crudMode === "U" &&
|
|
3001
|
+
// tree_obj.allowCreate &&
|
|
3002
|
+
// !_ds.v?.raw_data?.rows?.length
|
|
3003
|
+
// ) {
|
|
3004
|
+
// _ds.set_mode = "C";
|
|
3005
|
+
// data_arr = [{ id: "newRecord", value: {} }];
|
|
3006
|
+
// }
|
|
3007
|
+
|
|
3008
|
+
// if (tree_obj.crudMode === "C") {
|
|
3009
|
+
// _ds.set_mode = "C";
|
|
3010
|
+
// data_arr = [{ id: "newRecord", value: {} }];
|
|
3011
|
+
// }
|
|
3012
|
+
|
|
3013
|
+
// for await (let val of data_arr) {
|
|
3014
|
+
// _ds.currentRecordId = val.id;
|
|
3015
|
+
// if (await get_before_record_count()) {
|
|
3016
|
+
// await func.datasource.execute_view_events(
|
|
3017
|
+
// SESSION_ID,
|
|
3018
|
+
// dataSourceSession,
|
|
3019
|
+
// "before_record"
|
|
3020
|
+
// );
|
|
3021
|
+
// }
|
|
3022
|
+
|
|
3023
|
+
// await func.datasource.render_fields_dataset(
|
|
3024
|
+
// SESSION_ID,
|
|
3025
|
+
// dataSourceSession,
|
|
3026
|
+
// val
|
|
3027
|
+
// );
|
|
3028
|
+
// let data_feed_str = JSON.stringify(_ds.data_feed);
|
|
3029
|
+
|
|
3030
|
+
// if (await get_after_record_count()) {
|
|
3031
|
+
// await func.datasource.execute_view_events(
|
|
3032
|
+
// SESSION_ID,
|
|
3033
|
+
// dataSourceSession,
|
|
3034
|
+
// "after_record"
|
|
3035
|
+
// );
|
|
3036
|
+
// }
|
|
3037
|
+
|
|
3038
|
+
// if (
|
|
3039
|
+
// _ds.set_mode === "C" ||
|
|
3040
|
+
// JSON.stringify(_ds.data_feed) !== data_feed_str
|
|
3041
|
+
// ) {
|
|
3042
|
+
// const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
3043
|
+
// if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
3044
|
+
// _ds.set_mode = "M";
|
|
3045
|
+
// }
|
|
3046
|
+
|
|
3047
|
+
// if (_ds.set_mode === "D") {
|
|
3048
|
+
// const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
3049
|
+
// if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
3050
|
+
// }
|
|
3051
|
+
// }
|
|
3052
|
+
// // ret = await callback_datasource();
|
|
3053
|
+
|
|
3054
|
+
// break;
|
|
3055
|
+
|
|
3056
|
+
// case "component":
|
|
3057
|
+
// _ds.data_feed = { sort: {}, groupBy: {}, rows: {} };
|
|
3058
|
+
|
|
3059
|
+
// // _ds.rows_found = 0;
|
|
3060
|
+
// _ds.rows_processed = 0;
|
|
3061
|
+
// _ds.viewRangeExp_rows_deleted = 0;
|
|
3062
|
+
|
|
3063
|
+
// let rows = _ds.v.raw_data?.rows?.length;
|
|
3064
|
+
|
|
3065
|
+
// _ds.data_feed.rows_changed = [];
|
|
3066
|
+
// _ds.data_feed.rows_deleted = [];
|
|
3067
|
+
// _ds.data_feed.rows_added = [];
|
|
3068
|
+
|
|
3069
|
+
// const row_not_found = async function () {
|
|
3070
|
+
// _ds.currentRecordId = "newRecord";
|
|
3071
|
+
// _ds.set_mode = "C";
|
|
3072
|
+
// _ds.record_not_found = true;
|
|
3073
|
+
|
|
3074
|
+
// const newRecord = 999999;
|
|
3075
|
+
|
|
3076
|
+
// if (_.isEmpty(_ds.data_feed.rows[newRecord])) {
|
|
3077
|
+
// await func.datasource.render_fields_form(
|
|
3078
|
+
// SESSION_ID,
|
|
3079
|
+
// dataSourceSession,
|
|
3080
|
+
// { id: "newRecord", value: {} },
|
|
3081
|
+
// null,
|
|
3082
|
+
// false,
|
|
3083
|
+
// "newRecord"
|
|
3084
|
+
// );
|
|
3085
|
+
// }
|
|
3086
|
+
// var count = await func.datasource.get_field_init_count(
|
|
3087
|
+
// SESSION_ID,
|
|
3088
|
+
// dataSourceSession,
|
|
3089
|
+
// "newRecord",
|
|
3090
|
+
// false
|
|
3091
|
+
// );
|
|
3092
|
+
// if (
|
|
3093
|
+
// count > 0 // was: && !args.dataSourceNoP
|
|
3094
|
+
// ) {
|
|
3095
|
+
// await func.datasource.execute_field_init_events(
|
|
3096
|
+
// SESSION_ID,
|
|
3097
|
+
// dataSourceSession,
|
|
3098
|
+
// "form",
|
|
3099
|
+
// "newRecord"
|
|
3100
|
+
// );
|
|
3101
|
+
// }
|
|
3102
|
+
// // return await callback_datasource();
|
|
3103
|
+
// };
|
|
3104
|
+
// if (!rows) {
|
|
3105
|
+
// await row_not_found();
|
|
3106
|
+
// break;
|
|
3107
|
+
// }
|
|
3108
|
+
|
|
3109
|
+
// _ds.firstRecordId = _ds.v.raw_data.rows[0].id;
|
|
3110
|
+
|
|
3111
|
+
// const finish_form = async function () {
|
|
3112
|
+
// // check if locatedRecordId exist in SESSION_OBJ[SESSION_ID].DS_GLB
|
|
3113
|
+
// if (_ds.locatedRecordId) {
|
|
3114
|
+
// try {
|
|
3115
|
+
// const row_idx = func.common.find_ROWID_idx(
|
|
3116
|
+
// _ds,
|
|
3117
|
+
// _ds.locatedRecordId
|
|
3118
|
+
// );
|
|
3119
|
+
// } catch (error) {
|
|
3120
|
+
// delete _ds.locatedRecordId;
|
|
3121
|
+
// }
|
|
3122
|
+
// }
|
|
3123
|
+
|
|
3124
|
+
// // if (
|
|
3125
|
+
// // _ds.locatedRecordId &&
|
|
3126
|
+
// // typeof _ds.data_feed.rows[row_idx] === "undefined"
|
|
3127
|
+
// // ) {
|
|
3128
|
+
// // delete _ds.locatedRecordId;
|
|
3129
|
+
// // }
|
|
3130
|
+
|
|
3131
|
+
// db_adapter_module.sort_data(SESSION_ID, dataSourceSession, "form");
|
|
3132
|
+
|
|
3133
|
+
// _ds.finalRecordId = func.datasource.get_currentRecordId(
|
|
3134
|
+
// SESSION_ID,
|
|
3135
|
+
// dataSourceSession,
|
|
3136
|
+
// true
|
|
3137
|
+
// );
|
|
3138
|
+
// _ds.currentRecordId = _ds.finalRecordId;
|
|
3139
|
+
|
|
3140
|
+
// // clear db_raw_data to avoid refresh bug when rendering to locate index 0
|
|
3141
|
+
|
|
3142
|
+
// if (_ds.v.viewRangeExp_deleted) {
|
|
3143
|
+
// for (let [key, val] of Object.entries(
|
|
3144
|
+
// _ds.v.viewRangeExp_deleted.reverse()
|
|
3145
|
+
// )) {
|
|
3146
|
+
// SESSION_OBJ[SESSION_ID].DS_GLB[
|
|
3147
|
+
// dataSourceSession
|
|
3148
|
+
// ].db_raw_data.rows.splice(val, 1);
|
|
3149
|
+
// }
|
|
3150
|
+
// }
|
|
3151
|
+
|
|
3152
|
+
// // return await callback_datasource();
|
|
3153
|
+
// };
|
|
3154
|
+
|
|
3155
|
+
// for await (const [key, val] of Object.entries(_ds.v.raw_data.rows)) {
|
|
3156
|
+
// if (await get_before_record_count()) {
|
|
3157
|
+
// await func.datasource.execute_view_events(
|
|
3158
|
+
// SESSION_ID,
|
|
3159
|
+
// dataSourceSession,
|
|
3160
|
+
// "before_record"
|
|
3161
|
+
// );
|
|
3162
|
+
// }
|
|
3163
|
+
|
|
3164
|
+
// await func.datasource.run_rows_form(
|
|
3165
|
+
// SESSION_ID,
|
|
3166
|
+
// dataSourceSession,
|
|
3167
|
+
// key,
|
|
3168
|
+
// null,
|
|
3169
|
+
// null,
|
|
3170
|
+
// null,
|
|
3171
|
+
// _ds.pre_init_fields,
|
|
3172
|
+
// val,
|
|
3173
|
+
// db_adapter_module
|
|
3174
|
+
// );
|
|
3175
|
+
|
|
3176
|
+
// if (await get_after_record_count()) {
|
|
3177
|
+
// await func.datasource.execute_view_events(
|
|
3178
|
+
// SESSION_ID,
|
|
3179
|
+
// dataSourceSession,
|
|
3180
|
+
// "after_record"
|
|
3181
|
+
// );
|
|
3182
|
+
// }
|
|
3183
|
+
// }
|
|
3184
|
+
// await finish_form();
|
|
3185
|
+
|
|
3186
|
+
// break;
|
|
3187
|
+
|
|
3188
|
+
// default:
|
|
3189
|
+
// return func.utils.debug_report(
|
|
3190
|
+
// SESSION_ID,
|
|
3191
|
+
// "Data source",
|
|
3192
|
+
// "Program type not defined",
|
|
3193
|
+
// "E"
|
|
3194
|
+
// );
|
|
3195
|
+
// }
|
|
2775
3196
|
ret = await callback_datasource();
|
|
2776
3197
|
return ret;
|
|
2777
3198
|
};
|
|
@@ -2843,9 +3264,10 @@ func.datasource.render_fields_dataset = async function (
|
|
|
2843
3264
|
};
|
|
2844
3265
|
|
|
2845
3266
|
if (!_ds.data_feed) {
|
|
2846
|
-
_ds.data_feed = { rows:
|
|
3267
|
+
_ds.data_feed = { rows: [] };
|
|
2847
3268
|
}
|
|
2848
|
-
let data_feed =
|
|
3269
|
+
let data_feed = { _ROWID: _ds.currentRecordId };
|
|
3270
|
+
|
|
2849
3271
|
_ds.dataset_alias = {};
|
|
2850
3272
|
|
|
2851
3273
|
for await (const val of _progFields) {
|
|
@@ -2884,6 +3306,7 @@ func.datasource.render_fields_dataset = async function (
|
|
|
2884
3306
|
func.utils.debug_report(SESSION_ID, "Datasource", err, "E", null, _ds);
|
|
2885
3307
|
}
|
|
2886
3308
|
}
|
|
3309
|
+
_ds.data_feed.rows.push(data_feed);
|
|
2887
3310
|
};
|
|
2888
3311
|
|
|
2889
3312
|
func.datasource.run_events_functions = async function (
|
|
@@ -2993,7 +3416,17 @@ func.datasource.render_fields_form = async function (
|
|
|
2993
3416
|
);
|
|
2994
3417
|
};
|
|
2995
3418
|
|
|
2996
|
-
if (!_ds.data_feed.rows[
|
|
3419
|
+
// if (!_ds.data_feed.rows[row_idx])
|
|
3420
|
+
// _ds.data_feed.rows[row_idx] = { _ROWID: data.id };
|
|
3421
|
+
|
|
3422
|
+
let row_idx;
|
|
3423
|
+
try {
|
|
3424
|
+
row_idx = func.common.find_ROWID_idx(_ds, data.id);
|
|
3425
|
+
} catch (error) {
|
|
3426
|
+
_ds.data_feed.rows.push({ _ROWID: data.id });
|
|
3427
|
+
row_idx = func.common.find_ROWID_idx(_ds, data.id);
|
|
3428
|
+
}
|
|
3429
|
+
|
|
2997
3430
|
_ds.dataset_alias = {};
|
|
2998
3431
|
|
|
2999
3432
|
for await (const val of _progFields) {
|
|
@@ -3003,27 +3436,39 @@ func.datasource.render_fields_form = async function (
|
|
|
3003
3436
|
if (val.data.type === "virtual" || data.id === "newRecord") {
|
|
3004
3437
|
if (glb.PROTECTED_VARS.includes(fieldId)) {
|
|
3005
3438
|
switch (fieldId) {
|
|
3006
|
-
case "
|
|
3439
|
+
case "_ROWNO": {
|
|
3007
3440
|
let row_no =
|
|
3008
|
-
Object.keys(_ds?.data_feed?.rows).indexOf(data.id) || 0;
|
|
3009
|
-
|
|
3010
|
-
fieldId,
|
|
3011
|
-
row_no
|
|
3012
|
-
|
|
3441
|
+
// Object.keys(_ds?.data_feed?.rows).indexOf(data.id) || 0;
|
|
3442
|
+
// _ds.data_feed.rows[data.id][fieldId] = await get_value(
|
|
3443
|
+
// fieldId,
|
|
3444
|
+
// row_no
|
|
3445
|
+
// );
|
|
3446
|
+
(_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3447
|
+
fieldId,
|
|
3448
|
+
row_idx
|
|
3449
|
+
));
|
|
3013
3450
|
continue;
|
|
3014
3451
|
}
|
|
3015
|
-
case "
|
|
3016
|
-
_ds.data_feed.rows[
|
|
3452
|
+
case "_ROWID": {
|
|
3453
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3017
3454
|
fieldId,
|
|
3018
3455
|
data.id
|
|
3019
3456
|
);
|
|
3457
|
+
// _ds.data_feed.rows[data.id][fieldId] = await get_value(
|
|
3458
|
+
// fieldId,
|
|
3459
|
+
// data.id
|
|
3460
|
+
// );
|
|
3020
3461
|
continue;
|
|
3021
3462
|
}
|
|
3022
|
-
case "
|
|
3023
|
-
_ds.data_feed.rows[
|
|
3463
|
+
case "_ROWDOC": {
|
|
3464
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3024
3465
|
fieldId,
|
|
3025
3466
|
data
|
|
3026
3467
|
);
|
|
3468
|
+
// _ds.data_feed.rows[data.id][fieldId] = await get_value(
|
|
3469
|
+
// fieldId,
|
|
3470
|
+
// data
|
|
3471
|
+
// );
|
|
3027
3472
|
continue;
|
|
3028
3473
|
}
|
|
3029
3474
|
}
|
|
@@ -3038,28 +3483,40 @@ func.datasource.render_fields_form = async function (
|
|
|
3038
3483
|
"update",
|
|
3039
3484
|
data.id
|
|
3040
3485
|
);
|
|
3041
|
-
_ds.data_feed.rows[
|
|
3486
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3042
3487
|
fieldId,
|
|
3043
3488
|
ret.result
|
|
3044
3489
|
);
|
|
3490
|
+
// _ds.data_feed.rows[data.id][fieldId] = await get_value(
|
|
3491
|
+
// fieldId,
|
|
3492
|
+
// ret.result
|
|
3493
|
+
// );
|
|
3045
3494
|
|
|
3046
3495
|
continue;
|
|
3047
3496
|
}
|
|
3048
3497
|
|
|
3049
|
-
_ds.data_feed.rows[
|
|
3498
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3050
3499
|
fieldId,
|
|
3051
3500
|
val.props?.fieldValue
|
|
3052
3501
|
);
|
|
3502
|
+
// _ds.data_feed.rows[data.id][fieldId] = await get_value(
|
|
3503
|
+
// fieldId,
|
|
3504
|
+
// val.props?.fieldValue
|
|
3505
|
+
// );
|
|
3053
3506
|
continue;
|
|
3054
3507
|
}
|
|
3055
3508
|
if (val.data.type === "table" || val.data.type === "datasource") {
|
|
3056
3509
|
if (typeof data.value[fieldId] === "undefined") {
|
|
3057
3510
|
throw "field do not exist in data: " + fieldId;
|
|
3058
3511
|
}
|
|
3059
|
-
_ds.data_feed.rows[
|
|
3512
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3060
3513
|
fieldId,
|
|
3061
3514
|
data.value[fieldId]
|
|
3062
3515
|
);
|
|
3516
|
+
// _ds.data_feed.rows[data.id][fieldId] = await get_value(
|
|
3517
|
+
// fieldId,
|
|
3518
|
+
// data.value[fieldId]
|
|
3519
|
+
// );
|
|
3063
3520
|
}
|
|
3064
3521
|
} catch (err) {
|
|
3065
3522
|
func.utils.debug_report(SESSION_ID, "Datasource", err, "E", null, _ds);
|
|
@@ -3067,6 +3524,143 @@ func.datasource.render_fields_form = async function (
|
|
|
3067
3524
|
}
|
|
3068
3525
|
};
|
|
3069
3526
|
|
|
3527
|
+
// func.datasource.run_rows_form = async function (
|
|
3528
|
+
// SESSION_ID,
|
|
3529
|
+
// dataSourceSession,
|
|
3530
|
+
// rowIdxP,
|
|
3531
|
+
// NA_onDemandP,
|
|
3532
|
+
// NA_callbackP,
|
|
3533
|
+
// NA_oninit_triggers_to_runP,
|
|
3534
|
+
// pre_init_fieldsP,
|
|
3535
|
+
// data,
|
|
3536
|
+
// db_adapter_module
|
|
3537
|
+
// ) {
|
|
3538
|
+
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3539
|
+
// if (!_ds) return;
|
|
3540
|
+
// // var v = _ds.v;
|
|
3541
|
+
|
|
3542
|
+
// var val = _ds.data_feed.rows[rowIdxP];
|
|
3543
|
+
|
|
3544
|
+
// var idx;
|
|
3545
|
+
|
|
3546
|
+
// try {
|
|
3547
|
+
// if (typeof val !== "undefined") {
|
|
3548
|
+
// if (val.id) idx = val.id;
|
|
3549
|
+
// else if (val.value) idx = val.value._id;
|
|
3550
|
+
// else idx = val;
|
|
3551
|
+
// } else {
|
|
3552
|
+
// idx = "newRecord";
|
|
3553
|
+
// }
|
|
3554
|
+
// } catch (e) {
|
|
3555
|
+
// console.error(e);
|
|
3556
|
+
// }
|
|
3557
|
+
// // var sort_index = rowIdxP - _ds.viewRangeExp_rows_deleted;
|
|
3558
|
+
// //
|
|
3559
|
+
// const add_row = async function () {
|
|
3560
|
+
// var old_row_data;
|
|
3561
|
+
|
|
3562
|
+
// _ds.data_feed.rows[idx] = {};
|
|
3563
|
+
// // _ds.data_feed.rows[idx].arrIndex = sort_index; // removed 022623 needs other solution
|
|
3564
|
+
|
|
3565
|
+
// const form_continue = async function (render_fields) {
|
|
3566
|
+
// _ds.rows_processed++;
|
|
3567
|
+
// // const sort_form = async function () {
|
|
3568
|
+
// // await db_adapter_module.add_sort(
|
|
3569
|
+
// // SESSION_ID,
|
|
3570
|
+
// // dataSourceSession,
|
|
3571
|
+
// // "form",
|
|
3572
|
+
// // _ds.progDataSource.dataSourceSortScript,
|
|
3573
|
+
// // idx,
|
|
3574
|
+
// // sort_index
|
|
3575
|
+
// // );
|
|
3576
|
+
// // await db_adapter_module.add_GroupBy(
|
|
3577
|
+
// // SESSION_ID,
|
|
3578
|
+
// // dataSourceSession,
|
|
3579
|
+
// // "form",
|
|
3580
|
+
// // _ds.progDataSource.dataSourceGroupByScript,
|
|
3581
|
+
// // idx,
|
|
3582
|
+
// // sort_index
|
|
3583
|
+
// // );
|
|
3584
|
+
// // // _ds.rows_found++;
|
|
3585
|
+
// // };
|
|
3586
|
+
// const delete_row = async function () {
|
|
3587
|
+
// if (_ds) {
|
|
3588
|
+
// delete _ds.data_feed.rows[idx];
|
|
3589
|
+
|
|
3590
|
+
// if (!_ds.v.viewRangeExp_deleted) _ds.v.viewRangeExp_deleted = [];
|
|
3591
|
+
// _ds.v.viewRangeExp_deleted.push(rowIdxP);
|
|
3592
|
+
// }
|
|
3593
|
+
// // _ds.rows_found--;
|
|
3594
|
+
// _ds.viewRangeExp_rows_deleted++;
|
|
3595
|
+
// };
|
|
3596
|
+
// if (_ds.progDataSource?.dataSourceFiltersScript) {
|
|
3597
|
+
// var res = await func.datasource.validate_viewRange(
|
|
3598
|
+
// SESSION_ID,
|
|
3599
|
+
// _ds.progDataSource.dataSourceFiltersScript,
|
|
3600
|
+
// dataSourceSession,
|
|
3601
|
+
// idx,
|
|
3602
|
+
// "form"
|
|
3603
|
+
// );
|
|
3604
|
+
// if (
|
|
3605
|
+
// res === false ||
|
|
3606
|
+
// res === 0 ||
|
|
3607
|
+
// typeof res === "undefined" ||
|
|
3608
|
+
// res === null
|
|
3609
|
+
// ) {
|
|
3610
|
+
// await delete_row();
|
|
3611
|
+
// }
|
|
3612
|
+
// }
|
|
3613
|
+
// // await sort_form();
|
|
3614
|
+
|
|
3615
|
+
// if (_ds.progDataSource?.dataSourceLocateScript) {
|
|
3616
|
+
// var res = func.datasource.validate_viewLocate(
|
|
3617
|
+
// SESSION_ID,
|
|
3618
|
+
// _ds.progDataSource.dataSourceLocateScript,
|
|
3619
|
+
// dataSourceSession,
|
|
3620
|
+
// idx,
|
|
3621
|
+
// "form"
|
|
3622
|
+
// );
|
|
3623
|
+
// if (res) {
|
|
3624
|
+
// _ds.locatedRecordId = idx;
|
|
3625
|
+
// }
|
|
3626
|
+
// }
|
|
3627
|
+
// if (_ds.progDataSource?.dataSourceFiltersScript) {
|
|
3628
|
+
// return;
|
|
3629
|
+
// }
|
|
3630
|
+
// };
|
|
3631
|
+
// _ds.currentRecordId = idx; // set temporary to allow expression decoder work
|
|
3632
|
+
|
|
3633
|
+
// await func.datasource.render_fields_form(
|
|
3634
|
+
// SESSION_ID,
|
|
3635
|
+
// dataSourceSession,
|
|
3636
|
+
// data,
|
|
3637
|
+
// null,
|
|
3638
|
+
// true,
|
|
3639
|
+
// idx,
|
|
3640
|
+
// true,
|
|
3641
|
+
// pre_init_fieldsP
|
|
3642
|
+
// );
|
|
3643
|
+
// const init_count = await func.datasource.get_field_init_count(
|
|
3644
|
+
// SESSION_ID,
|
|
3645
|
+
// dataSourceSession,
|
|
3646
|
+
// idx,
|
|
3647
|
+
// false,
|
|
3648
|
+
// _ds.oninit_triggers_to_run
|
|
3649
|
+
// );
|
|
3650
|
+
// if (init_count > 0) {
|
|
3651
|
+
// await func.datasource.execute_field_init_events(
|
|
3652
|
+
// SESSION_ID,
|
|
3653
|
+
// dataSourceSession,
|
|
3654
|
+
// "form",
|
|
3655
|
+
// idx
|
|
3656
|
+
// );
|
|
3657
|
+
// }
|
|
3658
|
+
// await form_continue();
|
|
3659
|
+
// };
|
|
3660
|
+
|
|
3661
|
+
// await add_row();
|
|
3662
|
+
// };
|
|
3663
|
+
|
|
3070
3664
|
func.datasource.run_rows_form = async function (
|
|
3071
3665
|
SESSION_ID,
|
|
3072
3666
|
dataSourceSession,
|
|
@@ -3082,127 +3676,123 @@ func.datasource.run_rows_form = async function (
|
|
|
3082
3676
|
if (!_ds) return;
|
|
3083
3677
|
// var v = _ds.v;
|
|
3084
3678
|
|
|
3085
|
-
var val = _ds.
|
|
3679
|
+
var val = _ds.data_feed.rows[rowIdxP];
|
|
3086
3680
|
|
|
3087
3681
|
var idx;
|
|
3088
3682
|
|
|
3089
3683
|
try {
|
|
3090
3684
|
if (typeof val !== "undefined") {
|
|
3091
|
-
|
|
3092
|
-
else if (val.value) idx = val.value._id;
|
|
3093
|
-
else idx = val;
|
|
3685
|
+
idx = _ROWID;
|
|
3094
3686
|
} else {
|
|
3095
|
-
|
|
3687
|
+
const newRecord = 999999;
|
|
3688
|
+
val = _ds.data_feed.rows[newRecord] = { _ROWID: newRecord };
|
|
3689
|
+
idx = newRecord;
|
|
3096
3690
|
}
|
|
3097
3691
|
} catch (e) {
|
|
3098
3692
|
console.error(e);
|
|
3099
3693
|
}
|
|
3100
|
-
var sort_index = rowIdxP - _ds.viewRangeExp_rows_deleted;
|
|
3694
|
+
// var sort_index = rowIdxP - _ds.viewRangeExp_rows_deleted;
|
|
3101
3695
|
//
|
|
3102
|
-
const add_row = async function () {
|
|
3103
|
-
var old_row_data;
|
|
3104
|
-
|
|
3105
|
-
_ds.data_feed.rows[idx] = {};
|
|
3106
|
-
// _ds.data_feed.rows[idx].arrIndex = sort_index; // removed 022623 needs other solution
|
|
3107
|
-
|
|
3108
|
-
const form_continue = async function (render_fields) {
|
|
3109
|
-
_ds.rows_processed++;
|
|
3110
|
-
const sort_form = async function () {
|
|
3111
|
-
await db_adapter_module.add_sort(
|
|
3112
|
-
SESSION_ID,
|
|
3113
|
-
dataSourceSession,
|
|
3114
|
-
"form",
|
|
3115
|
-
_ds.progDataSource.dataSourceSortScript,
|
|
3116
|
-
idx,
|
|
3117
|
-
sort_index
|
|
3118
|
-
);
|
|
3119
|
-
await db_adapter_module.add_GroupBy(
|
|
3120
|
-
SESSION_ID,
|
|
3121
|
-
dataSourceSession,
|
|
3122
|
-
"form",
|
|
3123
|
-
_ds.progDataSource.dataSourceGroupByScript,
|
|
3124
|
-
idx,
|
|
3125
|
-
sort_index
|
|
3126
|
-
);
|
|
3127
|
-
// _ds.rows_found++;
|
|
3128
|
-
};
|
|
3129
|
-
const delete_row = async function () {
|
|
3130
|
-
if (_ds) {
|
|
3131
|
-
delete _ds.data_feed.rows[idx];
|
|
3132
3696
|
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3697
|
+
// _ds.data_feed.rows[idx] = { _ROWID: val._ROWID };
|
|
3698
|
+
// _ds.data_feed.rows[idx].arrIndex = sort_index; // removed 022623 needs other solution
|
|
3699
|
+
|
|
3700
|
+
// const form_continue = async function (render_fields) {
|
|
3701
|
+
// _ds.rows_processed++;
|
|
3702
|
+
// // const sort_form = async function () {
|
|
3703
|
+
// // await db_adapter_module.add_sort(
|
|
3704
|
+
// // SESSION_ID,
|
|
3705
|
+
// // dataSourceSession,
|
|
3706
|
+
// // "form",
|
|
3707
|
+
// // _ds.progDataSource.dataSourceSortScript,
|
|
3708
|
+
// // idx,
|
|
3709
|
+
// // sort_index
|
|
3710
|
+
// // );
|
|
3711
|
+
// // await db_adapter_module.add_GroupBy(
|
|
3712
|
+
// // SESSION_ID,
|
|
3713
|
+
// // dataSourceSession,
|
|
3714
|
+
// // "form",
|
|
3715
|
+
// // _ds.progDataSource.dataSourceGroupByScript,
|
|
3716
|
+
// // idx,
|
|
3717
|
+
// // sort_index
|
|
3718
|
+
// // );
|
|
3719
|
+
// // // _ds.rows_found++;
|
|
3720
|
+
// // };
|
|
3721
|
+
// const delete_row = async function () {
|
|
3722
|
+
// if (_ds) {
|
|
3723
|
+
// delete _ds.data_feed.rows[idx];
|
|
3724
|
+
|
|
3725
|
+
// if (!_ds.v.viewRangeExp_deleted) _ds.v.viewRangeExp_deleted = [];
|
|
3726
|
+
// _ds.v.viewRangeExp_deleted.push(rowIdxP);
|
|
3727
|
+
// }
|
|
3728
|
+
// // _ds.rows_found--;
|
|
3729
|
+
// _ds.viewRangeExp_rows_deleted++;
|
|
3730
|
+
// };
|
|
3731
|
+
// if (_ds.progDataSource?.dataSourceFiltersScript) {
|
|
3732
|
+
// var res = await func.datasource.validate_viewRange(
|
|
3733
|
+
// SESSION_ID,
|
|
3734
|
+
// _ds.progDataSource.dataSourceFiltersScript,
|
|
3735
|
+
// dataSourceSession,
|
|
3736
|
+
// idx,
|
|
3737
|
+
// "form"
|
|
3738
|
+
// );
|
|
3739
|
+
// if (
|
|
3740
|
+
// res === false ||
|
|
3741
|
+
// res === 0 ||
|
|
3742
|
+
// typeof res === "undefined" ||
|
|
3743
|
+
// res === null
|
|
3744
|
+
// ) {
|
|
3745
|
+
// await delete_row();
|
|
3746
|
+
// }
|
|
3747
|
+
// }
|
|
3748
|
+
// // await sort_form();
|
|
3157
3749
|
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3750
|
+
// if (_ds.progDataSource?.dataSourceLocateScript) {
|
|
3751
|
+
// var res = func.datasource.validate_viewLocate(
|
|
3752
|
+
// SESSION_ID,
|
|
3753
|
+
// _ds.progDataSource.dataSourceLocateScript,
|
|
3754
|
+
// dataSourceSession,
|
|
3755
|
+
// idx,
|
|
3756
|
+
// "form"
|
|
3757
|
+
// );
|
|
3758
|
+
// if (res) {
|
|
3759
|
+
// _ds.locatedRecordId = idx;
|
|
3760
|
+
// }
|
|
3761
|
+
// }
|
|
3762
|
+
// if (_ds.progDataSource?.dataSourceFiltersScript) {
|
|
3763
|
+
// return;
|
|
3764
|
+
// }
|
|
3765
|
+
// };
|
|
3766
|
+
_ds.currentRecordId = val._ROWID; // set temporary to allow expression decoder work
|
|
3175
3767
|
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3768
|
+
await func.datasource.render_fields_form(
|
|
3769
|
+
SESSION_ID,
|
|
3770
|
+
dataSourceSession,
|
|
3771
|
+
data
|
|
3772
|
+
// null,
|
|
3773
|
+
// true,
|
|
3774
|
+
// idx,
|
|
3775
|
+
// true,
|
|
3776
|
+
// pre_init_fieldsP
|
|
3777
|
+
);
|
|
3778
|
+
const init_count = await func.datasource.get_field_init_count(
|
|
3779
|
+
SESSION_ID,
|
|
3780
|
+
dataSourceSession,
|
|
3781
|
+
idx,
|
|
3782
|
+
false,
|
|
3783
|
+
_ds.oninit_triggers_to_run
|
|
3784
|
+
);
|
|
3785
|
+
if (init_count > 0) {
|
|
3786
|
+
await func.datasource.execute_field_init_events(
|
|
3187
3787
|
SESSION_ID,
|
|
3188
3788
|
dataSourceSession,
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
_ds.oninit_triggers_to_run
|
|
3789
|
+
"form",
|
|
3790
|
+
idx
|
|
3192
3791
|
);
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
SESSION_ID,
|
|
3196
|
-
dataSourceSession,
|
|
3197
|
-
"form",
|
|
3198
|
-
idx
|
|
3199
|
-
);
|
|
3200
|
-
}
|
|
3201
|
-
await form_continue();
|
|
3202
|
-
};
|
|
3203
|
-
|
|
3204
|
-
await add_row();
|
|
3792
|
+
}
|
|
3793
|
+
// await form_continue();
|
|
3205
3794
|
};
|
|
3795
|
+
|
|
3206
3796
|
func.datasource.execute_field_init_events = async function (
|
|
3207
3797
|
SESSION_ID,
|
|
3208
3798
|
dataSourceSession,
|
|
@@ -3809,9 +4399,9 @@ func.datasource.update = async function (
|
|
|
3809
4399
|
continue;
|
|
3810
4400
|
}
|
|
3811
4401
|
|
|
3812
|
-
for (const [
|
|
4402
|
+
for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
3813
4403
|
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
3814
|
-
if (
|
|
4404
|
+
if (record_id === "datasource_main") {
|
|
3815
4405
|
// _ds[field_id] = value;
|
|
3816
4406
|
_.set(_ds, field_id, value);
|
|
3817
4407
|
continue;
|
|
@@ -3824,7 +4414,14 @@ func.datasource.update = async function (
|
|
|
3824
4414
|
continue;
|
|
3825
4415
|
}
|
|
3826
4416
|
|
|
3827
|
-
|
|
4417
|
+
try {
|
|
4418
|
+
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4419
|
+
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
4420
|
+
} catch (err) {
|
|
4421
|
+
console.error(err);
|
|
4422
|
+
}
|
|
4423
|
+
|
|
4424
|
+
// _ds.data_feed.rows[record_id][field_id] = value;
|
|
3828
4425
|
|
|
3829
4426
|
if (!fields_changes.includes(field_id)) {
|
|
3830
4427
|
fields_changes.push(field_id);
|
|
@@ -3833,14 +4430,14 @@ func.datasource.update = async function (
|
|
|
3833
4430
|
datasource_changed.push(dataSource);
|
|
3834
4431
|
}
|
|
3835
4432
|
} else if (fields_data === "set") {
|
|
3836
|
-
_ds.currentRecordId =
|
|
4433
|
+
_ds.currentRecordId = record_id;
|
|
3837
4434
|
}
|
|
3838
4435
|
}
|
|
3839
4436
|
if (!_ds.data_feed.rows_changed) {
|
|
3840
4437
|
_ds.data_feed.rows_changed = [];
|
|
3841
4438
|
}
|
|
3842
|
-
if (!_ds.data_feed.rows_changed.includes(
|
|
3843
|
-
_ds.data_feed.rows_changed.push(
|
|
4439
|
+
if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
4440
|
+
_ds.data_feed.rows_changed.push(record_id);
|
|
3844
4441
|
}
|
|
3845
4442
|
|
|
3846
4443
|
if (!from_worker) {
|
|
@@ -3916,11 +4513,13 @@ func.datasource.callback = function (
|
|
|
3916
4513
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
3917
4514
|
var _ds = _session.DS_GLB[dsSessionP];
|
|
3918
4515
|
|
|
4516
|
+
const dataset = 0;
|
|
4517
|
+
|
|
3919
4518
|
if (_ds.PARAM_OUT_INFO) {
|
|
3920
4519
|
// write log for out params
|
|
3921
4520
|
for (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
3922
4521
|
if (
|
|
3923
|
-
typeof _ds?.data_feed?.rows?.[
|
|
4522
|
+
typeof _ds?.data_feed?.rows?.[dataset]?.[val.fieldId] === "undefined"
|
|
3924
4523
|
) {
|
|
3925
4524
|
// func.utils.debug.log(SESSION_ID, key, val);
|
|
3926
4525
|
func.utils.alerts.invoke(
|
|
@@ -3932,7 +4531,7 @@ func.datasource.callback = function (
|
|
|
3932
4531
|
);
|
|
3933
4532
|
break;
|
|
3934
4533
|
}
|
|
3935
|
-
val.result = _ds.data_feed.rows[
|
|
4534
|
+
val.result = _ds.data_feed.rows[dataset][val.fieldId];
|
|
3936
4535
|
}
|
|
3937
4536
|
}
|
|
3938
4537
|
|
|
@@ -4392,33 +4991,40 @@ func.datasource.get_value = async function (
|
|
|
4392
4991
|
}
|
|
4393
4992
|
|
|
4394
4993
|
if (!org_dsSessionP && recordId) {
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4994
|
+
try {
|
|
4995
|
+
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
4996
|
+
// if (typeof _ds.data_feed?.rows?.[recordId]?.[_field_id] !== "undefined") {
|
|
4997
|
+
if (
|
|
4998
|
+
Object.keys(_ds.data_feed?.rows?.[row_idx] || {})?.includes(_field_id)
|
|
4999
|
+
) {
|
|
5000
|
+
return await return_value(
|
|
5001
|
+
_field_id,
|
|
5002
|
+
_ds.data_feed.rows[row_idx][_field_id]
|
|
5003
|
+
);
|
|
5004
|
+
}
|
|
5005
|
+
// if (typeof _ds?.dynamic_fields?.[_field_id] !== "undefined") {
|
|
5006
|
+
if (Object.keys(_ds?.dynamic_fields || {})?.includes(_field_id)) {
|
|
5007
|
+
return await return_dynamic_value(
|
|
5008
|
+
_field_id,
|
|
5009
|
+
_ds.dynamic_fields[_field_id]
|
|
5010
|
+
);
|
|
5011
|
+
}
|
|
5012
|
+
} catch (err) {
|
|
5013
|
+
console.error(err);
|
|
4403
5014
|
}
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
5015
|
+
}
|
|
5016
|
+
|
|
5017
|
+
try {
|
|
5018
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
5019
|
+
|
|
5020
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== "undefined") {
|
|
5021
|
+
return await return_value(
|
|
4407
5022
|
_field_id,
|
|
4408
|
-
_ds.
|
|
5023
|
+
_ds.data_feed.rows[row_idx][_field_id]
|
|
4409
5024
|
);
|
|
4410
5025
|
}
|
|
4411
|
-
}
|
|
5026
|
+
} catch (error) {}
|
|
4412
5027
|
|
|
4413
|
-
if (
|
|
4414
|
-
typeof _ds.data_feed?.rows?.[_ds.currentRecordId]?.[_field_id] !==
|
|
4415
|
-
"undefined"
|
|
4416
|
-
) {
|
|
4417
|
-
return await return_value(
|
|
4418
|
-
_field_id,
|
|
4419
|
-
_ds.data_feed.rows[_ds.currentRecordId][_field_id]
|
|
4420
|
-
);
|
|
4421
|
-
}
|
|
4422
5028
|
if (typeof _ds?.dynamic_fields?.[_field_id] !== "undefined") {
|
|
4423
5029
|
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
4424
5030
|
}
|
|
@@ -5203,7 +5809,7 @@ func.utils.clean_returned_datasource = function (SESSION_ID, DS) {
|
|
|
5203
5809
|
// }
|
|
5204
5810
|
delete obj.pre_init_fields;
|
|
5205
5811
|
delete obj.oninit_triggers_to_run;
|
|
5206
|
-
delete obj.raw_data;
|
|
5812
|
+
// delete obj.raw_data;
|
|
5207
5813
|
|
|
5208
5814
|
delete obj.debug;
|
|
5209
5815
|
|