@xuda.io/xuda-worker-bundle 1.3.1242 → 1.3.1244
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 +82 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4114,8 +4114,75 @@ func.datasource.update = async function (
|
|
|
4114
4114
|
)
|
|
4115
4115
|
).system_globals;
|
|
4116
4116
|
}
|
|
4117
|
-
|
|
4117
|
+
|
|
4118
|
+
const set_fieldComputed_dependencies = async function (dsNo, 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
|
+
// find if field is computed
|
|
4125
|
+
let propExpressions
|
|
4126
|
+
for await (const val of _progFields) {
|
|
4127
|
+
|
|
4128
|
+
const fieldId = val.data.field_id;
|
|
4129
|
+
|
|
4130
|
+
if (fieldId !== field_id) continue
|
|
4131
|
+
if (val.data.type !== "virtual" || !val.props.fieldComputed) break
|
|
4132
|
+
|
|
4133
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue
|
|
4134
|
+
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
4135
|
+
propExpressions = _propExpressions
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
if (!propExpressions) return
|
|
4140
|
+
|
|
4141
|
+
let new_datasource_changes = {};
|
|
4142
|
+
// iterate child ds
|
|
4143
|
+
for (const _ds of _session.DS_GLB) {
|
|
4144
|
+
if (_ds.parentDataSourceNo !== dsNo) continue
|
|
4145
|
+
|
|
4146
|
+
if (!new_datasource_changes[_ds.dsSession]) {
|
|
4147
|
+
new_datasource_changes[_ds.dsSession] = {}
|
|
4148
|
+
}
|
|
4149
|
+
// iterate ds rows
|
|
4150
|
+
for (const row of _ds.data_feed?.rows || []) {
|
|
4151
|
+
// iterate row fields
|
|
4152
|
+
for (const [key, val] of Object.entries(row)) {
|
|
4153
|
+
if (key !== field_id) return
|
|
4154
|
+
try {
|
|
4155
|
+
if (!new_datasource_changes[_ds.dsSession][row._ROWID]) {
|
|
4156
|
+
new_datasource_changes[_ds.dsSession][row._ROWID] = {}
|
|
4157
|
+
}
|
|
4158
|
+
let ret = await func.expression.get(
|
|
4159
|
+
SESSION_ID,
|
|
4160
|
+
propExpressions,
|
|
4161
|
+
dsNo,
|
|
4162
|
+
"update",
|
|
4163
|
+
row._ROWID
|
|
4164
|
+
);
|
|
4165
|
+
new_datasource_changes[_ds.dsSession][row._ROWID][field_id] = ret.result
|
|
4166
|
+
// const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4167
|
+
|
|
4168
|
+
// _ds.data_feed.rows[row_idx][field_id] = ret.result;
|
|
4169
|
+
} catch (err) {
|
|
4170
|
+
console.error(err);
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
}
|
|
4176
|
+
debugger
|
|
4177
|
+
await func.datasource.update(SESSION_ID,
|
|
4178
|
+
new_datasource_changes,
|
|
4179
|
+
from_worker)
|
|
4180
|
+
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
var fields_changed = [];
|
|
4118
4184
|
var datasource_changed = [];
|
|
4185
|
+
// iterate changes datasource
|
|
4119
4186
|
for await (const [dataSource, row_data] of Object.entries(
|
|
4120
4187
|
datasource_changes
|
|
4121
4188
|
)) {
|
|
@@ -4123,11 +4190,12 @@ func.datasource.update = async function (
|
|
|
4123
4190
|
if (!_ds) {
|
|
4124
4191
|
continue;
|
|
4125
4192
|
}
|
|
4126
|
-
|
|
4193
|
+
// iterate changes records
|
|
4127
4194
|
for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
4195
|
+
// iterate changes fields
|
|
4128
4196
|
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
4197
|
+
// mechanism to make update directly on the datasource object
|
|
4129
4198
|
if (record_id === "datasource_main") {
|
|
4130
|
-
// _ds[field_id] = value;
|
|
4131
4199
|
_.set(_ds, field_id, value);
|
|
4132
4200
|
continue;
|
|
4133
4201
|
}
|
|
@@ -4142,14 +4210,15 @@ func.datasource.update = async function (
|
|
|
4142
4210
|
try {
|
|
4143
4211
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
4144
4212
|
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
4213
|
+
await set_fieldComputed_dependencies(dataSource, field_id, value)
|
|
4145
4214
|
} catch (err) {
|
|
4146
4215
|
console.error(err);
|
|
4147
4216
|
}
|
|
4148
4217
|
|
|
4149
4218
|
|
|
4150
4219
|
|
|
4151
|
-
if (!
|
|
4152
|
-
|
|
4220
|
+
if (!fields_changed.includes(field_id)) {
|
|
4221
|
+
fields_changed.push(field_id);
|
|
4153
4222
|
}
|
|
4154
4223
|
if (!datasource_changed.includes(dataSource)) {
|
|
4155
4224
|
datasource_changed.push(dataSource);
|
|
@@ -4174,11 +4243,11 @@ func.datasource.update = async function (
|
|
|
4174
4243
|
field_id
|
|
4175
4244
|
);
|
|
4176
4245
|
if (view_field_obj?.data?.serverField) {
|
|
4177
|
-
delete
|
|
4246
|
+
delete datasource_changes[dataSource][record_id][field_id]
|
|
4178
4247
|
}
|
|
4179
4248
|
|
|
4180
4249
|
if (record_id === "data_system") {
|
|
4181
|
-
delete
|
|
4250
|
+
delete datasource_changes[dataSource][record_id]
|
|
4182
4251
|
}
|
|
4183
4252
|
}
|
|
4184
4253
|
}
|
|
@@ -4255,11 +4324,11 @@ func.datasource.update = async function (
|
|
|
4255
4324
|
}
|
|
4256
4325
|
if (!glb.IS_WORKER) {
|
|
4257
4326
|
///// REFRESH SCREEN
|
|
4258
|
-
if (
|
|
4259
|
-
await func.UI.screen.refresh_xu_attributes(SESSION_ID,
|
|
4327
|
+
if (fields_changed.length) {
|
|
4328
|
+
await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
4260
4329
|
await func.UI.screen.refresh_screen(
|
|
4261
4330
|
SESSION_ID,
|
|
4262
|
-
|
|
4331
|
+
fields_changed,
|
|
4263
4332
|
null,
|
|
4264
4333
|
datasource_changed[0] // refresh the current datasource only
|
|
4265
4334
|
);
|
|
@@ -4269,6 +4338,9 @@ func.datasource.update = async function (
|
|
|
4269
4338
|
});
|
|
4270
4339
|
};
|
|
4271
4340
|
|
|
4341
|
+
|
|
4342
|
+
|
|
4343
|
+
|
|
4272
4344
|
func.datasource.callback = function (
|
|
4273
4345
|
SESSION_ID,
|
|
4274
4346
|
dsSessionP,
|