@xuda.io/runtime-bundle 1.0.285 → 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 +495 -1451
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +498 -1454
- package/js/xuda-runtime-slim.min.es.js +498 -1454
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +493 -1449
- package/js/xuda-worker-bundle.js +493 -1449
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-worker-bundle.js
CHANGED
|
@@ -1639,15 +1639,15 @@ func.datasource.create = async function (
|
|
|
1639
1639
|
parameters_obj_inP,
|
|
1640
1640
|
static_refreshP,
|
|
1641
1641
|
worker_id,
|
|
1642
|
-
NA_eventChangesResults
|
|
1642
|
+
NA_eventChangesResults,
|
|
1643
1643
|
) {
|
|
1644
1644
|
return new Promise(async function (resolve, reject) {
|
|
1645
|
-
if (!prog_id) return reject(
|
|
1645
|
+
if (!prog_id) return reject('Program is empty');
|
|
1646
1646
|
|
|
1647
1647
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1648
|
-
if (!_session.DS_GLB) return reject(
|
|
1648
|
+
if (!_session.DS_GLB) return reject('DS_GLB not exist');
|
|
1649
1649
|
var _prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
|
|
1650
|
-
if (!_prog_obj) return reject(
|
|
1650
|
+
if (!_prog_obj) return reject('Program not found');
|
|
1651
1651
|
|
|
1652
1652
|
var args = {
|
|
1653
1653
|
SESSION_ID,
|
|
@@ -1679,8 +1679,7 @@ func.datasource.create = async function (
|
|
|
1679
1679
|
old_dataSource_vars.SYS_STR_WIN_ID = _ds.data_system.SYS_STR_WIN_ID;
|
|
1680
1680
|
old_dataSource_vars.SYS_STR_WIN_NAME = _ds.data_system.SYS_STR_WIN_NAME;
|
|
1681
1681
|
}
|
|
1682
|
-
if (static_refreshP)
|
|
1683
|
-
old_dataSource_vars.in_parameters = _ds.in_parameters;
|
|
1682
|
+
if (static_refreshP) old_dataSource_vars.in_parameters = _ds.in_parameters;
|
|
1684
1683
|
}
|
|
1685
1684
|
const restore_old_dataSource_vars = function (dsSessionP) {
|
|
1686
1685
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
@@ -1692,26 +1691,20 @@ func.datasource.create = async function (
|
|
|
1692
1691
|
_ds.data_system.SYS_STR_WIN_NAME = old_dataSource_vars.SYS_STR_WIN_NAME;
|
|
1693
1692
|
}
|
|
1694
1693
|
|
|
1695
|
-
if (static_refreshP)
|
|
1696
|
-
_ds.in_parameters = old_dataSource_vars.in_parameters;
|
|
1694
|
+
if (static_refreshP) _ds.in_parameters = old_dataSource_vars.in_parameters;
|
|
1697
1695
|
};
|
|
1698
1696
|
|
|
1699
1697
|
var run_at = _prog_obj?.properties?.runAt;
|
|
1700
|
-
if (_session.opt.app_computing_mode ===
|
|
1701
|
-
run_at =
|
|
1698
|
+
if (_session.opt.app_computing_mode === 'main') {
|
|
1699
|
+
run_at = 'client';
|
|
1702
1700
|
}
|
|
1703
1701
|
|
|
1704
|
-
if (_prog_obj?.properties.menuType ===
|
|
1705
|
-
run_at =
|
|
1702
|
+
if (_prog_obj?.properties.menuType === 'globals') {
|
|
1703
|
+
run_at = 'client';
|
|
1706
1704
|
}
|
|
1707
1705
|
|
|
1708
|
-
if (
|
|
1709
|
-
|
|
1710
|
-
parentDataSourceNoP &&
|
|
1711
|
-
_session.DS_GLB[parentDataSourceNoP]
|
|
1712
|
-
) {
|
|
1713
|
-
if (_session.DS_GLB[parentDataSourceNoP]._run_at)
|
|
1714
|
-
run_at = _session.DS_GLB[parentDataSourceNoP].v.run_at;
|
|
1706
|
+
if (!run_at && parentDataSourceNoP && _session.DS_GLB[parentDataSourceNoP]) {
|
|
1707
|
+
if (_session.DS_GLB[parentDataSourceNoP]._run_at) run_at = _session.DS_GLB[parentDataSourceNoP].v.run_at;
|
|
1715
1708
|
}
|
|
1716
1709
|
|
|
1717
1710
|
const done = function (SESSION_ID, dsSessionP, is_serverP) {
|
|
@@ -1723,12 +1716,7 @@ func.datasource.create = async function (
|
|
|
1723
1716
|
|
|
1724
1717
|
if (!IS_DATASOURCE_REFRESH) {
|
|
1725
1718
|
if (!glb.IS_WORKER) {
|
|
1726
|
-
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP] =
|
|
1727
|
-
new func.datasource.interval(
|
|
1728
|
-
SESSION_ID,
|
|
1729
|
-
dsSessionP,
|
|
1730
|
-
"client_interval"
|
|
1731
|
-
);
|
|
1719
|
+
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP] = new func.datasource.interval(SESSION_ID, dsSessionP, 'client_interval');
|
|
1732
1720
|
DATASOURCE_INTERVALS[SESSION_ID][dsSessionP].init();
|
|
1733
1721
|
}
|
|
1734
1722
|
}
|
|
@@ -1743,8 +1731,8 @@ func.datasource.create = async function (
|
|
|
1743
1731
|
|
|
1744
1732
|
var datasource_changes = {
|
|
1745
1733
|
[dsSessionP]: {
|
|
1746
|
-
[
|
|
1747
|
-
stat:
|
|
1734
|
+
['datasource_main']: {
|
|
1735
|
+
stat: 'idle',
|
|
1748
1736
|
stat_ts: Date.now(),
|
|
1749
1737
|
is_worker: glb.IS_WORKER,
|
|
1750
1738
|
},
|
|
@@ -1758,7 +1746,7 @@ func.datasource.create = async function (
|
|
|
1758
1746
|
let interval = setInterval(() => {
|
|
1759
1747
|
let idle_count = 0;
|
|
1760
1748
|
for (const _ds of ds_connected) {
|
|
1761
|
-
if (_ds.stat ==
|
|
1749
|
+
if (_ds.stat == 'idle') {
|
|
1762
1750
|
idle_count++;
|
|
1763
1751
|
}
|
|
1764
1752
|
}
|
|
@@ -1787,12 +1775,7 @@ func.datasource.create = async function (
|
|
|
1787
1775
|
if (jobNoP) {
|
|
1788
1776
|
}
|
|
1789
1777
|
|
|
1790
|
-
if (
|
|
1791
|
-
glb.IS_WORKER ||
|
|
1792
|
-
run_at === "client" ||
|
|
1793
|
-
is_system_client_vars ||
|
|
1794
|
-
db_driver === "pouchdb"
|
|
1795
|
-
) {
|
|
1778
|
+
if (glb.IS_WORKER || run_at === 'client' || is_system_client_vars || db_driver === 'pouchdb') {
|
|
1796
1779
|
const ret = await func.datasource.prepare(
|
|
1797
1780
|
args.SESSION_ID,
|
|
1798
1781
|
args.prog_id,
|
|
@@ -1811,7 +1794,7 @@ func.datasource.create = async function (
|
|
|
1811
1794
|
args.parameters_obj_inP,
|
|
1812
1795
|
args.static_refreshP,
|
|
1813
1796
|
run_at,
|
|
1814
|
-
worker_id
|
|
1797
|
+
worker_id,
|
|
1815
1798
|
);
|
|
1816
1799
|
return done(SESSION_ID, ret.dsSessionP);
|
|
1817
1800
|
}
|
|
@@ -1820,19 +1803,16 @@ func.datasource.create = async function (
|
|
|
1820
1803
|
var data = _.assignIn(
|
|
1821
1804
|
{
|
|
1822
1805
|
session_id: SESSION_ID,
|
|
1823
|
-
dataSourceSessionGlobal:
|
|
1824
|
-
|
|
1825
|
-
parentDataSourceNo: IS_DATASOURCE_REFRESH
|
|
1826
|
-
? _ds.parentDataSourceNo
|
|
1827
|
-
: null,
|
|
1806
|
+
dataSourceSessionGlobal: SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal,
|
|
1807
|
+
parentDataSourceNo: IS_DATASOURCE_REFRESH ? _ds.parentDataSourceNo : null,
|
|
1828
1808
|
IS_DATASOURCE_REFRESH,
|
|
1829
1809
|
},
|
|
1830
|
-
args
|
|
1810
|
+
args,
|
|
1831
1811
|
);
|
|
1832
1812
|
delete data.SESSION_ID;
|
|
1833
1813
|
|
|
1834
1814
|
const jsonP = await func.index.call_worker(SESSION_ID, {
|
|
1835
|
-
service:
|
|
1815
|
+
service: 'datasource_create',
|
|
1836
1816
|
data,
|
|
1837
1817
|
id: SESSION_OBJ[SESSION_ID].worker_id,
|
|
1838
1818
|
});
|
|
@@ -1846,43 +1826,20 @@ func.datasource.create = async function (
|
|
|
1846
1826
|
return done(SESSION_ID, jsonP.dsSession, true);
|
|
1847
1827
|
});
|
|
1848
1828
|
};
|
|
1849
|
-
func.datasource.prepare = async function (
|
|
1850
|
-
SESSION_ID,
|
|
1851
|
-
prog_id,
|
|
1852
|
-
dataSourceNoP,
|
|
1853
|
-
parentDataSourceNoP,
|
|
1854
|
-
containerIdP,
|
|
1855
|
-
rowIdP,
|
|
1856
|
-
jobNoP,
|
|
1857
|
-
calling_trigger_prop,
|
|
1858
|
-
NA_screen_param,
|
|
1859
|
-
NA_isInitP,
|
|
1860
|
-
callingSourceP,
|
|
1861
|
-
calling_jobP,
|
|
1862
|
-
NA_screen_dsP,
|
|
1863
|
-
is_panelP,
|
|
1864
|
-
parameters_obj_inP,
|
|
1865
|
-
static_refreshP,
|
|
1866
|
-
run_atP,
|
|
1867
|
-
worker_id
|
|
1868
|
-
) {
|
|
1829
|
+
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) {
|
|
1869
1830
|
const set_parameters = async function () {
|
|
1870
1831
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1871
|
-
const get_Out_parameters = async function (
|
|
1872
|
-
fieldIdP,
|
|
1873
|
-
located_field_param_idxP,
|
|
1874
|
-
param_row_idP
|
|
1875
|
-
) {
|
|
1832
|
+
const get_Out_parameters = async function (fieldIdP, located_field_param_idxP, param_row_idP) {
|
|
1876
1833
|
var ret = parameters_obj_inP?.[fieldIdP] || fieldIdP;
|
|
1877
1834
|
|
|
1878
|
-
PARAM_OUT_INFO[prog_id +
|
|
1835
|
+
PARAM_OUT_INFO[prog_id + '_' + param_row_idP] = {
|
|
1879
1836
|
module: _ds.viewModule,
|
|
1880
|
-
action:
|
|
1881
|
-
prop:
|
|
1837
|
+
action: 'parameters',
|
|
1838
|
+
prop: 'out',
|
|
1882
1839
|
details: ret,
|
|
1883
1840
|
result: ret,
|
|
1884
1841
|
source: _ds.viewSourceDesc,
|
|
1885
|
-
type:
|
|
1842
|
+
type: 'parameters',
|
|
1886
1843
|
prog_id: prog_id,
|
|
1887
1844
|
dsSession: dataSourceSession,
|
|
1888
1845
|
fieldId: fieldIdP,
|
|
@@ -1901,34 +1858,24 @@ func.datasource.prepare = async function (
|
|
|
1901
1858
|
_ds.in_parameters = {};
|
|
1902
1859
|
_ds.out_parameters = {};
|
|
1903
1860
|
|
|
1904
|
-
for await (let [key, val] of Object.entries(
|
|
1905
|
-
screenInfo.properties?.progParams
|
|
1906
|
-
)) {
|
|
1861
|
+
for await (let [key, val] of Object.entries(screenInfo.properties?.progParams)) {
|
|
1907
1862
|
// run on parameters arr
|
|
1908
|
-
if (val.data.dir ===
|
|
1863
|
+
if (val.data.dir === 'in') {
|
|
1909
1864
|
_ds.in_parameters[val.data.parameter] = {
|
|
1910
1865
|
// value: parameters_obj_inP?.[val.data.parameter],
|
|
1911
1866
|
type: val.data.type,
|
|
1912
1867
|
};
|
|
1913
1868
|
|
|
1914
|
-
if (
|
|
1915
|
-
|
|
1916
|
-
) {
|
|
1917
|
-
_ds.in_parameters[val.data.parameter].value =
|
|
1918
|
-
parameters_obj_inP[val.data.parameter];
|
|
1919
|
-
} else if (_session.engine_mode === "live_preview") {
|
|
1920
|
-
_ds.in_parameters[val.data.parameter].value =
|
|
1921
|
-
_session?.url_params?.[val.data.parameter];
|
|
1869
|
+
if (typeof parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
|
|
1870
|
+
_ds.in_parameters[val.data.parameter].value = parameters_obj_inP[val.data.parameter];
|
|
1871
|
+
} else if (_session.engine_mode === 'live_preview') {
|
|
1872
|
+
_ds.in_parameters[val.data.parameter].value = _session?.url_params?.[val.data.parameter];
|
|
1922
1873
|
}
|
|
1923
1874
|
|
|
1924
1875
|
continue;
|
|
1925
1876
|
}
|
|
1926
|
-
if (val.data.dir ===
|
|
1927
|
-
_ds.out_parameters[val.data.parameter] = await get_Out_parameters(
|
|
1928
|
-
val.data.parameter,
|
|
1929
|
-
key,
|
|
1930
|
-
val.id
|
|
1931
|
-
);
|
|
1877
|
+
if (val.data.dir === 'out' && val.data.parameter) {
|
|
1878
|
+
_ds.out_parameters[val.data.parameter] = await get_Out_parameters(val.data.parameter, key, val.id);
|
|
1932
1879
|
}
|
|
1933
1880
|
}
|
|
1934
1881
|
|
|
@@ -1938,23 +1885,20 @@ func.datasource.prepare = async function (
|
|
|
1938
1885
|
};
|
|
1939
1886
|
const build_GLOBAL_SYS_fields = function () {
|
|
1940
1887
|
if (!_ds.data_system) _ds.data_system = {};
|
|
1941
|
-
_ds.data_system[
|
|
1942
|
-
_ds.data_system[
|
|
1943
|
-
_ds.data_system[
|
|
1944
|
-
_ds.data_system[
|
|
1888
|
+
_ds.data_system['SYS_GLOBAL_UTC'] = -new Date().getTimezoneOffset() / 60;
|
|
1889
|
+
_ds.data_system['SYS_GLOBAL_STR_APP_ID'] = APP_OBJ[_session.app_id]._id;
|
|
1890
|
+
_ds.data_system['SYS_GLOBAL_STR_SESSION_ID'] = SESSION_ID;
|
|
1891
|
+
_ds.data_system['SYS_GLOBAL_STR_LOGIN_USER_ID'] = _session.USR_OBJ._id;
|
|
1945
1892
|
|
|
1946
|
-
if (
|
|
1947
|
-
|
|
1948
|
-
PROJECT_OBJ[_session.app_id].info
|
|
1949
|
-
) {
|
|
1950
|
-
_ds.data_system["SYS_GLOBAL_OBJ_APP_INFO"] = {
|
|
1893
|
+
if (_session.engine_mode !== 'live_preview' && PROJECT_OBJ[_session.app_id].info) {
|
|
1894
|
+
_ds.data_system['SYS_GLOBAL_OBJ_APP_INFO'] = {
|
|
1951
1895
|
build: PROJECT_OBJ[_session.app_id].info.build_id,
|
|
1952
1896
|
author: PROJECT_OBJ[_session.app_id].info.author,
|
|
1953
1897
|
date: PROJECT_OBJ[_session.app_id].info.build_date,
|
|
1954
1898
|
name: APP_OBJ[_session.app_id].app_name,
|
|
1955
1899
|
};
|
|
1956
1900
|
}
|
|
1957
|
-
_ds.data_system[
|
|
1901
|
+
_ds.data_system['SYS_GLOBAL_OBJ_LOGIN_USER_INFO'] = {
|
|
1958
1902
|
id: _session.USR_OBJ._id,
|
|
1959
1903
|
user_name: _session.USR_OBJ.usr_name,
|
|
1960
1904
|
first_name: _session.USR_OBJ.usr_first_name,
|
|
@@ -1962,52 +1906,37 @@ func.datasource.prepare = async function (
|
|
|
1962
1906
|
email: _session.USR_OBJ.usr_email,
|
|
1963
1907
|
profile_picture: _session.USR_OBJ.usr_profile_picture,
|
|
1964
1908
|
};
|
|
1965
|
-
_ds.data_system[
|
|
1966
|
-
|
|
1967
|
-
_ds.data_system["SYS_GLOBAL_STR_BROWSER_TITLE"] =
|
|
1968
|
-
_session.SYS_GLOBAL_STR_BROWSER_TITLE;
|
|
1909
|
+
_ds.data_system['SYS_GLOBAL_STR_BROWSER_HASH_ID'] = _session.SYS_GLOBAL_STR_BROWSER_HASH_ID;
|
|
1910
|
+
_ds.data_system['SYS_GLOBAL_STR_BROWSER_TITLE'] = _session.SYS_GLOBAL_STR_BROWSER_TITLE;
|
|
1969
1911
|
// }
|
|
1970
|
-
_ds.data_system[
|
|
1971
|
-
_ds.data_system[
|
|
1972
|
-
_ds.data_system[
|
|
1973
|
-
_ds.data_system[
|
|
1974
|
-
_ds.data_system[
|
|
1912
|
+
_ds.data_system['SYS_GLOBAL_STR_SITE_CSS'] = {};
|
|
1913
|
+
_ds.data_system['SYS_GLOBAL_BOL_SHIFT_KEY_STATE'] = 0;
|
|
1914
|
+
_ds.data_system['SYS_GLOBAL_BOL_COMMAND_KEY_STATE'] = 0;
|
|
1915
|
+
_ds.data_system['SYS_GLOBAL_BOL_CONTROL_KEY_STATE'] = 0;
|
|
1916
|
+
_ds.data_system['SYS_GLOBAL_BOL_ALT_KEY_STATE'] = 0;
|
|
1975
1917
|
|
|
1976
|
-
_ds.data_system[
|
|
1977
|
-
_ds.data_system[
|
|
1978
|
-
_ds.data_system[
|
|
1979
|
-
_ds.data_system[
|
|
1980
|
-
_ds.data_system[
|
|
1918
|
+
_ds.data_system['SYS_GLOBAL_BOL_ONLINE'] = 0;
|
|
1919
|
+
_ds.data_system['SYS_GLOBAL_BOL_REPLICATION_STAT'] = 0;
|
|
1920
|
+
_ds.data_system['SYS_GLOBAL_BOL_AJAX_BUSY'] = 0;
|
|
1921
|
+
_ds.data_system['SYS_GLOBAL_BOL_CONNECTED'] = 1;
|
|
1922
|
+
_ds.data_system['SYS_GLOBAL_BOL_IDLE'] = 0;
|
|
1981
1923
|
|
|
1982
|
-
_ds.data_system[
|
|
1924
|
+
_ds.data_system['SYS_GLOBAL_STR_FIREBASE_TOKEN_ID'] = 0;
|
|
1983
1925
|
|
|
1984
|
-
_ds.data_system[
|
|
1985
|
-
_session.PUSH_NOTIFICATION_GRANTED;
|
|
1926
|
+
_ds.data_system['SYS_GLOBAL_BOL_PUSH_NOTIFICATION_GRANTED'] = _session.PUSH_NOTIFICATION_GRANTED;
|
|
1986
1927
|
|
|
1987
|
-
_ds.data_system[
|
|
1988
|
-
_session.SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO;
|
|
1928
|
+
_ds.data_system['SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO'] = _session.SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO;
|
|
1989
1929
|
|
|
1990
|
-
_ds.data_system[
|
|
1991
|
-
_session.SYS_GLOBAL_OBJ_CLIENT_INFO;
|
|
1930
|
+
_ds.data_system['SYS_GLOBAL_OBJ_CLIENT_INFO'] = _session.SYS_GLOBAL_OBJ_CLIENT_INFO;
|
|
1992
1931
|
};
|
|
1993
1932
|
if (!SESSION_OBJ[SESSION_ID].DS_GLB) return;
|
|
1994
1933
|
|
|
1995
1934
|
if (dataSourceNoP && !SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceNoP]) {
|
|
1996
|
-
return func.utils.debug_report(
|
|
1997
|
-
SESSION_ID,
|
|
1998
|
-
"Datasource",
|
|
1999
|
-
"Datasource not exist: " + dataSourceNoP,
|
|
2000
|
-
"E"
|
|
2001
|
-
);
|
|
1935
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Datasource not exist: ' + dataSourceNoP, 'E');
|
|
2002
1936
|
}
|
|
2003
1937
|
|
|
2004
1938
|
if (!prog_id) {
|
|
2005
|
-
return func.utils.debug_report(
|
|
2006
|
-
SESSION_ID,
|
|
2007
|
-
"Datasource",
|
|
2008
|
-
"Program is null",
|
|
2009
|
-
"E"
|
|
2010
|
-
);
|
|
1939
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Program is null', 'E');
|
|
2011
1940
|
}
|
|
2012
1941
|
|
|
2013
1942
|
const args = {
|
|
@@ -2033,18 +1962,13 @@ func.datasource.prepare = async function (
|
|
|
2033
1962
|
|
|
2034
1963
|
const init_dataSource = async function () {
|
|
2035
1964
|
const init_new_dataSource = async function () {
|
|
2036
|
-
if (
|
|
2037
|
-
!["main"].includes(SESSION_OBJ[SESSION_ID].opt.app_computing_mode) &&
|
|
2038
|
-
run_atP === "client" &&
|
|
2039
|
-
prog_id !== "system"
|
|
2040
|
-
) {
|
|
1965
|
+
if (!['main'].includes(SESSION_OBJ[SESSION_ID].opt.app_computing_mode) && run_atP === 'client' && prog_id !== 'system') {
|
|
2041
1966
|
const ret = await func.index.call_worker(SESSION_ID, {
|
|
2042
|
-
service:
|
|
1967
|
+
service: 'get_dataSourceSessionGlobal',
|
|
2043
1968
|
data: { session_id: SESSION_ID },
|
|
2044
1969
|
id: SESSION_OBJ[SESSION_ID].worker_id,
|
|
2045
1970
|
});
|
|
2046
|
-
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal =
|
|
2047
|
-
ret?.new_dataSourceSessionGlobal || 1;
|
|
1971
|
+
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal = ret?.new_dataSourceSessionGlobal || 1;
|
|
2048
1972
|
} else {
|
|
2049
1973
|
SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal++;
|
|
2050
1974
|
}
|
|
@@ -2055,7 +1979,7 @@ func.datasource.prepare = async function (
|
|
|
2055
1979
|
};
|
|
2056
1980
|
const init_existing_dataSource = function () {
|
|
2057
1981
|
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceNoP];
|
|
2058
|
-
console.log(
|
|
1982
|
+
console.log('DATASOURCE_REFRESH', dataSourceNoP);
|
|
2059
1983
|
IS_DATASOURCE_REFRESH = true;
|
|
2060
1984
|
_ds.refreshed = true;
|
|
2061
1985
|
try {
|
|
@@ -2068,13 +1992,13 @@ func.datasource.prepare = async function (
|
|
|
2068
1992
|
|
|
2069
1993
|
_ds.v.old_dataSource = _.cloneDeep(_ds);
|
|
2070
1994
|
} catch (err) {
|
|
2071
|
-
console.error(
|
|
1995
|
+
console.error('function: init_existing_dataSource - error');
|
|
2072
1996
|
return;
|
|
2073
1997
|
}
|
|
2074
1998
|
dataSourceSession = dataSourceNoP;
|
|
2075
1999
|
};
|
|
2076
2000
|
|
|
2077
|
-
if (typeof dataSourceNoP ===
|
|
2001
|
+
if (typeof dataSourceNoP === 'undefined' || dataSourceNoP === null) {
|
|
2078
2002
|
await init_new_dataSource();
|
|
2079
2003
|
} else {
|
|
2080
2004
|
init_existing_dataSource();
|
|
@@ -2084,7 +2008,7 @@ func.datasource.prepare = async function (
|
|
|
2084
2008
|
};
|
|
2085
2009
|
var _ds = await init_dataSource();
|
|
2086
2010
|
|
|
2087
|
-
_ds.stat =
|
|
2011
|
+
_ds.stat = 'busy';
|
|
2088
2012
|
_ds._run_at = run_atP;
|
|
2089
2013
|
// init_v();
|
|
2090
2014
|
|
|
@@ -2096,12 +2020,7 @@ func.datasource.prepare = async function (
|
|
|
2096
2020
|
_ds.tree_obj = await func.utils.TREE_OBJ.get(SESSION_ID, prog_id);
|
|
2097
2021
|
|
|
2098
2022
|
if (!_ds.tree_obj) {
|
|
2099
|
-
return func.utils.debug_report(
|
|
2100
|
-
SESSION_ID,
|
|
2101
|
-
"Datasource",
|
|
2102
|
-
"Program not exist: " + prog_id,
|
|
2103
|
-
"E"
|
|
2104
|
-
);
|
|
2023
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', 'Program not exist: ' + prog_id, 'E');
|
|
2105
2024
|
}
|
|
2106
2025
|
|
|
2107
2026
|
await func.datasource.set_VIEW_data(SESSION_ID, args, _ds);
|
|
@@ -2111,7 +2030,7 @@ func.datasource.prepare = async function (
|
|
|
2111
2030
|
) {
|
|
2112
2031
|
_ds.v.viewSourceDesc = callingSourceP;
|
|
2113
2032
|
}
|
|
2114
|
-
if (dataSourceSession === 0) _ds.v.viewSourceDesc =
|
|
2033
|
+
if (dataSourceSession === 0) _ds.v.viewSourceDesc = 'system startup';
|
|
2115
2034
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
2116
2035
|
|
|
2117
2036
|
const set_DS_GLB = async function () {
|
|
@@ -2137,7 +2056,7 @@ func.datasource.prepare = async function (
|
|
|
2137
2056
|
await set_DS_GLB();
|
|
2138
2057
|
|
|
2139
2058
|
if (
|
|
2140
|
-
prog_id ===
|
|
2059
|
+
prog_id === 'system' &&
|
|
2141
2060
|
!parentDataSourceNoP // do only on first time datasource 0 call
|
|
2142
2061
|
) {
|
|
2143
2062
|
build_GLOBAL_SYS_fields();
|
|
@@ -2152,18 +2071,10 @@ func.datasource.prepare = async function (
|
|
|
2152
2071
|
// INTERVALS
|
|
2153
2072
|
//======================================
|
|
2154
2073
|
|
|
2155
|
-
_ds.client_interval = func.datasource.get_event_interval_arr(
|
|
2156
|
-
SESSION_ID,
|
|
2157
|
-
dataSourceSession,
|
|
2158
|
-
"client_interval"
|
|
2159
|
-
);
|
|
2074
|
+
_ds.client_interval = func.datasource.get_event_interval_arr(SESSION_ID, dataSourceSession, 'client_interval');
|
|
2160
2075
|
|
|
2161
|
-
if (prog_id ===
|
|
2162
|
-
_ds.server_interval = func.datasource.get_event_interval_arr(
|
|
2163
|
-
SESSION_ID,
|
|
2164
|
-
dataSourceSession,
|
|
2165
|
-
"server_interval"
|
|
2166
|
-
);
|
|
2076
|
+
if (prog_id === 'system') {
|
|
2077
|
+
_ds.server_interval = func.datasource.get_event_interval_arr(SESSION_ID, dataSourceSession, 'server_interval');
|
|
2167
2078
|
}
|
|
2168
2079
|
|
|
2169
2080
|
// if (static_refreshP) {
|
|
@@ -2172,22 +2083,14 @@ func.datasource.prepare = async function (
|
|
|
2172
2083
|
// if (!static_refreshP) await set_parameters(); // do only on new datasource or refresh
|
|
2173
2084
|
|
|
2174
2085
|
// try {
|
|
2175
|
-
let ret_execute = await func.datasource.execute(
|
|
2176
|
-
SESSION_ID,
|
|
2177
|
-
dataSourceSession
|
|
2178
|
-
);
|
|
2086
|
+
let ret_execute = await func.datasource.execute(SESSION_ID, dataSourceSession);
|
|
2179
2087
|
return ret_execute;
|
|
2180
2088
|
// } catch (e) {
|
|
2181
2089
|
// console.error(e);
|
|
2182
2090
|
// }
|
|
2183
2091
|
};
|
|
2184
2092
|
|
|
2185
|
-
func.datasource.execute = async function (
|
|
2186
|
-
SESSION_ID,
|
|
2187
|
-
dataSourceSession,
|
|
2188
|
-
IS_DATASOURCE_REFRESH
|
|
2189
|
-
) {
|
|
2190
|
-
|
|
2093
|
+
func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATASOURCE_REFRESH) {
|
|
2191
2094
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
2192
2095
|
var _ds = _session.DS_GLB[dataSourceSession];
|
|
2193
2096
|
var args = _ds.args;
|
|
@@ -2196,60 +2099,32 @@ func.datasource.execute = async function (
|
|
|
2196
2099
|
let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
2197
2100
|
|
|
2198
2101
|
const callback_datasource = async function () {
|
|
2199
|
-
if (typeof IS_WORKER ===
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
if (!["main"].includes(_session.opt.app_computing_mode)) {
|
|
2102
|
+
if (typeof IS_WORKER === 'undefined' && typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined' && _ds.viewSourceProp === 'globals') {
|
|
2103
|
+
if (!['main'].includes(_session.opt.app_computing_mode)) {
|
|
2203
2104
|
await func.index.call_worker(SESSION_ID, {
|
|
2204
|
-
service:
|
|
2105
|
+
service: 'create_webworker_globals',
|
|
2205
2106
|
data: { ds_data: _ds, session_id: SESSION_ID },
|
|
2206
2107
|
});
|
|
2207
2108
|
}
|
|
2208
2109
|
}
|
|
2209
2110
|
|
|
2210
|
-
if (
|
|
2211
|
-
await func.datasource.
|
|
2212
|
-
SESSION_ID,
|
|
2213
|
-
dataSourceSession,
|
|
2214
|
-
"on_load"
|
|
2215
|
-
)
|
|
2216
|
-
) {
|
|
2217
|
-
await func.datasource.execute_view_events(
|
|
2218
|
-
SESSION_ID,
|
|
2219
|
-
dataSourceSession,
|
|
2220
|
-
"on_load"
|
|
2221
|
-
);
|
|
2111
|
+
if (await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'on_load')) {
|
|
2112
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'on_load');
|
|
2222
2113
|
}
|
|
2223
2114
|
// }
|
|
2224
|
-
return func.datasource.callback(
|
|
2225
|
-
SESSION_ID,
|
|
2226
|
-
dataSourceSession,
|
|
2227
|
-
args.dataSourceNoP,
|
|
2228
|
-
args.rowIdP,
|
|
2229
|
-
args.jobNoP,
|
|
2230
|
-
null,
|
|
2231
|
-
_ds.prog_id
|
|
2232
|
-
);
|
|
2115
|
+
return await func.datasource.callback(SESSION_ID, dataSourceSession, args.dataSourceNoP, args.rowIdP, args.jobNoP, null, _ds.prog_id);
|
|
2233
2116
|
};
|
|
2234
2117
|
|
|
2235
2118
|
const get_limit = async function () {
|
|
2236
2119
|
var ret = 0;
|
|
2237
2120
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
2238
|
-
if (tree_ret.menuType ===
|
|
2121
|
+
if (tree_ret.menuType === 'get_data') {
|
|
2239
2122
|
return 1;
|
|
2240
2123
|
}
|
|
2241
2124
|
ret = _ds.progDataSource?.dataSourceLimit;
|
|
2242
2125
|
|
|
2243
2126
|
if (prog_obj.progDataSource?.dataSourceLoopExp) {
|
|
2244
|
-
ret = (
|
|
2245
|
-
await func.expression.get(
|
|
2246
|
-
SESSION_ID,
|
|
2247
|
-
prog_obj.progDataSource.dataSourceLoopExp,
|
|
2248
|
-
dataSourceSession,
|
|
2249
|
-
"view_loop",
|
|
2250
|
-
args.rowIdP
|
|
2251
|
-
)
|
|
2252
|
-
).result;
|
|
2127
|
+
ret = (await func.expression.get(SESSION_ID, prog_obj.progDataSource.dataSourceLoopExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
2253
2128
|
}
|
|
2254
2129
|
return ret;
|
|
2255
2130
|
};
|
|
@@ -2259,24 +2134,13 @@ func.datasource.execute = async function (
|
|
|
2259
2134
|
ret = _ds.progDataSource?.dataSourceSkip;
|
|
2260
2135
|
|
|
2261
2136
|
if (prog_obj.progDataSource?.dataSourceSkipExp) {
|
|
2262
|
-
ret = (
|
|
2263
|
-
await func.expression.get(
|
|
2264
|
-
SESSION_ID,
|
|
2265
|
-
prog_obj.progDataSource.dataSourceSkipExp,
|
|
2266
|
-
dataSourceSession,
|
|
2267
|
-
"view_loop",
|
|
2268
|
-
args.rowIdP
|
|
2269
|
-
)
|
|
2270
|
-
).result;
|
|
2137
|
+
ret = (await func.expression.get(SESSION_ID, prog_obj.progDataSource.dataSourceSkipExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
2271
2138
|
}
|
|
2272
2139
|
return ret;
|
|
2273
2140
|
};
|
|
2274
2141
|
|
|
2275
2142
|
const calc_batch_loops = async () => {
|
|
2276
|
-
if (
|
|
2277
|
-
!prog_obj.progDataSource?.dataSourceType ||
|
|
2278
|
-
_ds.progDataSource.dataSourceType === "none"
|
|
2279
|
-
) {
|
|
2143
|
+
if (!prog_obj.progDataSource?.dataSourceType || _ds.progDataSource.dataSourceType === 'none') {
|
|
2280
2144
|
_ds.v.batch_loops = await get_limit();
|
|
2281
2145
|
return false;
|
|
2282
2146
|
}
|
|
@@ -2285,10 +2149,7 @@ func.datasource.execute = async function (
|
|
|
2285
2149
|
// ? await get_limit()
|
|
2286
2150
|
// : _ds?.data_feed?.rows?.length;
|
|
2287
2151
|
|
|
2288
|
-
_ds.v.batch_loops =
|
|
2289
|
-
(await get_limit()) <= _ds.v.raw_data?.rows?.length
|
|
2290
|
-
? await get_limit()
|
|
2291
|
-
: _ds.v.raw_data?.rows?.length;
|
|
2152
|
+
_ds.v.batch_loops = (await get_limit()) <= _ds.v.raw_data?.rows?.length ? await get_limit() : _ds.v.raw_data?.rows?.length;
|
|
2292
2153
|
return true;
|
|
2293
2154
|
// _ds.v.batch_loops =
|
|
2294
2155
|
// (await get_limit()) <= _ds.v?.raw_data?.rows?.length
|
|
@@ -2299,54 +2160,39 @@ func.datasource.execute = async function (
|
|
|
2299
2160
|
|
|
2300
2161
|
const render_api_output = async function () {
|
|
2301
2162
|
if (prog_obj?.scriptData?.value) {
|
|
2302
|
-
var exp = await func.expression.get(
|
|
2303
|
-
SESSION_ID,
|
|
2304
|
-
prog_obj.scriptData.value,
|
|
2305
|
-
dataSourceSession,
|
|
2306
|
-
"api_rendered_output",
|
|
2307
|
-
null, null, null, null, null, null, null, null, null, tree_obj.apiOutput
|
|
2308
|
-
);
|
|
2163
|
+
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);
|
|
2309
2164
|
|
|
2310
|
-
let output_result = exp.result
|
|
2311
|
-
if (tree_obj.apiOutput ===
|
|
2165
|
+
let output_result = exp.result;
|
|
2166
|
+
if (tree_obj.apiOutput === 'json') {
|
|
2312
2167
|
// iterate object to fix expressions
|
|
2313
2168
|
try {
|
|
2314
2169
|
// let output_result_obj = JSON5.parse(output_result)
|
|
2315
|
-
let output_result_obj = await func.expression.secure_eval(
|
|
2316
|
-
SESSION_ID,
|
|
2317
|
-
"api_rendered_output",
|
|
2318
|
-
"(" + output_result + ")",
|
|
2319
|
-
null,
|
|
2320
|
-
dataSourceSession,
|
|
2321
|
-
|
|
2322
|
-
);
|
|
2170
|
+
let output_result_obj = await func.expression.secure_eval(SESSION_ID, 'api_rendered_output', '(' + output_result + ')', null, dataSourceSession);
|
|
2323
2171
|
// for await (let [key, val] of Object.entries(output_result_obj)) {
|
|
2324
2172
|
// output_result_obj[key] = (await func.expression.get(
|
|
2325
2173
|
// SESSION_ID,
|
|
2326
2174
|
// val,
|
|
2327
2175
|
// dataSourceSession, "object_property")).result
|
|
2328
2176
|
// }
|
|
2329
|
-
output_result = JSON.stringify(output_result_obj)
|
|
2177
|
+
output_result = JSON.stringify(output_result_obj);
|
|
2330
2178
|
} catch (err) {
|
|
2331
|
-
console.error(err)
|
|
2179
|
+
console.error(err);
|
|
2332
2180
|
}
|
|
2333
|
-
|
|
2334
2181
|
}
|
|
2335
|
-
_ds.api_rendered_output +=
|
|
2336
|
-
output_result + (tree_obj.apiOutput === "json" ? "," : "");
|
|
2182
|
+
_ds.api_rendered_output += output_result + (tree_obj.apiOutput === 'json' ? ',' : '');
|
|
2337
2183
|
} else {
|
|
2338
|
-
_ds.api_rendered_output =
|
|
2184
|
+
_ds.api_rendered_output = ''; //empty
|
|
2339
2185
|
}
|
|
2340
2186
|
};
|
|
2341
2187
|
|
|
2342
2188
|
// ======================================
|
|
2343
2189
|
// COMPUTE GLOBALS
|
|
2344
2190
|
// ======================================
|
|
2345
|
-
if (_ds.prog_id ===
|
|
2191
|
+
if (_ds.prog_id === 'system') {
|
|
2346
2192
|
//TBD tree_obj.menuType === "globals"
|
|
2347
|
-
_ds.currentRecordId =
|
|
2193
|
+
_ds.currentRecordId = 'dataset';
|
|
2348
2194
|
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, {
|
|
2349
|
-
id:
|
|
2195
|
+
id: 'dataset',
|
|
2350
2196
|
value: _session.url_params,
|
|
2351
2197
|
});
|
|
2352
2198
|
|
|
@@ -2359,47 +2205,31 @@ func.datasource.execute = async function (
|
|
|
2359
2205
|
let db_adapter_module;
|
|
2360
2206
|
|
|
2361
2207
|
if (prog_obj.progDataSource?.dataSourceType) {
|
|
2362
|
-
db_adapter_module = await func.common.get_module(
|
|
2363
|
-
SESSION_ID,
|
|
2364
|
-
"xuda-datasource-db-adapter-module.mjs"
|
|
2365
|
-
);
|
|
2208
|
+
db_adapter_module = await func.common.get_module(SESSION_ID, 'xuda-datasource-db-adapter-module.mjs');
|
|
2366
2209
|
}
|
|
2367
2210
|
|
|
2368
2211
|
const get_data_from_source = async function () {
|
|
2369
2212
|
switch (prog_obj.progDataSource.dataSourceSrcType) {
|
|
2370
|
-
case
|
|
2371
|
-
const { result, error } = await func.expression.get(
|
|
2372
|
-
SESSION_ID,
|
|
2373
|
-
prog_obj.progDataSource.progDataSourceInput,
|
|
2374
|
-
dataSourceSession,
|
|
2375
|
-
"datasource select"
|
|
2376
|
-
);
|
|
2213
|
+
case 'input': {
|
|
2214
|
+
const { result, error } = await func.expression.get(SESSION_ID, prog_obj.progDataSource.progDataSourceInput, dataSourceSession, 'datasource select');
|
|
2377
2215
|
if (error) {
|
|
2378
|
-
func.utils.debug_report(
|
|
2379
|
-
SESSION_ID,
|
|
2380
|
-
"Data source",
|
|
2381
|
-
`Datasource parse error using ${prog_obj.progDataSource?.dataSourceType} input`,
|
|
2382
|
-
"E"
|
|
2383
|
-
);
|
|
2216
|
+
func.utils.debug_report(SESSION_ID, 'Data source', `Datasource parse error using ${prog_obj.progDataSource?.dataSourceType} input`, 'E');
|
|
2384
2217
|
return null;
|
|
2385
2218
|
}
|
|
2386
2219
|
|
|
2387
2220
|
return result;
|
|
2388
2221
|
break;
|
|
2389
2222
|
}
|
|
2390
|
-
case
|
|
2223
|
+
case 'url': {
|
|
2391
2224
|
let opt = {
|
|
2392
|
-
method: prog_obj.progDataSource.dataSourceMethod ||
|
|
2225
|
+
method: prog_obj.progDataSource.dataSourceMethod || 'POST',
|
|
2393
2226
|
headers: {
|
|
2394
|
-
Accept:
|
|
2395
|
-
|
|
2227
|
+
Accept: 'application/json',
|
|
2228
|
+
'Content-Type': 'application/json',
|
|
2396
2229
|
},
|
|
2397
2230
|
};
|
|
2398
2231
|
let data = {};
|
|
2399
|
-
if (
|
|
2400
|
-
prog_obj.progDataSource.dataSourceMethod == "POST" &&
|
|
2401
|
-
prog_obj.progDataSource.dataSourceParameters
|
|
2402
|
-
) {
|
|
2232
|
+
if (prog_obj.progDataSource.dataSourceMethod == 'POST' && prog_obj.progDataSource.dataSourceParameters) {
|
|
2403
2233
|
for (let val of prog_obj.progDataSource.dataSourceParameters) {
|
|
2404
2234
|
data[val.key] = val.val;
|
|
2405
2235
|
}
|
|
@@ -2407,21 +2237,11 @@ func.datasource.execute = async function (
|
|
|
2407
2237
|
opt.body = JSON.stringify(data);
|
|
2408
2238
|
}
|
|
2409
2239
|
try {
|
|
2410
|
-
const response = await fetch(
|
|
2411
|
-
"https://" + prog_obj.progDataSource.dataSourceDataUrl,
|
|
2412
|
-
opt
|
|
2413
|
-
);
|
|
2240
|
+
const response = await fetch('https://' + prog_obj.progDataSource.dataSourceDataUrl, opt);
|
|
2414
2241
|
const json = await response.json();
|
|
2415
2242
|
return json.data;
|
|
2416
2243
|
} catch (err) {
|
|
2417
|
-
func.utils.debug_report(
|
|
2418
|
-
SESSION_ID,
|
|
2419
|
-
"Data source",
|
|
2420
|
-
err.message +
|
|
2421
|
-
" https://" +
|
|
2422
|
-
prog_obj.progDataSource.dataSourceDataUrl,
|
|
2423
|
-
"E"
|
|
2424
|
-
);
|
|
2244
|
+
func.utils.debug_report(SESSION_ID, 'Data source', err.message + ' https://' + prog_obj.progDataSource.dataSourceDataUrl, 'E');
|
|
2425
2245
|
return null;
|
|
2426
2246
|
}
|
|
2427
2247
|
|
|
@@ -2441,76 +2261,37 @@ func.datasource.execute = async function (
|
|
|
2441
2261
|
_ds.data_feed.rows = [];
|
|
2442
2262
|
|
|
2443
2263
|
switch (prog_obj.progDataSource?.dataSourceType) {
|
|
2444
|
-
case
|
|
2264
|
+
case 'table':
|
|
2445
2265
|
_ds._dataSourceTableId = prog_obj.progDataSource?.dataSourceTableId; // get file id
|
|
2446
2266
|
|
|
2447
2267
|
if (prog_obj.progDataSource?.dataSourceTableIdExp) {
|
|
2448
|
-
_ds.v.dataSourceTableIdExp = await func.expression.get(
|
|
2449
|
-
SESSION_ID,
|
|
2450
|
-
prog_obj.progDataSource?.dataSourceTableIdExp,
|
|
2451
|
-
dataSourceSession,
|
|
2452
|
-
"dataSourceTableIdExp",
|
|
2453
|
-
args.rowIdP
|
|
2454
|
-
);
|
|
2268
|
+
_ds.v.dataSourceTableIdExp = await func.expression.get(SESSION_ID, prog_obj.progDataSource?.dataSourceTableIdExp, dataSourceSession, 'dataSourceTableIdExp', args.rowIdP);
|
|
2455
2269
|
if (_ds.v.dataSourceTableIdExp.result) {
|
|
2456
2270
|
_ds._dataSourceTableId = _ds.v.dataSourceTableIdExp.result;
|
|
2457
2271
|
} else {
|
|
2458
|
-
func.utils.debug_report(
|
|
2459
|
-
SESSION_ID,
|
|
2460
|
-
"get_VIEW_data",
|
|
2461
|
-
"Table Expression returned empty result",
|
|
2462
|
-
"W"
|
|
2463
|
-
);
|
|
2272
|
+
func.utils.debug_report(SESSION_ID, 'get_VIEW_data', 'Table Expression returned empty result', 'W');
|
|
2464
2273
|
}
|
|
2465
2274
|
}
|
|
2466
2275
|
|
|
2467
2276
|
if (!_ds._dataSourceTableId) {
|
|
2468
|
-
return func.utils.debug_report(
|
|
2469
|
-
SESSION_ID,
|
|
2470
|
-
"Data source",
|
|
2471
|
-
"Table cannot be empty when Db Table selected",
|
|
2472
|
-
"E"
|
|
2473
|
-
);
|
|
2277
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Table cannot be empty when Db Table selected', 'E');
|
|
2474
2278
|
}
|
|
2475
2279
|
|
|
2476
|
-
let table_ret = await func.utils.TREE_OBJ.get(
|
|
2477
|
-
SESSION_ID,
|
|
2478
|
-
_ds._dataSourceTableId
|
|
2479
|
-
);
|
|
2280
|
+
let table_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
2480
2281
|
if (!table_ret) {
|
|
2481
|
-
return func.utils.debug_report(
|
|
2482
|
-
SESSION_ID,
|
|
2483
|
-
"Data source",
|
|
2484
|
-
"Table not found: " + _ds._dataSourceTableId,
|
|
2485
|
-
"E"
|
|
2486
|
-
);
|
|
2282
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Table not found: ' + _ds._dataSourceTableId, 'E');
|
|
2487
2283
|
}
|
|
2488
2284
|
|
|
2489
|
-
await db_adapter_module.build_filter(
|
|
2490
|
-
SESSION_ID,
|
|
2491
|
-
dataSourceSession,
|
|
2492
|
-
_ds.v,
|
|
2493
|
-
_ds
|
|
2494
|
-
);
|
|
2285
|
+
await db_adapter_module.build_filter(SESSION_ID, dataSourceSession, _ds.v, _ds);
|
|
2495
2286
|
|
|
2496
2287
|
let filterModelMongo = _ds.progDataSource.filterModelMongo;
|
|
2497
2288
|
if (_ds.progDataSource.filterModelMongoFx) {
|
|
2498
|
-
let ret = await func.expression.get(
|
|
2499
|
-
SESSION_ID,
|
|
2500
|
-
_ds.progDataSource.filterModelMongoFx,
|
|
2501
|
-
dataSourceSession,
|
|
2502
|
-
"query"
|
|
2503
|
-
);
|
|
2289
|
+
let ret = await func.expression.get(SESSION_ID, _ds.progDataSource.filterModelMongoFx, dataSourceSession, 'query');
|
|
2504
2290
|
filterModelMongo = ret.result;
|
|
2505
2291
|
}
|
|
2506
2292
|
let filterModelSql = _ds.progDataSource.filterModelSql;
|
|
2507
2293
|
if (_ds.progDataSource.filterModelSqlFx) {
|
|
2508
|
-
let ret = await func.expression.get(
|
|
2509
|
-
SESSION_ID,
|
|
2510
|
-
_ds.progDataSource.filterModelSqlFx,
|
|
2511
|
-
dataSourceSession,
|
|
2512
|
-
"query"
|
|
2513
|
-
);
|
|
2294
|
+
let ret = await func.expression.get(SESSION_ID, _ds.progDataSource.filterModelSqlFx, dataSourceSession, 'query');
|
|
2514
2295
|
filterModelSql = ret.result;
|
|
2515
2296
|
}
|
|
2516
2297
|
|
|
@@ -2530,7 +2311,7 @@ func.datasource.execute = async function (
|
|
|
2530
2311
|
_ds.v.couchView,
|
|
2531
2312
|
dataSourceSession,
|
|
2532
2313
|
_ds.viewSourceDesc,
|
|
2533
|
-
|
|
2314
|
+
'datasource table',
|
|
2534
2315
|
prog_obj.progDataSource.dataSourceReduce,
|
|
2535
2316
|
await get_skip(),
|
|
2536
2317
|
(await get_limit()) || 99999999,
|
|
@@ -2539,7 +2320,7 @@ func.datasource.execute = async function (
|
|
|
2539
2320
|
_ds?.progDataSource?.sortModel,
|
|
2540
2321
|
null,
|
|
2541
2322
|
filterModel,
|
|
2542
|
-
_ds?.progDataSource?.dataSourceFilterModelType
|
|
2323
|
+
_ds?.progDataSource?.dataSourceFilterModelType,
|
|
2543
2324
|
);
|
|
2544
2325
|
if (_ds?.progDataSource?.dataSourceLimit) {
|
|
2545
2326
|
const ret_rows_found = await func.db.get_query(
|
|
@@ -2548,7 +2329,7 @@ func.datasource.execute = async function (
|
|
|
2548
2329
|
_ds.v.couchView,
|
|
2549
2330
|
dataSourceSession,
|
|
2550
2331
|
_ds.viewSourceDesc,
|
|
2551
|
-
|
|
2332
|
+
'datasource table',
|
|
2552
2333
|
prog_obj.progDataSource.dataSourceReduce,
|
|
2553
2334
|
null,
|
|
2554
2335
|
null,
|
|
@@ -2557,7 +2338,7 @@ func.datasource.execute = async function (
|
|
|
2557
2338
|
null,
|
|
2558
2339
|
null,
|
|
2559
2340
|
filterModel,
|
|
2560
|
-
_ds?.progDataSource?.dataSourceFilterModelType
|
|
2341
|
+
_ds?.progDataSource?.dataSourceFilterModelType,
|
|
2561
2342
|
);
|
|
2562
2343
|
_ds.rows_found = ret_rows_found?.rows?.[0]?.value || 0;
|
|
2563
2344
|
} else {
|
|
@@ -2565,7 +2346,7 @@ func.datasource.execute = async function (
|
|
|
2565
2346
|
}
|
|
2566
2347
|
break;
|
|
2567
2348
|
|
|
2568
|
-
case
|
|
2349
|
+
case 'array': {
|
|
2569
2350
|
let data = await get_data_from_source();
|
|
2570
2351
|
|
|
2571
2352
|
if (data === null) {
|
|
@@ -2591,7 +2372,7 @@ func.datasource.execute = async function (
|
|
|
2591
2372
|
break;
|
|
2592
2373
|
}
|
|
2593
2374
|
|
|
2594
|
-
case
|
|
2375
|
+
case 'json': {
|
|
2595
2376
|
let data = await get_data_from_source();
|
|
2596
2377
|
if (data === null) {
|
|
2597
2378
|
data = {};
|
|
@@ -2612,12 +2393,10 @@ func.datasource.execute = async function (
|
|
|
2612
2393
|
break;
|
|
2613
2394
|
}
|
|
2614
2395
|
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
case "csv":
|
|
2396
|
+
case 'csv':
|
|
2618
2397
|
let data = await get_data_from_source();
|
|
2619
2398
|
if (data === null) {
|
|
2620
|
-
data =
|
|
2399
|
+
data = '';
|
|
2621
2400
|
}
|
|
2622
2401
|
|
|
2623
2402
|
// if (!_ds.v.raw_data) {
|
|
@@ -2636,7 +2415,7 @@ func.datasource.execute = async function (
|
|
|
2636
2415
|
// }
|
|
2637
2416
|
|
|
2638
2417
|
let _KEY = 0;
|
|
2639
|
-
let arr = data.split(
|
|
2418
|
+
let arr = data.split(',');
|
|
2640
2419
|
for (const _VAL of arr) {
|
|
2641
2420
|
_ds.v.raw_data.rows.push({ id: _KEY, value: { _KEY, _VAL } });
|
|
2642
2421
|
_KEY++;
|
|
@@ -2655,24 +2434,16 @@ func.datasource.execute = async function (
|
|
|
2655
2434
|
let ret;
|
|
2656
2435
|
|
|
2657
2436
|
const get_before_record_count = async () => {
|
|
2658
|
-
return await func.datasource.get_view_events_count(
|
|
2659
|
-
SESSION_ID,
|
|
2660
|
-
dataSourceSession,
|
|
2661
|
-
"before_record"
|
|
2662
|
-
);
|
|
2437
|
+
return await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'before_record');
|
|
2663
2438
|
};
|
|
2664
2439
|
const get_after_record_count = async () => {
|
|
2665
|
-
return await func.datasource.get_view_events_count(
|
|
2666
|
-
SESSION_ID,
|
|
2667
|
-
dataSourceSession,
|
|
2668
|
-
"after_record"
|
|
2669
|
-
);
|
|
2440
|
+
return await func.datasource.get_view_events_count(SESSION_ID, dataSourceSession, 'after_record');
|
|
2670
2441
|
};
|
|
2671
2442
|
|
|
2672
2443
|
let _raw_data_rows = [];
|
|
2673
2444
|
switch (tree_obj.menuType) {
|
|
2674
|
-
case
|
|
2675
|
-
_ds.api_rendered_output =
|
|
2445
|
+
case 'api': {
|
|
2446
|
+
_ds.api_rendered_output = '';
|
|
2676
2447
|
let has_datasource = await calc_batch_loops();
|
|
2677
2448
|
|
|
2678
2449
|
_raw_data_rows = _ds.v.raw_data.rows || [];
|
|
@@ -2681,7 +2452,7 @@ func.datasource.execute = async function (
|
|
|
2681
2452
|
_raw_data_rows.push({ id: n, value: {} });
|
|
2682
2453
|
}
|
|
2683
2454
|
}
|
|
2684
|
-
_ds.currentRecordId =
|
|
2455
|
+
_ds.currentRecordId = 'dataset';
|
|
2685
2456
|
for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
|
|
2686
2457
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
2687
2458
|
|
|
@@ -2690,47 +2461,31 @@ func.datasource.execute = async function (
|
|
|
2690
2461
|
}
|
|
2691
2462
|
|
|
2692
2463
|
if (await get_before_record_count()) {
|
|
2693
|
-
await func.datasource.execute_view_events(
|
|
2694
|
-
SESSION_ID,
|
|
2695
|
-
dataSourceSession,
|
|
2696
|
-
"before_record"
|
|
2697
|
-
);
|
|
2464
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
2698
2465
|
}
|
|
2699
2466
|
|
|
2700
|
-
await func.datasource.render_fields_dataset(
|
|
2701
|
-
SESSION_ID,
|
|
2702
|
-
dataSourceSession,
|
|
2703
|
-
raw_data_row
|
|
2704
|
-
);
|
|
2467
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
2705
2468
|
|
|
2706
2469
|
if (await get_after_record_count()) {
|
|
2707
|
-
await func.datasource.execute_view_events(
|
|
2708
|
-
SESSION_ID,
|
|
2709
|
-
dataSourceSession,
|
|
2710
|
-
"after_record"
|
|
2711
|
-
);
|
|
2470
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
2712
2471
|
}
|
|
2713
2472
|
|
|
2714
2473
|
await render_api_output();
|
|
2715
2474
|
}
|
|
2716
2475
|
|
|
2717
|
-
if (tree_obj.apiOutput ===
|
|
2718
|
-
var str = _ds.api_rendered_output.substring(
|
|
2719
|
-
0,
|
|
2720
|
-
_ds.api_rendered_output.length - 1
|
|
2721
|
-
);
|
|
2476
|
+
if (tree_obj.apiOutput === 'json') {
|
|
2477
|
+
var str = _ds.api_rendered_output.substring(0, _ds.api_rendered_output.length - 1);
|
|
2722
2478
|
if (Number(_ds.progDataSource?.dataSourceLimit) === 1) {
|
|
2723
2479
|
_ds.api_rendered_output = str;
|
|
2724
2480
|
} else {
|
|
2725
|
-
_ds.api_rendered_output =
|
|
2481
|
+
_ds.api_rendered_output = '[' + str + ']';
|
|
2726
2482
|
}
|
|
2727
2483
|
}
|
|
2728
2484
|
|
|
2729
2485
|
break;
|
|
2730
2486
|
}
|
|
2731
2487
|
|
|
2732
|
-
case
|
|
2733
|
-
|
|
2488
|
+
case 'batch': {
|
|
2734
2489
|
let has_datasource = await calc_batch_loops();
|
|
2735
2490
|
|
|
2736
2491
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
@@ -2739,7 +2494,7 @@ func.datasource.execute = async function (
|
|
|
2739
2494
|
_raw_data_rows.push({ id: n, value: {} });
|
|
2740
2495
|
}
|
|
2741
2496
|
}
|
|
2742
|
-
_ds.currentRecordId =
|
|
2497
|
+
_ds.currentRecordId = 'dataset';
|
|
2743
2498
|
for await (let [key, raw_data_row] of Object.entries(_raw_data_rows)) {
|
|
2744
2499
|
if (has_datasource && Number(key) >= _ds.v.batch_loops) break;
|
|
2745
2500
|
|
|
@@ -2748,68 +2503,35 @@ func.datasource.execute = async function (
|
|
|
2748
2503
|
}
|
|
2749
2504
|
|
|
2750
2505
|
if (await get_before_record_count()) {
|
|
2751
|
-
await func.datasource.execute_view_events(
|
|
2752
|
-
SESSION_ID,
|
|
2753
|
-
dataSourceSession,
|
|
2754
|
-
"before_record"
|
|
2755
|
-
);
|
|
2506
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
2756
2507
|
}
|
|
2757
2508
|
|
|
2758
|
-
await func.datasource.render_fields_dataset(
|
|
2759
|
-
SESSION_ID,
|
|
2760
|
-
dataSourceSession,
|
|
2761
|
-
raw_data_row
|
|
2762
|
-
);
|
|
2509
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
2763
2510
|
|
|
2764
2511
|
if (await get_after_record_count()) {
|
|
2765
|
-
await func.datasource.execute_view_events(
|
|
2766
|
-
SESSION_ID,
|
|
2767
|
-
dataSourceSession,
|
|
2768
|
-
"after_record"
|
|
2769
|
-
);
|
|
2512
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
2770
2513
|
}
|
|
2771
2514
|
}
|
|
2772
2515
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
2773
2516
|
break;
|
|
2774
2517
|
}
|
|
2775
2518
|
|
|
2776
|
-
case
|
|
2519
|
+
case 'get_data':
|
|
2777
2520
|
if (await get_before_record_count()) {
|
|
2778
|
-
await func.datasource.execute_view_events(
|
|
2779
|
-
SESSION_ID,
|
|
2780
|
-
dataSourceSession,
|
|
2781
|
-
"before_record"
|
|
2782
|
-
);
|
|
2521
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
2783
2522
|
}
|
|
2784
2523
|
|
|
2785
|
-
ret = await db_adapter_module.process_view_dataset(
|
|
2786
|
-
SESSION_ID,
|
|
2787
|
-
dataSourceSession,
|
|
2788
|
-
_ds
|
|
2789
|
-
);
|
|
2524
|
+
ret = await db_adapter_module.process_view_dataset(SESSION_ID, dataSourceSession, _ds);
|
|
2790
2525
|
|
|
2791
2526
|
if (await get_after_record_count()) {
|
|
2792
|
-
await func.datasource.execute_view_events(
|
|
2793
|
-
SESSION_ID,
|
|
2794
|
-
dataSourceSession,
|
|
2795
|
-
"after_record"
|
|
2796
|
-
);
|
|
2527
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
2797
2528
|
}
|
|
2798
2529
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
2799
2530
|
break;
|
|
2800
2531
|
|
|
2801
|
-
case
|
|
2802
|
-
if (
|
|
2803
|
-
|
|
2804
|
-
_ds.progDataSource.dataSourceType !== "table" ||
|
|
2805
|
-
!_ds._dataSourceTableId
|
|
2806
|
-
) {
|
|
2807
|
-
return func.utils.debug_report(
|
|
2808
|
-
SESSION_ID,
|
|
2809
|
-
"Data source",
|
|
2810
|
-
"Datasource DB Table must be defined for Set Data operation",
|
|
2811
|
-
"E"
|
|
2812
|
-
);
|
|
2532
|
+
case 'set_data':
|
|
2533
|
+
if (!prog_obj.progDataSource?.dataSourceType || _ds.progDataSource.dataSourceType !== 'table' || !_ds._dataSourceTableId) {
|
|
2534
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Datasource DB Table must be defined for Set Data operation', 'E');
|
|
2813
2535
|
}
|
|
2814
2536
|
|
|
2815
2537
|
// const get_data_from_data_feed = function () {
|
|
@@ -2824,7 +2546,7 @@ func.datasource.execute = async function (
|
|
|
2824
2546
|
|
|
2825
2547
|
const find_ROWID_idx_from_raw_data_arr = function (rowId) {
|
|
2826
2548
|
if (!_raw_data_rows) {
|
|
2827
|
-
throw new Error(
|
|
2549
|
+
throw new Error('_raw_data_rows not found');
|
|
2828
2550
|
}
|
|
2829
2551
|
|
|
2830
2552
|
const index = _raw_data_rows.findIndex((item) => item.id === rowId);
|
|
@@ -2834,81 +2556,62 @@ func.datasource.execute = async function (
|
|
|
2834
2556
|
return index;
|
|
2835
2557
|
};
|
|
2836
2558
|
|
|
2837
|
-
if (tree_obj.crudMode ===
|
|
2838
|
-
_ds.set_mode =
|
|
2559
|
+
if (tree_obj.crudMode === 'U') {
|
|
2560
|
+
_ds.set_mode = 'U';
|
|
2839
2561
|
// _raw_data_rows = get_data_from_data_feed(); // _ds?.raw_data?.rows || [];
|
|
2840
2562
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
2841
2563
|
}
|
|
2842
2564
|
|
|
2843
|
-
if (tree_obj.crudMode ===
|
|
2844
|
-
_ds.set_mode =
|
|
2565
|
+
if (tree_obj.crudMode === 'D') {
|
|
2566
|
+
_ds.set_mode = 'D';
|
|
2845
2567
|
// _raw_data_rows = get_data_from_data_feed(); // _ds.raw_data?.rows || [];
|
|
2846
2568
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
2847
2569
|
}
|
|
2848
2570
|
|
|
2849
2571
|
// initiated with Update but no rows found
|
|
2850
|
-
if (
|
|
2851
|
-
|
|
2852
|
-
tree_obj.allowCreate &&
|
|
2853
|
-
!_ds?.data_feed?.rows?.length
|
|
2854
|
-
) {
|
|
2855
|
-
_ds.set_mode = "C";
|
|
2572
|
+
if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
|
|
2573
|
+
_ds.set_mode = 'C';
|
|
2856
2574
|
// _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
|
|
2857
2575
|
|
|
2858
2576
|
try {
|
|
2859
|
-
const row_idx = find_ROWID_idx_from_raw_data_arr(
|
|
2860
|
-
_raw_data_rows[row_idx] = [{ id:
|
|
2577
|
+
const row_idx = find_ROWID_idx_from_raw_data_arr('newRecord');
|
|
2578
|
+
_raw_data_rows[row_idx] = [{ id: 'newRecord', value: {} }];
|
|
2861
2579
|
} catch (error) {
|
|
2862
|
-
_raw_data_rows.push({ _ROWID:
|
|
2580
|
+
_raw_data_rows.push({ _ROWID: 'newRecord' });
|
|
2863
2581
|
}
|
|
2864
2582
|
}
|
|
2865
2583
|
|
|
2866
|
-
if (tree_obj.crudMode ===
|
|
2867
|
-
_ds.set_mode =
|
|
2584
|
+
if (tree_obj.crudMode === 'C') {
|
|
2585
|
+
_ds.set_mode = 'C';
|
|
2868
2586
|
// _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
|
|
2869
2587
|
try {
|
|
2870
|
-
const row_idx = find_ROWID_idx_from_raw_data_arr(
|
|
2871
|
-
_raw_data_rows[row_idx] = [{ id:
|
|
2588
|
+
const row_idx = find_ROWID_idx_from_raw_data_arr('newRecord');
|
|
2589
|
+
_raw_data_rows[row_idx] = [{ id: 'newRecord', value: {} }];
|
|
2872
2590
|
} catch (error) {
|
|
2873
|
-
_raw_data_rows.push({ id:
|
|
2591
|
+
_raw_data_rows.push({ id: 'newRecord', value: {} });
|
|
2874
2592
|
}
|
|
2875
2593
|
}
|
|
2876
2594
|
|
|
2877
2595
|
for await (let raw_data_row of _raw_data_rows) {
|
|
2878
2596
|
_ds.currentRecordId = raw_data_row.id;
|
|
2879
2597
|
if (await get_before_record_count()) {
|
|
2880
|
-
await func.datasource.execute_view_events(
|
|
2881
|
-
SESSION_ID,
|
|
2882
|
-
dataSourceSession,
|
|
2883
|
-
"before_record"
|
|
2884
|
-
);
|
|
2598
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
2885
2599
|
}
|
|
2886
2600
|
|
|
2887
|
-
await func.datasource.render_fields_dataset(
|
|
2888
|
-
SESSION_ID,
|
|
2889
|
-
dataSourceSession,
|
|
2890
|
-
raw_data_row
|
|
2891
|
-
);
|
|
2601
|
+
await func.datasource.render_fields_dataset(SESSION_ID, dataSourceSession, raw_data_row);
|
|
2892
2602
|
let data_feed_str = JSON.stringify(_ds.data_feed);
|
|
2893
2603
|
|
|
2894
2604
|
if (await get_after_record_count()) {
|
|
2895
|
-
await func.datasource.execute_view_events(
|
|
2896
|
-
SESSION_ID,
|
|
2897
|
-
dataSourceSession,
|
|
2898
|
-
"after_record"
|
|
2899
|
-
);
|
|
2605
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
2900
2606
|
}
|
|
2901
2607
|
|
|
2902
|
-
if (
|
|
2903
|
-
_ds.set_mode === "C" ||
|
|
2904
|
-
JSON.stringify(_ds.data_feed) !== data_feed_str
|
|
2905
|
-
) {
|
|
2608
|
+
if (_ds.set_mode === 'C' || JSON.stringify(_ds.data_feed) !== data_feed_str) {
|
|
2906
2609
|
const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
2907
2610
|
if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
2908
|
-
_ds.set_mode =
|
|
2611
|
+
_ds.set_mode = 'U';
|
|
2909
2612
|
}
|
|
2910
2613
|
|
|
2911
|
-
if (_ds.set_mode ===
|
|
2614
|
+
if (_ds.set_mode === 'D') {
|
|
2912
2615
|
const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
|
|
2913
2616
|
if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
|
|
2914
2617
|
}
|
|
@@ -2917,7 +2620,7 @@ func.datasource.execute = async function (
|
|
|
2917
2620
|
await func.datasource.set_outputField(SESSION_ID, dataSourceSession, _ds?.v?.raw_data?.rows, _ds.args);
|
|
2918
2621
|
break;
|
|
2919
2622
|
|
|
2920
|
-
case
|
|
2623
|
+
case 'component':
|
|
2921
2624
|
_raw_data_rows = _ds?.v.raw_data?.rows || [];
|
|
2922
2625
|
_ds.rows_processed = 0;
|
|
2923
2626
|
_ds.viewRangeExp_rows_deleted = 0;
|
|
@@ -2928,49 +2631,29 @@ func.datasource.execute = async function (
|
|
|
2928
2631
|
_ds.data_feed.rows_deleted = [];
|
|
2929
2632
|
_ds.data_feed.rows_added = [];
|
|
2930
2633
|
|
|
2931
|
-
if (tree_obj.rwMode ===
|
|
2932
|
-
_ds.set_mode =
|
|
2634
|
+
if (tree_obj.rwMode === 'U') {
|
|
2635
|
+
_ds.set_mode = 'U';
|
|
2933
2636
|
} else {
|
|
2934
|
-
_ds.set_mode =
|
|
2637
|
+
_ds.set_mode = 'R';
|
|
2935
2638
|
}
|
|
2936
2639
|
|
|
2937
2640
|
const row_not_found = async function () {
|
|
2938
|
-
if (
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
) {
|
|
2942
|
-
_ds.currentRecordId = "newRecord";
|
|
2943
|
-
_ds.set_mode = "C";
|
|
2641
|
+
if (!prog_obj.progDataSource?.dataSourceType || (tree_obj.rwMode === 'U' && tree_obj.allowCreate)) {
|
|
2642
|
+
_ds.currentRecordId = 'newRecord';
|
|
2643
|
+
_ds.set_mode = 'C';
|
|
2944
2644
|
_ds.record_not_found = true;
|
|
2945
2645
|
|
|
2946
2646
|
try {
|
|
2947
|
-
const row_idx = func.common.find_ROWID_idx(
|
|
2948
|
-
_ds,
|
|
2949
|
-
_ds.currentRecordId
|
|
2950
|
-
);
|
|
2647
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
2951
2648
|
} catch (error) {
|
|
2952
|
-
await func.datasource.render_fields_form(
|
|
2953
|
-
SESSION_ID,
|
|
2954
|
-
dataSourceSession,
|
|
2955
|
-
{ id: "newRecord", value: {} }
|
|
2956
|
-
);
|
|
2649
|
+
await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, { id: 'newRecord', value: {} });
|
|
2957
2650
|
}
|
|
2958
2651
|
|
|
2959
|
-
var count = await func.datasource.get_field_init_count(
|
|
2960
|
-
SESSION_ID,
|
|
2961
|
-
dataSourceSession,
|
|
2962
|
-
"newRecord",
|
|
2963
|
-
false
|
|
2964
|
-
);
|
|
2652
|
+
var count = await func.datasource.get_field_init_count(SESSION_ID, dataSourceSession, 'newRecord', false);
|
|
2965
2653
|
if (
|
|
2966
2654
|
count > 0 // was: && !args.dataSourceNoP
|
|
2967
2655
|
) {
|
|
2968
|
-
await func.datasource.execute_field_init_events(
|
|
2969
|
-
SESSION_ID,
|
|
2970
|
-
dataSourceSession,
|
|
2971
|
-
"form",
|
|
2972
|
-
"newRecord"
|
|
2973
|
-
);
|
|
2656
|
+
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', 'newRecord');
|
|
2974
2657
|
}
|
|
2975
2658
|
}
|
|
2976
2659
|
};
|
|
@@ -2985,20 +2668,13 @@ func.datasource.execute = async function (
|
|
|
2985
2668
|
// check if locatedRecordId exist in SESSION_OBJ[SESSION_ID].DS_GLB
|
|
2986
2669
|
if (_ds.locatedRecordId) {
|
|
2987
2670
|
try {
|
|
2988
|
-
const row_idx = func.common.find_ROWID_idx(
|
|
2989
|
-
_ds,
|
|
2990
|
-
_ds.locatedRecordId
|
|
2991
|
-
);
|
|
2671
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.locatedRecordId);
|
|
2992
2672
|
} catch (error) {
|
|
2993
2673
|
delete _ds.locatedRecordId;
|
|
2994
2674
|
}
|
|
2995
2675
|
}
|
|
2996
2676
|
|
|
2997
|
-
_ds.finalRecordId = func.datasource.get_currentRecordId(
|
|
2998
|
-
SESSION_ID,
|
|
2999
|
-
dataSourceSession,
|
|
3000
|
-
true
|
|
3001
|
-
);
|
|
2677
|
+
_ds.finalRecordId = func.datasource.get_currentRecordId(SESSION_ID, dataSourceSession, true);
|
|
3002
2678
|
_ds.currentRecordId = _ds.finalRecordId;
|
|
3003
2679
|
};
|
|
3004
2680
|
|
|
@@ -3006,11 +2682,7 @@ func.datasource.execute = async function (
|
|
|
3006
2682
|
const idx = Number(key);
|
|
3007
2683
|
|
|
3008
2684
|
if (await get_before_record_count()) {
|
|
3009
|
-
await func.datasource.execute_view_events(
|
|
3010
|
-
SESSION_ID,
|
|
3011
|
-
dataSourceSession,
|
|
3012
|
-
"before_record"
|
|
3013
|
-
);
|
|
2685
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'before_record');
|
|
3014
2686
|
}
|
|
3015
2687
|
|
|
3016
2688
|
// await func.datasource.run_rows_form(
|
|
@@ -3024,28 +2696,13 @@ func.datasource.execute = async function (
|
|
|
3024
2696
|
|
|
3025
2697
|
_ds.currentRecordId = raw_data_row.id; // set temporary to allow expression decoder work
|
|
3026
2698
|
|
|
3027
|
-
await func.datasource.render_fields_form(
|
|
3028
|
-
SESSION_ID,
|
|
3029
|
-
dataSourceSession,
|
|
3030
|
-
raw_data_row
|
|
3031
|
-
);
|
|
2699
|
+
await func.datasource.render_fields_form(SESSION_ID, dataSourceSession, raw_data_row);
|
|
3032
2700
|
|
|
3033
2701
|
try {
|
|
3034
|
-
const init_count = await func.datasource.get_field_init_count(
|
|
3035
|
-
SESSION_ID,
|
|
3036
|
-
dataSourceSession,
|
|
3037
|
-
raw_data_row.id,
|
|
3038
|
-
false,
|
|
3039
|
-
_ds.oninit_triggers_to_run
|
|
3040
|
-
);
|
|
2702
|
+
const init_count = await func.datasource.get_field_init_count(SESSION_ID, dataSourceSession, raw_data_row.id, false, _ds.oninit_triggers_to_run);
|
|
3041
2703
|
|
|
3042
2704
|
if (init_count > 0) {
|
|
3043
|
-
await func.datasource.execute_field_init_events(
|
|
3044
|
-
SESSION_ID,
|
|
3045
|
-
dataSourceSession,
|
|
3046
|
-
"form",
|
|
3047
|
-
raw_data_row.id
|
|
3048
|
-
);
|
|
2705
|
+
await func.datasource.execute_field_init_events(SESSION_ID, dataSourceSession, 'form', raw_data_row.id);
|
|
3049
2706
|
}
|
|
3050
2707
|
} catch (err) {
|
|
3051
2708
|
console.error(err);
|
|
@@ -3054,11 +2711,7 @@ func.datasource.execute = async function (
|
|
|
3054
2711
|
/////////////////////
|
|
3055
2712
|
|
|
3056
2713
|
if (await get_after_record_count()) {
|
|
3057
|
-
await func.datasource.execute_view_events(
|
|
3058
|
-
SESSION_ID,
|
|
3059
|
-
dataSourceSession,
|
|
3060
|
-
"after_record"
|
|
3061
|
-
);
|
|
2714
|
+
await func.datasource.execute_view_events(SESSION_ID, dataSourceSession, 'after_record');
|
|
3062
2715
|
}
|
|
3063
2716
|
}
|
|
3064
2717
|
await finish_form();
|
|
@@ -3066,82 +2719,42 @@ func.datasource.execute = async function (
|
|
|
3066
2719
|
break;
|
|
3067
2720
|
|
|
3068
2721
|
default:
|
|
3069
|
-
return func.utils.debug_report(
|
|
3070
|
-
SESSION_ID,
|
|
3071
|
-
"Data source",
|
|
3072
|
-
"Program type not defined",
|
|
3073
|
-
"E"
|
|
3074
|
-
);
|
|
2722
|
+
return func.utils.debug_report(SESSION_ID, 'Data source', 'Program type not defined', 'E');
|
|
3075
2723
|
}
|
|
3076
2724
|
|
|
3077
2725
|
ret = await callback_datasource();
|
|
3078
2726
|
return ret;
|
|
3079
2727
|
};
|
|
3080
2728
|
|
|
3081
|
-
func.datasource.render_fields_dataset = async function (
|
|
3082
|
-
SESSION_ID,
|
|
3083
|
-
dataSourceSession,
|
|
3084
|
-
raw_data_row
|
|
3085
|
-
) {
|
|
2729
|
+
func.datasource.render_fields_dataset = async function (SESSION_ID, dataSourceSession, raw_data_row) {
|
|
3086
2730
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3087
2731
|
var args = _ds.args;
|
|
3088
2732
|
|
|
3089
|
-
const _progFields = await func.datasource.get_progFields(
|
|
3090
|
-
SESSION_ID,
|
|
3091
|
-
dataSourceSession
|
|
3092
|
-
);
|
|
2733
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSourceSession);
|
|
3093
2734
|
|
|
3094
2735
|
if (!_progFields) {
|
|
3095
2736
|
return;
|
|
3096
2737
|
}
|
|
3097
2738
|
|
|
3098
2739
|
const get_value = async (field_id, value) => {
|
|
3099
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
3100
|
-
_progFields,
|
|
3101
|
-
"field_id",
|
|
3102
|
-
field_id
|
|
3103
|
-
);
|
|
2740
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
3104
2741
|
var fieldType = view_field_obj?.props?.fieldType;
|
|
3105
2742
|
let table_field_obj;
|
|
3106
|
-
if (view_field_obj.data.type ===
|
|
2743
|
+
if (view_field_obj.data.type === 'table' && field_id !== 'REDUCE_VALUE') {
|
|
3107
2744
|
if (!_ds.progDataSource?.dataSourceTableId) {
|
|
3108
|
-
return func.utils.debug_report(
|
|
3109
|
-
SESSION_ID,
|
|
3110
|
-
"Datasource",
|
|
3111
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
3112
|
-
"E"
|
|
3113
|
-
);
|
|
2745
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
3114
2746
|
}
|
|
3115
2747
|
|
|
3116
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
3117
|
-
SESSION_ID,
|
|
3118
|
-
_ds._dataSourceTableId
|
|
3119
|
-
);
|
|
2748
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
3120
2749
|
|
|
3121
2750
|
if (!table_obj) {
|
|
3122
|
-
return func.utils.debug_report(
|
|
3123
|
-
SESSION_ID,
|
|
3124
|
-
"Datasource",
|
|
3125
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
3126
|
-
"E"
|
|
3127
|
-
);
|
|
2751
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
3128
2752
|
}
|
|
3129
|
-
table_field_obj = func.common.find_item_by_key(
|
|
3130
|
-
table_obj.tableFields,
|
|
3131
|
-
"field_id",
|
|
3132
|
-
field_id
|
|
3133
|
-
);
|
|
2753
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
3134
2754
|
fieldType = table_field_obj.props?.fieldType;
|
|
3135
2755
|
}
|
|
3136
2756
|
|
|
3137
|
-
return await func.common.get_cast_val(
|
|
3138
|
-
SESSION_ID,
|
|
3139
|
-
`render fields dataset ${_ds.viewSourceDesc}`,
|
|
3140
|
-
field_id,
|
|
3141
|
-
fieldType,
|
|
3142
|
-
value,
|
|
3143
|
-
null
|
|
3144
|
-
);
|
|
2757
|
+
return await func.common.get_cast_val(SESSION_ID, `render fields dataset ${_ds.viewSourceDesc}`, field_id, fieldType, value, null);
|
|
3145
2758
|
};
|
|
3146
2759
|
|
|
3147
2760
|
if (!_ds.data_feed) {
|
|
@@ -3162,64 +2775,38 @@ func.datasource.render_fields_dataset = async function (
|
|
|
3162
2775
|
try {
|
|
3163
2776
|
var fieldId = val.data.field_id;
|
|
3164
2777
|
|
|
3165
|
-
if (val.data.type ===
|
|
3166
|
-
if (typeof raw_data_row?.value?.[fieldId] !==
|
|
2778
|
+
if (val.data.type === 'virtual' || _ds.set_mode === 'C') {
|
|
2779
|
+
if (typeof raw_data_row?.value?.[fieldId] !== 'undefined') {
|
|
3167
2780
|
// supports x=x+1
|
|
3168
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3169
|
-
fieldId,
|
|
3170
|
-
raw_data_row.value[fieldId]
|
|
3171
|
-
);
|
|
2781
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
3172
2782
|
continue;
|
|
3173
2783
|
}
|
|
3174
2784
|
|
|
3175
2785
|
if (val.props?.propExpressions?.fieldValue) {
|
|
3176
|
-
let ret = await func.expression.get(
|
|
3177
|
-
|
|
3178
|
-
val.props?.propExpressions?.fieldValue,
|
|
3179
|
-
dataSourceSession,
|
|
3180
|
-
"update",
|
|
3181
|
-
args.rowIdP
|
|
3182
|
-
);
|
|
3183
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3184
|
-
fieldId,
|
|
3185
|
-
ret.result
|
|
3186
|
-
);
|
|
2786
|
+
let ret = await func.expression.get(SESSION_ID, val.props?.propExpressions?.fieldValue, dataSourceSession, 'update', args.rowIdP);
|
|
2787
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, ret.result);
|
|
3187
2788
|
continue;
|
|
3188
2789
|
}
|
|
3189
2790
|
|
|
3190
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3191
|
-
fieldId,
|
|
3192
|
-
val.props?.fieldValue
|
|
3193
|
-
);
|
|
2791
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, val.props?.fieldValue);
|
|
3194
2792
|
continue;
|
|
3195
2793
|
}
|
|
3196
|
-
if (val.data.type ===
|
|
3197
|
-
if (typeof raw_data_row.value[fieldId] ===
|
|
3198
|
-
throw
|
|
2794
|
+
if (val.data.type === 'table' || val.data.type === 'datasource') {
|
|
2795
|
+
if (typeof raw_data_row.value[fieldId] === 'undefined') {
|
|
2796
|
+
throw 'field do not exist in data: ' + fieldId;
|
|
3199
2797
|
}
|
|
3200
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3201
|
-
fieldId,
|
|
3202
|
-
raw_data_row.value[fieldId]
|
|
3203
|
-
);
|
|
2798
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
3204
2799
|
}
|
|
3205
2800
|
} catch (err) {
|
|
3206
|
-
func.utils.debug_report(SESSION_ID,
|
|
2801
|
+
func.utils.debug_report(SESSION_ID, 'Datasource', err, 'E', null, _ds);
|
|
3207
2802
|
}
|
|
3208
2803
|
}
|
|
3209
2804
|
};
|
|
3210
2805
|
|
|
3211
|
-
func.datasource.run_events_functions = async function (
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
calling_job,
|
|
3216
|
-
async_event,
|
|
3217
|
-
event_parameters
|
|
3218
|
-
) {
|
|
3219
|
-
|
|
3220
|
-
if (typeof dataSourceSession === "undefined" || dataSourceSession === null) {
|
|
3221
|
-
console.warn(`Event ${event_id} not exist or not found`)
|
|
3222
|
-
return
|
|
2806
|
+
func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSession, event_id, calling_job, async_event, event_parameters) {
|
|
2807
|
+
if (typeof dataSourceSession === 'undefined' || dataSourceSession === null) {
|
|
2808
|
+
console.warn(`Event ${event_id} not exist or not found`);
|
|
2809
|
+
return;
|
|
3223
2810
|
}
|
|
3224
2811
|
|
|
3225
2812
|
// return new Promise(async (resolve, reject) => {
|
|
@@ -3227,123 +2814,75 @@ func.datasource.run_events_functions = async function (
|
|
|
3227
2814
|
var args = _ds.args;
|
|
3228
2815
|
// var v = _ds.v;
|
|
3229
2816
|
const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
3230
|
-
let job_promises = []
|
|
2817
|
+
let job_promises = [];
|
|
3231
2818
|
if (_view_obj.progEvents) {
|
|
3232
2819
|
for await (const [key, val] of Object.entries(_view_obj.progEvents)) {
|
|
3233
|
-
if (
|
|
3234
|
-
val.data.type === "user_defined" &&
|
|
3235
|
-
val.data.event_name &&
|
|
3236
|
-
val.data.event_name === event_id
|
|
3237
|
-
) {
|
|
2820
|
+
if (val.data.type === 'user_defined' && val.data.event_name && val.data.event_name === event_id) {
|
|
3238
2821
|
const jobs = await func.events.validate(
|
|
3239
2822
|
SESSION_ID,
|
|
3240
|
-
|
|
2823
|
+
'user_defined',
|
|
3241
2824
|
dataSourceSession,
|
|
3242
2825
|
val.data.event_name,
|
|
3243
2826
|
args.callingSourceP,
|
|
3244
|
-
event_parameters// val.data.parameters
|
|
2827
|
+
event_parameters, // val.data.parameters
|
|
3245
2828
|
);
|
|
3246
2829
|
|
|
3247
|
-
if (calling_job || async_event) continue
|
|
2830
|
+
if (calling_job || async_event) continue;
|
|
3248
2831
|
|
|
3249
2832
|
for (let job_num of jobs) {
|
|
3250
|
-
job_promises.push(
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
2833
|
+
job_promises.push(
|
|
2834
|
+
new Promise((resolve, reject) => {
|
|
2835
|
+
const interval = setInterval(() => {
|
|
2836
|
+
var job_index = func.events.find_job_index(SESSION_ID, job_num);
|
|
2837
|
+
if (job_index == null) {
|
|
2838
|
+
clearInterval(interval);
|
|
2839
|
+
resolve(job_num);
|
|
2840
|
+
}
|
|
2841
|
+
}, 100);
|
|
2842
|
+
}),
|
|
2843
|
+
);
|
|
3260
2844
|
}
|
|
3261
2845
|
}
|
|
3262
2846
|
}
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
2847
|
}
|
|
3267
2848
|
if (job_promises.length) {
|
|
3268
|
-
await Promise.all(job_promises)
|
|
2849
|
+
await Promise.all(job_promises);
|
|
3269
2850
|
}
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
2851
|
};
|
|
3273
2852
|
|
|
3274
|
-
func.datasource.render_fields_form = async function (
|
|
3275
|
-
SESSION_ID,
|
|
3276
|
-
dataSourceSession,
|
|
3277
|
-
raw_data_row
|
|
3278
|
-
) {
|
|
2853
|
+
func.datasource.render_fields_form = async function (SESSION_ID, dataSourceSession, raw_data_row) {
|
|
3279
2854
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3280
2855
|
|
|
3281
|
-
const _progFields = await func.datasource.get_progFields(
|
|
3282
|
-
SESSION_ID,
|
|
3283
|
-
dataSourceSession
|
|
3284
|
-
);
|
|
2856
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSourceSession);
|
|
3285
2857
|
|
|
3286
2858
|
if (!_progFields) {
|
|
3287
2859
|
return;
|
|
3288
2860
|
}
|
|
3289
2861
|
|
|
3290
2862
|
const get_value = async (field_id, value) => {
|
|
3291
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
3292
|
-
_progFields,
|
|
3293
|
-
"field_id",
|
|
3294
|
-
field_id
|
|
3295
|
-
);
|
|
2863
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
3296
2864
|
var fieldType = view_field_obj.props?.fieldType;
|
|
3297
2865
|
let table_field_obj;
|
|
3298
|
-
if (view_field_obj.data.type ===
|
|
2866
|
+
if (view_field_obj.data.type === 'table' && field_id !== 'REDUCE_VALUE') {
|
|
3299
2867
|
if (!_ds._dataSourceTableId) {
|
|
3300
|
-
return func.utils.debug_report(
|
|
3301
|
-
SESSION_ID,
|
|
3302
|
-
"Datasource",
|
|
3303
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
3304
|
-
"E"
|
|
3305
|
-
);
|
|
2868
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
3306
2869
|
}
|
|
3307
2870
|
|
|
3308
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
3309
|
-
SESSION_ID,
|
|
3310
|
-
_ds._dataSourceTableId
|
|
3311
|
-
);
|
|
2871
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
3312
2872
|
|
|
3313
2873
|
if (!table_obj) {
|
|
3314
|
-
return func.utils.debug_report(
|
|
3315
|
-
SESSION_ID,
|
|
3316
|
-
"Datasource",
|
|
3317
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
3318
|
-
"E"
|
|
3319
|
-
);
|
|
2874
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
3320
2875
|
}
|
|
3321
|
-
table_field_obj = func.common.find_item_by_key(
|
|
3322
|
-
table_obj.tableFields,
|
|
3323
|
-
"field_id",
|
|
3324
|
-
field_id
|
|
3325
|
-
);
|
|
2876
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
3326
2877
|
|
|
3327
2878
|
if (!table_field_obj) {
|
|
3328
|
-
return func.utils.debug_report(
|
|
3329
|
-
SESSION_ID,
|
|
3330
|
-
"Datasource",
|
|
3331
|
-
`Field Id: ${field_id} not exist in table ${table_obj.properties.menuName}`,
|
|
3332
|
-
"E"
|
|
3333
|
-
);
|
|
2879
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Field Id: ${field_id} not exist in table ${table_obj.properties.menuName}`, 'E');
|
|
3334
2880
|
}
|
|
3335
2881
|
|
|
3336
2882
|
fieldType = table_field_obj.props?.fieldType;
|
|
3337
2883
|
}
|
|
3338
2884
|
|
|
3339
|
-
return await func.common.get_cast_val(
|
|
3340
|
-
SESSION_ID,
|
|
3341
|
-
`render fields datasource ${_ds.viewSourceDesc}`,
|
|
3342
|
-
field_id,
|
|
3343
|
-
fieldType,
|
|
3344
|
-
value,
|
|
3345
|
-
null
|
|
3346
|
-
);
|
|
2885
|
+
return await func.common.get_cast_val(SESSION_ID, `render fields datasource ${_ds.viewSourceDesc}`, field_id, fieldType, value, null);
|
|
3347
2886
|
};
|
|
3348
2887
|
|
|
3349
2888
|
let row_idx;
|
|
@@ -3360,29 +2899,20 @@ func.datasource.render_fields_form = async function (
|
|
|
3360
2899
|
try {
|
|
3361
2900
|
var fieldId = val.data.field_id;
|
|
3362
2901
|
|
|
3363
|
-
if (val.data.type ===
|
|
2902
|
+
if (val.data.type === 'virtual' || raw_data_row.id === 'newRecord') {
|
|
3364
2903
|
if (glb.PROTECTED_VARS.includes(fieldId)) {
|
|
3365
2904
|
switch (fieldId) {
|
|
3366
|
-
case
|
|
3367
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3368
|
-
fieldId,
|
|
3369
|
-
row_idx
|
|
3370
|
-
);
|
|
2905
|
+
case '_ROWNO': {
|
|
2906
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, row_idx);
|
|
3371
2907
|
continue;
|
|
3372
2908
|
}
|
|
3373
|
-
case
|
|
3374
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3375
|
-
fieldId,
|
|
3376
|
-
raw_data_row.id
|
|
3377
|
-
);
|
|
2909
|
+
case '_ROWID': {
|
|
2910
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.id);
|
|
3378
2911
|
|
|
3379
2912
|
continue;
|
|
3380
2913
|
}
|
|
3381
|
-
case
|
|
3382
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3383
|
-
fieldId,
|
|
3384
|
-
raw_data_row.value
|
|
3385
|
-
);
|
|
2914
|
+
case '_ROWDOC': {
|
|
2915
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value);
|
|
3386
2916
|
|
|
3387
2917
|
continue;
|
|
3388
2918
|
}
|
|
@@ -3391,39 +2921,24 @@ func.datasource.render_fields_form = async function (
|
|
|
3391
2921
|
|
|
3392
2922
|
if (val.props?.propExpressions?.fieldValue) {
|
|
3393
2923
|
// check init exp existence
|
|
3394
|
-
let ret = await func.expression.get(
|
|
3395
|
-
|
|
3396
|
-
val.props?.propExpressions?.fieldValue,
|
|
3397
|
-
dataSourceSession,
|
|
3398
|
-
"update",
|
|
3399
|
-
raw_data_row.id
|
|
3400
|
-
);
|
|
3401
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3402
|
-
fieldId,
|
|
3403
|
-
ret.result
|
|
3404
|
-
);
|
|
2924
|
+
let ret = await func.expression.get(SESSION_ID, val.props?.propExpressions?.fieldValue, dataSourceSession, 'update', raw_data_row.id);
|
|
2925
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, ret.result);
|
|
3405
2926
|
|
|
3406
2927
|
continue;
|
|
3407
2928
|
}
|
|
3408
2929
|
|
|
3409
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3410
|
-
fieldId,
|
|
3411
|
-
val.props?.fieldValue
|
|
3412
|
-
);
|
|
2930
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, val.props?.fieldValue);
|
|
3413
2931
|
|
|
3414
2932
|
continue;
|
|
3415
2933
|
}
|
|
3416
|
-
if (val.data.type ===
|
|
3417
|
-
if (typeof raw_data_row.value[fieldId] ===
|
|
3418
|
-
throw
|
|
2934
|
+
if (val.data.type === 'table' || val.data.type === 'datasource') {
|
|
2935
|
+
if (typeof raw_data_row.value[fieldId] === 'undefined') {
|
|
2936
|
+
throw 'field do not exist in data: ' + fieldId;
|
|
3419
2937
|
}
|
|
3420
|
-
_ds.data_feed.rows[row_idx][fieldId] = await get_value(
|
|
3421
|
-
fieldId,
|
|
3422
|
-
raw_data_row.value[fieldId]
|
|
3423
|
-
);
|
|
2938
|
+
_ds.data_feed.rows[row_idx][fieldId] = await get_value(fieldId, raw_data_row.value[fieldId]);
|
|
3424
2939
|
}
|
|
3425
2940
|
} catch (err) {
|
|
3426
|
-
func.utils.debug_report(SESSION_ID,
|
|
2941
|
+
func.utils.debug_report(SESSION_ID, 'Datasource', err, 'E', null, _ds);
|
|
3427
2942
|
}
|
|
3428
2943
|
}
|
|
3429
2944
|
};
|
|
@@ -3486,12 +3001,7 @@ func.datasource.render_fields_form = async function (
|
|
|
3486
3001
|
// // await form_continue();
|
|
3487
3002
|
// };
|
|
3488
3003
|
|
|
3489
|
-
func.datasource.execute_field_init_events = async function (
|
|
3490
|
-
SESSION_ID,
|
|
3491
|
-
dataSourceSession,
|
|
3492
|
-
sourceP,
|
|
3493
|
-
rowIdP
|
|
3494
|
-
) {
|
|
3004
|
+
func.datasource.execute_field_init_events = async function (SESSION_ID, dataSourceSession, sourceP, rowIdP) {
|
|
3495
3005
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3496
3006
|
var args = _ds.args;
|
|
3497
3007
|
var arr = _ds.dataSource_init_arr[rowIdP];
|
|
@@ -3501,21 +3011,11 @@ func.datasource.execute_field_init_events = async function (
|
|
|
3501
3011
|
if (!func.utils.is_onscreen_event(val.eventInfo.data.action)) {
|
|
3502
3012
|
var cond = val?.eventInfo?.data?.enabled;
|
|
3503
3013
|
var expression = undefined;
|
|
3504
|
-
if (val.eventInfo.props.condition)
|
|
3505
|
-
expression = val.eventInfo.props.condition;
|
|
3014
|
+
if (val.eventInfo.props.condition) expression = val.eventInfo.props.condition;
|
|
3506
3015
|
var expCond = {};
|
|
3507
3016
|
if (expression && !_.isEmpty(expression)) {
|
|
3508
3017
|
// check if expression exist
|
|
3509
|
-
expCond = await func.expression.get(
|
|
3510
|
-
SESSION_ID,
|
|
3511
|
-
expression,
|
|
3512
|
-
dataSourceSession,
|
|
3513
|
-
"condition",
|
|
3514
|
-
rowIdP,
|
|
3515
|
-
null,
|
|
3516
|
-
null,
|
|
3517
|
-
val.fieldId
|
|
3518
|
-
); // execute expression
|
|
3018
|
+
expCond = await func.expression.get(SESSION_ID, expression, dataSourceSession, 'condition', rowIdP, null, null, val.fieldId); // execute expression
|
|
3519
3019
|
cond = expCond.result;
|
|
3520
3020
|
expCond.conditional = true;
|
|
3521
3021
|
val.DEBUG_INFO_OBJ.result = expCond.result;
|
|
@@ -3557,20 +3057,14 @@ func.datasource.execute_field_init_events = async function (
|
|
|
3557
3057
|
null,
|
|
3558
3058
|
null,
|
|
3559
3059
|
null,
|
|
3560
|
-
ds.parentDataSourceNo
|
|
3060
|
+
ds.parentDataSourceNo,
|
|
3561
3061
|
);
|
|
3562
3062
|
}
|
|
3563
3063
|
}
|
|
3564
3064
|
}
|
|
3565
3065
|
};
|
|
3566
3066
|
|
|
3567
|
-
func.datasource.get_field_init_count = async function (
|
|
3568
|
-
SESSION_ID,
|
|
3569
|
-
dataSourceSession,
|
|
3570
|
-
rowIdP,
|
|
3571
|
-
pre_initP,
|
|
3572
|
-
oninit_triggers_to_runP
|
|
3573
|
-
) {
|
|
3067
|
+
func.datasource.get_field_init_count = async function (SESSION_ID, dataSourceSession, rowIdP, pre_initP, oninit_triggers_to_runP) {
|
|
3574
3068
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3575
3069
|
var args = _ds.args;
|
|
3576
3070
|
|
|
@@ -3586,25 +3080,15 @@ func.datasource.get_field_init_count = async function (
|
|
|
3586
3080
|
continue;
|
|
3587
3081
|
}
|
|
3588
3082
|
for await (const trigger_obj of field_obj.triggers) {
|
|
3589
|
-
if (
|
|
3590
|
-
oninit_triggers_to_runP &&
|
|
3591
|
-
!oninit_triggers_to_runP?.includes(trigger_obj.id)
|
|
3592
|
-
) {
|
|
3083
|
+
if (oninit_triggers_to_runP && !oninit_triggers_to_runP?.includes(trigger_obj.id)) {
|
|
3593
3084
|
continue;
|
|
3594
3085
|
}
|
|
3595
3086
|
if (
|
|
3596
3087
|
// trigger_obj.data.trigger === "oninit" &&
|
|
3597
|
-
[
|
|
3598
|
-
trigger_obj.data.action
|
|
3599
|
-
)
|
|
3088
|
+
['get_data', 'set_data', 'batch', 'update', 'raise_event'].includes(trigger_obj.data.action)
|
|
3600
3089
|
) {
|
|
3601
3090
|
if (!trigger_obj.data.action) {
|
|
3602
|
-
func.utils.debug_report(
|
|
3603
|
-
SESSION_ID,
|
|
3604
|
-
"_ds.get_field_init_count",
|
|
3605
|
-
`Error initiating event for field: ${fieldId} prog: ${_ds.v.viewSourceDesc} row: ${rowIdP} reason: missing action`,
|
|
3606
|
-
"E"
|
|
3607
|
-
);
|
|
3091
|
+
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');
|
|
3608
3092
|
break;
|
|
3609
3093
|
}
|
|
3610
3094
|
|
|
@@ -3638,14 +3122,14 @@ func.datasource.get_field_init_count = async function (
|
|
|
3638
3122
|
fieldId: fieldId,
|
|
3639
3123
|
rowId: rowIdP,
|
|
3640
3124
|
colId: field_obj.id,
|
|
3641
|
-
node_id: args.prog_id +
|
|
3125
|
+
node_id: args.prog_id + '_' + trigger_obj.id + '_' + field_obj.id,
|
|
3642
3126
|
fieldProp: field_obj,
|
|
3643
3127
|
DEBUG_INFO_OBJ: {
|
|
3644
3128
|
module: _ds.viewModule,
|
|
3645
|
-
action:
|
|
3129
|
+
action: 'init field event',
|
|
3646
3130
|
prop: fieldId,
|
|
3647
3131
|
source: _ds.viewSourceDesc,
|
|
3648
|
-
type:
|
|
3132
|
+
type: 'event',
|
|
3649
3133
|
prog_id: args.prog_id,
|
|
3650
3134
|
dsSession: dataSourceSession,
|
|
3651
3135
|
},
|
|
@@ -3659,19 +3143,14 @@ func.datasource.get_field_init_count = async function (
|
|
|
3659
3143
|
return ret;
|
|
3660
3144
|
};
|
|
3661
3145
|
|
|
3662
|
-
func.datasource.get_view_events_count = async function (
|
|
3663
|
-
SESSION_ID,
|
|
3664
|
-
dataSourceSession,
|
|
3665
|
-
typeP,
|
|
3666
|
-
eventIdP
|
|
3667
|
-
) {
|
|
3146
|
+
func.datasource.get_view_events_count = async function (SESSION_ID, dataSourceSession, typeP, eventIdP) {
|
|
3668
3147
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3669
3148
|
const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
3670
3149
|
if (!_ds) return 0;
|
|
3671
3150
|
var args = _ds.args;
|
|
3672
3151
|
|
|
3673
3152
|
var index = typeP;
|
|
3674
|
-
if (eventIdP) index = typeP +
|
|
3153
|
+
if (eventIdP) index = typeP + '_' + eventIdP;
|
|
3675
3154
|
|
|
3676
3155
|
// client interval
|
|
3677
3156
|
if (!_ds.viewEventExec_arr) _ds.viewEventExec_arr = {};
|
|
@@ -3685,18 +3164,7 @@ func.datasource.get_view_events_count = async function (
|
|
|
3685
3164
|
if (eventIdP && event_obj.id !== eventIdP) continue; // match w ID added 03312017
|
|
3686
3165
|
|
|
3687
3166
|
if (event_obj.data.condition) {
|
|
3688
|
-
let res = await func.expression.get(
|
|
3689
|
-
SESSION_ID,
|
|
3690
|
-
event_obj.data.condition,
|
|
3691
|
-
dataSourceSession,
|
|
3692
|
-
"condition",
|
|
3693
|
-
args.rowIdP,
|
|
3694
|
-
null,
|
|
3695
|
-
null,
|
|
3696
|
-
null,
|
|
3697
|
-
null,
|
|
3698
|
-
event_obj
|
|
3699
|
-
);
|
|
3167
|
+
let res = await func.expression.get(SESSION_ID, event_obj.data.condition, dataSourceSession, 'condition', args.rowIdP, null, null, null, null, event_obj);
|
|
3700
3168
|
if (!res.result) {
|
|
3701
3169
|
continue;
|
|
3702
3170
|
}
|
|
@@ -3706,13 +3174,12 @@ func.datasource.get_view_events_count = async function (
|
|
|
3706
3174
|
for (const trigger_obj of event_obj.triggers) {
|
|
3707
3175
|
if (trigger_obj.data.enabled) {
|
|
3708
3176
|
var expression;
|
|
3709
|
-
if (trigger_obj.props.condition)
|
|
3710
|
-
expression = trigger_obj.props.condition;
|
|
3177
|
+
if (trigger_obj.props.condition) expression = trigger_obj.props.condition;
|
|
3711
3178
|
var expCond = {};
|
|
3712
3179
|
if (expression) {
|
|
3713
3180
|
expCond.conditional = true;
|
|
3714
3181
|
}
|
|
3715
|
-
func.utils.debug.log(SESSION_ID, args.prog_id +
|
|
3182
|
+
func.utils.debug.log(SESSION_ID, args.prog_id + '_' + trigger_obj.id, {
|
|
3716
3183
|
module: _ds.viewModule,
|
|
3717
3184
|
action: trigger_obj.data.action,
|
|
3718
3185
|
prop: event_obj.data.type,
|
|
@@ -3721,31 +3188,18 @@ func.datasource.get_view_events_count = async function (
|
|
|
3721
3188
|
error: expCond.error,
|
|
3722
3189
|
source: _ds.viewSourceDesc,
|
|
3723
3190
|
fields: expCond.fields,
|
|
3724
|
-
type:
|
|
3191
|
+
type: 'event',
|
|
3725
3192
|
prog_id: args.prog_id,
|
|
3726
3193
|
dsSession: dataSourceSession,
|
|
3727
3194
|
conditional: expCond.conditional,
|
|
3728
3195
|
});
|
|
3729
3196
|
}
|
|
3730
3197
|
if (!trigger_obj.data.action) {
|
|
3731
|
-
func.utils.debug_report(
|
|
3732
|
-
SESSION_ID,
|
|
3733
|
-
"get_view_events_count",
|
|
3734
|
-
`Error initiating ${typeP} prog:${_ds.v.viewSourceDesc} reason: missing action`,
|
|
3735
|
-
"E"
|
|
3736
|
-
);
|
|
3198
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog:${_ds.v.viewSourceDesc} reason: missing action`, 'E');
|
|
3737
3199
|
break;
|
|
3738
3200
|
}
|
|
3739
|
-
if (
|
|
3740
|
-
|
|
3741
|
-
!trigger_obj.data.action
|
|
3742
|
-
) {
|
|
3743
|
-
func.utils.debug_report(
|
|
3744
|
-
SESSION_ID,
|
|
3745
|
-
"get_view_events_count",
|
|
3746
|
-
`Error initiating ${typeP} prog: ${_ds.v.viewSourceDesc} reason: missing reference`,
|
|
3747
|
-
"E"
|
|
3748
|
-
);
|
|
3201
|
+
if (!glb.REFERENCE_LESS_FUNCTIONS.includes(trigger_obj.data.action) && !trigger_obj.data.action) {
|
|
3202
|
+
func.utils.debug_report(SESSION_ID, 'get_view_events_count', `Error initiating ${typeP} prog: ${_ds.v.viewSourceDesc} reason: missing reference`, 'E');
|
|
3749
3203
|
break;
|
|
3750
3204
|
}
|
|
3751
3205
|
if (trigger_obj.data.enabled) {
|
|
@@ -3761,50 +3215,28 @@ func.datasource.get_view_events_count = async function (
|
|
|
3761
3215
|
}
|
|
3762
3216
|
return _ds.viewEventExec_arr[index].length;
|
|
3763
3217
|
};
|
|
3764
|
-
func.datasource.execute_view_events = async function (
|
|
3765
|
-
SESSION_ID,
|
|
3766
|
-
dataSourceSession,
|
|
3767
|
-
typeP,
|
|
3768
|
-
eventIdP
|
|
3769
|
-
) {
|
|
3218
|
+
func.datasource.execute_view_events = async function (SESSION_ID, dataSourceSession, typeP, eventIdP) {
|
|
3770
3219
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3771
3220
|
var args = _ds.args;
|
|
3772
3221
|
|
|
3773
3222
|
var i = -1;
|
|
3774
3223
|
var index = typeP;
|
|
3775
|
-
if (eventIdP) index = typeP +
|
|
3224
|
+
if (eventIdP) index = typeP + '_' + eventIdP;
|
|
3776
3225
|
var arr = _ds.viewEventExec_arr[index];
|
|
3777
3226
|
if (_.isEmpty(arr)) return;
|
|
3778
3227
|
|
|
3779
3228
|
for await (const val of arr) {
|
|
3780
|
-
if (
|
|
3781
|
-
!glb.IS_WORKER ||
|
|
3782
|
-
!func.utils.is_onscreen_event(val.eventInfo.data.action) ||
|
|
3783
|
-
(glb.IS_WORKER &&
|
|
3784
|
-
_ds.v.run_at === "server" &&
|
|
3785
|
-
!func.utils.is_onscreen_event(val.eventInfo.data.action))
|
|
3786
|
-
) {
|
|
3229
|
+
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))) {
|
|
3787
3230
|
// val.done = true;
|
|
3788
3231
|
var cond = true;
|
|
3789
3232
|
if (val.expression) {
|
|
3790
|
-
var expCond = await func.expression.get(
|
|
3791
|
-
SESSION_ID,
|
|
3792
|
-
val.expression,
|
|
3793
|
-
dataSourceSession,
|
|
3794
|
-
"condition",
|
|
3795
|
-
args.rowIdP,
|
|
3796
|
-
null,
|
|
3797
|
-
null,
|
|
3798
|
-
null,
|
|
3799
|
-
null,
|
|
3800
|
-
val.eventInfo
|
|
3801
|
-
); // execute expression
|
|
3233
|
+
var expCond = await func.expression.get(SESSION_ID, val.expression, dataSourceSession, 'condition', args.rowIdP, null, null, null, null, val.eventInfo); // execute expression
|
|
3802
3234
|
cond = expCond.result;
|
|
3803
3235
|
}
|
|
3804
3236
|
if (cond) {
|
|
3805
3237
|
var elem_params = undefined;
|
|
3806
3238
|
if (!glb.IS_WORKER) {
|
|
3807
|
-
elem_params = $(
|
|
3239
|
+
elem_params = $('#' + _ds.containerId).data('params');
|
|
3808
3240
|
}
|
|
3809
3241
|
const ret = await func.events.execute(
|
|
3810
3242
|
SESSION_ID,
|
|
@@ -3821,39 +3253,28 @@ func.datasource.execute_view_events = async function (
|
|
|
3821
3253
|
null,
|
|
3822
3254
|
dataSourceSession,
|
|
3823
3255
|
val.eventId,
|
|
3824
|
-
_ds.tree_obj.menuType +
|
|
3256
|
+
_ds.tree_obj.menuType + ' event',
|
|
3825
3257
|
true,
|
|
3826
3258
|
null,
|
|
3827
3259
|
null,
|
|
3828
3260
|
args.jobNoP,
|
|
3829
3261
|
elem_params,
|
|
3830
3262
|
null,
|
|
3831
|
-
val.eventInfo
|
|
3263
|
+
val.eventInfo,
|
|
3832
3264
|
);
|
|
3833
3265
|
}
|
|
3834
3266
|
|
|
3835
3267
|
continue;
|
|
3836
3268
|
}
|
|
3837
3269
|
// on screen event
|
|
3838
|
-
if (
|
|
3839
|
-
typeP == "before_record" ||
|
|
3840
|
-
typeP == "after_record" ||
|
|
3841
|
-
typeP == "on_load" ||
|
|
3842
|
-
typeP == "on_exit"
|
|
3843
|
-
) {
|
|
3270
|
+
if (typeP == 'before_record' || typeP == 'after_record' || typeP == 'on_load' || typeP == 'on_exit') {
|
|
3844
3271
|
_ds.v.onscreen_events_active = {
|
|
3845
3272
|
i: i,
|
|
3846
3273
|
type: typeP,
|
|
3847
3274
|
};
|
|
3848
|
-
var parent_ds_chain = func.datasource.get_parent_ds_chain(
|
|
3849
|
-
SESSION_ID,
|
|
3850
|
-
dataSourceSession
|
|
3851
|
-
);
|
|
3275
|
+
var parent_ds_chain = func.datasource.get_parent_ds_chain(SESSION_ID, dataSourceSession);
|
|
3852
3276
|
var obj = {
|
|
3853
|
-
ds_obj: func.utils.clean_returned_datasource(
|
|
3854
|
-
SESSION_ID,
|
|
3855
|
-
dataSourceSession
|
|
3856
|
-
),
|
|
3277
|
+
ds_obj: func.utils.clean_returned_datasource(SESSION_ID, dataSourceSession),
|
|
3857
3278
|
dsSessionP: dataSourceSession,
|
|
3858
3279
|
};
|
|
3859
3280
|
obj.ds_obj.parent_ds_chain = parent_ds_chain;
|
|
@@ -3864,10 +3285,7 @@ func.datasource.get_parent_ds_chain = function (SESSION_ID, dataSourceSession) {
|
|
|
3864
3285
|
var arr = [];
|
|
3865
3286
|
var drill = function (ds) {
|
|
3866
3287
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[ds]) {
|
|
3867
|
-
if (
|
|
3868
|
-
typeof SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo !==
|
|
3869
|
-
"undefined"
|
|
3870
|
-
) {
|
|
3288
|
+
if (typeof SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo !== 'undefined') {
|
|
3871
3289
|
arr.push(SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo);
|
|
3872
3290
|
drill(SESSION_OBJ[SESSION_ID].DS_GLB[ds].parentDataSourceNo);
|
|
3873
3291
|
}
|
|
@@ -3876,11 +3294,7 @@ func.datasource.get_parent_ds_chain = function (SESSION_ID, dataSourceSession) {
|
|
|
3876
3294
|
drill(dataSourceSession);
|
|
3877
3295
|
return arr;
|
|
3878
3296
|
};
|
|
3879
|
-
func.datasource.execute_onscreen_view_events = async function (
|
|
3880
|
-
SESSION_ID,
|
|
3881
|
-
dataSourceSession,
|
|
3882
|
-
sourceP
|
|
3883
|
-
) {
|
|
3297
|
+
func.datasource.execute_onscreen_view_events = async function (SESSION_ID, dataSourceSession, sourceP) {
|
|
3884
3298
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3885
3299
|
var args = _ds.args;
|
|
3886
3300
|
|
|
@@ -3893,13 +3307,7 @@ func.datasource.execute_onscreen_view_events = async function (
|
|
|
3893
3307
|
|
|
3894
3308
|
var cond = true;
|
|
3895
3309
|
if (evnt.expression) {
|
|
3896
|
-
var expCond = await func.expression.get(
|
|
3897
|
-
SESSION_ID,
|
|
3898
|
-
evnt.expression,
|
|
3899
|
-
dataSourceSession,
|
|
3900
|
-
"condition",
|
|
3901
|
-
args.rowIdP
|
|
3902
|
-
); // execute expression
|
|
3310
|
+
var expCond = await func.expression.get(SESSION_ID, evnt.expression, dataSourceSession, 'condition', args.rowIdP); // execute expression
|
|
3903
3311
|
cond = expCond.result;
|
|
3904
3312
|
}
|
|
3905
3313
|
if (cond) {
|
|
@@ -3918,20 +3326,16 @@ func.datasource.execute_onscreen_view_events = async function (
|
|
|
3918
3326
|
null,
|
|
3919
3327
|
dataSourceSession,
|
|
3920
3328
|
null,
|
|
3921
|
-
sourceP +
|
|
3329
|
+
sourceP + ' event',
|
|
3922
3330
|
true,
|
|
3923
3331
|
null,
|
|
3924
3332
|
null,
|
|
3925
|
-
args.jobNoP
|
|
3333
|
+
args.jobNoP,
|
|
3926
3334
|
);
|
|
3927
3335
|
}
|
|
3928
|
-
} else console.error(
|
|
3336
|
+
} else console.error('*execute_onscreen_view_events error');
|
|
3929
3337
|
};
|
|
3930
|
-
func.datasource.get_event_interval_arr = function (
|
|
3931
|
-
SESSION_ID,
|
|
3932
|
-
dataSourceSession,
|
|
3933
|
-
typeP
|
|
3934
|
-
) {
|
|
3338
|
+
func.datasource.get_event_interval_arr = function (SESSION_ID, dataSourceSession, typeP) {
|
|
3935
3339
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
3936
3340
|
// var v = _ds.v;
|
|
3937
3341
|
var arr = [];
|
|
@@ -3972,19 +3376,17 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
|
|
|
3972
3376
|
Number(key) > 0 &&
|
|
3973
3377
|
(val.screenId === screenIdP ||
|
|
3974
3378
|
val.rootScreenId === screenIdP ||
|
|
3975
|
-
$(
|
|
3379
|
+
$('#' + val.screenId)
|
|
3976
3380
|
.parent()
|
|
3977
|
-
.attr(
|
|
3978
|
-
(val &&
|
|
3979
|
-
val.parentDataSourceNo &&
|
|
3980
|
-
arr.includes(val.parentDataSourceNo.toString())))
|
|
3381
|
+
.attr('id') === screenIdP ||
|
|
3382
|
+
(val && val.parentDataSourceNo && arr.includes(val.parentDataSourceNo.toString())))
|
|
3981
3383
|
) {
|
|
3982
3384
|
arr.push(key);
|
|
3983
3385
|
if (val.screenId) func.UI.utils.screen_blocker(false, val.screenId);
|
|
3984
3386
|
}
|
|
3985
3387
|
} catch (err) {
|
|
3986
|
-
console.warn(
|
|
3987
|
-
func.datasource.reset_jobs(SESSION_ID, key,
|
|
3388
|
+
console.warn('func.datasource.clean failed');
|
|
3389
|
+
func.datasource.reset_jobs(SESSION_ID, key, 'datasource.clean', err);
|
|
3988
3390
|
}
|
|
3989
3391
|
}
|
|
3990
3392
|
for (let val of arr) {
|
|
@@ -3992,27 +3394,19 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
|
|
|
3992
3394
|
}
|
|
3993
3395
|
};
|
|
3994
3396
|
func.datasource.del = function (SESSION_ID, dsP) {
|
|
3995
|
-
if (
|
|
3996
|
-
|
|
3997
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].keep_alive) ||
|
|
3998
|
-
dsP == 0
|
|
3999
|
-
)
|
|
4000
|
-
return;
|
|
4001
|
-
if (
|
|
4002
|
-
DATASOURCE_INTERVALS[SESSION_ID] &&
|
|
4003
|
-
DATASOURCE_INTERVALS[SESSION_ID][dsP]
|
|
4004
|
-
) {
|
|
3397
|
+
if ((SESSION_OBJ[SESSION_ID].DS_GLB[dsP] && SESSION_OBJ[SESSION_ID].DS_GLB[dsP].keep_alive) || dsP == 0) return;
|
|
3398
|
+
if (DATASOURCE_INTERVALS[SESSION_ID] && DATASOURCE_INTERVALS[SESSION_ID][dsP]) {
|
|
4005
3399
|
DATASOURCE_INTERVALS[SESSION_ID][dsP].clear();
|
|
4006
3400
|
}
|
|
4007
3401
|
|
|
4008
3402
|
const perform_delete = async function () {
|
|
4009
3403
|
var response = {
|
|
4010
|
-
success: function (jsonP, ajaxP) {
|
|
3404
|
+
success: function (jsonP, ajaxP) {},
|
|
4011
3405
|
error: function (status) {
|
|
4012
|
-
console.error(
|
|
3406
|
+
console.error('error datasource:' + status);
|
|
4013
3407
|
},
|
|
4014
3408
|
fail: function (status) {
|
|
4015
|
-
console.error(
|
|
3409
|
+
console.error('error datasource:' + status);
|
|
4016
3410
|
},
|
|
4017
3411
|
};
|
|
4018
3412
|
|
|
@@ -4026,14 +3420,9 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
4026
3420
|
let _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsP];
|
|
4027
3421
|
if (_ds.worker_id) {
|
|
4028
3422
|
// if (_ds.data_xuda) console.log(dsP);
|
|
4029
|
-
if (
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
(!_session.opt.app_computing_mode ||
|
|
4033
|
-
_session.opt.app_computing_mode === "server")
|
|
4034
|
-
) {
|
|
4035
|
-
WEB_WORKER[SESSION_ID][_ds.worker_id].emit("message", {
|
|
4036
|
-
service: "close_websocket",
|
|
3423
|
+
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
|
|
3424
|
+
WEB_WORKER[SESSION_ID][_ds.worker_id].emit('message', {
|
|
3425
|
+
service: 'close_websocket',
|
|
4037
3426
|
});
|
|
4038
3427
|
} else {
|
|
4039
3428
|
WEB_WORKER[SESSION_ID][_ds.worker_id].worker.terminate();
|
|
@@ -4042,7 +3431,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
4042
3431
|
delete WEB_WORKER[SESSION_ID][_ds.worker_id];
|
|
4043
3432
|
} else {
|
|
4044
3433
|
const json = await func.index.call_worker(SESSION_ID, {
|
|
4045
|
-
service:
|
|
3434
|
+
service: 'datasource_delete',
|
|
4046
3435
|
data: data,
|
|
4047
3436
|
id: _ds.worker_id,
|
|
4048
3437
|
});
|
|
@@ -4058,7 +3447,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
4058
3447
|
_.forEach(SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs, function (val, key) {
|
|
4059
3448
|
if (val && val.dsSessionP == dsP) {
|
|
4060
3449
|
arr.push(key);
|
|
4061
|
-
for (const [key, val] of Object.entries($(
|
|
3450
|
+
for (const [key, val] of Object.entries($('.screen_blocker'))) {
|
|
4062
3451
|
$(val).remove();
|
|
4063
3452
|
}
|
|
4064
3453
|
}
|
|
@@ -4066,23 +3455,16 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
4066
3455
|
for (let val of arr.reverse()) {
|
|
4067
3456
|
SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.splice(val, 1);
|
|
4068
3457
|
}
|
|
4069
|
-
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length)
|
|
4070
|
-
SESSION_OBJ[SESSION_ID].WORKER_OBJ.stat = null;
|
|
3458
|
+
if (!SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs.length) SESSION_OBJ[SESSION_ID].WORKER_OBJ.stat = null;
|
|
4071
3459
|
};
|
|
4072
3460
|
if (!glb.IS_WORKER) {
|
|
4073
3461
|
if (SESSION_OBJ[SESSION_ID].DS_GLB[dsP]) {
|
|
4074
|
-
delete SCREEN_BLOCKER_OBJ[
|
|
4075
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].screenId +
|
|
4076
|
-
"_" +
|
|
4077
|
-
SESSION_OBJ[SESSION_ID].DS_GLB[dsP].callingScreenId
|
|
4078
|
-
];
|
|
3462
|
+
delete SCREEN_BLOCKER_OBJ[SESSION_OBJ[SESSION_ID].DS_GLB[dsP].screenId + '_' + SESSION_OBJ[SESSION_ID].DS_GLB[dsP].callingScreenId];
|
|
4079
3463
|
|
|
4080
3464
|
delete_pending_jobs();
|
|
4081
3465
|
}
|
|
4082
|
-
if ($(SESSION_OBJ[SESSION_ID].root_element).find(
|
|
4083
|
-
var ds_obj = $(SESSION_OBJ[SESSION_ID].root_element)
|
|
4084
|
-
.find("xu-nav")
|
|
4085
|
-
?.data()?.xuData.nav_params;
|
|
3466
|
+
if ($(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav').length) {
|
|
3467
|
+
var ds_obj = $(SESSION_OBJ[SESSION_ID].root_element).find('xu-nav')?.data()?.xuData.nav_params;
|
|
4086
3468
|
if (ds_obj) {
|
|
4087
3469
|
delete ds_obj[dsP];
|
|
4088
3470
|
}
|
|
@@ -4090,86 +3472,63 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
4090
3472
|
}
|
|
4091
3473
|
perform_delete();
|
|
4092
3474
|
};
|
|
4093
|
-
func.datasource.update = async function (
|
|
4094
|
-
SESSION_ID,
|
|
4095
|
-
datasource_changes,
|
|
4096
|
-
update_local_scope_only,
|
|
4097
|
-
avoid_refresh
|
|
4098
|
-
) {
|
|
3475
|
+
func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
4099
3476
|
return new Promise(async (resolve, reject) => {
|
|
4100
3477
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
4101
3478
|
|
|
4102
|
-
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !==
|
|
4103
|
-
update_local_scope_only = true
|
|
3479
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
3480
|
+
update_local_scope_only = true;
|
|
4104
3481
|
}
|
|
4105
3482
|
|
|
4106
|
-
if (typeof glb.GLOBAL_VARS ===
|
|
4107
|
-
glb.GLOBAL_VARS = (
|
|
4108
|
-
await func.common.get_module(
|
|
4109
|
-
SESSION_ID,
|
|
4110
|
-
"xuda-system-globals-module.mjs"
|
|
4111
|
-
)
|
|
4112
|
-
).system_globals;
|
|
3483
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
3484
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
4113
3485
|
}
|
|
4114
3486
|
|
|
4115
3487
|
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
4116
|
-
|
|
4117
3488
|
// iterate child ds
|
|
4118
3489
|
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
4119
3490
|
if (parent_ds !== null) {
|
|
4120
|
-
if (_ds.parentDataSourceNo != parent_ds) continue
|
|
3491
|
+
if (_ds.parentDataSourceNo != parent_ds) continue;
|
|
4121
3492
|
} else {
|
|
4122
|
-
if (dsSession != dsNo) continue
|
|
3493
|
+
if (dsSession != dsNo) continue;
|
|
4123
3494
|
}
|
|
4124
3495
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4125
|
-
if (tree_ret.menuType ===
|
|
3496
|
+
if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
|
|
4126
3497
|
// check if field has fieldComputed property
|
|
4127
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4128
|
-
SESSION_ID,
|
|
4129
|
-
dsSession
|
|
4130
|
-
);
|
|
3498
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
|
|
4131
3499
|
// find if field is computed
|
|
4132
|
-
let fieldComputed_propExpressions, fieldComputed_id
|
|
3500
|
+
let fieldComputed_propExpressions, fieldComputed_id;
|
|
4133
3501
|
for await (const val of _progFields) {
|
|
4134
|
-
|
|
4135
3502
|
const fieldId = val.data.field_id;
|
|
4136
3503
|
|
|
4137
3504
|
// if (fieldId !== field_id) continue
|
|
4138
|
-
if (val.data.type !==
|
|
3505
|
+
if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
|
|
4139
3506
|
|
|
4140
|
-
const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
3507
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue;
|
|
4141
3508
|
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
4142
|
-
fieldComputed_propExpressions = _propExpressions
|
|
4143
|
-
fieldComputed_id = fieldId
|
|
3509
|
+
fieldComputed_propExpressions = _propExpressions;
|
|
3510
|
+
fieldComputed_id = fieldId;
|
|
4144
3511
|
}
|
|
4145
3512
|
}
|
|
4146
3513
|
|
|
4147
|
-
if (!fieldComputed_id) return
|
|
4148
|
-
|
|
3514
|
+
if (!fieldComputed_id) return;
|
|
4149
3515
|
|
|
4150
3516
|
// iterate ds rows
|
|
4151
3517
|
for (const row of _ds.data_feed?.rows || []) {
|
|
4152
3518
|
// iterate row fields
|
|
4153
3519
|
for (const [key, val] of Object.entries(row)) {
|
|
4154
|
-
if (key !== fieldComputed_id) continue
|
|
3520
|
+
if (key !== fieldComputed_id) continue;
|
|
4155
3521
|
try {
|
|
4156
|
-
|
|
4157
|
-
let ret = await func.expression.get(
|
|
4158
|
-
SESSION_ID,
|
|
4159
|
-
fieldComputed_propExpressions,
|
|
4160
|
-
dsNo,
|
|
4161
|
-
"update",
|
|
4162
|
-
row._ROWID
|
|
4163
|
-
);
|
|
3522
|
+
let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
|
|
4164
3523
|
|
|
4165
3524
|
const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
|
|
4166
3525
|
if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
|
|
4167
3526
|
_ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
|
|
4168
3527
|
if (!fields_changed.includes(fieldComputed_id)) {
|
|
4169
|
-
fields_changed.push(fieldComputed_id)
|
|
3528
|
+
fields_changed.push(fieldComputed_id);
|
|
4170
3529
|
}
|
|
4171
3530
|
if (!datasource_changed.includes(dsSession)) {
|
|
4172
|
-
datasource_changed.push(dsSession)
|
|
3531
|
+
datasource_changed.push(dsSession);
|
|
4173
3532
|
}
|
|
4174
3533
|
}
|
|
4175
3534
|
} catch (err) {
|
|
@@ -4178,19 +3537,16 @@ func.datasource.update = async function (
|
|
|
4178
3537
|
}
|
|
4179
3538
|
}
|
|
4180
3539
|
}
|
|
4181
|
-
await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
3540
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
|
|
4182
3541
|
}
|
|
4183
|
-
|
|
4184
|
-
}
|
|
3542
|
+
};
|
|
4185
3543
|
|
|
4186
3544
|
var fields_changed = [];
|
|
4187
3545
|
var datasource_changed = [];
|
|
4188
|
-
let client_datasource_changes = {}
|
|
4189
|
-
let server_datasource_changes = {}
|
|
3546
|
+
let client_datasource_changes = {};
|
|
3547
|
+
let server_datasource_changes = {};
|
|
4190
3548
|
// iterate changes datasource
|
|
4191
|
-
for await (const [dataSource, row_data] of Object.entries(
|
|
4192
|
-
datasource_changes
|
|
4193
|
-
)) {
|
|
3549
|
+
for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
|
|
4194
3550
|
var _ds = _session.DS_GLB[dataSource];
|
|
4195
3551
|
if (!_ds) {
|
|
4196
3552
|
continue;
|
|
@@ -4200,12 +3556,12 @@ func.datasource.update = async function (
|
|
|
4200
3556
|
// iterate changes fields
|
|
4201
3557
|
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
4202
3558
|
// mechanism to make update directly on the datasource object
|
|
4203
|
-
if (record_id ===
|
|
3559
|
+
if (record_id === 'datasource_main') {
|
|
4204
3560
|
_.set(_ds, field_id, value);
|
|
4205
3561
|
continue;
|
|
4206
3562
|
}
|
|
4207
3563
|
|
|
4208
|
-
if (typeof fields_data ===
|
|
3564
|
+
if (typeof fields_data === 'object') {
|
|
4209
3565
|
if (glb.GLOBAL_VARS[field_id]) {
|
|
4210
3566
|
_ds.data_system[field_id] = value;
|
|
4211
3567
|
|
|
@@ -4215,42 +3571,33 @@ func.datasource.update = async function (
|
|
|
4215
3571
|
try {
|
|
4216
3572
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4217
3573
|
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
4218
|
-
await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
3574
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
4219
3575
|
|
|
4220
3576
|
if (!update_local_scope_only) {
|
|
4221
3577
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4222
3578
|
if (glb.IS_WORKER) {
|
|
4223
3579
|
// RUN AT SERVER
|
|
4224
|
-
if (tree_ret.menuType ===
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
dataSource
|
|
4229
|
-
);
|
|
4230
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
4231
|
-
_progFields,
|
|
4232
|
-
"field_id",
|
|
4233
|
-
field_id
|
|
4234
|
-
);
|
|
4235
|
-
if (!view_field_obj?.data?.serverField && record_id !== "data_system") {
|
|
3580
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
3581
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
3582
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
3583
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
4236
3584
|
if (!client_datasource_changes[dataSource]) {
|
|
4237
|
-
client_datasource_changes[dataSource] = {}
|
|
3585
|
+
client_datasource_changes[dataSource] = {};
|
|
4238
3586
|
}
|
|
4239
3587
|
if (!client_datasource_changes[dataSource][record_id]) {
|
|
4240
|
-
client_datasource_changes[dataSource][record_id] = {}
|
|
3588
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
4241
3589
|
}
|
|
4242
3590
|
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
4243
3591
|
}
|
|
4244
|
-
|
|
4245
3592
|
}
|
|
4246
3593
|
} else {
|
|
4247
3594
|
// RUN AT CLIENT
|
|
4248
|
-
if ((tree_ret.menuType ===
|
|
3595
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
4249
3596
|
if (!server_datasource_changes[dataSource]) {
|
|
4250
|
-
server_datasource_changes[dataSource] = {}
|
|
3597
|
+
server_datasource_changes[dataSource] = {};
|
|
4251
3598
|
}
|
|
4252
3599
|
if (!server_datasource_changes[dataSource][record_id]) {
|
|
4253
|
-
server_datasource_changes[dataSource][record_id] = {}
|
|
3600
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
4254
3601
|
}
|
|
4255
3602
|
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
4256
3603
|
}
|
|
@@ -4270,14 +3617,10 @@ func.datasource.update = async function (
|
|
|
4270
3617
|
if (!_ds.data_feed.rows_changed) {
|
|
4271
3618
|
_ds.data_feed.rows_changed = [];
|
|
4272
3619
|
}
|
|
4273
|
-
if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
} else if (fields_data === "set") {
|
|
3620
|
+
if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
|
|
3621
|
+
} else if (fields_data === 'set') {
|
|
4277
3622
|
_ds.currentRecordId = record_id;
|
|
4278
3623
|
}
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
3624
|
}
|
|
4282
3625
|
// if (!_ds.data_feed.rows_changed) {
|
|
4283
3626
|
// _ds.data_feed.rows_changed = [];
|
|
@@ -4285,30 +3628,16 @@ func.datasource.update = async function (
|
|
|
4285
3628
|
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
4286
3629
|
// _ds.data_feed.rows_changed.push(record_id);
|
|
4287
3630
|
}
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
3631
|
}
|
|
4294
3632
|
|
|
4295
3633
|
if (glb.IS_WORKER) {
|
|
4296
|
-
|
|
4297
3634
|
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
4298
|
-
func.utils.post_back_to_client(
|
|
4299
|
-
SESSION_ID,
|
|
4300
|
-
"update_client_eventChangesResults_from_worker",
|
|
4301
|
-
_session.worker_id,
|
|
4302
|
-
client_datasource_changes
|
|
4303
|
-
);
|
|
4304
|
-
|
|
3635
|
+
func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
|
|
4305
3636
|
}
|
|
4306
|
-
|
|
4307
3637
|
} else {
|
|
4308
3638
|
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
4309
|
-
|
|
4310
3639
|
const ret = await func.index.call_worker(SESSION_ID, {
|
|
4311
|
-
service:
|
|
3640
|
+
service: 'update_datasource_changes_from_client',
|
|
4312
3641
|
data: {
|
|
4313
3642
|
session_id: SESSION_ID,
|
|
4314
3643
|
datasource_changes: server_datasource_changes,
|
|
@@ -4323,16 +3652,14 @@ func.datasource.update = async function (
|
|
|
4323
3652
|
SESSION_ID,
|
|
4324
3653
|
fields_changed,
|
|
4325
3654
|
null,
|
|
4326
|
-
datasource_changed[0] // refresh the current datasource only
|
|
3655
|
+
datasource_changed[0], // refresh the current datasource only
|
|
4327
3656
|
);
|
|
4328
3657
|
}
|
|
4329
3658
|
}
|
|
4330
3659
|
resolve();
|
|
4331
3660
|
});
|
|
4332
|
-
|
|
4333
3661
|
};
|
|
4334
3662
|
|
|
4335
|
-
|
|
4336
3663
|
// func.datasource.update = async function (
|
|
4337
3664
|
// SESSION_ID,
|
|
4338
3665
|
// datasource_changes,
|
|
@@ -4418,8 +3745,6 @@ func.datasource.update = async function (
|
|
|
4418
3745
|
// }
|
|
4419
3746
|
// debugger
|
|
4420
3747
|
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
3748
|
// }
|
|
4424
3749
|
|
|
4425
3750
|
// var fields_changed = [];
|
|
@@ -4458,8 +3783,6 @@ func.datasource.update = async function (
|
|
|
4458
3783
|
// console.error(err);
|
|
4459
3784
|
// }
|
|
4460
3785
|
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
3786
|
// if (!fields_changed.includes(field_id)) {
|
|
4464
3787
|
// fields_changed.push(field_id);
|
|
4465
3788
|
// }
|
|
@@ -4503,14 +3826,12 @@ func.datasource.update = async function (
|
|
|
4503
3826
|
// _ds.data_feed.rows_changed.push(record_id);
|
|
4504
3827
|
// }
|
|
4505
3828
|
|
|
4506
|
-
|
|
4507
3829
|
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
4508
3830
|
|
|
4509
3831
|
// if (!update_local_scope_only) {
|
|
4510
3832
|
// if (glb.IS_WORKER) {
|
|
4511
3833
|
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4512
3834
|
|
|
4513
|
-
|
|
4514
3835
|
// if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
4515
3836
|
// continue;
|
|
4516
3837
|
// }
|
|
@@ -4567,55 +3888,53 @@ func.datasource.update = async function (
|
|
|
4567
3888
|
// });
|
|
4568
3889
|
// };
|
|
4569
3890
|
|
|
4570
|
-
func.datasource.callback = function (
|
|
4571
|
-
SESSION_ID,
|
|
4572
|
-
dsSessionP,
|
|
4573
|
-
na,
|
|
4574
|
-
rowIdP,
|
|
4575
|
-
jobNoP,
|
|
4576
|
-
NA_callingDataSourceP,
|
|
4577
|
-
NA_isInitP,
|
|
4578
|
-
nodeIdP
|
|
4579
|
-
) {
|
|
3891
|
+
func.datasource.callback = async function (SESSION_ID, dsSessionP, na, rowIdP, jobNoP, NA_callingDataSourceP, NA_isInitP, nodeIdP) {
|
|
4580
3892
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
4581
3893
|
var _ds = _session.DS_GLB[dsSessionP];
|
|
4582
3894
|
|
|
4583
3895
|
try {
|
|
4584
|
-
const row_idx = func.common.find_ROWID_idx(_ds,
|
|
3896
|
+
const row_idx = func.common.find_ROWID_idx(_ds, 'dataset');
|
|
4585
3897
|
|
|
4586
3898
|
if (_ds.PARAM_OUT_INFO) {
|
|
4587
3899
|
// write log for out params
|
|
4588
3900
|
for (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
4589
|
-
if (
|
|
4590
|
-
typeof _ds?.data_feed?.rows?.[row_idx]?.[val.fieldId] === "undefined"
|
|
4591
|
-
) {
|
|
3901
|
+
if (typeof _ds?.data_feed?.rows?.[row_idx]?.[val.fieldId] === 'undefined') {
|
|
4592
3902
|
// func.utils.debug.log(SESSION_ID, key, val);
|
|
4593
|
-
func.utils.alerts.invoke(
|
|
4594
|
-
SESSION_ID,
|
|
4595
|
-
"system_msg",
|
|
4596
|
-
"SYS_MSG_0310",
|
|
4597
|
-
val.fieldId,
|
|
4598
|
-
dsSessionP
|
|
4599
|
-
);
|
|
3903
|
+
func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0310', val.fieldId, dsSessionP);
|
|
4600
3904
|
break;
|
|
4601
3905
|
}
|
|
4602
3906
|
val.result = _ds.data_feed.rows[row_idx][val.fieldId];
|
|
4603
3907
|
}
|
|
4604
3908
|
}
|
|
3909
|
+
|
|
3910
|
+
if (_ds?.progDataSource?.datasetOutputField) {
|
|
3911
|
+
let datasource_changes = {};
|
|
3912
|
+
|
|
3913
|
+
let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
|
|
3914
|
+
if (!datasource_changes[_ds.dsSession]) {
|
|
3915
|
+
datasource_changes[_ds.dsSession] = {};
|
|
3916
|
+
}
|
|
3917
|
+
if (!datasource_changes[_ds.dsSession][_ds.currentRecordId]) {
|
|
3918
|
+
datasource_changes[_ds.dsSession][_ds.currentRecordId] = {};
|
|
3919
|
+
|
|
3920
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][_ds?.progDataSource?.datasetOutputField] = _ds?.data_feed?.rows || [];
|
|
3921
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
4605
3924
|
} catch (err) {
|
|
4606
3925
|
// console.error(err);
|
|
4607
3926
|
}
|
|
4608
3927
|
|
|
4609
3928
|
func.utils.debug.log(SESSION_ID, nodeIdP, {
|
|
4610
3929
|
module: _ds.viewModule,
|
|
4611
|
-
action:
|
|
3930
|
+
action: 'close',
|
|
4612
3931
|
source: _ds.viewSourceDesc,
|
|
4613
|
-
type:
|
|
3932
|
+
type: 'adapter',
|
|
4614
3933
|
prog_id: _ds.prog_id,
|
|
4615
3934
|
dsSession: dsSessionP,
|
|
4616
|
-
prop: _ds.log_prop +
|
|
3935
|
+
prop: _ds.log_prop + ' ' + 'adapter',
|
|
4617
3936
|
});
|
|
4618
|
-
if (!glb.IS_WORKER) $(_session.root_element).css(
|
|
3937
|
+
if (!glb.IS_WORKER) $(_session.root_element).css('cursor', 'default');
|
|
4619
3938
|
|
|
4620
3939
|
if (_ds.prog_id) {
|
|
4621
3940
|
let _ds = _session.DS_GLB[dsSessionP];
|
|
@@ -4623,19 +3942,17 @@ func.datasource.callback = function (
|
|
|
4623
3942
|
func.utils.debug.watch(
|
|
4624
3943
|
SESSION_ID,
|
|
4625
3944
|
_ds.prog_id,
|
|
4626
|
-
|
|
3945
|
+
'program',
|
|
4627
3946
|
{
|
|
4628
3947
|
in_parameters: _ds.in_parameters,
|
|
4629
3948
|
out_parameters: _ds.out_parameters,
|
|
4630
3949
|
data_feed: _ds.data_feed,
|
|
4631
3950
|
},
|
|
4632
|
-
_ds.tree_obj.menuType
|
|
3951
|
+
_ds.tree_obj.menuType,
|
|
4633
3952
|
);
|
|
4634
3953
|
}
|
|
4635
3954
|
delete _ds.old_dataSource;
|
|
4636
3955
|
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
3956
|
return {
|
|
4640
3957
|
SESSION_ID,
|
|
4641
3958
|
dsSessionP,
|
|
@@ -4645,28 +3962,14 @@ func.datasource.callback = function (
|
|
|
4645
3962
|
calling_jobP: _ds.calling_jobP,
|
|
4646
3963
|
};
|
|
4647
3964
|
};
|
|
4648
|
-
func.datasource.validate_viewRange = async function (
|
|
4649
|
-
SESSION_ID,
|
|
4650
|
-
viewRangeExpP,
|
|
4651
|
-
dsSessionP,
|
|
4652
|
-
rowIdP,
|
|
4653
|
-
sourceP
|
|
4654
|
-
) {
|
|
3965
|
+
func.datasource.validate_viewRange = async function (SESSION_ID, viewRangeExpP, dsSessionP, rowIdP, sourceP) {
|
|
4655
3966
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
4656
3967
|
if (viewRangeExpP && _ds) {
|
|
4657
|
-
var ret = func.expression.remove_quotes(
|
|
4658
|
-
await func.expression.get(
|
|
4659
|
-
SESSION_ID,
|
|
4660
|
-
viewRangeExpP,
|
|
4661
|
-
dsSessionP,
|
|
4662
|
-
"range",
|
|
4663
|
-
rowIdP
|
|
4664
|
-
)
|
|
4665
|
-
);
|
|
3968
|
+
var ret = func.expression.remove_quotes(await func.expression.get(SESSION_ID, viewRangeExpP, dsSessionP, 'range', rowIdP));
|
|
4666
3969
|
ret.result = func.expression.remove_quotes(ret.result);
|
|
4667
3970
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
4668
3971
|
module: _ds.viewModule,
|
|
4669
|
-
action:
|
|
3972
|
+
action: 'range Exp',
|
|
4670
3973
|
prop: sourceP,
|
|
4671
3974
|
details: viewRangeExpP,
|
|
4672
3975
|
result: ret.result,
|
|
@@ -4689,27 +3992,13 @@ func.datasource.validate_viewRange = async function (
|
|
|
4689
3992
|
return ret.result;
|
|
4690
3993
|
} else return false;
|
|
4691
3994
|
};
|
|
4692
|
-
func.datasource.validate_viewLocate = async function (
|
|
4693
|
-
SESSION_ID,
|
|
4694
|
-
viewLocateExpP,
|
|
4695
|
-
dsSessionP,
|
|
4696
|
-
rowIdP,
|
|
4697
|
-
sourceP
|
|
4698
|
-
) {
|
|
3995
|
+
func.datasource.validate_viewLocate = async function (SESSION_ID, viewLocateExpP, dsSessionP, rowIdP, sourceP) {
|
|
4699
3996
|
if (viewLocateExpP && _ds) {
|
|
4700
|
-
var ret = func.expression.remove_quotes(
|
|
4701
|
-
await func.expression.get(
|
|
4702
|
-
SESSION_ID,
|
|
4703
|
-
viewLocateExpP,
|
|
4704
|
-
dsSessionP,
|
|
4705
|
-
"locate",
|
|
4706
|
-
rowIdP
|
|
4707
|
-
)
|
|
4708
|
-
);
|
|
3997
|
+
var ret = func.expression.remove_quotes(await func.expression.get(SESSION_ID, viewLocateExpP, dsSessionP, 'locate', rowIdP));
|
|
4709
3998
|
ret.result = func.expression.remove_quotes(ret.result);
|
|
4710
3999
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
4711
4000
|
module: _ds.viewModule,
|
|
4712
|
-
action:
|
|
4001
|
+
action: 'locate Exp',
|
|
4713
4002
|
prop: sourceP,
|
|
4714
4003
|
details: viewLocateExpP,
|
|
4715
4004
|
result: ret.result,
|
|
@@ -4724,12 +4013,7 @@ func.datasource.validate_viewLocate = async function (
|
|
|
4724
4013
|
} else return false;
|
|
4725
4014
|
};
|
|
4726
4015
|
|
|
4727
|
-
func.datasource.get_viewFields_for_update_function = function (
|
|
4728
|
-
SESSION_ID,
|
|
4729
|
-
calling_trigger_prop,
|
|
4730
|
-
na,
|
|
4731
|
-
dsSessionP
|
|
4732
|
-
) {
|
|
4016
|
+
func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calling_trigger_prop, na, dsSessionP) {
|
|
4733
4017
|
var viewFields = [];
|
|
4734
4018
|
|
|
4735
4019
|
var exp = calling_trigger_prop?.data?.name?.value;
|
|
@@ -4738,7 +4022,7 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
4738
4022
|
}
|
|
4739
4023
|
try {
|
|
4740
4024
|
// parse json
|
|
4741
|
-
var json = JSON5.parse(exp.replace(/\n/gi,
|
|
4025
|
+
var json = JSON5.parse(exp.replace(/\n/gi, ''));
|
|
4742
4026
|
for (const [key, val] of Object.entries(json)) {
|
|
4743
4027
|
let id = key.substr(1, key.length - 1);
|
|
4744
4028
|
if (!id) continue;
|
|
@@ -4752,13 +4036,12 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
4752
4036
|
if (!exp) {
|
|
4753
4037
|
return;
|
|
4754
4038
|
}
|
|
4755
|
-
if (exp.substr(exp.length - 1, 1) ===
|
|
4756
|
-
exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
4039
|
+
if (exp.substr(exp.length - 1, 1) === ';') exp = exp.substr(0, exp.length - 1); // remove closing if exist;
|
|
4757
4040
|
var exp_arr = exp.split(/;\s*(?=(?:[^"]|"[^"]*")*$)/g); // split ; outside quotes
|
|
4758
4041
|
if (exp_arr?.length) {
|
|
4759
4042
|
for (let val of exp_arr) {
|
|
4760
4043
|
// run view fields
|
|
4761
|
-
var pos = val.indexOf(
|
|
4044
|
+
var pos = val.indexOf(':');
|
|
4762
4045
|
var seg = [val.substring(0, pos), val.substring(pos + 1)];
|
|
4763
4046
|
if (seg && seg.length === 2) {
|
|
4764
4047
|
let id = seg[0].substr(1, seg[0].length);
|
|
@@ -4771,14 +4054,14 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
4771
4054
|
} else {
|
|
4772
4055
|
func.utils.debug.log(SESSION_ID, _ds.prog_id, {
|
|
4773
4056
|
module: _ds.viewModule,
|
|
4774
|
-
action:
|
|
4775
|
-
prop:
|
|
4057
|
+
action: 'set',
|
|
4058
|
+
prop: 'parse update exp',
|
|
4776
4059
|
details: exp,
|
|
4777
|
-
result:
|
|
4778
|
-
error:
|
|
4060
|
+
result: '',
|
|
4061
|
+
error: 'Invalid json; too many segments',
|
|
4779
4062
|
source: _ds.viewSourceDesc,
|
|
4780
|
-
json:
|
|
4781
|
-
fields:
|
|
4063
|
+
json: '',
|
|
4064
|
+
fields: '',
|
|
4782
4065
|
dsSession: dsSessionP,
|
|
4783
4066
|
});
|
|
4784
4067
|
}
|
|
@@ -4788,74 +4071,36 @@ func.datasource.get_viewFields_for_update_function = function (
|
|
|
4788
4071
|
return viewFields;
|
|
4789
4072
|
}
|
|
4790
4073
|
};
|
|
4791
|
-
func.datasource.get_value = async function (
|
|
4792
|
-
SESSION_ID,
|
|
4793
|
-
fieldIdP,
|
|
4794
|
-
dsSessionP,
|
|
4795
|
-
rowIdP,
|
|
4796
|
-
org_dsSessionP
|
|
4797
|
-
) {
|
|
4074
|
+
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
4798
4075
|
const return_value = async (field_id, value) => {
|
|
4799
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
);
|
|
4803
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
4804
|
-
_progFields,
|
|
4805
|
-
"field_id",
|
|
4806
|
-
field_id
|
|
4807
|
-
);
|
|
4808
|
-
var fieldType = view_field_obj?.props?.fieldType || "string";
|
|
4076
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
4077
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
4078
|
+
var fieldType = view_field_obj?.props?.fieldType || 'string';
|
|
4809
4079
|
var fieldProp = view_field_obj?.props;
|
|
4810
4080
|
let table_field_obj;
|
|
4811
|
-
if (view_field_obj?.data?.type ===
|
|
4081
|
+
if (view_field_obj?.data?.type === 'table') {
|
|
4812
4082
|
if (!_ds._dataSourceTableId) {
|
|
4813
|
-
return func.utils.debug_report(
|
|
4814
|
-
SESSION_ID,
|
|
4815
|
-
"Datasource",
|
|
4816
|
-
`Table type defined without dataSourceTableId deceleration`,
|
|
4817
|
-
"E"
|
|
4818
|
-
);
|
|
4083
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `Table type defined without dataSourceTableId deceleration`, 'E');
|
|
4819
4084
|
}
|
|
4820
4085
|
|
|
4821
|
-
let table_obj = await func.utils.FILES_OBJ.get(
|
|
4822
|
-
SESSION_ID,
|
|
4823
|
-
_ds._dataSourceTableId
|
|
4824
|
-
);
|
|
4086
|
+
let table_obj = await func.utils.FILES_OBJ.get(SESSION_ID, _ds._dataSourceTableId);
|
|
4825
4087
|
|
|
4826
4088
|
if (!table_obj) {
|
|
4827
|
-
return func.utils.debug_report(
|
|
4828
|
-
SESSION_ID,
|
|
4829
|
-
"Datasource",
|
|
4830
|
-
`dataSourceTableId reference error: ` + _ds._dataSourceTableId,
|
|
4831
|
-
"E"
|
|
4832
|
-
);
|
|
4089
|
+
return func.utils.debug_report(SESSION_ID, 'Datasource', `dataSourceTableId reference error: ` + _ds._dataSourceTableId, 'E');
|
|
4833
4090
|
}
|
|
4834
|
-
table_field_obj = func.common.find_item_by_key(
|
|
4835
|
-
table_obj.tableFields,
|
|
4836
|
-
"field_id",
|
|
4837
|
-
field_id
|
|
4838
|
-
);
|
|
4091
|
+
table_field_obj = func.common.find_item_by_key(table_obj.tableFields, 'field_id', field_id);
|
|
4839
4092
|
fieldType = table_field_obj.props?.fieldType;
|
|
4840
4093
|
fieldProp = table_field_obj.props;
|
|
4841
4094
|
}
|
|
4842
4095
|
|
|
4843
4096
|
let ret = {
|
|
4844
|
-
value: await func.common.get_cast_val(
|
|
4845
|
-
SESSION_ID,
|
|
4846
|
-
`datasource get value ${_ds.tree_obj.menuName}`,
|
|
4847
|
-
fieldIdP,
|
|
4848
|
-
fieldType,
|
|
4849
|
-
value,
|
|
4850
|
-
null
|
|
4851
|
-
),
|
|
4097
|
+
value: await func.common.get_cast_val(SESSION_ID, `datasource get value ${_ds.tree_obj.menuName}`, fieldIdP, fieldType, value, null),
|
|
4852
4098
|
type: fieldType,
|
|
4853
4099
|
prop: fieldProp,
|
|
4854
4100
|
};
|
|
4855
4101
|
|
|
4856
|
-
if (ret.value && typeof ret.value ===
|
|
4857
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
4858
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
4102
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
4103
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
4859
4104
|
}
|
|
4860
4105
|
|
|
4861
4106
|
return {
|
|
@@ -4863,12 +4108,12 @@ func.datasource.get_value = async function (
|
|
|
4863
4108
|
dsSessionP,
|
|
4864
4109
|
fieldIdP: field_id,
|
|
4865
4110
|
currentRecordId: _ds.currentRecordId,
|
|
4866
|
-
found: typeof value !==
|
|
4111
|
+
found: typeof value !== 'undefined',
|
|
4867
4112
|
};
|
|
4868
4113
|
};
|
|
4869
4114
|
const return_dynamic_value = async (field_id, value) => {
|
|
4870
4115
|
let view_field_obj = _ds.dynamic_fields[field_id];
|
|
4871
|
-
var fieldType = view_field_obj?.props?.fieldType ||
|
|
4116
|
+
var fieldType = view_field_obj?.props?.fieldType || 'string';
|
|
4872
4117
|
var fieldProp = view_field_obj?.props;
|
|
4873
4118
|
|
|
4874
4119
|
let ret = {
|
|
@@ -4877,9 +4122,8 @@ func.datasource.get_value = async function (
|
|
|
4877
4122
|
prop: fieldProp,
|
|
4878
4123
|
};
|
|
4879
4124
|
|
|
4880
|
-
if (ret.value && typeof ret.value ===
|
|
4881
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
4882
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
4125
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
4126
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
4883
4127
|
}
|
|
4884
4128
|
|
|
4885
4129
|
return {
|
|
@@ -4887,26 +4131,18 @@ func.datasource.get_value = async function (
|
|
|
4887
4131
|
dsSessionP,
|
|
4888
4132
|
fieldIdP: field_id,
|
|
4889
4133
|
currentRecordId: _ds.currentRecordId,
|
|
4890
|
-
found: typeof value !==
|
|
4134
|
+
found: typeof value !== 'undefined',
|
|
4891
4135
|
};
|
|
4892
4136
|
};
|
|
4893
4137
|
const return_value_parameters = async (field_id, value) => {
|
|
4894
4138
|
let ret = {
|
|
4895
|
-
value: await func.common.get_cast_val(
|
|
4896
|
-
SESSION_ID,
|
|
4897
|
-
"datasource get value",
|
|
4898
|
-
fieldIdP,
|
|
4899
|
-
value.type,
|
|
4900
|
-
value.value,
|
|
4901
|
-
null
|
|
4902
|
-
),
|
|
4139
|
+
value: await func.common.get_cast_val(SESSION_ID, 'datasource get value', fieldIdP, value.type, value.value, null),
|
|
4903
4140
|
type: value.type,
|
|
4904
4141
|
prop: null,
|
|
4905
4142
|
};
|
|
4906
4143
|
|
|
4907
|
-
if (ret.value && typeof ret.value ===
|
|
4908
|
-
if (/"/.test(ret.value) && ret.value.indexOf(
|
|
4909
|
-
ret.value = ret.value.replace(/"/g, '"');
|
|
4144
|
+
if (ret.value && typeof ret.value === 'string' && ret.type !== 'exp') {
|
|
4145
|
+
if (/"/.test(ret.value) && ret.value.indexOf('\\') === -1) ret.value = ret.value.replace(/"/g, '"');
|
|
4910
4146
|
// if (/"/.test(ret.value) && ret.value.indexOf("\\") === -1)
|
|
4911
4147
|
// ret.value = ret.value.replace(/"/g, '\\"');
|
|
4912
4148
|
}
|
|
@@ -4916,7 +4152,7 @@ func.datasource.get_value = async function (
|
|
|
4916
4152
|
dsSessionP,
|
|
4917
4153
|
fieldIdP: field_id,
|
|
4918
4154
|
currentRecordId: _ds.currentRecordId,
|
|
4919
|
-
found: typeof value !==
|
|
4155
|
+
found: typeof value !== 'undefined',
|
|
4920
4156
|
};
|
|
4921
4157
|
};
|
|
4922
4158
|
const return_value_system = async (field_id, value) => {
|
|
@@ -4924,14 +4160,7 @@ func.datasource.get_value = async function (
|
|
|
4924
4160
|
let fieldProp = null;
|
|
4925
4161
|
|
|
4926
4162
|
let ret = {
|
|
4927
|
-
value: await func.common.get_cast_val(
|
|
4928
|
-
SESSION_ID,
|
|
4929
|
-
`datasource get value ${_ds.tree_obj.menuName}`,
|
|
4930
|
-
field_id,
|
|
4931
|
-
fieldType,
|
|
4932
|
-
value,
|
|
4933
|
-
null
|
|
4934
|
-
),
|
|
4163
|
+
value: await func.common.get_cast_val(SESSION_ID, `datasource get value ${_ds.tree_obj.menuName}`, field_id, fieldType, value, null),
|
|
4935
4164
|
type: fieldType,
|
|
4936
4165
|
prop: fieldProp,
|
|
4937
4166
|
};
|
|
@@ -4941,52 +4170,35 @@ func.datasource.get_value = async function (
|
|
|
4941
4170
|
dsSessionP,
|
|
4942
4171
|
fieldIdP: field_id,
|
|
4943
4172
|
currentRecordId: _ds.currentRecordId,
|
|
4944
|
-
found: typeof value !==
|
|
4173
|
+
found: typeof value !== 'undefined',
|
|
4945
4174
|
};
|
|
4946
4175
|
};
|
|
4947
4176
|
const search_in_parameters = async (field_id) => {
|
|
4948
|
-
if (typeof _ds?.in_parameters?.[field_id]?.value !==
|
|
4949
|
-
let ret = await return_value_parameters(
|
|
4950
|
-
field_id,
|
|
4951
|
-
_ds.in_parameters[field_id]
|
|
4952
|
-
);
|
|
4177
|
+
if (typeof _ds?.in_parameters?.[field_id]?.value !== 'undefined') {
|
|
4178
|
+
let ret = await return_value_parameters(field_id, _ds.in_parameters[field_id]);
|
|
4953
4179
|
return ret;
|
|
4954
4180
|
}
|
|
4955
4181
|
|
|
4956
|
-
if (typeof _ds.parentDataSourceNo !==
|
|
4182
|
+
if (typeof _ds.parentDataSourceNo !== 'undefined') {
|
|
4957
4183
|
var org_dsSession = org_dsSessionP;
|
|
4958
4184
|
if (!org_dsSessionP) org_dsSession = dsSessionP;
|
|
4959
|
-
if (recordId && recordId !==
|
|
4185
|
+
if (recordId && recordId !== 'newRecord') org_dsSession = null;
|
|
4960
4186
|
|
|
4961
|
-
return await func.datasource.get_value(
|
|
4962
|
-
SESSION_ID,
|
|
4963
|
-
fieldIdP,
|
|
4964
|
-
_ds.parentDataSourceNo,
|
|
4965
|
-
recordId,
|
|
4966
|
-
org_dsSession
|
|
4967
|
-
);
|
|
4187
|
+
return await func.datasource.get_value(SESSION_ID, fieldIdP, _ds.parentDataSourceNo, recordId, org_dsSession);
|
|
4968
4188
|
}
|
|
4969
4189
|
|
|
4970
4190
|
return await return_value(field_id);
|
|
4971
4191
|
};
|
|
4972
4192
|
|
|
4973
|
-
if (typeof glb.GLOBAL_VARS ===
|
|
4974
|
-
glb.GLOBAL_VARS = (
|
|
4975
|
-
await func.common.get_module(SESSION_ID, "xuda-system-globals-module.mjs")
|
|
4976
|
-
).system_globals;
|
|
4193
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
4194
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
4977
4195
|
}
|
|
4978
4196
|
|
|
4979
4197
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
4980
4198
|
if (!_ds) {
|
|
4981
4199
|
if (dsSessionP > 0) {
|
|
4982
4200
|
// let prev_ds = dsSessionP - 1;
|
|
4983
|
-
return await func.datasource.get_value(
|
|
4984
|
-
SESSION_ID,
|
|
4985
|
-
fieldIdP,
|
|
4986
|
-
dsSessionP - 1,
|
|
4987
|
-
rowIdP,
|
|
4988
|
-
org_dsSessionP
|
|
4989
|
-
);
|
|
4201
|
+
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
4990
4202
|
}
|
|
4991
4203
|
return await return_value(fieldIdP);
|
|
4992
4204
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
@@ -5002,8 +4214,8 @@ func.datasource.get_value = async function (
|
|
|
5002
4214
|
}
|
|
5003
4215
|
|
|
5004
4216
|
if (dsSessionP > 0) {
|
|
5005
|
-
_ds.data_system[
|
|
5006
|
-
_ds.data_system[
|
|
4217
|
+
_ds.data_system['SYS_STR_ACTIVE_ROW_ID'] = _ds.currentRecordId;
|
|
4218
|
+
_ds.data_system['SYS_STR_PROG_DS_SESSION'] = dsSessionP;
|
|
5007
4219
|
}
|
|
5008
4220
|
|
|
5009
4221
|
// set system time
|
|
@@ -5014,19 +4226,15 @@ func.datasource.get_value = async function (
|
|
|
5014
4226
|
if (!_ds_0.data_system) {
|
|
5015
4227
|
_ds_0.data_system = {};
|
|
5016
4228
|
}
|
|
5017
|
-
const ts = await func.utils.get_dateTime(SESSION_ID,
|
|
4229
|
+
const ts = await func.utils.get_dateTime(SESSION_ID, 'SYS_DATE_VALUE');
|
|
5018
4230
|
for (const val of glb.SYS_DATE_ARR) {
|
|
5019
|
-
_ds_0.data_system[val] = await func.utils.get_dateTime(
|
|
5020
|
-
SESSION_ID,
|
|
5021
|
-
val,
|
|
5022
|
-
ts
|
|
5023
|
-
);
|
|
4231
|
+
_ds_0.data_system[val] = await func.utils.get_dateTime(SESSION_ID, val, ts);
|
|
5024
4232
|
}
|
|
5025
4233
|
}
|
|
5026
4234
|
}
|
|
5027
4235
|
|
|
5028
4236
|
// await func.datasource.set_system_vars(SESSION_ID, dsSessionP);
|
|
5029
|
-
if (typeof _ds?.data_system?.[fieldIdP] !==
|
|
4237
|
+
if (typeof _ds?.data_system?.[fieldIdP] !== 'undefined') {
|
|
5030
4238
|
return await return_value_system(fieldIdP, _ds?.data_system?.[fieldIdP]);
|
|
5031
4239
|
}
|
|
5032
4240
|
return await search_in_parameters(fieldIdP);
|
|
@@ -5049,28 +4257,20 @@ func.datasource.get_value = async function (
|
|
|
5049
4257
|
|
|
5050
4258
|
var _field_id = fieldIdP;
|
|
5051
4259
|
|
|
5052
|
-
if (fieldIdP.substr(0, 1) ===
|
|
4260
|
+
if (fieldIdP.substr(0, 1) === '_') {
|
|
5053
4261
|
if (_ds.alias) _field_id = _ds.alias[fieldIdP];
|
|
5054
4262
|
}
|
|
5055
4263
|
|
|
5056
4264
|
if (!org_dsSessionP && recordId) {
|
|
5057
4265
|
try {
|
|
5058
4266
|
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
5059
|
-
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !==
|
|
5060
|
-
if (
|
|
5061
|
-
|
|
5062
|
-
) {
|
|
5063
|
-
return await return_value(
|
|
5064
|
-
_field_id,
|
|
5065
|
-
_ds.data_feed.rows[row_idx][_field_id]
|
|
5066
|
-
);
|
|
4267
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== 'undefined') {
|
|
4268
|
+
if (Object.keys(_ds.data_feed?.rows?.[row_idx] || {})?.includes(_field_id)) {
|
|
4269
|
+
return await return_value(_field_id, _ds.data_feed.rows[row_idx][_field_id]);
|
|
5067
4270
|
}
|
|
5068
4271
|
|
|
5069
4272
|
if (Object.keys(_ds?.dynamic_fields || {})?.includes(_field_id)) {
|
|
5070
|
-
return await return_dynamic_value(
|
|
5071
|
-
_field_id,
|
|
5072
|
-
_ds.dynamic_fields[_field_id]
|
|
5073
|
-
);
|
|
4273
|
+
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
5074
4274
|
}
|
|
5075
4275
|
}
|
|
5076
4276
|
} catch (err) {
|
|
@@ -5081,26 +4281,19 @@ func.datasource.get_value = async function (
|
|
|
5081
4281
|
try {
|
|
5082
4282
|
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
5083
4283
|
|
|
5084
|
-
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !==
|
|
5085
|
-
return await return_value(
|
|
5086
|
-
_field_id,
|
|
5087
|
-
_ds.data_feed.rows[row_idx][_field_id]
|
|
5088
|
-
);
|
|
4284
|
+
if (typeof _ds.data_feed?.rows?.[row_idx]?.[_field_id] !== 'undefined') {
|
|
4285
|
+
return await return_value(_field_id, _ds.data_feed.rows[row_idx][_field_id]);
|
|
5089
4286
|
}
|
|
5090
|
-
} catch (error) {
|
|
4287
|
+
} catch (error) {}
|
|
5091
4288
|
|
|
5092
|
-
if (typeof _ds?.dynamic_fields?.[_field_id] !==
|
|
4289
|
+
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
5093
4290
|
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
5094
4291
|
}
|
|
5095
4292
|
|
|
5096
4293
|
return await search_in_parameters(fieldIdP);
|
|
5097
4294
|
};
|
|
5098
4295
|
|
|
5099
|
-
func.datasource.find_event_dataSource = async function (
|
|
5100
|
-
SESSION_ID,
|
|
5101
|
-
eventIdP,
|
|
5102
|
-
dsSessionP
|
|
5103
|
-
) {
|
|
4296
|
+
func.datasource.find_event_dataSource = async function (SESSION_ID, eventIdP, dsSessionP) {
|
|
5104
4297
|
const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
5105
4298
|
var ret;
|
|
5106
4299
|
//============================
|
|
@@ -5108,14 +4301,10 @@ func.datasource.find_event_dataSource = async function (
|
|
|
5108
4301
|
//============================
|
|
5109
4302
|
if (_ds?.prog_id) {
|
|
5110
4303
|
let view_ret = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5111
|
-
if (
|
|
5112
|
-
view_ret?.progEvents &&
|
|
5113
|
-
func.common.find_item_by_key(view_ret.progEvents, "event_name", eventIdP)
|
|
5114
|
-
) {
|
|
4304
|
+
if (view_ret?.progEvents && func.common.find_item_by_key(view_ret.progEvents, 'event_name', eventIdP)) {
|
|
5115
4305
|
ret = dsSessionP;
|
|
5116
|
-
if (_ds.callingSource ===
|
|
5117
|
-
if (_ds.callingSource ===
|
|
5118
|
-
ret = dsSessionP;
|
|
4306
|
+
if (_ds.callingSource === 'system') ret = 0;
|
|
4307
|
+
if (_ds.callingSource === 'program' || !_ds.callingSource) ret = dsSessionP;
|
|
5119
4308
|
// >>> found value
|
|
5120
4309
|
return ret;
|
|
5121
4310
|
}
|
|
@@ -5124,46 +4313,24 @@ func.datasource.find_event_dataSource = async function (
|
|
|
5124
4313
|
//=======================================
|
|
5125
4314
|
// continue Search in parent datasource
|
|
5126
4315
|
//=======================================
|
|
5127
|
-
if (
|
|
5128
|
-
_ds
|
|
5129
|
-
_ds.parentDataSourceNo &&
|
|
5130
|
-
Number(_ds.parentDataSourceNo) > 0 &&
|
|
5131
|
-
Number(_ds.parentDataSourceNo) < dsSessionP
|
|
5132
|
-
) {
|
|
5133
|
-
return await func.datasource.find_event_dataSource(
|
|
5134
|
-
SESSION_ID,
|
|
5135
|
-
eventIdP,
|
|
5136
|
-
_ds.parentDataSourceNo
|
|
5137
|
-
);
|
|
4316
|
+
if (_ds && _ds.parentDataSourceNo && Number(_ds.parentDataSourceNo) > 0 && Number(_ds.parentDataSourceNo) < dsSessionP) {
|
|
4317
|
+
return await func.datasource.find_event_dataSource(SESSION_ID, eventIdP, _ds.parentDataSourceNo);
|
|
5138
4318
|
} else {
|
|
5139
4319
|
//========================================
|
|
5140
4320
|
// continue Search in global system
|
|
5141
4321
|
//=========================================
|
|
5142
|
-
if (!ret)
|
|
5143
|
-
return await func.datasource.find_event_dataSource(
|
|
5144
|
-
SESSION_ID,
|
|
5145
|
-
eventIdP,
|
|
5146
|
-
0
|
|
5147
|
-
);
|
|
4322
|
+
if (!ret) return await func.datasource.find_event_dataSource(SESSION_ID, eventIdP, 0);
|
|
5148
4323
|
}
|
|
5149
4324
|
}
|
|
5150
4325
|
};
|
|
5151
4326
|
func.datasource.reset_jobs = function (SESSION_ID, dsSessionP, sourceP, errP) {
|
|
5152
|
-
for (const [key, val] of Object.entries(
|
|
5153
|
-
SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs
|
|
5154
|
-
)) {
|
|
4327
|
+
for (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].WORKER_OBJ.jobs)) {
|
|
5155
4328
|
if (val.dsSessionP === dsSessionP) {
|
|
5156
4329
|
func.events.delete_job(SESSION_ID, val.job_num);
|
|
5157
4330
|
break;
|
|
5158
4331
|
}
|
|
5159
4332
|
}
|
|
5160
|
-
func.utils.debug_report(
|
|
5161
|
-
SESSION_ID,
|
|
5162
|
-
sourceP + "Missing datasource: " + dsSessionP,
|
|
5163
|
-
errP,
|
|
5164
|
-
"W",
|
|
5165
|
-
null
|
|
5166
|
-
);
|
|
4333
|
+
func.utils.debug_report(SESSION_ID, sourceP + 'Missing datasource: ' + dsSessionP, errP, 'W', null);
|
|
5167
4334
|
};
|
|
5168
4335
|
// func.datasource.set_system_vars = async function (SESSION_ID, dsSessionP) {
|
|
5169
4336
|
// var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
@@ -5207,13 +4374,9 @@ func.datasource.reset_jobs = function (SESSION_ID, dsSessionP, sourceP, errP) {
|
|
|
5207
4374
|
// _ds_0.data_system[val] = await func.utils.get_dateTime(SESSION_ID, val, ts);
|
|
5208
4375
|
// }
|
|
5209
4376
|
// };
|
|
5210
|
-
func.datasource.get_currentRecordId = function (
|
|
5211
|
-
SESSION_ID,
|
|
5212
|
-
dsSessionP,
|
|
5213
|
-
from_datasourceP
|
|
5214
|
-
) {
|
|
4377
|
+
func.datasource.get_currentRecordId = function (SESSION_ID, dsSessionP, from_datasourceP) {
|
|
5215
4378
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
5216
|
-
if (_ds._dataSourceTableId !==
|
|
4379
|
+
if (_ds._dataSourceTableId !== '') {
|
|
5217
4380
|
var firstRecordId = _ds.firstRecordId; // returns the value of the fist row
|
|
5218
4381
|
var currentRecordId = _ds.currentRecordId; // record id that exist on ds after entering the form
|
|
5219
4382
|
var locatedRecordId = _ds.locatedRecordId; // record id located by ds
|
|
@@ -5223,7 +4386,7 @@ func.datasource.get_currentRecordId = function (
|
|
|
5223
4386
|
// set first row when no rec located
|
|
5224
4387
|
else currentRecordId = locatedRecordId; // set with located row
|
|
5225
4388
|
}
|
|
5226
|
-
} else currentRecordId =
|
|
4389
|
+
} else currentRecordId = 'newRecord'; // create mode
|
|
5227
4390
|
return currentRecordId;
|
|
5228
4391
|
};
|
|
5229
4392
|
func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
@@ -5250,34 +4413,19 @@ func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
|
5250
4413
|
interval.push(
|
|
5251
4414
|
setInterval(async function () {
|
|
5252
4415
|
if (!SESSION_OBJ[SESSION_ID]) return;
|
|
5253
|
-
var event_count = await func.datasource.get_view_events_count(
|
|
5254
|
-
SESSION_ID,
|
|
5255
|
-
dsSessionP,
|
|
5256
|
-
typeP,
|
|
5257
|
-
event_id
|
|
5258
|
-
);
|
|
4416
|
+
var event_count = await func.datasource.get_view_events_count(SESSION_ID, dsSessionP, typeP, event_id);
|
|
5259
4417
|
if (!event_count) {
|
|
5260
4418
|
fx.clear();
|
|
5261
4419
|
return;
|
|
5262
4420
|
}
|
|
5263
|
-
var event_condition = await func.expression.get(
|
|
5264
|
-
SESSION_ID,
|
|
5265
|
-
condition,
|
|
5266
|
-
dsSessionP,
|
|
5267
|
-
"condition"
|
|
5268
|
-
); // execute condition;
|
|
4421
|
+
var event_condition = await func.expression.get(SESSION_ID, condition, dsSessionP, 'condition'); // execute condition;
|
|
5269
4422
|
if (condition && !event_condition.result) return;
|
|
5270
4423
|
|
|
5271
|
-
const e = await func.datasource.execute_view_events(
|
|
5272
|
-
SESSION_ID,
|
|
5273
|
-
dsSessionP,
|
|
5274
|
-
typeP,
|
|
5275
|
-
event_id
|
|
5276
|
-
);
|
|
4424
|
+
const e = await func.datasource.execute_view_events(SESSION_ID, dsSessionP, typeP, event_id);
|
|
5277
4425
|
// for (const [key, val] of Object.entries(e)) {
|
|
5278
4426
|
// val.done = false;
|
|
5279
4427
|
// }
|
|
5280
|
-
}, Number(interval_rate) * 1000)
|
|
4428
|
+
}, Number(interval_rate) * 1000),
|
|
5281
4429
|
);
|
|
5282
4430
|
}
|
|
5283
4431
|
} else {
|
|
@@ -5286,8 +4434,7 @@ func.datasource.interval = function (session_id, dsSessionP, typeP) {
|
|
|
5286
4434
|
}
|
|
5287
4435
|
},
|
|
5288
4436
|
clear: function () {
|
|
5289
|
-
if (DATASOURCE_INTERVALS[session_id])
|
|
5290
|
-
delete DATASOURCE_INTERVALS[session_id][dsSessionP];
|
|
4437
|
+
if (DATASOURCE_INTERVALS[session_id]) delete DATASOURCE_INTERVALS[session_id][dsSessionP];
|
|
5291
4438
|
for (const [key, val] of Object.entries(interval)) {
|
|
5292
4439
|
clearInterval(val);
|
|
5293
4440
|
}
|
|
@@ -5300,12 +4447,8 @@ func.datasource.server_cron = function (session_id) {
|
|
|
5300
4447
|
var jobs = [];
|
|
5301
4448
|
// var ds = SESSION_OBJ[SESSION_ID].DS_GLB[0];
|
|
5302
4449
|
// var v = ds.v;
|
|
5303
|
-
var arr = func.datasource.get_event_interval_arr(
|
|
5304
|
-
|
|
5305
|
-
0,
|
|
5306
|
-
"server_cron"
|
|
5307
|
-
);
|
|
5308
|
-
const schedule = require("node-schedule");
|
|
4450
|
+
var arr = func.datasource.get_event_interval_arr(SESSION_ID, 0, 'server_cron');
|
|
4451
|
+
const schedule = require('node-schedule');
|
|
5309
4452
|
|
|
5310
4453
|
if (!arr.length) {
|
|
5311
4454
|
return jobs;
|
|
@@ -5318,75 +4461,43 @@ func.datasource.server_cron = function (session_id) {
|
|
|
5318
4461
|
jobs.push(
|
|
5319
4462
|
schedule.scheduleJob(cron_prop, async function () {
|
|
5320
4463
|
if (!SESSION_OBJ[SESSION_ID]) return;
|
|
5321
|
-
var event_count = await func.datasource.get_view_events_count(
|
|
5322
|
-
SESSION_ID,
|
|
5323
|
-
0,
|
|
5324
|
-
"server_cron",
|
|
5325
|
-
event_id
|
|
5326
|
-
);
|
|
4464
|
+
var event_count = await func.datasource.get_view_events_count(SESSION_ID, 0, 'server_cron', event_id);
|
|
5327
4465
|
if (!event_count) {
|
|
5328
4466
|
fx.clear();
|
|
5329
4467
|
return;
|
|
5330
4468
|
}
|
|
5331
|
-
var event_condition = await func.expression.get(
|
|
5332
|
-
SESSION_ID,
|
|
5333
|
-
condition,
|
|
5334
|
-
0,
|
|
5335
|
-
"condition"
|
|
5336
|
-
); // execute condition;
|
|
4469
|
+
var event_condition = await func.expression.get(SESSION_ID, condition, 0, 'condition'); // execute condition;
|
|
5337
4470
|
if (condition && !event_condition.result) return;
|
|
5338
4471
|
if (event_count) {
|
|
5339
|
-
const e = await func.datasource.execute_view_events(
|
|
5340
|
-
SESSION_ID,
|
|
5341
|
-
0,
|
|
5342
|
-
"server_cron",
|
|
5343
|
-
event_id
|
|
5344
|
-
);
|
|
4472
|
+
const e = await func.datasource.execute_view_events(SESSION_ID, 0, 'server_cron', event_id);
|
|
5345
4473
|
// for (const [key, val] of Object.entries(e)) {
|
|
5346
4474
|
// val.done = false;
|
|
5347
4475
|
// }
|
|
5348
4476
|
}
|
|
5349
|
-
})
|
|
4477
|
+
}),
|
|
5350
4478
|
);
|
|
5351
4479
|
}
|
|
5352
4480
|
|
|
5353
4481
|
return jobs;
|
|
5354
4482
|
};
|
|
5355
|
-
func.datasource.get_viewLoops = async function (
|
|
5356
|
-
SESSION_ID,
|
|
5357
|
-
dataSourceSession,
|
|
5358
|
-
data,
|
|
5359
|
-
batch_source,
|
|
5360
|
-
default_limit
|
|
5361
|
-
) {
|
|
4483
|
+
func.datasource.get_viewLoops = async function (SESSION_ID, dataSourceSession, data, batch_source, default_limit) {
|
|
5362
4484
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5363
4485
|
var args = _ds.args;
|
|
5364
4486
|
// var v = _ds.v;
|
|
5365
4487
|
var ret = default_limit;
|
|
5366
4488
|
|
|
5367
|
-
if (batch_source ===
|
|
5368
|
-
if (batch_source ===
|
|
5369
|
-
if (batch_source ===
|
|
4489
|
+
if (batch_source === 'db_data') ret = _.size(data.rows);
|
|
4490
|
+
if (batch_source === 'array' || batch_source === 'csv') ret = data.length;
|
|
4491
|
+
if (batch_source === 'json') ret = Object.keys(data).length;
|
|
5370
4492
|
if (_ds.progDataSource?.dataSourceLimit) {
|
|
5371
|
-
if (
|
|
5372
|
-
batch_source !== "no_data" &&
|
|
5373
|
-
Number(_ds.progDataSource?.dataSourceLimit) < ret
|
|
5374
|
-
) {
|
|
4493
|
+
if (batch_source !== 'no_data' && Number(_ds.progDataSource?.dataSourceLimit) < ret) {
|
|
5375
4494
|
ret = Number(_ds.progDataSource.dataSourceLimit);
|
|
5376
4495
|
}
|
|
5377
4496
|
if (!batch_source) ret = Number(_ds.progDataSource.dataSourceLimit);
|
|
5378
4497
|
}
|
|
5379
4498
|
if (prog_obj.progDataSource?.dataSourceLoopExp) {
|
|
5380
|
-
var n = (
|
|
5381
|
-
|
|
5382
|
-
SESSION_ID,
|
|
5383
|
-
_ds.v.viewLoopsExp,
|
|
5384
|
-
dataSourceSession,
|
|
5385
|
-
"view_loop",
|
|
5386
|
-
args.rowIdP
|
|
5387
|
-
)
|
|
5388
|
-
).result;
|
|
5389
|
-
if (batch_source !== "no_data" && n < ret) ret = n;
|
|
4499
|
+
var n = (await func.expression.get(SESSION_ID, _ds.v.viewLoopsExp, dataSourceSession, 'view_loop', args.rowIdP)).result;
|
|
4500
|
+
if (batch_source !== 'no_data' && n < ret) ret = n;
|
|
5390
4501
|
if (!batch_source) ret = n;
|
|
5391
4502
|
}
|
|
5392
4503
|
return ret;
|
|
@@ -5398,13 +4509,11 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
5398
4509
|
segTo: [],
|
|
5399
4510
|
segLocateFrom: [],
|
|
5400
4511
|
segLocateTo: [],
|
|
5401
|
-
viewModule:
|
|
4512
|
+
viewModule: 'adapter',
|
|
5402
4513
|
};
|
|
5403
4514
|
_ds.viewEventExec_arr = {};
|
|
5404
4515
|
|
|
5405
|
-
var view = _.cloneDeep(
|
|
5406
|
-
await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id)
|
|
5407
|
-
);
|
|
4516
|
+
var view = _.cloneDeep(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
|
|
5408
4517
|
|
|
5409
4518
|
_ds.v.dataSourceSrcType = view.dataSourceSrcType;
|
|
5410
4519
|
|
|
@@ -5420,7 +4529,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
5420
4529
|
}
|
|
5421
4530
|
|
|
5422
4531
|
if (glb.FUNCTION_NODES_ARR.includes(tree_ret.menuType)) {
|
|
5423
|
-
_ds.v.viewModule =
|
|
4532
|
+
_ds.v.viewModule = 'function';
|
|
5424
4533
|
}
|
|
5425
4534
|
_ds.v.viewSourceProp = tree_ret.menuType;
|
|
5426
4535
|
if (view.progEvents) _ds.v.progEvents = view.progEvents;
|
|
@@ -5434,15 +4543,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
|
|
|
5434
4543
|
}
|
|
5435
4544
|
};
|
|
5436
4545
|
|
|
5437
|
-
func.datasource.get_cast_val = async function (
|
|
5438
|
-
SESSION_ID,
|
|
5439
|
-
source,
|
|
5440
|
-
dsSession,
|
|
5441
|
-
valP,
|
|
5442
|
-
typeP,
|
|
5443
|
-
req,
|
|
5444
|
-
error
|
|
5445
|
-
) {
|
|
4546
|
+
func.datasource.get_cast_val = async function (SESSION_ID, source, dsSession, valP, typeP, req, error) {
|
|
5446
4547
|
var prog_id, prog_name;
|
|
5447
4548
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5448
4549
|
var _ds = _session.DS_GLB[dsSession];
|
|
@@ -5450,73 +4551,39 @@ func.datasource.get_cast_val = async function (
|
|
|
5450
4551
|
prog_id = _ds.prog_id;
|
|
5451
4552
|
prog_name = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id).menuName;
|
|
5452
4553
|
|
|
5453
|
-
const prog_info = prog_id ? ` (prog: ${prog_id} ${prog_name})` :
|
|
4554
|
+
const prog_info = prog_id ? ` (prog: ${prog_id} ${prog_name})` : '';
|
|
5454
4555
|
|
|
5455
4556
|
const report_conversion_error = function (res) {
|
|
5456
4557
|
var msg = `error converting from ${valP} to ${typeP}`;
|
|
5457
4558
|
if (error) {
|
|
5458
|
-
return func.utils.debug_report(SESSION_ID, msg,
|
|
4559
|
+
return func.utils.debug_report(SESSION_ID, msg, '', 'W');
|
|
5459
4560
|
}
|
|
5460
|
-
func.utils.debug_report(
|
|
5461
|
-
SESSION_ID,
|
|
5462
|
-
msg + " " + _.capitalize(source) + prog_info,
|
|
5463
|
-
"",
|
|
5464
|
-
"E"
|
|
5465
|
-
);
|
|
4561
|
+
func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'E');
|
|
5466
4562
|
};
|
|
5467
4563
|
const report_conversion_warn = function (res) {
|
|
5468
4564
|
var msg = `type mismatch auto conversion from value ${valP} to ${typeP}`;
|
|
5469
|
-
func.utils.debug_report(
|
|
5470
|
-
SESSION_ID,
|
|
5471
|
-
msg + " " + _.capitalize(source) + prog_info,
|
|
5472
|
-
"",
|
|
5473
|
-
"W"
|
|
5474
|
-
);
|
|
4565
|
+
func.utils.debug_report(SESSION_ID, msg + ' ' + _.capitalize(source) + prog_info, '', 'W');
|
|
5475
4566
|
};
|
|
5476
4567
|
// var ret = valP;
|
|
5477
4568
|
if (error) {
|
|
5478
4569
|
return report_conversion_error();
|
|
5479
4570
|
}
|
|
5480
4571
|
|
|
5481
|
-
const module = await func.common.get_module(
|
|
5482
|
-
|
|
5483
|
-
"xuda-get-cast-util-module.mjs"
|
|
5484
|
-
);
|
|
5485
|
-
return module.cast(
|
|
5486
|
-
typeP,
|
|
5487
|
-
valP,
|
|
5488
|
-
report_conversion_error,
|
|
5489
|
-
report_conversion_warn
|
|
5490
|
-
);
|
|
4572
|
+
const module = await func.common.get_module(SESSION_ID, 'xuda-get-cast-util-module.mjs');
|
|
4573
|
+
return module.cast(typeP, valP, report_conversion_error, report_conversion_warn);
|
|
5491
4574
|
};
|
|
5492
|
-
func.datasource.get_field_init_triggers_to_run = function (
|
|
5493
|
-
SESSION_ID,
|
|
5494
|
-
dataSourceSession,
|
|
5495
|
-
pre_init_fieldsP
|
|
5496
|
-
) {
|
|
4575
|
+
func.datasource.get_field_init_triggers_to_run = function (SESSION_ID, dataSourceSession, pre_init_fieldsP) {
|
|
5497
4576
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
|
|
5498
4577
|
if (!_ds) return;
|
|
5499
4578
|
|
|
5500
4579
|
return []; // inactive 021617
|
|
5501
4580
|
}; // inactive temporary, design to execute init triggers when querying large datasets
|
|
5502
|
-
func.datasource.get_pre_init_fields = function (
|
|
5503
|
-
SESSION_ID,
|
|
5504
|
-
dsSessionP,
|
|
5505
|
-
viewRangeExpP,
|
|
5506
|
-
viewSortExpP,
|
|
5507
|
-
viewGroupByExpP,
|
|
5508
|
-
viewLocateExpP
|
|
5509
|
-
) {
|
|
4581
|
+
func.datasource.get_pre_init_fields = function (SESSION_ID, dsSessionP, viewRangeExpP, viewSortExpP, viewGroupByExpP, viewLocateExpP) {
|
|
5510
4582
|
var ret = [];
|
|
5511
4583
|
return; // inactive 021617
|
|
5512
4584
|
}; // temporary inactive, init preformed on the first round
|
|
5513
4585
|
|
|
5514
|
-
func.datasource.add_dynamic_field_to_ds = function (
|
|
5515
|
-
SESSION_ID,
|
|
5516
|
-
dsSessionP,
|
|
5517
|
-
key,
|
|
5518
|
-
val
|
|
5519
|
-
) {
|
|
4586
|
+
func.datasource.add_dynamic_field_to_ds = function (SESSION_ID, dsSessionP, key, val) {
|
|
5520
4587
|
var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
|
|
5521
4588
|
if (!_ds.dynamic_fields) {
|
|
5522
4589
|
_ds.dynamic_fields = {};
|
|
@@ -5532,11 +4599,11 @@ func.datasource.add_dynamic_field_to_ds = function (
|
|
|
5532
4599
|
_ds.dynamic_fields[key] = {
|
|
5533
4600
|
id: crypto.randomUUID(),
|
|
5534
4601
|
data: {
|
|
5535
|
-
type:
|
|
4602
|
+
type: 'virtual',
|
|
5536
4603
|
field_id: key,
|
|
5537
4604
|
},
|
|
5538
4605
|
props: {
|
|
5539
|
-
fieldType: typeof
|
|
4606
|
+
fieldType: typeof val !== 'undefined' ? toType(val) : 'string',
|
|
5540
4607
|
},
|
|
5541
4608
|
value: val,
|
|
5542
4609
|
};
|
|
@@ -5547,11 +4614,7 @@ func.datasource.get_progFields = async function (SESSION_ID, dsSessionP) {
|
|
|
5547
4614
|
const _view_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5548
4615
|
return _view_obj.progFields;
|
|
5549
4616
|
};
|
|
5550
|
-
func.datasource.update_changes_for_out_parameter = async function (
|
|
5551
|
-
SESSION_ID,
|
|
5552
|
-
dsSessionP,
|
|
5553
|
-
calling_dsP
|
|
5554
|
-
) {
|
|
4617
|
+
func.datasource.update_changes_for_out_parameter = async function (SESSION_ID, dsSessionP, calling_dsP) {
|
|
5555
4618
|
let _session = SESSION_OBJ[SESSION_ID];
|
|
5556
4619
|
let _ds = _session.DS_GLB[dsSessionP];
|
|
5557
4620
|
const _calling_ds = _session.DS_GLB[calling_dsP];
|
|
@@ -5559,7 +4622,7 @@ func.datasource.update_changes_for_out_parameter = async function (
|
|
|
5559
4622
|
if (_ds.PARAM_OUT_INFO) {
|
|
5560
4623
|
let data = {};
|
|
5561
4624
|
for await (const [key, val] of Object.entries(_ds.PARAM_OUT_INFO)) {
|
|
5562
|
-
if (val.prop ===
|
|
4625
|
+
if (val.prop === 'out') {
|
|
5563
4626
|
try {
|
|
5564
4627
|
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
5565
4628
|
data[val.details] = _ds.data_feed.rows[row_idx][val.fieldId];
|
|
@@ -5581,50 +4644,31 @@ func.datasource.set_outputField = async function (SESSION_ID, dsSessionP, result
|
|
|
5581
4644
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
5582
4645
|
// let _ds = _session.DS_GLB[dsSessionP];
|
|
5583
4646
|
|
|
5584
|
-
|
|
5585
|
-
const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSessionP, args, "outputField")
|
|
5586
|
-
|
|
4647
|
+
const output_field = await func.datasource.get_args_property_value(SESSION_ID, dsSessionP, args, 'outputField');
|
|
5587
4648
|
|
|
5588
4649
|
if (output_field) {
|
|
5589
4650
|
let datasource_changes = {};
|
|
5590
4651
|
|
|
5591
|
-
let ret_get_value = await func.datasource.get_value(
|
|
5592
|
-
SESSION_ID,
|
|
5593
|
-
output_field,
|
|
5594
|
-
dsSessionP
|
|
5595
|
-
);
|
|
4652
|
+
let ret_get_value = await func.datasource.get_value(SESSION_ID, output_field, dsSessionP);
|
|
5596
4653
|
if (ret_get_value.found) {
|
|
5597
4654
|
let _ds = _session.DS_GLB[ret_get_value.dsSessionP];
|
|
5598
4655
|
if (!datasource_changes[_ds.dsSession]) {
|
|
5599
4656
|
datasource_changes[_ds.dsSession] = {};
|
|
5600
4657
|
}
|
|
5601
|
-
if (
|
|
5602
|
-
|
|
5603
|
-
) {
|
|
5604
|
-
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] =
|
|
5605
|
-
{};
|
|
4658
|
+
if (!datasource_changes[_ds.dsSession][ret_get_value.currentRecordId]) {
|
|
4659
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId] = {};
|
|
5606
4660
|
}
|
|
5607
|
-
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][
|
|
5608
|
-
output_field
|
|
5609
|
-
] = result;
|
|
4661
|
+
datasource_changes[_ds.dsSession][ret_get_value.currentRecordId][output_field] = result;
|
|
5610
4662
|
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
5611
4663
|
}
|
|
5612
4664
|
}
|
|
5613
|
-
|
|
5614
|
-
}
|
|
4665
|
+
};
|
|
5615
4666
|
|
|
5616
4667
|
func.datasource.get_args_property_value = async function (SESSION_ID, dsSession, args, prop_name) {
|
|
5617
4668
|
let _prop = args?.calling_trigger_prop?.data?.name;
|
|
5618
4669
|
let _value = _prop[prop_name];
|
|
5619
4670
|
if (_prop?.[`xu-exp:${prop_name}`]) {
|
|
5620
|
-
_value = (
|
|
5621
|
-
await func.expression.get(
|
|
5622
|
-
SESSION_ID,
|
|
5623
|
-
_prop[`xu-exp:${prop_name}`],
|
|
5624
|
-
dsSession,
|
|
5625
|
-
`${prop_name} expression`
|
|
5626
|
-
)
|
|
5627
|
-
).result;
|
|
4671
|
+
_value = (await func.expression.get(SESSION_ID, _prop[`xu-exp:${prop_name}`], dsSession, `${prop_name} expression`)).result;
|
|
5628
4672
|
}
|
|
5629
4673
|
|
|
5630
4674
|
return _value;
|