@xuda.io/runtime-bundle 1.0.675 → 1.0.677

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.
@@ -8695,39 +8695,27 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
8695
8695
  return done();
8696
8696
  },
8697
8697
  execute_xu_for: async function () {
8698
- var $elm = queue_obj?.paramsP?.elem_val?.$elm; // $(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-ui-id=${queue_obj.paramsP.elem_key}]`)
8698
+ try {
8699
+ var $elm = queue_obj?.paramsP?.elem_val?.$elm; // $(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-ui-id=${queue_obj.paramsP.elem_key}]`)
8699
8700
 
8700
- if (!$elm?.length) {
8701
- return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8702
- }
8701
+ if (!$elm?.length) {
8702
+ return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8703
+ }
8703
8704
 
8704
- // $elm.empty();
8705
+ // $elm.empty();
8705
8706
 
8706
- $.each($elm.children(), (key, val) => {
8707
- if (!$(val)?.data()?.xuData) return true;
8707
+ $.each($elm.children(), (key, val) => {
8708
+ if (!$(val)?.data()?.xuData) return true;
8708
8709
 
8709
- if ($(val).data().xuData.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
8710
- $(val).remove();
8711
- }
8712
- });
8713
-
8714
- let _data = queue_obj.paramsP.elem_val.$elm.data();
8715
- const node_to_render = _data.xuData.node_org.children?.find((e) => e.id === queue_obj?.paramsP?.xu_for_item_id);
8716
- func.UI.screen.render_ui_tree(
8717
- queue_obj.paramsP.SESSION_ID,
8718
- queue_obj.paramsP.elem_val.$elm,
8719
- node_to_render, //_data.xuData.node_org.children[0], //_data?.xuData?.node?.children?.length ? _data.xuData.node.children[0] : _data.xuData.node,
8720
- null,
8721
- _data.xuData.paramsP,
8722
- queue_obj.jobNoP,
8723
- null,
8724
- _data.xuData.key,
8725
- null,
8726
- _data.xuData.parent_node,
8727
- null,
8728
- _data.xuData.$root_container,
8729
- );
8710
+ if ($(val).data().xuData.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
8711
+ $(val).remove();
8712
+ }
8713
+ });
8730
8714
 
8715
+ let _data = queue_obj.paramsP.elem_val.$elm.data();
8716
+ const node_to_render = _data.xuData.node_org.children?.find((e) => e.id === queue_obj?.paramsP?.xu_for_item_id);
8717
+ func.UI.screen.render_ui_tree(queue_obj.paramsP.SESSION_ID, queue_obj.paramsP.elem_val.$elm, node_to_render, null, _data.xuData.paramsP, queue_obj.jobNoP, null, _data.xuData.key, null, _data.xuData.parent_node, null, _data.xuData.$root_container);
8718
+ } catch (error) {}
8731
8719
  return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8732
8720
  },
8733
8721
  };
