@xuda.io/xuda-worker-bundle-min 1.3.1184 → 1.3.1185

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.
Files changed (2) hide show
  1. package/index.js +76 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4114,8 +4114,70 @@ func.datasource.update = async function (
4114
4114
  )
4115
4115
  ).system_globals;
4116
4116
  }
4117
- var fields_changes = [];
4117
+
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
+
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
+ propExpressions = val.props?.propExpressions?.fieldValue
4134
+
4135
+ }
4136
+
4137
+ if (!propExpressions) return
4138
+
4139
+ let new_datasource_changes = {}
4140
+ for (const _ds of _session.DS_GLB) {
4141
+ if (_ds.parentDataSourceNo !== dsNo) continue
4142
+
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
+
4163
+ // _ds.data_feed.rows[row_idx][field_id] = ret.result;
4164
+ } catch (err) {
4165
+ console.error(err);
4166
+ }
4167
+ }
4168
+ }
4169
+
4170
+ }
4171
+ debugger
4172
+ await func.datasource.update(SESSION_ID,
4173
+ new_datasource_changes,
4174
+ from_worker)
4175
+
4176
+ }
4177
+
4178
+ var fields_changed = [];
4118
4179
  var datasource_changed = [];
4180
+ // iterate changes datasource
4119
4181
  for await (const [dataSource, row_data] of Object.entries(
4120
4182
  datasource_changes
4121
4183
  )) {
@@ -4123,11 +4185,12 @@ func.datasource.update = async function (
4123
4185
  if (!_ds) {
4124
4186
  continue;
4125
4187
  }
4126
-
4188
+ // iterate changes records
4127
4189
  for (const [record_id, fields_data] of Object.entries(row_data)) {
4190
+ // iterate changes fields
4128
4191
  for (const [field_id, value] of Object.entries(fields_data)) {
4192
+ // mechanism to make update directly on the datasource object
4129
4193
  if (record_id === "datasource_main") {
4130
- // _ds[field_id] = value;
4131
4194
  _.set(_ds, field_id, value);
4132
4195
  continue;
4133
4196
  }
@@ -4148,8 +4211,8 @@ func.datasource.update = async function (
4148
4211
 
4149
4212
 
4150
4213
 
4151
- if (!fields_changes.includes(field_id)) {
4152
- fields_changes.push(field_id);
4214
+ if (!fields_changed.includes(field_id)) {
4215
+ fields_changed.push(field_id);
4153
4216
  }
4154
4217
  if (!datasource_changed.includes(dataSource)) {
4155
4218
  datasource_changed.push(dataSource);
@@ -4174,11 +4237,11 @@ func.datasource.update = async function (
4174
4237
  field_id
4175
4238
  );
4176
4239
  if (view_field_obj?.data?.serverField) {
4177
- delete datasource_changed[dataSource][record_id][field_id]
4240
+ delete datasource_changes[dataSource][record_id][field_id]
4178
4241
  }
4179
4242
 
4180
4243
  if (record_id === "data_system") {
4181
- delete datasource_changed[dataSource][record_id]
4244
+ delete datasource_changes[dataSource][record_id]
4182
4245
  }
4183
4246
  }
4184
4247
  }
@@ -4255,11 +4318,11 @@ func.datasource.update = async function (
4255
4318
  }
4256
4319
  if (!glb.IS_WORKER) {
4257
4320
  ///// REFRESH SCREEN
4258
- if (fields_changes.length) {
4259
- await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changes);
4321
+ if (fields_changed.length) {
4322
+ await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
4260
4323
  await func.UI.screen.refresh_screen(
4261
4324
  SESSION_ID,
4262
- fields_changes,
4325
+ fields_changed,
4263
4326
  null,
4264
4327
  datasource_changed[0] // refresh the current datasource only
4265
4328
  );
@@ -4269,6 +4332,9 @@ func.datasource.update = async function (
4269
4332
  });
4270
4333
  };
4271
4334
 
4335
+
4336
+
4337
+
4272
4338
  func.datasource.callback = function (
4273
4339
  SESSION_ID,
4274
4340
  dsSessionP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.1184",
3
+ "version": "1.3.1185",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {