@xuda.io/xuda-worker-bundle 1.3.1247 → 1.3.1249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +391 -132
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4101,11 +4101,15 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
4101
4101
|
func.datasource.update = async function (
|
|
4102
4102
|
SESSION_ID,
|
|
4103
4103
|
datasource_changes,
|
|
4104
|
-
|
|
4104
|
+
update_local_scope_only
|
|
4105
4105
|
) {
|
|
4106
4106
|
return new Promise(async (resolve, reject) => {
|
|
4107
4107
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
4108
4108
|
|
|
4109
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
4110
|
+
update_local_scope_only = true
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4109
4113
|
if (typeof glb.GLOBAL_VARS === "undefined") {
|
|
4110
4114
|
glb.GLOBAL_VARS = (
|
|
4111
4115
|
await func.common.get_module(
|
|
@@ -4115,76 +4119,82 @@ func.datasource.update = async function (
|
|
|
4115
4119
|
).system_globals;
|
|
4116
4120
|
}
|
|
4117
4121
|
|
|
4118
|
-
|
|
4122
|
+
let fieldComputed_datasource_changes = {};
|
|
4119
4123
|
|
|
4124
|
+
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
4120
4125
|
|
|
4121
|
-
let new_datasource_changes = {};
|
|
4122
4126
|
// iterate child ds
|
|
4123
|
-
for (const [
|
|
4124
|
-
if (
|
|
4127
|
+
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
4128
|
+
if (parent_ds !== null) {
|
|
4129
|
+
if (_ds.parentDataSourceNo != parent_ds) continue
|
|
4130
|
+
} else {
|
|
4131
|
+
if (dsSession != dsNo) continue
|
|
4132
|
+
}
|
|
4133
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4134
|
+
if (tree_ret.menuType === "component" || tree_ret.menuType === "globals") {
|
|
4135
|
+
// check if field has fieldComputed property
|
|
4136
|
+
const _progFields = await func.datasource.get_progFields(
|
|
4137
|
+
SESSION_ID,
|
|
4138
|
+
dsSession
|
|
4139
|
+
);
|
|
4140
|
+
// find if field is computed
|
|
4141
|
+
let propExpressions
|
|
4142
|
+
for await (const val of _progFields) {
|
|
4125
4143
|
|
|
4144
|
+
const fieldId = val.data.field_id;
|
|
4126
4145
|
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
SESSION_ID,
|
|
4130
|
-
_ds.dsSession
|
|
4131
|
-
);
|
|
4132
|
-
// find if field is computed
|
|
4133
|
-
let propExpressions
|
|
4134
|
-
for await (const val of _progFields) {
|
|
4146
|
+
if (fieldId !== field_id) continue
|
|
4147
|
+
if (val.data.type !== "virtual" || !val.props.fieldComputed) break
|
|
4135
4148
|
|
|
4136
|
-
|
|
4149
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
4150
|
+
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
4151
|
+
propExpressions = _propExpressions
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4137
4154
|
|
|
4138
|
-
if (
|
|
4139
|
-
if (val.data.type !== "virtual" || !val.props.fieldComputed) break
|
|
4155
|
+
if (!propExpressions) return
|
|
4140
4156
|
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
propExpressions = _propExpressions
|
|
4157
|
+
if (!fieldComputed_datasource_changes[dsSession]) {
|
|
4158
|
+
fieldComputed_datasource_changes[dsSession] = {}
|
|
4144
4159
|
}
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4160
|
+
// iterate ds rows
|
|
4161
|
+
for (const row of _ds.data_feed?.rows || []) {
|
|
4162
|
+
// iterate row fields
|
|
4163
|
+
for (const [key, val] of Object.entries(row)) {
|
|
4164
|
+
if (key !== field_id) return
|
|
4165
|
+
try {
|
|
4166
|
+
if (!fieldComputed_datasource_changes[dsSession][row._ROWID]) {
|
|
4167
|
+
fieldComputed_datasource_changes[dsSession][row._ROWID] = {}
|
|
4168
|
+
}
|
|
4169
|
+
let ret = await func.expression.get(
|
|
4170
|
+
SESSION_ID,
|
|
4171
|
+
propExpressions,
|
|
4172
|
+
dsNo,
|
|
4173
|
+
"update",
|
|
4174
|
+
row._ROWID
|
|
4175
|
+
);
|
|
4176
|
+
fieldComputed_datasource_changes[dsSession][row._ROWID][field_id] = ret.result
|
|
4177
|
+
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4148
4178
|
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
// iterate ds rows
|
|
4153
|
-
for (const row of _ds.data_feed?.rows || []) {
|
|
4154
|
-
// iterate row fields
|
|
4155
|
-
for (const [key, val] of Object.entries(row)) {
|
|
4156
|
-
if (key !== field_id) return
|
|
4157
|
-
try {
|
|
4158
|
-
if (!new_datasource_changes[_ds.dsSession][row._ROWID]) {
|
|
4159
|
-
new_datasource_changes[_ds.dsSession][row._ROWID] = {}
|
|
4179
|
+
// _ds.data_feed.rows[row_idx][field_id] = ret.result;
|
|
4180
|
+
} catch (err) {
|
|
4181
|
+
console.error(err);
|
|
4160
4182
|
}
|
|
4161
|
-
let ret = await func.expression.get(
|
|
4162
|
-
SESSION_ID,
|
|
4163
|
-
propExpressions,
|
|
4164
|
-
dsNo,
|
|
4165
|
-
"update",
|
|
4166
|
-
row._ROWID
|
|
4167
|
-
);
|
|
4168
|
-
new_datasource_changes[_ds.dsSession][row._ROWID][field_id] = ret.result
|
|
4169
|
-
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4170
|
-
|
|
4171
|
-
// _ds.data_feed.rows[row_idx][field_id] = ret.result;
|
|
4172
|
-
} catch (err) {
|
|
4173
|
-
console.error(err);
|
|
4174
4183
|
}
|
|
4175
4184
|
}
|
|
4176
4185
|
}
|
|
4177
|
-
|
|
4186
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
4178
4187
|
}
|
|
4179
4188
|
debugger
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
from_worker)
|
|
4189
|
+
|
|
4190
|
+
|
|
4183
4191
|
|
|
4184
4192
|
}
|
|
4185
4193
|
|
|
4186
4194
|
var fields_changed = [];
|
|
4187
4195
|
var datasource_changed = [];
|
|
4196
|
+
let client_datasource_changes = {}
|
|
4197
|
+
let server_datasource_changes = {}
|
|
4188
4198
|
// iterate changes datasource
|
|
4189
4199
|
for await (const [dataSource, row_data] of Object.entries(
|
|
4190
4200
|
datasource_changes
|
|
@@ -4213,13 +4223,51 @@ func.datasource.update = async function (
|
|
|
4213
4223
|
try {
|
|
4214
4224
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4215
4225
|
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
4216
|
-
await set_fieldComputed_dependencies(dataSource, field_id,
|
|
4226
|
+
// await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
4227
|
+
|
|
4228
|
+
if (!update_local_scope_only) {
|
|
4229
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4230
|
+
if (glb.IS_WORKER) {
|
|
4231
|
+
// RUN AT SERVER
|
|
4232
|
+
if (tree_ret.menuType === "globals" || tree_ret.menuType === "component") {
|
|
4233
|
+
|
|
4234
|
+
const _progFields = await func.datasource.get_progFields(
|
|
4235
|
+
SESSION_ID,
|
|
4236
|
+
dataSource
|
|
4237
|
+
);
|
|
4238
|
+
let view_field_obj = func.common.find_item_by_key(
|
|
4239
|
+
_progFields,
|
|
4240
|
+
"field_id",
|
|
4241
|
+
field_id
|
|
4242
|
+
);
|
|
4243
|
+
if (!view_field_obj?.data?.serverField && record_id !== "data_system") {
|
|
4244
|
+
if (!client_datasource_changes[dataSource]) {
|
|
4245
|
+
client_datasource_changes[dataSource] = {}
|
|
4246
|
+
}
|
|
4247
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
4248
|
+
client_datasource_changes[dataSource][record_id] = {}
|
|
4249
|
+
}
|
|
4250
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
}
|
|
4254
|
+
} else {
|
|
4255
|
+
// RUN AT CLIENT
|
|
4256
|
+
if ((tree_ret.menuType === "component" && _ds._run_at !== "client") || tree_ret.menuType === "globals") {
|
|
4257
|
+
if (!server_datasource_changes[dataSource]) {
|
|
4258
|
+
server_datasource_changes[dataSource] = {}
|
|
4259
|
+
}
|
|
4260
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
4261
|
+
server_datasource_changes[dataSource][record_id] = {}
|
|
4262
|
+
}
|
|
4263
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4217
4267
|
} catch (err) {
|
|
4218
4268
|
console.error(err);
|
|
4219
4269
|
}
|
|
4220
4270
|
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
4271
|
if (!fields_changed.includes(field_id)) {
|
|
4224
4272
|
fields_changed.push(field_id);
|
|
4225
4273
|
}
|
|
@@ -4230,102 +4278,80 @@ func.datasource.update = async function (
|
|
|
4230
4278
|
_ds.currentRecordId = record_id;
|
|
4231
4279
|
}
|
|
4232
4280
|
|
|
4233
|
-
if (!from_worker) {
|
|
4234
|
-
if (glb.IS_WORKER) {
|
|
4235
|
-
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4236
|
-
|
|
4237
|
-
if (tree_ret.menuType === "globals") {
|
|
4238
|
-
|
|
4239
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4240
|
-
SESSION_ID,
|
|
4241
|
-
dataSource
|
|
4242
|
-
);
|
|
4243
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
4244
|
-
_progFields,
|
|
4245
|
-
"field_id",
|
|
4246
|
-
field_id
|
|
4247
|
-
);
|
|
4248
|
-
if (view_field_obj?.data?.serverField) {
|
|
4249
|
-
delete datasource_changes[dataSource][record_id][field_id]
|
|
4250
|
-
}
|
|
4251
4281
|
|
|
4252
|
-
if (record_id === "data_system") {
|
|
4253
|
-
delete datasource_changes[dataSource][record_id]
|
|
4254
|
-
}
|
|
4255
|
-
}
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
4282
|
}
|
|
4259
4283
|
if (!_ds.data_feed.rows_changed) {
|
|
4260
4284
|
_ds.data_feed.rows_changed = [];
|
|
4261
4285
|
}
|
|
4262
4286
|
if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
4263
4287
|
_ds.data_feed.rows_changed.push(record_id);
|
|
4288
|
+
}
|
|
4264
4289
|
|
|
4265
4290
|
|
|
4291
|
+
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
4266
4292
|
|
|
4267
|
-
}
|
|
4268
4293
|
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
// if (tree_ret.menuType === "globals") {
|
|
4294
|
+
}
|
|
4295
|
+
// if (!update_local_scope_only) {
|
|
4296
|
+
// if (glb.IS_WORKER) {
|
|
4297
|
+
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4274
4298
|
|
|
4275
|
-
// const _progFields = await func.datasource.get_progFields(
|
|
4276
|
-
// SESSION_ID,
|
|
4277
|
-
// dataSource
|
|
4278
|
-
// );
|
|
4279
|
-
// let view_field_obj = func.common.find_item_by_key(
|
|
4280
|
-
// _progFields,
|
|
4281
|
-
// "field_id",
|
|
4282
|
-
// field_id
|
|
4283
|
-
// );
|
|
4284
|
-
// server_field = view_field_obj.serverField
|
|
4285
|
-
// }
|
|
4286
4299
|
|
|
4287
4300
|
|
|
4288
|
-
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
4289
|
-
continue;
|
|
4290
|
-
}
|
|
4291
4301
|
|
|
4292
|
-
|
|
4293
|
-
// if (tree_ret.menuType !== "globals" || server_field) {
|
|
4294
|
-
continue;
|
|
4295
|
-
// }
|
|
4296
|
-
}
|
|
4297
|
-
// debugger;
|
|
4298
|
-
// update client
|
|
4302
|
+
// // update client
|
|
4299
4303
|
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4304
|
+
// func.utils.post_back_to_client(
|
|
4305
|
+
// SESSION_ID,
|
|
4306
|
+
// "update_client_eventChangesResults_from_worker",
|
|
4307
|
+
// _session.worker_id,
|
|
4308
|
+
// new_datasource_changes
|
|
4309
|
+
// );
|
|
4310
|
+
// return resolve();
|
|
4311
|
+
// }
|
|
4312
|
+
|
|
4313
|
+
// if (!glb.IS_WORKER) {
|
|
4314
|
+
// if (_ds._run_at !== "client" || _ds.tree_obj.menuType === "globals") {
|
|
4315
|
+
// // no need to update worker
|
|
4316
|
+
// // return resolve();
|
|
4317
|
+
// // continue;
|
|
4318
|
+
// // }
|
|
4319
|
+
|
|
4320
|
+
// const ret = await func.index.call_worker(SESSION_ID, {
|
|
4321
|
+
// service: "update_datasource_changes_from_client",
|
|
4322
|
+
// data: {
|
|
4323
|
+
// session_id: SESSION_ID,
|
|
4324
|
+
// new_datasource_changes,
|
|
4325
|
+
// },
|
|
4326
|
+
// id: _ds.worker_id,
|
|
4327
|
+
// });
|
|
4328
|
+
// }
|
|
4329
|
+
// }
|
|
4330
|
+
// }
|
|
4331
|
+
if (glb.IS_WORKER) {
|
|
4332
|
+
|
|
4333
|
+
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
4334
|
+
func.utils.post_back_to_client(
|
|
4335
|
+
SESSION_ID,
|
|
4336
|
+
"update_client_eventChangesResults_from_worker",
|
|
4337
|
+
_session.worker_id,
|
|
4338
|
+
client_datasource_changes
|
|
4339
|
+
);
|
|
4308
4340
|
|
|
4309
|
-
if (!glb.IS_WORKER) {
|
|
4310
|
-
if (_ds._run_at !== "client" || _ds.tree_obj.menuType === "globals") {
|
|
4311
|
-
// no need to update worker
|
|
4312
|
-
// return resolve();
|
|
4313
|
-
// continue;
|
|
4314
|
-
// }
|
|
4315
|
-
|
|
4316
|
-
const ret = await func.index.call_worker(SESSION_ID, {
|
|
4317
|
-
service: "update_datasource_changes_from_client",
|
|
4318
|
-
data: {
|
|
4319
|
-
session_id: SESSION_ID,
|
|
4320
|
-
datasource_changes,
|
|
4321
|
-
},
|
|
4322
|
-
id: _ds.worker_id,
|
|
4323
|
-
});
|
|
4324
|
-
}
|
|
4325
|
-
}
|
|
4326
4341
|
}
|
|
4327
|
-
|
|
4328
|
-
|
|
4342
|
+
|
|
4343
|
+
} else {
|
|
4344
|
+
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
4345
|
+
|
|
4346
|
+
const ret = await func.index.call_worker(SESSION_ID, {
|
|
4347
|
+
service: "update_datasource_changes_from_client",
|
|
4348
|
+
data: {
|
|
4349
|
+
session_id: SESSION_ID,
|
|
4350
|
+
server_datasource_changes,
|
|
4351
|
+
},
|
|
4352
|
+
id: _ds.worker_id,
|
|
4353
|
+
});
|
|
4354
|
+
}
|
|
4329
4355
|
///// REFRESH SCREEN
|
|
4330
4356
|
if (fields_changed.length) {
|
|
4331
4357
|
await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
@@ -4337,12 +4363,245 @@ func.datasource.update = async function (
|
|
|
4337
4363
|
);
|
|
4338
4364
|
}
|
|
4339
4365
|
}
|
|
4340
|
-
|
|
4366
|
+
resolve();
|
|
4341
4367
|
});
|
|
4368
|
+
|
|
4342
4369
|
};
|
|
4343
4370
|
|
|
4344
4371
|
|
|
4372
|
+
// func.datasource.update = async function (
|
|
4373
|
+
// SESSION_ID,
|
|
4374
|
+
// datasource_changes,
|
|
4375
|
+
// update_local_scope_only
|
|
4376
|
+
// ) {
|
|
4377
|
+
// return new Promise(async (resolve, reject) => {
|
|
4378
|
+
// var _session = SESSION_OBJ[SESSION_ID];
|
|
4379
|
+
|
|
4380
|
+
// if (typeof glb.GLOBAL_VARS === "undefined") {
|
|
4381
|
+
// glb.GLOBAL_VARS = (
|
|
4382
|
+
// await func.common.get_module(
|
|
4383
|
+
// SESSION_ID,
|
|
4384
|
+
// "xuda-system-globals-module.mjs"
|
|
4385
|
+
// )
|
|
4386
|
+
// ).system_globals;
|
|
4387
|
+
// }
|
|
4388
|
+
|
|
4389
|
+
// let fieldComputed_datasource_changes = {};
|
|
4345
4390
|
|
|
4391
|
+
// const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
4392
|
+
|
|
4393
|
+
// // iterate child ds
|
|
4394
|
+
// for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
4395
|
+
// if (parent_ds !== null) {
|
|
4396
|
+
// if (_ds.parentDataSourceNo != parent_ds) continue
|
|
4397
|
+
// } else {
|
|
4398
|
+
// if (dsSession != dsNo) continue
|
|
4399
|
+
// }
|
|
4400
|
+
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4401
|
+
// if (tree_ret.menuType === "component" || tree_ret.menuType === "globals") {
|
|
4402
|
+
// // check if field has fieldComputed property
|
|
4403
|
+
// const _progFields = await func.datasource.get_progFields(
|
|
4404
|
+
// SESSION_ID,
|
|
4405
|
+
// dsSession
|
|
4406
|
+
// );
|
|
4407
|
+
// // find if field is computed
|
|
4408
|
+
// let propExpressions
|
|
4409
|
+
// for await (const val of _progFields) {
|
|
4410
|
+
|
|
4411
|
+
// const fieldId = val.data.field_id;
|
|
4412
|
+
|
|
4413
|
+
// if (fieldId !== field_id) continue
|
|
4414
|
+
// if (val.data.type !== "virtual" || !val.props.fieldComputed) break
|
|
4415
|
+
|
|
4416
|
+
// const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
4417
|
+
// if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
4418
|
+
// propExpressions = _propExpressions
|
|
4419
|
+
// }
|
|
4420
|
+
// }
|
|
4421
|
+
|
|
4422
|
+
// if (!propExpressions) return
|
|
4423
|
+
|
|
4424
|
+
// if (!fieldComputed_datasource_changes[dsSession]) {
|
|
4425
|
+
// fieldComputed_datasource_changes[dsSession] = {}
|
|
4426
|
+
// }
|
|
4427
|
+
// // iterate ds rows
|
|
4428
|
+
// for (const row of _ds.data_feed?.rows || []) {
|
|
4429
|
+
// // iterate row fields
|
|
4430
|
+
// for (const [key, val] of Object.entries(row)) {
|
|
4431
|
+
// if (key !== field_id) return
|
|
4432
|
+
// try {
|
|
4433
|
+
// if (!fieldComputed_datasource_changes[dsSession][row._ROWID]) {
|
|
4434
|
+
// fieldComputed_datasource_changes[dsSession][row._ROWID] = {}
|
|
4435
|
+
// }
|
|
4436
|
+
// let ret = await func.expression.get(
|
|
4437
|
+
// SESSION_ID,
|
|
4438
|
+
// propExpressions,
|
|
4439
|
+
// dsNo,
|
|
4440
|
+
// "update",
|
|
4441
|
+
// row._ROWID
|
|
4442
|
+
// );
|
|
4443
|
+
// fieldComputed_datasource_changes[dsSession][row._ROWID][field_id] = ret.result
|
|
4444
|
+
// // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4445
|
+
|
|
4446
|
+
// // _ds.data_feed.rows[row_idx][field_id] = ret.result;
|
|
4447
|
+
// } catch (err) {
|
|
4448
|
+
// console.error(err);
|
|
4449
|
+
// }
|
|
4450
|
+
// }
|
|
4451
|
+
// }
|
|
4452
|
+
// }
|
|
4453
|
+
// await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
4454
|
+
// }
|
|
4455
|
+
// debugger
|
|
4456
|
+
|
|
4457
|
+
|
|
4458
|
+
|
|
4459
|
+
// }
|
|
4460
|
+
|
|
4461
|
+
// var fields_changed = [];
|
|
4462
|
+
// var datasource_changed = [];
|
|
4463
|
+
// let client_datasource_changes={}
|
|
4464
|
+
// // iterate changes datasource
|
|
4465
|
+
// for await (const [dataSource, row_data] of Object.entries(
|
|
4466
|
+
// datasource_changes
|
|
4467
|
+
// )) {
|
|
4468
|
+
// var _ds = _session.DS_GLB[dataSource];
|
|
4469
|
+
// if (!_ds) {
|
|
4470
|
+
// continue;
|
|
4471
|
+
// }
|
|
4472
|
+
// // iterate changes records
|
|
4473
|
+
// for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
4474
|
+
// // iterate changes fields
|
|
4475
|
+
// for (const [field_id, value] of Object.entries(fields_data)) {
|
|
4476
|
+
// // mechanism to make update directly on the datasource object
|
|
4477
|
+
// if (record_id === "datasource_main") {
|
|
4478
|
+
// _.set(_ds, field_id, value);
|
|
4479
|
+
// continue;
|
|
4480
|
+
// }
|
|
4481
|
+
|
|
4482
|
+
// if (typeof fields_data === "object") {
|
|
4483
|
+
// if (glb.GLOBAL_VARS[field_id]) {
|
|
4484
|
+
// _ds.data_system[field_id] = value;
|
|
4485
|
+
|
|
4486
|
+
// continue;
|
|
4487
|
+
// }
|
|
4488
|
+
|
|
4489
|
+
// try {
|
|
4490
|
+
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4491
|
+
// _ds.data_feed.rows[row_idx][field_id] = value;
|
|
4492
|
+
// await set_fieldComputed_dependencies(dataSource, field_id, null)
|
|
4493
|
+
// } catch (err) {
|
|
4494
|
+
// console.error(err);
|
|
4495
|
+
// }
|
|
4496
|
+
|
|
4497
|
+
|
|
4498
|
+
|
|
4499
|
+
// if (!fields_changed.includes(field_id)) {
|
|
4500
|
+
// fields_changed.push(field_id);
|
|
4501
|
+
// }
|
|
4502
|
+
// if (!datasource_changed.includes(dataSource)) {
|
|
4503
|
+
// datasource_changed.push(dataSource);
|
|
4504
|
+
// }
|
|
4505
|
+
// } else if (fields_data === "set") {
|
|
4506
|
+
// _ds.currentRecordId = record_id;
|
|
4507
|
+
// }
|
|
4508
|
+
|
|
4509
|
+
// if (!update_local_scope_only) {
|
|
4510
|
+
// if (glb.IS_WORKER) {
|
|
4511
|
+
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4512
|
+
|
|
4513
|
+
// if (tree_ret.menuType === "globals") {
|
|
4514
|
+
|
|
4515
|
+
// const _progFields = await func.datasource.get_progFields(
|
|
4516
|
+
// SESSION_ID,
|
|
4517
|
+
// dataSource
|
|
4518
|
+
// );
|
|
4519
|
+
// let view_field_obj = func.common.find_item_by_key(
|
|
4520
|
+
// _progFields,
|
|
4521
|
+
// "field_id",
|
|
4522
|
+
// field_id
|
|
4523
|
+
// );
|
|
4524
|
+
// if (view_field_obj?.data?.serverField) {
|
|
4525
|
+
// delete datasource_changes[dataSource][record_id][field_id]
|
|
4526
|
+
// }
|
|
4527
|
+
|
|
4528
|
+
// if (record_id === "data_system") {
|
|
4529
|
+
// delete datasource_changes[dataSource][record_id]
|
|
4530
|
+
// }
|
|
4531
|
+
// }
|
|
4532
|
+
// }
|
|
4533
|
+
// }
|
|
4534
|
+
// }
|
|
4535
|
+
// if (!_ds.data_feed.rows_changed) {
|
|
4536
|
+
// _ds.data_feed.rows_changed = [];
|
|
4537
|
+
// }
|
|
4538
|
+
// if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
4539
|
+
// _ds.data_feed.rows_changed.push(record_id);
|
|
4540
|
+
// }
|
|
4541
|
+
|
|
4542
|
+
|
|
4543
|
+
// let new_datasource_changes = { ...datasource_changes, ...fieldComputed_datasource_changes }
|
|
4544
|
+
|
|
4545
|
+
// if (!update_local_scope_only) {
|
|
4546
|
+
// if (glb.IS_WORKER) {
|
|
4547
|
+
// let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4548
|
+
|
|
4549
|
+
|
|
4550
|
+
// if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== "undefined" || typeof IS_PROCESS_SERVER !== "undefined") {
|
|
4551
|
+
// continue;
|
|
4552
|
+
// }
|
|
4553
|
+
|
|
4554
|
+
// if (tree_ret.menuType !== "component" && tree_ret.menuType !== "globals") {
|
|
4555
|
+
|
|
4556
|
+
// continue;
|
|
4557
|
+
|
|
4558
|
+
// }
|
|
4559
|
+
|
|
4560
|
+
// // update client
|
|
4561
|
+
|
|
4562
|
+
// func.utils.post_back_to_client(
|
|
4563
|
+
// SESSION_ID,
|
|
4564
|
+
// "update_client_eventChangesResults_from_worker",
|
|
4565
|
+
// _session.worker_id,
|
|
4566
|
+
// new_datasource_changes
|
|
4567
|
+
// );
|
|
4568
|
+
// return resolve();
|
|
4569
|
+
// }
|
|
4570
|
+
|
|
4571
|
+
// if (!glb.IS_WORKER) {
|
|
4572
|
+
// if (_ds._run_at !== "client" || _ds.tree_obj.menuType === "globals") {
|
|
4573
|
+
// // no need to update worker
|
|
4574
|
+
// // return resolve();
|
|
4575
|
+
// // continue;
|
|
4576
|
+
// // }
|
|
4577
|
+
|
|
4578
|
+
// const ret = await func.index.call_worker(SESSION_ID, {
|
|
4579
|
+
// service: "update_datasource_changes_from_client",
|
|
4580
|
+
// data: {
|
|
4581
|
+
// session_id: SESSION_ID,
|
|
4582
|
+
// new_datasource_changes,
|
|
4583
|
+
// },
|
|
4584
|
+
// id: _ds.worker_id,
|
|
4585
|
+
// });
|
|
4586
|
+
// }
|
|
4587
|
+
// }
|
|
4588
|
+
// }
|
|
4589
|
+
// }
|
|
4590
|
+
// if (!glb.IS_WORKER) {
|
|
4591
|
+
// ///// REFRESH SCREEN
|
|
4592
|
+
// if (fields_changed.length) {
|
|
4593
|
+
// await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
4594
|
+
// await func.UI.screen.refresh_screen(
|
|
4595
|
+
// SESSION_ID,
|
|
4596
|
+
// fields_changed,
|
|
4597
|
+
// null,
|
|
4598
|
+
// datasource_changed[0] // refresh the current datasource only
|
|
4599
|
+
// );
|
|
4600
|
+
// }
|
|
4601
|
+
// }
|
|
4602
|
+
// return resolve();
|
|
4603
|
+
// });
|
|
4604
|
+
// };
|
|
4346
4605
|
|
|
4347
4606
|
func.datasource.callback = function (
|
|
4348
4607
|
SESSION_ID,
|