@xuda.io/runtime-bundle 1.0.681 → 1.0.683

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,104 @@ 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
+ validate_change(prog_doc);
31529
+ }
31530
+
31531
+ const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
31532
+
31533
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
31534
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
31535
+
31536
+ if (fields_changed_arr) {
31537
+ if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
31538
+ continue;
31523
31539
  }
31540
+ validate_change(panel_val.prog_doc, panel_val?.panelXuAttributes);
31524
31541
  }
31525
31542
 
31526
31543
  if (datasource_changed) {
@@ -31591,25 +31608,40 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31591
31608
  }
31592
31609
  };
31593
31610
 
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);
31611
+ // func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
31612
+ // // check the main program
31613
+ // if (fields_changed_datasource) {
31614
+ // const _session = SESSION_OBJ[SESSION_ID];
31615
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
31616
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
31617
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
31618
+ // for (const field_id of fields_changed_arr || []) {
31619
+
31620
+ // }
31621
+ // }
31622
+
31623
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
31596
31624
 
31597
31625
  // 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);
31626
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
31600
31627
 
31601
- // var found;
31628
+ // var found, refresh_reason, refresh_details;
31602
31629
  // if (fields_changed_arr) {
31603
- // if (fields_changed_datasource && panel_val._ds.dsSession < fields_changed_datasource) {
31630
+ // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
31604
31631
  // continue;
31605
31632
  // }
31606
31633
  // for (const field_id of fields_changed_arr) {
31607
31634
  // // get panel attributes
31608
- // const _attributes = panel_val?.$div?.data()?.xuPanelData?.node?.attributes || {};
31635
+ // const _attributes = panel_val?.panelXuAttributes || {};
31609
31636
 
31610
31637
  // // detect if program changed
31611
31638
  // found = _attributes['xu-exp:program']?.includes('@' + field_id);
31612
- // if (found) break;
31639
+
31640
+ // if (found) {
31641
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
31642
+ // refresh_details = _attributes;
31643
+ // break;
31644
+ // }
31613
31645
 
31614
31646
  // // _attributes holds also info of parameters in code_in: @code
31615
31647
  // // search field changed in panel call send parameters exp
@@ -31627,11 +31659,23 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31627
31659
  // if (value.includes(field_id)) {
31628
31660
  // // search parameter in field in the target program's progDataSource
31629
31661
  // found = progDataSource_str?.includes('@' + parameter_in_field_id);
31630
- // if (found) break;
31662
+
31663
+ // if (found) {
31664
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
31665
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
31666
+
31667
+ // break;
31668
+ // }
31631
31669
 
31632
31670
  // // 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;
31671
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
31672
+
31673
+ // if (found) {
31674
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
31675
+ // refresh_details = found;
31676
+
31677
+ // break;
31678
+ // }
31635
31679
  // }
31636
31680
  // }
31637
31681
 
@@ -31639,63 +31683,93 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
31639
31683
 
31640
31684
  // // search field changed in the target program's progDataSource // @code
31641
31685
  // found = progDataSource_str?.includes('@' + field_id);
31642
- // if (found) break;
31686
+ // if (found) {
31687
+ // refresh_reason = `field ${field_id} in progDataSource changed`;
31688
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
31689
+
31690
+ // break;
31691
+ // }
31692
+
31693
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
31694
+ // if (found) {
31695
+ // refresh_reason = `field ${field_id} in progUi xu-for changed`;
31696
+ // refresh_details = found;
31697
+
31698
+ // break;
31699
+ // }
31700
+
31701
+ // if (found) {
31702
+ // break;
31703
+ // }
31643
31704
  // }
31644
31705
  // }
31645
31706
 
31646
31707
  // if (datasource_changed) {
31647
31708
  // if (panel_val._ds.dsSession == datasource_changed) {
31709
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
31710
+ // refresh_details = '';
31711
+
31648
31712
  // found = true;
31649
31713
  // }
31650
31714
  // }
31651
31715
  // if (found) {
31652
- // var $div_elm = panel_val.$div
31653
- // .parent()
31654
- // .parent()
31655
- // .find("[xu-ui-id='" + parent_element_ui_id + "']");
31716
+ // const _session = SESSION_OBJ[SESSION_ID];
31717
+ // if (_session.engine_mode === 'live_preview') {
31718
+ // console.info('========= refresh info ==============');
31719
+ // console.info('reason:', refresh_reason);
31720
+ // console.info('details:', refresh_details);
31721
+ // console.info('panel:', panel_val);
31722
+ // console.info('=====================================');
31723
+ // }
31724
+ // const $div_elm = panel_val.$panel_div;
31725
+ // const wrapper_data = $div_elm.data();
31726
+
31727
+ // if (_.isEmpty(wrapper_data)) continue;
31656
31728
 
31657
- // // restore original panel
31658
31729
  // try {
31659
- // // const $org_panel = panel_val.$div.data().xuPanelData.$panel_div;
31730
+ // const ts = Date.now();
31731
+ // // remove old panel content
31732
+ // $.each(panel_val.ids, async function (key, val) {
31733
+ // $("[xu-ui-id='" + val + "']")
31734
+ // .attr('xu-ui-id', val + ts)
31735
+ // .removeData();
31736
+ // });
31660
31737
 
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);
31738
+ // let refreshed_ds;
31739
+ // // check if ds exist and deleted by garbage collector
31740
+
31741
+ // if (_session.DS_GLB[panel_val._ds.dsSession]) {
31742
+ // refreshed_ds = panel_val._ds.dsSession;
31743
+ // }
31744
+ // for await (const item of wrapper_data.xuData.node_org.children) {
31745
+ // if (item.tagName !== 'xu-panel') continue;
31746
+
31747
+ // const new_$div = await func.UI.screen.render_ui_tree(
31748
+ // SESSION_ID,
31749
+ // $div_elm, // the wrapper
31750
+ // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
31751
+ // {},
31752
+ // wrapper_data.xuData.paramsP, // the wrapper params
31753
+ // null,
31754
+ // null,
31755
+ // wrapper_data.xuData.key, // the wrapper key
31756
+ // refreshed_ds, // the refreshed_ds
31757
+ // wrapper_data.xuData.parent_node, // the wrapper parent node
31758
+ // null,
31759
+ // wrapper_data.xuData.$root_container, // the wrapper root container
31760
+ // );
31761
+ // }
31662
31762
 
31663
31763
  // // remove old panel content
31664
31764
  // $.each(panel_val.ids, async function (key, val) {
31665
- // $("[xu-ui-id='" + val + "']").remove();
31765
+ // $("[xu-ui-id='" + val + ts + "']").remove();
31666
31766
  // });
31667
31767
  // } catch (error) {
31668
31768
  // debugger;
31669
31769
  // }
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`);
31770
+ // // continue;
31696
31771
  // }
31697
31772
  // }
31698
- // return params_obj;
31699
31773
  // };
31700
31774
 
31701
31775
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {