@xuda.io/runtime-bundle 1.0.656 → 1.0.658

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.
@@ -4160,9 +4160,10 @@ func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSes
4160
4160
  clearInterval(interval);
4161
4161
  resolve(job_num);
4162
4162
  }
4163
- if (i > 100) {
4163
+ if (i > 20) {
4164
4164
  console.error('deadlock detected');
4165
- i = 0;
4165
+ clearInterval(interval);
4166
+ resolve(job_num);
4166
4167
  }
4167
4168
  }, 100);
4168
4169
  }),
@@ -4740,201 +4741,6 @@ func.datasource.del = function (SESSION_ID, dsP) {
4740
4741
  }
4741
4742
  perform_delete();
4742
4743
  };
4743
- // func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
4744
- // return new Promise(async (resolve, reject) => {
4745
- // var _session = SESSION_OBJ[SESSION_ID];
4746
-
4747
- // if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
4748
- // update_local_scope_only = true;
4749
- // }
4750
-
4751
- // if (typeof glb.GLOBAL_VARS === 'undefined') {
4752
- // glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
4753
- // }
4754
-
4755
- // const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
4756
- // // iterate child ds
4757
- // for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
4758
- // if (parent_ds !== null) {
4759
- // if (_ds.parentDataSourceNo != parent_ds) continue;
4760
- // } else {
4761
- // if (dsSession != dsNo) continue;
4762
- // }
4763
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
4764
- // if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
4765
- // // check if field has fieldComputed property
4766
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
4767
- // // find if field is computed
4768
- // let fieldComputed_propExpressions, fieldComputed_id;
4769
- // for await (const val of _progFields) {
4770
- // const fieldId = val.data.field_id;
4771
-
4772
- // // if (fieldId !== field_id) continue
4773
- // if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
4774
-
4775
- // const _propExpressions = val.props?.propExpressions?.fieldValue;
4776
- // if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
4777
- // fieldComputed_propExpressions = _propExpressions;
4778
- // fieldComputed_id = fieldId;
4779
- // }
4780
- // }
4781
-
4782
- // if (!fieldComputed_id) return;
4783
-
4784
- // // iterate ds rows
4785
- // for (const row of _ds.data_feed?.rows || []) {
4786
- // // iterate row fields
4787
- // for (const [key, val] of Object.entries(row)) {
4788
- // if (key !== fieldComputed_id) continue;
4789
- // try {
4790
- // let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
4791
-
4792
- // const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
4793
- // if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
4794
- // _ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
4795
- // if (!fields_changed.includes(fieldComputed_id)) {
4796
- // fields_changed.push(fieldComputed_id);
4797
- // }
4798
- // if (!datasource_changed.includes(dsSession)) {
4799
- // datasource_changed.push(dsSession);
4800
- // }
4801
- // }
4802
- // } catch (err) {
4803
- // console.error(err);
4804
- // }
4805
- // }
4806
- // }
4807
- // }
4808
- // await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
4809
- // }
4810
- // };
4811
-
4812
- // var fields_changed = [];
4813
- // var datasource_changed = [];
4814
- // let client_datasource_changes = {};
4815
- // let server_datasource_changes = {};
4816
- // // iterate changes datasource
4817
- // for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
4818
- // var _ds = _session.DS_GLB[dataSource];
4819
- // if (!_ds) {
4820
- // continue;
4821
- // }
4822
-
4823
- // const update_xu_ref = async function () {
4824
- // let _ds_0 = _session.DS_GLB[0];
4825
- // for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
4826
- // if (val.ds.dsSession == dataSource) {
4827
- // func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
4828
- // }
4829
- // }
4830
- // };
4831
-
4832
- // // iterate changes records
4833
- // for (const [record_id, fields_data] of Object.entries(row_data)) {
4834
- // // iterate changes fields
4835
- // for (const [field_id, value] of Object.entries(fields_data)) {
4836
- // // mechanism to make update directly on the datasource object
4837
- // if (record_id === 'datasource_main') {
4838
- // _.set(_ds, field_id, value);
4839
- // update_xu_ref();
4840
- // continue;
4841
- // }
4842
-
4843
- // if (typeof fields_data === 'object') {
4844
- // if (glb.GLOBAL_VARS[field_id]) {
4845
- // _ds.data_system[field_id] = value;
4846
- // continue;
4847
- // }
4848
-
4849
- // // try {
4850
- // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
4851
- // if (_ds.data_feed.rows[row_idx][field_id] !== value) {
4852
- // _ds.data_feed.rows[row_idx][field_id] = value;
4853
- // await set_fieldComputed_dependencies(dataSource, field_id, null);
4854
-
4855
- // // search the field in refs
4856
- // update_xu_ref();
4857
-
4858
- // if (!update_local_scope_only) {
4859
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
4860
- // if (glb.IS_WORKER) {
4861
- // // RUN AT SERVER
4862
- // if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
4863
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
4864
- // let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
4865
- // if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
4866
- // if (!client_datasource_changes[dataSource]) {
4867
- // client_datasource_changes[dataSource] = {};
4868
- // }
4869
- // if (!client_datasource_changes[dataSource][record_id]) {
4870
- // client_datasource_changes[dataSource][record_id] = {};
4871
- // }
4872
- // client_datasource_changes[dataSource][record_id][field_id] = value;
4873
- // }
4874
- // }
4875
- // } else {
4876
- // // RUN AT CLIENT
4877
- // if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
4878
- // if (!server_datasource_changes[dataSource]) {
4879
- // server_datasource_changes[dataSource] = {};
4880
- // }
4881
- // if (!server_datasource_changes[dataSource][record_id]) {
4882
- // server_datasource_changes[dataSource][record_id] = {};
4883
- // }
4884
- // server_datasource_changes[dataSource][record_id][field_id] = value;
4885
- // }
4886
- // }
4887
- // }
4888
-
4889
- // if (!fields_changed.includes(field_id)) {
4890
- // fields_changed.push(field_id);
4891
- // }
4892
- // if (!datasource_changed.includes(dataSource)) {
4893
- // datasource_changed.push(dataSource);
4894
- // }
4895
-
4896
- // if (!_ds.data_feed.rows_changed) {
4897
- // _ds.data_feed.rows_changed = [];
4898
- // }
4899
- // if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
4900
- // }
4901
- // } else if (fields_data === 'set') {
4902
- // _ds.currentRecordId = record_id;
4903
- // }
4904
- // }
4905
- // }
4906
- // }
4907
-
4908
- // if (glb.IS_WORKER) {
4909
- // if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
4910
- // func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
4911
- // }
4912
- // } else {
4913
- // if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
4914
- // const ret = await func.index.call_worker(SESSION_ID, {
4915
- // service: 'update_datasource_changes_from_client',
4916
- // data: {
4917
- // session_id: SESSION_ID,
4918
- // datasource_changes: server_datasource_changes,
4919
- // },
4920
- // id: _ds.worker_id,
4921
- // });
4922
- // }
4923
- // ///// REFRESH SCREEN
4924
- // if (!avoid_refresh && fields_changed.length) {
4925
- // await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
4926
- // // await removed from the below function cause to dead lock Mar 3 25
4927
- // func.UI.screen.refresh_screen(
4928
- // SESSION_ID,
4929
- // fields_changed,
4930
- // null,
4931
- // datasource_changed[0], // refresh the current datasource only
4932
- // );
4933
- // }
4934
- // }
4935
- // resolve();
4936
- // });
4937
- // };
4938
4744
 
4939
4745
  func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
4940
4746
  return new Promise(async (resolve, reject) => {
@@ -12579,6 +12385,12 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12579
12385
 
12580
12386
  const field_changed = async function (e) {
12581
12387
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
12388
+
12389
+ if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && val_is_reference_field) {
12390
+ let value_before_cast = await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId);
12391
+ debugger;
12392
+ }
12393
+
12582
12394
  var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_prop.props.fieldType, bind.getter($elm[0]));
12583
12395
 
12584
12396
  if (field_prop.props.fieldType === 'object' && !val_is_reference_field) {
@@ -12644,6 +12456,13 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12644
12456
  const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
12645
12457
  value = _ds.data_feed.rows?.[row_idx]?.[val.value];
12646
12458
  }
12459
+ if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && $elm.attr('value')) {
12460
+ if (value.includes($elm.attr('value'))) {
12461
+ value = true;
12462
+ } else {
12463
+ value = false;
12464
+ }
12465
+ }
12647
12466
  } else {
12648
12467
  value = val.value;
12649
12468
  }
@@ -4161,9 +4161,10 @@ func.datasource.run_events_functions = async function (SESSION_ID, dataSourceSes
4161
4161
  clearInterval(interval);
4162
4162
  resolve(job_num);
4163
4163
  }
