@xuda.io/runtime-bundle 1.0.680 → 1.0.682

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.
@@ -28966,7 +28966,8 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
28966
28966
  }
28967
28967
 
28968
28968
  // initiated with Update but no rows found
28969
- if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
28969
+ // if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_ds?.data_feed?.rows?.length) {
28970
+ if (tree_obj.crudMode === 'U' && tree_obj.allowCreate && !_raw_data_rows?.length) {
28970
28971
  _ds.set_mode = 'C';
28971
28972
  // _raw_data_rows[glb.newRecord] = [{ _ROWID: "newRecord" }];
28972
28973
 
@@ -31439,88 +31440,105 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
31439
31440
  };
31440
31441
 
31441
31442
  func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31442
- const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
31443
-
31444
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31445
- const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
31446
-
31447
- var found, refresh_reason, refresh_details;
31448
- if (fields_changed_arr) {
31449
- if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
31450
- continue;
31443
+ var found, refresh_reason, refresh_details;
31444
+ const validate_change = function (prog_doc, panelXuAttributes) {
31445
+ found = null;
31446
+ refresh_reason = null;
31447
+ refresh_details = null;
31448
+ const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31449
+ for (const field_id of fields_changed_arr) {
31450
+ // get panel attributes
31451
+ const _attributes = panelXuAttributes || {};
31452
+
31453
+ // detect if program changed
31454
+ found = _attributes['xu-exp:program']?.includes('@' + field_id);
31455
+
31456
+ if (found) {
31457
+ refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
31458
+ refresh_details = _attributes;
31459
+ break;
31451
31460
  }
31452
- for (const field_id of fields_changed_arr) {
31453
- // get panel attributes
31454
- const _attributes = panel_val?.panelXuAttributes || {};
31455
31461
 
31456
- // detect if program changed
31457
- found = _attributes['xu-exp:program']?.includes('@' + field_id);
31462
+ // _attributes holds also info of parameters in code_in: @code
31463
+ // search field changed in panel call send parameters exp
31464
+ for (const [attr, value] of Object.entries(_attributes)) {
31465
+ const pattern = /xu-exp:(\w+)/;
31466
+ const match = attr.match(pattern);
31458
31467
 
31459
- if (found) {
31460
- refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
31461
- refresh_details = _attributes;
31462
- break;
31468
+ if (!match) {
31469
+ // continue if attribute is not expression
31470
+ continue;
31463
31471
  }
31472
+ // code_in
31473
+ const parameter_in_field_id = match?.[1];
31474
+ // @code
31475
+ if (value.includes(field_id)) {
31476
+ // search parameter in field in the target program's progDataSource
31477
+ found = progDataSource_str?.includes('@' + parameter_in_field_id);
31464
31478
 
31465
- // _attributes holds also info of parameters in code_in: @code
31466
- // search field changed in panel call send parameters exp
31467
- for (const [attr, value] of Object.entries(_attributes)) {
31468
- const pattern = /xu-exp:(\w+)/;
31469
- const match = attr.match(pattern);
31479
+ if (found) {
31480
+ refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
31481
+ refresh_details = prog_doc?.progDataSource;
31470
31482
 
31471
- if (!match) {
31472
- // continue if attribute is not expression
31473
- continue;
31483
+ break;
31474
31484
  }
31475
- // code_in
31476
- const parameter_in_field_id = match?.[1];
31477
- // @code
31478
- if (value.includes(field_id)) {
31479
- // search parameter in field in the target program's progDataSource
31480
- found = progDataSource_str?.includes('@' + parameter_in_field_id);
31481
31485
 
31482
- if (found) {
31483
- refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
31484
- refresh_details = panel_val?.prog_doc?.progDataSource;
31486
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31485
31487
 
31486
- break;
31487
- }
31488
-
31489
- // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
31490
- found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31488
+ if (found) {
31489
+ refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
31490
+ refresh_details = found;
31491
31491
 
31492
- if (found) {
31493
- refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
31494
- refresh_details = found;
31495
-
31496
- break;
31497
- }
31492
+ break;
31498
31493
  }
31499
31494
  }
31495
+ }
31500
31496
 
31501
- if (found) break;
31497
+ if (found) break;
31502
31498
 
31503
- // search field changed in the target program's progDataSource // @code
31504
- found = progDataSource_str?.includes('@' + field_id);
31505
- if (found) {
31506
- refresh_reason = `field ${field_id} in progDataSource changed`;
31507
- refresh_details = panel_val?.prog_doc?.progDataSource;
31499
+ // search field changed in the target program's progDataSource // @code
31500
+ found = progDataSource_str?.includes('@' + field_id);
31501
+ if (found) {
31502
+ refresh_reason = `field ${field_id} in progDataSource changed`;
31503
+ refresh_details = prog_doc?.progDataSource;
31508
31504
 
31509
- break;
31510
- }
31505
+ break;
31506
+ }
31511
31507
 
31512
- found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
31513
- if (found) {
31514
- refresh_reason = `field ${field_id} in progUi xu-for changed`;
31515
- refresh_details = found;
31508
+ found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, field_id, 'xu-for').length;
31509
+ if (found) {
31510
+ refresh_reason = `field ${field_id} in progUi xu-for changed`;
31511
+ refresh_details = found;
31516
31512
 
31517
- break;
31518
- }
31513
+ break;
31514
+ }
31519
31515
 
31520
- if (found) {
31521
- break;
31522
- }
31516
+ if (found) {
31517
+ break;
31518
+ }
31519
+ }
31520
+ };
31521
+
31522
+ // check the main program
31523
+ if (fields_changed_datasource) {
31524
+ const _session = SESSION_OBJ[SESSION_ID];
31525
+ const _ds = _session.DS_GLB[fields_changed_datasource];
31526
+ const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
31527
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31528
+ for (const field_id of fields_changed_arr || []) {
31529
+ }
31530
+ }
31531
+
31532
+ const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
31533
+
31534
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31535
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
31536
+
31537
+ if (fields_changed_arr) {
31538
+ if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
31539
+ continue;
31523
31540
  }
31541
+ validate_change(panel_val.prog_doc, panel_val?.panelXuAttributes);
31524
31542
  }
31525
31543
 
31526
31544
  if (datasource_changed) {
@@ -31591,25 +31609,40 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31591
31609
  }
31592
31610
  };
31593
31611
 
31594
- // func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31595
- // const panels_obj = func.UI.utils.get_panels_from_dom(SESSION_ID, false);
31612
+ // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31613
+ // // check the main program
31614
+ // if (fields_changed_datasource) {
31615
+ // const _session = SESSION_OBJ[SESSION_ID];
31616
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
31617
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
31618
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31619
+ // for (const field_id of fields_changed_arr || []) {
31620
+
31621
+ // }
31622
+ // }
31623
+
31624
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
31596
31625
 
31597
31626
  // for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31598
- // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, panel_val._ds.prog_id);
31599
- // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31627
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
31600
31628
 
31601
- // var found;
31629
+ // var found, refresh_reason, refresh_details;
31602
31630
  // if (fields_changed_arr) {
31603
- // if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
31631
+ // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
31604
31632
  // continue;
31605
31633
  // }
31606
31634
  // for (const field_id of fields_changed_arr) {
31607
31635
  // // get panel attributes
31608
- // const _attributes = panel_val?.$div?.data()?.xuPanelData?.node?.attributes || {};
31636
+ // const _attributes = panel_val?.panelXuAttributes || {};
31609
31637
 
31610
31638
  // // detect if program changed
31611
31639
  // found = _attributes['xu-exp:program']?.includes('@' + field_id);
31612
- // if (found) break;
31640
+
31641
+ // if (found) {
31642
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
31643
+ // refresh_details = _attributes;
31644
+ // break;
31645
+ // }
31613
31646
 
31614
31647
  // // _attributes holds also info of parameters in code_in: @code
31615
31648
  // // search field changed in panel call send parameters exp
@@ -31627,11 +31660,23 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31627
31660
  // if (value.includes(field_id)) {
31628
31661
  // // search parameter in field in the target program's progDataSource
31629
31662
  // found = progDataSource_str?.includes('@' + parameter_in_field_id);
31630
- // if (found) break;
31663
+
31664
+ // if (found) {
31665
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
31666
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
31667
+
31668
+ // break;
31669
+ // }
31631
31670
 
31632
31671
  // // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
31633
- // found = func.UI.find_field_in_progUi_attributes(prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31634
- // if (found) break;
31672
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31673
+
31674
+ // if (found) {
31675
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
31676
+ // refresh_details = found;
31677
+
31678
+ // break;
31679
+ // }
31635
31680
  // }
31636
31681
  // }
31637
31682
 
@@ -31639,63 +31684,93 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31639
31684
 
31640
31685
  // // search field changed in the target program's progDataSource // @code
31641
31686
  // found = progDataSource_str?.includes('@' + field_id);
31642
- // if (found) break;
31687
+ // if (found) {
31688
+ // refresh_reason = `field ${field_id} in progDataSource changed`;
31689
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
31690
+
31691
+ // break;
31692
+ // }
31693
+
31694
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
31695
+ // if (found) {
31696
+ // refresh_reason = `field ${field_id} in progUi xu-for changed`;
31697
+ // refresh_details = found;
31698
+
31699
+ // break;
31700
+ // }
31701
+
31702
+ // if (found) {
31703
+ // break;
31704
+ // }
31643
31705
  // }
31644
31706
  // }
31645
31707
 
31646
31708
  // if (datasource_changed) {
31647
31709
  // if (panel_val._ds.dsSession == datasource_changed) {
31710
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
31711
+ // refresh_details = '';
31712
+
31648
31713
  // found = true;
31649
31714
  // }
31650
31715
  // }
31651
31716
  // if (found) {
31652
- // var $div_elm = panel_val.$div
31653
- // .parent()
31654
- // .parent()
31655
- // .find("[xu-ui-id='" + parent_element_ui_id + "']");
31717
+ // const _session = SESSION_OBJ[SESSION_ID];
31718
+ // if (_session.engine_mode === 'live_preview') {
31719
+ // console.info('========= refresh info ==============');
31720
+ // console.info('reason:', refresh_reason);
31721
+ // console.info('details:', refresh_details);
31722
+ // console.info('panel:', panel_val);
31723
+ // console.info('=====================================');
31724
+ // }
31725
+ // const $div_elm = panel_val.$panel_div;
31726
+ // const wrapper_data = $div_elm.data();
31727
+
31728
+ // if (_.isEmpty(wrapper_data)) continue;
31656
31729
 
31657
- // // restore original panel
31658
31730
  // try {
31659
- // // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
31731
+ // const ts = Date.now();
31732
+ // // remove old panel content
31733
+ // $.each(panel_val.ids, async function (key, val) {
31734
+ // $("[xu-ui-id='" + val + "']")
31735
+ // .attr('xu-ui-id', val + ts)
31736
+ // .removeData();
31737
+ // });
31738
+
31739
+ // let refreshed_ds;
31740
+ // // check if ds exist and deleted by garbage collector
31660
31741
 
31661
- // const new_$div = await func.UI.screen.render_ui_tree(SESSION_ID, $div_elm, _.cloneDeep(panel_val.$div.data().xuPanelData.node), {}, $div_elm.data().xuData.paramsP, null, null, $div_elm.data().xuData.key, null, $div_elm.data().xuData.parent_node, null, $div_elm.data().xuData.$root_container);
31742
+ // if (_session.DS_GLB[panel_val._ds.dsSession]) {
31743
+ // refreshed_ds = panel_val._ds.dsSession;
31744
+ // }
31745
+ // for await (const item of wrapper_data.xuData.node_org.children) {
31746
+ // if (item.tagName !== 'xu-panel') continue;
31747
+
31748
+ // const new_$div = await func.UI.screen.render_ui_tree(
31749
+ // SESSION_ID,
31750
+ // $div_elm, // the wrapper
31751
+ // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
31752
+ // {},
31753
+ // wrapper_data.xuData.paramsP, // the wrapper params
31754
+ // null,
31755
+ // null,
31756
+ // wrapper_data.xuData.key, // the wrapper key
31757
+ // refreshed_ds, // the refreshed_ds
31758
+ // wrapper_data.xuData.parent_node, // the wrapper parent node
31759
+ // null,
31760
+ // wrapper_data.xuData.$root_container, // the wrapper root container
31761
+ // );
31762
+ // }
31662
31763
 
31663
31764
  // // remove old panel content
31664
31765
  // $.each(panel_val.ids, async function (key, val) {
31665
- // $("[xu-ui-id='" + val + "']").remove();
31766
+ // $("[xu-ui-id='" + val + ts + "']").remove();
31666
31767
  // });
31667
31768
  // } catch (error) {
31668
31769
  // debugger;
31669
31770
  // }
31670
- // break;
31671
- // }
31672
- // }
31673
- // };
31674
-
31675
- // const get_params_obj = async function (SESSION_ID, prog_id, parameters_obj_inP) {
31676
- // const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
31677
- // if (!_prog) {
31678
- // return;
31679
- // }
31680
-
31681
- // // get in parameters
31682
- // var params_obj = {};
31683
- // if (_prog?.properties?.progParams) {
31684
- // for await (const [key, val] of Object.entries(_prog.properties.progParams)) {
31685
- // if (!val.data.dir === 'in') continue;
31686
- // if (typeof parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
31687
- // if (parameters_obj_inP?.[val.data.parameter].fx) {
31688
- // let ret = await func.expression.get(SESSION_ID, parameters_obj_inP?.[val.data.parameter].fx, dsSession, 'parameters');
31689
- // params_obj[val.data.parameter] = ret.result;
31690
- // } else {
31691
- // params_obj[val.data.parameter] = parameters_obj_inP?.[val.data.parameter].value;
31692
- // }
31693
- // continue;
31694
- // }
31695
- // console.warn(`Warning: Program ${_prog.properties.menuName} expected In parameter: ${val.data.parameter} but received null instead`);
31771
+ // // continue;
31696
31772
  // }
31697
31773
  // }
31698
- // return params_obj;
31699
31774
  // };
31700
31775
 
31701
31776
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {