@xuda.io/runtime-bundle 1.0.676 → 1.0.678

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.
@@ -3599,6 +3599,16 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3599
3599
  filterModelUserSql: _ds.progDataSource.filterModelUserSql,
3600
3600
  };
3601
3601
 
3602
+ let _dataSourceFilterModelType = ds?.progDataSource?.dataSourceFilterModelType;
3603
+
3604
+ if (ds?.progDataSource?.dataSourceFilterModelTypeFx) {
3605
+ const fx_ret = await func.expression.get(SESSION_ID, _ds.progDataSource.dataSourceFilterModelTypeFx, dataSourceSession, 'query');
3606
+ _dataSourceFilterModelType = fx_ret.result;
3607
+ }
3608
+ if (!['query', 'index'].includes(_dataSourceFilterModelType)) {
3609
+ return func.utils.debug_report(SESSION_ID, 'Data source', `Valid values for dataSourceFilterModelType are: "query" or "index" (${_dataSourceFilterModelType})`, 'E');
3610
+ }
3611
+
3602
3612
  _ds.v.raw_data = await func.db.get_query(
3603
3613
  SESSION_ID,
3604
3614
  _ds._dataSourceTableId,
@@ -3614,27 +3624,11 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3614
3624
  _ds?.progDataSource?.sortModel,
3615
3625
  null,
3616
3626
  filterModel,
3617
- _ds?.progDataSource?.dataSourceFilterModelType,
3627
+ _dataSourceFilterModelType,
3618
3628
  );
3619
3629
 
3620
3630
  if (_ds?.progDataSource?.dataSourceLimit) {
3621
- const ret_rows_found = await func.db.get_query(
3622
- SESSION_ID,
3623
- _ds._dataSourceTableId,
3624
- _ds.v.couchView,
3625
- dataSourceSession,
3626
- _ds.viewSourceDesc,
3627
- 'datasource table',
3628
- prog_obj.progDataSource.dataSourceReduce,
3629
- null,
3630
- null,
3631
- true,
3632
- null,
3633
- null,
3634
- null,
3635
- filterModel,
3636
- _ds?.progDataSource?.dataSourceFilterModelType,
3637
- );
3631
+ const ret_rows_found = await func.db.get_query(SESSION_ID, _ds._dataSourceTableId, _ds.v.couchView, dataSourceSession, _ds.viewSourceDesc, 'datasource table', prog_obj.progDataSource.dataSourceReduce, null, null, true, null, null, null, filterModel, _dataSourceFilterModelType);
3638
3632
  _ds.rows_found = ret_rows_found?.rows?.[0]?.value || 0;
3639
3633
  } else {
3640
3634
  _ds.rows_found = _ds?.v?.raw_data?.rows?.length || 0;
@@ -11510,24 +11504,6 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11510
11504
  .filter(function () {
11511
11505
  // // look if the changed field include in the calling in parameters
11512
11506
  let parameter_in_filed_id;
11513
- // const _$callingContainer = $(this).data()?.xuData?.paramsP?.$callingContainerP;
11514
- // if (_$callingContainer) {
11515
- // const _source_xuAttributes = _$callingContainer.data()?.xuAttributes;
11516
- // if (_source_xuAttributes) {
11517
- // for (const [attr, value] of Object.entries(_source_xuAttributes)) {
11518
- // if (value && typeof value === 'string' && value.includes(val_field)) {
11519
- // const pattern = /xu-exp:(\w+)/;
11520
- // const match = attr.match(pattern);
11521
- // if (match) {
11522
- // parameter_in_filed_id = attr.split(':')[1];
11523
- // } else {
11524
- // parameter_in_filed_id = attr;
11525
- // }
11526
- // break;
11527
- // }
11528
- // }
11529
- // }
11530
- // }
11531
11507
 
11532
11508
  let attr = [];
11533
11509
 
@@ -12305,7 +12281,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12305
12281
  'xu-bind': async function ($elm, val) {
12306
12282
  if (is_skeleton) return;
12307
12283
 
12308
- // let view_field_id = val.value;
12309
12284
  let val_is_reference_field = false;
12310
12285
 
12311
12286
  let _prog_id = $elm.data().xuData.paramsP.prog_id;
@@ -12399,17 +12374,9 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12399
12374
  return await func.datasource.update(SESSION_ID, datasource_changes);
12400
12375
  }
12401
12376
 
12402
- // update array for checkbox that not in xu-for
12377
+ // update array for radio that not in xu-for
12403
12378
  if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && val_is_reference_field) {
12404
- let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
12405
12379
  let value_from_getter = bind.getter($elm[0]);
12406
- // let value;
12407
- // if (arr_value_before_cast.includes(value_from_getter)) {
12408
- // value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
12409
- // } else {
12410
- // arr_value_before_cast.push(value_from_getter);
12411
- // value = arr_value_before_cast;
12412
- // }
12413
12380
 
12414
12381
  let datasource_changes = {
12415
12382
  [_dsP]: {
@@ -12870,6 +12837,11 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12870
12837
  const trigger = val.key.split('xu-on:')[1].toLowerCase();
12871
12838
  $elm.on(trigger, async function (evt) {
12872
12839
  for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
12840
+ if (!_.isEmpty(val.props.condition)) {
12841
+ const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
12842
+ if (!expCond.result) continue;
12843
+ }
12844
+
12873
12845
  if (val.event_modifiers && evt[val.event_modifiers]) {
12874
12846
  evt[val.event_modifiers]();
12875
12847
  }
@@ -3600,6 +3600,16 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3600
3600
  filterModelUserSql: _ds.progDataSource.filterModelUserSql,
3601
3601
  };
3602
3602
 
3603
+ let _dataSourceFilterModelType = ds?.progDataSource?.dataSourceFilterModelType;
3604
+
3605
+ if (ds?.progDataSource?.dataSourceFilterModelTypeFx) {
3606
+ const fx_ret = await func.expression.get(SESSION_ID, _ds.progDataSource.dataSourceFilterModelTypeFx, dataSourceSession, 'query');
3607
+ _dataSourceFilterModelType = fx_ret.result;
3608
+ }
3609
+ if (!['query', 'index'].includes(_dataSourceFilterModelType)) {
3610
+ return func.utils.debug_report(SESSION_ID, 'Data source', `Valid values for dataSourceFilterModelType are: "query" or "index" (${_dataSourceFilterModelType})`, 'E');
3611
+ }
3612
+
3603
3613
  _ds.v.raw_data = await func.db.get_query(
3604
3614
  SESSION_ID,
3605
3615
  _ds._dataSourceTableId,
@@ -3615,27 +3625,11 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
3615
3625
  _ds?.progDataSource?.sortModel,
3616
3626
  null,
3617
3627
  filterModel,
3618
- _ds?.progDataSource?.dataSourceFilterModelType,
3628
+ _dataSourceFilterModelType,
3619
3629
  );
3620
3630
 
3621
3631
  if (_ds?.progDataSource?.dataSourceLimit) {
3622
- const ret_rows_found = await func.db.get_query(
3623
- SESSION_ID,
3624
- _ds._dataSourceTableId,
3625
- _ds.v.couchView,
3626
- dataSourceSession,
3627
- _ds.viewSourceDesc,
3628
- 'datasource table',
3629
- prog_obj.progDataSource.dataSourceReduce,
3630
- null,
3631
- null,
3632
- true,
3633
- null,
3634
- null,
3635
- null,
3636
- filterModel,
3637
- _ds?.progDataSource?.dataSourceFilterModelType,
3638
- );
3632
+ const ret_rows_found = await func.db.get_query(SESSION_ID, _ds._dataSourceTableId, _ds.v.couchView, dataSourceSession, _ds.viewSourceDesc, 'datasource table', prog_obj.progDataSource.dataSourceReduce, null, null, true, null, null, null, filterModel, _dataSourceFilterModelType);
3639
3633
  _ds.rows_found = ret_rows_found?.rows?.[0]?.value || 0;
3640
3634
  } else {
3641
3635
  _ds.rows_found = _ds?.v?.raw_data?.rows?.length || 0;
@@ -9232,24 +9226,6 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
9232
9226
  .filter(function () {
9233
9227
  // // look if the changed field include in the calling in parameters
9234
9228
  let parameter_in_filed_id;
9235
- // const _$callingContainer = $(this).data()?.xuData?.paramsP?.$callingContainerP;
9236
- // if (_$callingContainer) {
9237
- // const _source_xuAttributes = _$callingContainer.data()?.xuAttributes;
9238
- // if (_source_xuAttributes) {
9239
- // for (const [attr, value] of Object.entries(_source_xuAttributes)) {
9240
- // if (value && typeof value === 'string' && value.includes(val_field)) {
9241
- // const pattern = /xu-exp:(\w+)/;
9242
- // const match = attr.match(pattern);
9243
- // if (match) {
9244
- // parameter_in_filed_id = attr.split(':')[1];
9245
- // } else {
9246
- // parameter_in_filed_id = attr;
9247
- // }
9248
- // break;
9249
- // }
9250
- // }
9251
- // }
9252
- // }
9253
9229
 
9254
9230
  let attr = [];
9255
9231
 
@@ -10027,7 +10003,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10027
10003
  'xu-bind': async function ($elm, val) {
10028
10004
  if (is_skeleton) return;
10029
10005
 
10030
- // let view_field_id = val.value;
10031
10006
  let val_is_reference_field = false;
10032
10007
 
10033
10008
  let _prog_id = $elm.data().xuData.paramsP.prog_id;
@@ -10121,17 +10096,9 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10121
10096
  return await func.datasource.update(SESSION_ID, datasource_changes);
10122
10097
  }
10123
10098
 
10124
- // update array for checkbox that not in xu-for
10099
+ // update array for radio that not in xu-for
10125
10100
  if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && val_is_reference_field) {
10126
- let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
10127
10101
  let value_from_getter = bind.getter($elm[0]);
10128
- // let value;
10129
- // if (arr_value_before_cast.includes(value_from_getter)) {
10130
- // value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
10131
- // } else {
10132
- // arr_value_before_cast.push(value_from_getter);
10133
- // value = arr_value_before_cast;
10134
- // }
10135
10102
 
10136
10103
  let datasource_changes = {
10137
10104
  [_dsP]: {
@@ -10592,6 +10559,11 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10592
10559
  const trigger = val.key.split('xu-on:')[1].toLowerCase();
10593
10560
  $elm.on(trigger, async function (evt) {
10594
10561
  for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
10562
+ if (!_.isEmpty(val.props.condition)) {
10563
+ const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
10564
+ if (!expCond.result) continue;
10565
+ }
10566
+
10595
10567
  if (val.event_modifiers && evt[val.event_modifiers]) {
10596
10568
  evt[val.event_modifiers]();
10597
10569
  }