@@ -11522,24 +11510,6 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11522
11510
  .filter(function () {
11523
11511
  // // look if the changed field include in the calling in parameters
11524
11512
  let parameter_in_filed_id;
11525
- // const _$callingContainer = $(this).data()?.xuData?.paramsP?.$callingContainerP;
11526
- // if (_$callingContainer) {
11527
- // const _source_xuAttributes = _$callingContainer.data()?.xuAttributes;
11528
- // if (_source_xuAttributes) {
11529
- // for (const [attr, value] of Object.entries(_source_xuAttributes)) {
11530
- // if (value && typeof value === 'string' && value.includes(val_field)) {
11531
- // const pattern = /xu-exp:(\w+)/;
11532
- // const match = attr.match(pattern);
11533
- // if (match) {
11534
- // parameter_in_filed_id = attr.split(':')[1];
11535
- // } else {
11536
- // parameter_in_filed_id = attr;
11537
- // }
11538
- // break;
11539
- // }
11540
- // }
11541
- // }
11542
- // }
11543
11513
 
11544
11514
  let attr = [];
11545
11515
 
@@ -12317,7 +12287,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12317
12287
  'xu-bind': async function ($elm, val) {
12318
12288
  if (is_skeleton) return;
12319
12289
 
12320
- // let view_field_id = val.value;
12321
12290
  let val_is_reference_field = false;
12322
12291
 
12323
12292
  let _prog_id = $elm.data().xuData.paramsP.prog_id;
@@ -12411,17 +12380,9 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12411
12380
  return await func.datasource.update(SESSION_ID, datasource_changes);
12412
12381
  }
12413
12382
 
12414
- // update array for checkbox that not in xu-for
12383
+ // update array for radio that not in xu-for
12415
12384
  if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && val_is_reference_field) {
12416
- let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
12417
12385
  let value_from_getter = bind.getter($elm[0]);
12418
- // let value;
12419
- // if (arr_value_before_cast.includes(value_from_getter)) {
12420
- // value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
12421
- // } else {
12422
- // arr_value_before_cast.push(value_from_getter);
12423
- // value = arr_value_before_cast;
12424
- // }
12425
12386
 
12426
12387
  let datasource_changes = {
12427
12388
  [_dsP]: {
@@ -12882,6 +12843,11 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12882
12843
  const trigger = val.key.split('xu-on:')[1].toLowerCase();
12883
12844
  $elm.on(trigger, async function (evt) {
12884
12845
  for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
12846
+ if (!_.isEmpty(val.props.condition)) {
12847
+ const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
12848
+ if (!expCond.result) continue;
12849
+ }
12850
+
12885
12851
  if (val.event_modifiers && evt[val.event_modifiers]) {
12886
12852
  evt[val.event_modifiers]();
12887
12853
  }
@@ -8696,39 +8696,27 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
8696
8696
  return done();
8697
8697
  },
8698
8698
  execute_xu_for: async function () {
8699
- var $elm = queue_obj?.paramsP?.elem_val?.$elm; // $(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-ui-id=${queue_obj.paramsP.elem_key}]`)
8699
+ try {
8700
+ var $elm = queue_obj?.paramsP?.elem_val?.$elm; // $(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-ui-id=${queue_obj.paramsP.elem_key}]`)
8700
8701
 
8701
- if (!$elm?.length) {
8702
- return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8703
- }
8702
+ if (!$elm?.length) {
8703
+ return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8704
+ }
8704
8705
 
8705
- // $elm.empty();
8706
+ // $elm.empty();
8706
8707
 
8707
- $.each($elm.children(), (key, val) => {
8708
- if (!$(val)?.data()?.xuData) return true;
8708
+ $.each($elm.children(), (key, val) => {
8709
+ if (!$(val)?.data()?.xuData) return true;
8709
8710
 
8710
- if ($(val).data().xuData.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
8711
- $(val).remove();
8712
- }
8713
- });
8714
-
8715
- let _data = queue_obj.paramsP.elem_val.$elm.data();
8716
- const node_to_render = _data.xuData.node_org.children?.find((e) => e.id === queue_obj?.paramsP?.xu_for_item_id);
8717
- func.UI.screen.render_ui_tree(
8718
- queue_obj.paramsP.SESSION_ID,
8719
- queue_obj.paramsP.elem_val.$elm,
8720
- node_to_render, //_data.xuData.node_org.children[0], //_data?.xuData?.node?.children?.length ? _data.xuData.node.children[0] : _data.xuData.node,
8721
- null,
8722
- _data.xuData.paramsP,
8723
- queue_obj.jobNoP,
8724
- null,
8725
- _data.xuData.key,
8726
- null,
8727
- _data.xuData.parent_node,
8728
- null,
8729
- _data.xuData.$root_container,
8730
- );
8711
+ if ($(val).data().xuData.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
8712
+ $(val).remove();
8713
+ }
8714
+ });
8731
8715
 
8716
+ let _data = queue_obj.paramsP.elem_val.$elm.data();
8717
+ const node_to_render = _data.xuData.node_org.children?.find((e) => e.id === queue_obj?.paramsP?.xu_for_item_id);
8718
+ func.UI.screen.render_ui_tree(queue_obj.paramsP.SESSION_ID, queue_obj.paramsP.elem_val.$elm, node_to_render, null, _data.xuData.paramsP, queue_obj.jobNoP, null, _data.xuData.key, null, _data.xuData.parent_node, null, _data.xuData.$root_container);
8719
+ } catch (error) {}
8732
8720
  return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8733
8721
  },
8734
8722
  };
@@ -9244,24 +9232,6 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
9244
9232
  .filter(function () {
9245
9233
  // // look if the changed field include in the calling in parameters
9246
9234
  let parameter_in_filed_id;
9247
- // const _$callingContainer = $(this).data()?.xuData?.paramsP?.$callingContainerP;
9248
- // if (_$callingContainer) {
9249
- // const _source_xuAttributes = _$callingContainer.data()?.xuAttributes;
9250
- // if (_source_xuAttributes) {
9251
- // for (const [attr, value] of Object.entries(_source_xuAttributes)) {
9252
- // if (value && typeof value === 'string' && value.includes(val_field)) {
9253
- // const pattern = /xu-exp:(\w+)/;
9254
- // const match = attr.match(pattern);
9255
- // if (match) {
9256
- // parameter_in_filed_id = attr.split(':')[1];
9257
- // } else {
9258
- // parameter_in_filed_id = attr;
9259
- // }
9260
- // break;
9261
- // }
9262
- // }
9263
- // }
9264
- // }
9265
9235
 
9266
9236
  let attr = [];
9267
9237
 
@@ -10039,7 +10009,6 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10039
10009
  'xu-bind': async function ($elm, val) {
10040
10010
  if (is_skeleton) return;
10041
10011
 
10042
- // let view_field_id = val.value;
10043
10012
  let val_is_reference_field = false;
10044
10013
 
10045
10014
  let _prog_id = $elm.data().xuData.paramsP.prog_id;
@@ -10133,17 +10102,9 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10133
10102
  return await func.datasource.update(SESSION_ID, datasource_changes);
10134
10103
  }
10135
10104
 
10136
- // update array for checkbox that not in xu-for
10105
+ // update array for radio that not in xu-for
10137
10106
  if (field_prop.props.fieldType === 'array' && $elm.attr('type') === 'radio' && val_is_reference_field) {
10138
- let arr_value_before_cast = _.clone((await func.datasource.get_value(SESSION_ID, bind_field_id, _dsP, _ds.currentRecordId)).ret.value);
10139
10107
  let value_from_getter = bind.getter($elm[0]);
10140
- // let value;
10141
- // if (arr_value_before_cast.includes(value_from_getter)) {
10142
- // value = arr_value_before_cast.filter((item) => !_.isEqual(item, value_from_getter));
10143
- // } else {
10144
- // arr_value_before_cast.push(value_from_getter);
10145
- // value = arr_value_before_cast;
10146
- // }
10147
10108
 
10148
10109
  let datasource_changes = {
10149
10110
  [_dsP]: {
@@ -10604,6 +10565,11 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10604
10565
  const trigger = val.key.split('xu-on:')[1].toLowerCase();
10605
10566
  $elm.on(trigger, async function (evt) {
10606
10567
  for await (const [key, val] of Object.entries($elm.data().xuAttributes['xu-on:' + evt.type])) {
10568
+ if (!_.isEmpty(val.props.condition)) {
10569
+ const expCond = await func.expression.get(SESSION_ID, val.props.condition, paramsP.dsSessionP, 'condition', paramsP.recordid); // execute expression
10570
+ if (!expCond.result) continue;
10571
+ }
10572
+
10607
10573
  if (val.event_modifiers && evt[val.event_modifiers]) {
10608
10574
  evt[val.event_modifiers]();
10609
10575
  }