4164
- if (i > 100) {
4164
+ if (i > 20) {
4165
4165
  console.error('deadlock detected');
4166
- i = 0;
4166
+ clearInterval(interval);
4167
+ resolve(job_num);
4167
4168
  }
4168
4169
  }, 100);
4169
4170
  }),
@@ -4741,201 +4742,6 @@ func.datasource.del = function (SESSION_ID, dsP) {
4741
4742
  }
4742
4743
  perform_delete();
4743
4744
  };
4744
- // func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
4745
- // return new Promise(async (resolve, reject) => {
4746
- // var _session = SESSION_OBJ[SESSION_ID];
4747
-
4748
- // if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
4749
- // update_local_scope_only = true;
4750
- // }
4751
-
4752
- // if (typeof glb.GLOBAL_VARS === 'undefined') {
4753
- // glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
4754
- // }
4755
-
4756
- // const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
4757
- // // iterate child ds
4758
- // for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
4759
- // if (parent_ds !== null) {
4760
- // if (_ds.parentDataSourceNo != parent_ds) continue;
4761
- // } else {
4762
- // if (dsSession != dsNo) continue;
4763
- // }
4764
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
4765
- // if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
4766
- // // check if field has fieldComputed property
4767
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
4768
- // // find if field is computed
4769
- // let fieldComputed_propExpressions, fieldComputed_id;
4770
- // for await (const val of _progFields) {
4771
- // const fieldId = val.data.field_id;
4772
-
4773
- // // if (fieldId !== field_id) continue
4774
- // if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
4775
-
4776
- // const _propExpressions = val.props?.propExpressions?.fieldValue;
4777
- // if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
4778
- // fieldComputed_propExpressions = _propExpressions;
4779
- // fieldComputed_id = fieldId;
4780
- // }
4781
- // }
4782
-
4783
- // if (!fieldComputed_id) return;
4784
-
4785
- // // iterate ds rows
4786
- // for (const row of _ds.data_feed?.rows || []) {
4787
- // // iterate row fields
4788
- // for (const [key, val] of Object.entries(row)) {
4789
- // if (key !== fieldComputed_id) continue;
4790
- // try {
4791
- // let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
4792
-
4793
- // const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
4794
- // if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
4795
- // _ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
4796
- // if (!fields_changed.includes(fieldComputed_id)) {
4797
- // fields_changed.push(fieldComputed_id);
4798
- // }
4799
- // if (!datasource_changed.includes(dsSession)) {
4800
- // datasource_changed.push(dsSession);
4801
- // }
4802
- // }
4803
- // } catch (err) {
4804
- // console.error(err);
4805
- // }
4806
- // }
4807
- // }
4808
- // }
4809
- // await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
4810
- // }
4811
- // };
4812
-
4813
- // var fields_changed = [];
4814
- // var datasource_changed = [];
4815
- // let client_datasource_changes = {};
4816
- // let server_datasource_changes = {};
4817
- // // iterate changes datasource
4818
- // for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
4819
- // var _ds = _session.DS_GLB[dataSource];
4820
- // if (!_ds) {
4821
- // continue;
4822
- // }
4823
-
4824
- // const update_xu_ref = async function () {
4825
- // let _ds_0 = _session.DS_GLB[0];
4826
- // for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
4827
- // if (val.ds.dsSession == dataSource) {
4828
- // func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
4829
- // }
4830
- // }
4831
- // };
4832
-
4833
- // // iterate changes records
4834
- // for (const [record_id, fields_data] of Object.entries(row_data)) {
4835
- // // iterate changes fields
4836
- // for (const [field_id, value] of Object.entries(fields_data)) {
4837
- // // mechanism to make update directly on the datasource object
4838
- // if (record_id === 'datasource_main') {
4839
- // _.set(_ds, field_id, value);
4840
- // update_xu_ref();
4841
- // continue;
4842
- // }
4843
-
4844
- // if (typeof fields_data === 'object') {
4845
- // if (glb.GLOBAL_VARS[field_id]) {
4846
- // _ds.data_system[field_id] = value;
4847
- // continue;
4848
- // }
4849
-
4850
- // // try {
4851
- // const row_idx = func.common.find_ROWID_idx(_ds, record_id);
4852
- // if (_ds.data_feed.rows[row_idx][field_id] !== value) {
4853
- // _ds.data_feed.rows[row_idx][field_id] = value;
4854
- // await set_fieldComputed_dependencies(dataSource, field_id, null);
4855
-
4856
- // // search the field in refs
4857
- // update_xu_ref();
4858
-
4859
- // if (!update_local_scope_only) {
4860
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
4861
- // if (glb.IS_WORKER) {
4862
- // // RUN AT SERVER
4863
- // if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
4864
- // const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
4865
- // let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
4866
- // if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
4867
- // if (!client_datasource_changes[dataSource]) {
4868
- // client_datasource_changes[dataSource] = {};
4869
- // }
4870
- // if (!client_datasource_changes[dataSource][record_id]) {
4871
- // client_datasource_changes[dataSource][record_id] = {};
4872
- // }
4873
- // client_datasource_changes[dataSource][record_id][field_id] = value;
4874
- // }
4875
- // }
4876
- // } else {
4877
- // // RUN AT CLIENT
4878
- // if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
4879
- // if (!server_datasource_changes[dataSource]) {
4880
- // server_datasource_changes[dataSource] = {};
4881
- // }
4882
- // if (!server_datasource_changes[dataSource][record_id]) {
4883
- // server_datasource_changes[dataSource][record_id] = {};
4884
- // }
4885
- // server_datasource_changes[dataSource][record_id][field_id] = value;
4886
- // }
4887
- // }
4888
- // }
4889
-
4890
- // if (!fields_changed.includes(field_id)) {
4891
- // fields_changed.push(field_id);
4892
- // }
4893
- // if (!datasource_changed.includes(dataSource)) {
4894
- // datasource_changed.push(dataSource);
4895
- // }
4896
-
4897
- // if (!_ds.data_feed.rows_changed) {
4898
- // _ds.data_feed.rows_changed = [];
4899
- // }
4900
- // if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
4901
- // }
4902
- // } else if (fields_data === 'set') {
4903
- // _ds.currentRecordId = record_id;
4904
- // }
4905
- // }
4906
- // }
4907
- // }
4908
-
4909
- // if (glb.IS_WORKER) {
4910
- // if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
4911
- // func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
4912
- // }
4913
- // } else {
4914
- // if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
4915
- // const ret = await func.index.call_worker(SESSION_ID, {
4916
- // service: 'update_datasource_changes_from_client',
4917
- // data: {
4918
- // session_id: SESSION_ID,
4919
- // datasource_changes: server_datasource_changes,
4920
- // },
4921
- // id: _ds.worker_id,
4922
- // });
4923
- // }
4924
- // ///// REFRESH SCREEN
4925
- // if (!avoid_refresh && fields_changed.length) {
4926
- // await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
4927
- // // await removed from the below function cause to dead lock Mar 3 25
4928
- // func.UI.screen.refresh_screen(
4929
- // SESSION_ID,
4930
- // fields_changed,
4931
- // null,
4932
- // datasource_changed[0], // refresh the current datasource only
4933
- // );
4934
- // }
4935
- // }
4936
- // resolve();
4937
- // });
4938
- // };
4939
4745
 
4940
4746
  func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
4941
4747
  return new Promise(async (resolve, reject) => {
@@ -10301,6 +10107,12 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10301
10107
 
10302
10108
  const field_changed = async function (e) {
10303
10109
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[_dsP];
10110
+
10111
+ if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && val_is_reference_field) {
10112
+ let value_before_cast = await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId);
10113
+ debugger;
10114
+ }
10115
+
10304
10116
  var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_prop.props.fieldType, bind.getter($elm[0]));
10305
10117
 
10306
10118
  if (field_prop.props.fieldType === 'object' && !val_is_reference_field) {
@@ -10366,6 +10178,13 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10366
10178
  const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
10367
10179
  value = _ds.data_feed.rows?.[row_idx]?.[val.value];
10368
10180
  }
10181
+ if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'checkbox' && $elm.attr('value')) {
10182
+ if (value.includes($elm.attr('value'))) {
10183
+ value = true;
10184
+ } else {
10185
+ value = false;
10186
+ }
10187
+ }
10369
10188
  } else {
10370
10189
  value = val.value;
10371
10190
  }