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