@xuda.io/xuda-worker-bundle-min 1.3.1185 → 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 +360 -126
- 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,68 +4119,83 @@ func.datasource.update = async function (
|
|
|
4115
4119
|
).system_globals;
|
|
4116
4120
|
}
|
|
4117
4121
|
|
|
4118
|
-
const set_fieldComputed_dependencies = async function (dsNo, record_id, field_id, value) {
|
|
4119
|
-
// check if field has fieldComputed property
|
|
4120
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4121
|
-
SESSION_ID,
|
|
4122
|
-
dataSource
|
|
4123
|
-
);
|
|
4124
4122
|
|
|
4125
|
-
let propExpressions
|
|
4126
|
-
for await (const val of _progFields) {
|
|
4127
4123
|
|
|
4128
|
-
|
|
4124
|
+
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
4129
4125
|
|
|
4130
|
-
|
|
4131
|
-
|
|
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) {
|
|
4132
4143
|
|
|
4133
|
-
|
|
4144
|
+
const fieldId = val.data.field_id;
|
|
4134
4145
|
|
|
4135
|
-
|
|
4146
|
+
// if (fieldId !== field_id) continue
|
|
4147
|
+
if (val.data.type !== "virtual" || !val.props.fieldComputed) continue
|
|
4136
4148
|
|
|
4137
|
-
|
|
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
|
+
}
|
|
4138
4155
|
|
|
4139
|
-
|
|
4140
|
-
for (const _ds of _session.DS_GLB) {
|
|
4141
|
-
if (_ds.parentDataSourceNo !== dsNo) continue
|
|
4156
|
+
if (!fieldComputed_id) return
|
|
4142
4157
|
|
|
4143
|
-
if (!new_datasource_changes[_ds.dsSession]) {
|
|
4144
|
-
new_datasource_changes[_ds.dsSession] = {}
|
|
4145
|
-
}
|
|
4146
|
-
for (const row of _ds.data_feed?.rows || []) {
|
|
4147
|
-
for (const [key, val] of Object.entries(row)) {
|
|
4148
|
-
if (key !== field_id) return
|
|
4149
|
-
try {
|
|
4150
|
-
if (!new_datasource_changes[_ds.dsSession][row._ROWID]) {
|
|
4151
|
-
new_datasource_changes[_ds.dsSession][row._ROWID] = {}
|
|
4152
|
-
}
|
|
4153
|
-
let ret = await func.expression.get(
|
|
4154
|
-
SESSION_ID,
|
|
4155
|
-
propExpressions,
|
|
4156
|
-
dsNo,
|
|
4157
|
-
"update",
|
|
4158
|
-
row._ROWID
|
|
4159
|
-
);
|
|
4160
|
-
new_datasource_changes[_ds.dsSession][row._ROWID][field_id] = ret.result
|
|
4161
|
-
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4162
4158
|
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
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
|
+
}
|
|
4166
4187
|
}
|
|
4167
4188
|
}
|
|
4168
4189
|
}
|
|
4169
|
-
|
|
4190
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession)
|
|
4170
4191
|
}
|
|
4171
|
-
debugger
|
|
4172
|
-
await func.datasource.update(SESSION_ID,
|
|
4173
|
-
new_datasource_changes,
|
|
4174
|
-
from_worker)
|
|
4175
4192
|
|
|
4176
4193
|
}
|
|
4177
4194
|
|
|
4178
4195
|
var fields_changed = [];
|
|
4179
4196
|
var datasource_changed = [];
|
|
4197
|
+
let client_datasource_changes = {}
|
|
4198
|
+
let server_datasource_changes = {}
|
|
4180
4199
|
// iterate changes datasource
|
|
4181
4200
|
for await (const [dataSource, row_data] of Object.entries(
|
|
4182
4201
|
datasource_changes
|
|
@@ -4205,12 +4224,51 @@ func.datasource.update = async function (
|
|
|
4205
4224
|
try {
|
|
4206
4225
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4207
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
|
+
}
|
|
4208
4268
|
} catch (err) {
|
|
4209
4269
|
console.error(err);
|
|
4210
4270
|
}
|
|
4211
4271
|
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
4272
|
if (!fields_changed.includes(field_id)) {
|
|
4215
4273
|
fields_changed.push(field_id);
|
|
4216
4274
|
}
|
|
@@ -4221,102 +4279,45 @@ func.datasource.update = async function (
|
|
|
4221
4279
|
_ds.currentRecordId = record_id;
|
|
4222
4280
|
}
|
|
4223
4281
|
|
|
4224
|
-
if (!from_worker) {
|
|
4225
|
-
if (glb.IS_WORKER) {
|
|
4226
|
-
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4227
|
-
|
|
4228
|
-
if (tree_ret.menuType === "globals") {
|
|
4229
4282
|
|
|
4230
|
-
const _progFields = await func.datasource.get_progFields(
|
|
4231
|
-
SESSION_ID,
|
|
4232
|
-
dataSource
|
|
4233
|
-
);
|
|
4234
|
-
let view_field_obj = func.common.find_item_by_key(
|
|
4235
|
-
_progFields,
|
|
4236
|
-
"field_id",
|
|
4237
|
-
field_id
|
|
4238
|
-
);
|
|
4239
|
-
if (view_field_obj?.data?.serverField) {
|
|
4240
|
-
delete datasource_changes[dataSource][record_id][field_id]
|
|
4241
|
-
}
|
|
4242
|
-
|
|
4243
|
-
if (record_id === "data_system") {
|
|
4244
|
-
delete datasource_changes[dataSource][record_id]
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
}
|
|
4249
4283
|
}
|
|
4250
4284
|
if (!_ds.data_feed.rows_changed) {
|
|
4251
4285
|
_ds.data_feed.rows_changed = [];
|
|
4252
4286
|
}
|
|
4253
4287
|
if (!_ds.data_feed.rows_changed.includes(record_id))
|
|
4254
4288
|
_ds.data_feed.rows_changed.push(record_id);
|
|
4289
|
+
}
|
|
4255
4290
|
|
|
4256
4291
|
|
|
4257
4292
|
|
|
4258
|
-
}
|
|
4259
4293
|
|
|
4260
|
-
if (!from_worker) {
|
|
4261
|
-
if (glb.IS_WORKER) {
|
|
4262
|
-
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
4263
|
-
let server_field = false
|
|
4264
|
-
// if (tree_ret.menuType === "globals") {
|
|
4265
4294
|
|
|
4266
|
-
|
|
4267
|
-
// SESSION_ID,
|
|
4268
|
-
// dataSource
|
|
4269
|
-
// );
|
|
4270
|
-
// let view_field_obj = func.common.find_item_by_key(
|
|
4271
|
-
// _progFields,
|
|
4272
|
-
// "field_id",
|
|
4273
|
-
// field_id
|
|
4274
|
-
// );
|
|
4275
|
-
// server_field = view_field_obj.serverField
|
|
4276
|
-
// }
|
|
4295
|
+
}
|
|
4277
4296
|
|
|
4297
|
+
if (glb.IS_WORKER) {
|
|
4278
4298
|
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
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
|
+
);
|
|
4282
4306
|
|
|
4283
|
-
|
|
4284
|
-
// if (tree_ret.menuType !== "globals" || server_field) {
|
|
4285
|
-
continue;
|
|
4286
|
-
// }
|
|
4287
|
-
}
|
|
4288
|
-
// debugger;
|
|
4289
|
-
// update client
|
|
4307
|
+
}
|
|
4290
4308
|
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
"update_client_eventChangesResults_from_worker",
|
|
4294
|
-
_session.worker_id,
|
|
4295
|
-
datasource_changes
|
|
4296
|
-
);
|
|
4297
|
-
return resolve();
|
|
4298
|
-
}
|
|
4309
|
+
} else {
|
|
4310
|
+
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
4299
4311
|
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
service: "update_datasource_changes_from_client",
|
|
4309
|
-
data: {
|
|
4310
|
-
session_id: SESSION_ID,
|
|
4311
|
-
datasource_changes,
|
|
4312
|
-
},
|
|
4313
|
-
id: _ds.worker_id,
|
|
4314
|
-
});
|
|
4315
|
-
}
|
|
4316
|
-
}
|
|
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
|
+
});
|
|
4317
4320
|
}
|
|
4318
|
-
}
|
|
4319
|
-
if (!glb.IS_WORKER) {
|
|
4320
4321
|
///// REFRESH SCREEN
|
|
4321
4322
|
if (fields_changed.length) {
|
|
4322
4323
|
await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
@@ -4328,12 +4329,245 @@ func.datasource.update = async function (
|
|
|
4328
4329
|
);
|
|
4329
4330
|
}
|
|
4330
4331
|
}
|
|
4331
|
-
|
|
4332
|
+
resolve();
|
|
4332
4333
|
});
|
|
4334
|
+
|
|
4333
4335
|
};
|
|
4334
4336
|
|
|
4335
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
|
+
|
|
4336
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
|
+
// };
|
|
4337
4571
|
|
|
4338
4572
|
func.datasource.callback = function (
|
|
4339
4573
|
SESSION_ID,
|