@xuda.io/xuda-worker-bundle-min 1.3.883 → 1.3.885

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.
Files changed (2) hide show
  1. package/index.js +129 -110
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2724,7 +2724,7 @@ func.datasource.execute = async function (
2724
2724
  ) {
2725
2725
  const dbMsgP = await func.db.save_data(SESSION_ID, dataSourceSession);
2726
2726
  if (dbMsgP) _ds.currentRecordId = dbMsgP.id;
2727
- _ds.set_mode = "M";
2727
+ _ds.set_mode = "U";
2728
2728
  }
2729
2729
 
2730
2730
  if (_ds.set_mode === "D") {
@@ -2747,48 +2747,51 @@ func.datasource.execute = async function (
2747
2747
  _ds.data_feed.rows_deleted = [];
2748
2748
  _ds.data_feed.rows_added = [];
2749
2749
 
2750
- const row_not_found = async function () {
2751
- _ds.currentRecordId = "newRecord";
2752
- _ds.set_mode = "C";
2753
- _ds.record_not_found = true;
2754
-
2755
- try {
2756
- const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
2757
- } catch (error) {
2758
- await func.datasource.render_fields_form(
2759
- SESSION_ID,
2760
- dataSourceSession,
2761
- { id: "newRecord", value: {} }
2762
- );
2763
- }
2750
+ if (tree_obj.rwMode === "U") {
2751
+ _ds.set_mode = "U";
2752
+ } else {
2753
+ _ds.set_mode = "R";
2754
+ }
2764
2755
 
2765
- // if (_.isEmpty(_ds.data_feed.rows[glb.newRecord])) {
2766
- // await func.datasource.render_fields_form(
2767
- // SESSION_ID,
2768
- // dataSourceSession,
2769
- // { _ROWID: "newRecord" } // { id: "newRecord", value: {} },
2770
- // // null,
2771
- // // false,
2772
- // // "newRecord"
2773
- // );
2774
- // }
2775
- var count = await func.datasource.get_field_init_count(
2776
- SESSION_ID,
2777
- dataSourceSession,
2778
- "newRecord",
2779
- false
2780
- );
2756
+ const row_not_found = async function () {
2781
2757
  if (
2782
- count > 0 // was: && !args.dataSourceNoP
2758
+ !prog_obj.progDataSource?.dataSourceType ||
2759
+ (tree_obj.rwMode === "U" && tree_obj.allowCreate)
2783
2760
  ) {
2784
- await func.datasource.execute_field_init_events(
2761
+ _ds.currentRecordId = "newRecord";
2762
+ _ds.set_mode = "C";
2763
+ _ds.record_not_found = true;
2764
+
2765
+ try {
2766
+ const row_idx = func.common.find_ROWID_idx(
2767
+ _ds,
2768
+ _ds.currentRecordId
2769
+ );
2770
+ } catch (error) {
2771
+ await func.datasource.render_fields_form(
2772
+ SESSION_ID,
2773
+ dataSourceSession,
2774
+ { id: "newRecord", value: {} }
2775
+ );
2776
+ }
2777
+
2778
+ var count = await func.datasource.get_field_init_count(
2785
2779
  SESSION_ID,
2786
2780
  dataSourceSession,
2787
- "form",
2788
- "newRecord"
2781
+ "newRecord",
2782
+ false
2789
2783
  );
2784
+ if (
2785
+ count > 0 // was: && !args.dataSourceNoP
2786
+ ) {
2787
+ await func.datasource.execute_field_init_events(
2788
+ SESSION_ID,
2789
+ dataSourceSession,
2790
+ "form",
2791
+ "newRecord"
2792
+ );
2793
+ }
2790
2794
  }
2791
- // return await callback_datasource();
2792
2795
  };
2793
2796
  if (!rows) {
2794
2797
  await row_not_found();
@@ -2829,13 +2832,46 @@ func.datasource.execute = async function (
2829
2832
  );
2830
2833
  }
2831
2834
 
2832
- await func.datasource.run_rows_form(
2835
+ // await func.datasource.run_rows_form(
2836
+ // SESSION_ID,
2837
+ // dataSourceSession,
2838
+ // idx,
2839
+ // raw_data_row
2840
+ // );
2841
+
2842
+ ///////////////////////
2843
+
2844
+ _ds.currentRecordId = raw_data_row.id; // set temporary to allow expression decoder work
2845
+
2846
+ await func.datasource.render_fields_form(
2833
2847
  SESSION_ID,
2834
2848
  dataSourceSession,
2835
- idx,
2836
2849
  raw_data_row
2837
2850
  );
2838
2851
 
2852
+ try {
2853
+ const init_count = await func.datasource.get_field_init_count(
2854
+ SESSION_ID,
2855
+ dataSourceSession,
2856
+ _ROWID,
2857
+ false,
2858
+ _ds.oninit_triggers_to_run
2859
+ );
2860
+
2861
+ if (init_count > 0) {
2862
+ await func.datasource.execute_field_init_events(
2863
+ SESSION_ID,
2864
+ dataSourceSession,
2865
+ "form",
2866
+ raw_data_row.id
2867
+ );
2868
+ }
2869
+ } catch (err) {
2870
+ console.error(err);
2871
+ }
2872
+
2873
+ /////////////////////
2874
+
2839
2875
  if (await get_after_record_count()) {
2840
2876
  await func.datasource.execute_view_events(
2841
2877
  SESSION_ID,
@@ -3028,7 +3064,6 @@ func.datasource.render_fields_form = async function (
3028
3064
  raw_data_row
3029
3065
  ) {
3030
3066
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
3031
- // var v = _ds.v;
3032
3067
 
3033
3068
  const _progFields = await func.datasource.get_progFields(
3034
3069
  SESSION_ID,
@@ -3101,13 +3136,8 @@ func.datasource.render_fields_form = async function (
3101
3136
  let row_idx;
3102
3137
  try {
3103
3138
  row_idx = func.common.find_ROWID_idx(_ds, raw_data_row.id);
3104
- // data_arr[row_idx] = [{ _ROWID: "newRecord" }];
3105
3139
  } catch (error) {
3106
- // if (raw_data_row._ROWID === "newRecord") {
3107
- // _ds.data_feed.rows[glb.newRecord] = { _ROWID: raw_data_row._ROWID };
3108
- // } else {
3109
3140
  _ds.data_feed.rows.push({ _ROWID: raw_data_row.id });
3110
- // }
3111
3141
  row_idx = func.common.find_ROWID_idx(_ds, raw_data_row.id);
3112
3142
  }
3113
3143
 
@@ -3185,76 +3215,63 @@ func.datasource.render_fields_form = async function (
3185
3215
  }
3186
3216
  };
3187
3217
 
3188
- func.datasource.run_rows_form = async function (
3189
- SESSION_ID,
3190
- dataSourceSession,
3191
- rowIdxP,
3192
- raw_data_row
3193
- ) {
3194
- var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
3195
- if (!_ds) return;
3196
- let _ROWID = raw_data_row.id;
3197
- // var val = _ds.data_feed.rows[rowIdxP];
3198
-
3199
- var idx = rowIdxP;
3200
-
3201
- const find_ROWID_idx_from_raw_data_arr = function (rowId) {
3202
- if (!_ds?.v?.raw_data?.rows) {
3203
- throw new Error("ds.v.raw_data.rows not found");
3204
- }
3218
+ // func.datasource.run_rows_form = async function (
3219
+ // SESSION_ID,
3220
+ // dataSourceSession,
3221
+ // rowIdxP,
3222
+ // raw_data_row
3223
+ // ) {
3224
+ // var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dataSourceSession];
3225
+ // if (!_ds) return;
3226
+ // let _ROWID = raw_data_row.id;
3227
+ // // var val = _ds.data_feed.rows[rowIdxP];
3205
3228
 
3206
- const index = _ds.v.raw_data.rows.findIndex((item) => item.id === rowId);
3207
- if (index === -1) {
3208
- throw new Error(`item.id "${rowId}" not found`);
3209
- }
3210
- return index;
3211
- };
3229
+ // var idx = rowIdxP;
3212
3230
 
3213
- try {
3214
- idx = find_ROWID_idx_from_raw_data_arr(raw_data_row.id);
3215
- } catch (e) {
3216
- _ROWID = "newRecord";
3217
- _ds.data_feed.rows.push({ _ROWID });
3218
- idx = func.common.find_ROWID_idx(_ds, _ROWID);
3219
- }
3220
-
3221
- // try {
3222
- // if (typeof val !== "undefined") {
3223
- // idx = rowIdxP;
3224
- // _ROWID = val._ROWID;
3225
- // } else {
3226
- // _ROWID = "newRecord";
3227
- // val = _ds.data_feed.rows.push({ _ROWID });
3228
- // idx = func.common.find_ROWID_idx(_ds, _ROWID);
3229
- // }
3230
- // } catch (e) {
3231
- // console.error(e);
3232
- // }
3231
+ // const find_ROWID_idx_from_raw_data_arr = function (rowId) {
3232
+ // if (!_ds?.v?.raw_data?.rows) {
3233
+ // throw new Error("ds.v.raw_data.rows not found");
3234
+ // }
3233
3235
 
3234
- _ds.currentRecordId = _ROWID; // set temporary to allow expression decoder work
3236
+ // const index = _ds.v.raw_data.rows.findIndex((item) => item.id === rowId);
3237
+ // if (index === -1) {
3238
+ // throw new Error(`item.id "${rowId}" not found`);
3239
+ // }
3240
+ // return index;
3241
+ // };
3242
+
3243
+ // try {
3244
+ // idx = find_ROWID_idx_from_raw_data_arr(raw_data_row.id);
3245
+ // } catch (e) {
3246
+ // _ROWID = "newRecord";
3247
+ // _ds.data_feed.rows.push({ _ROWID });
3248
+ // idx = func.common.find_ROWID_idx(_ds, _ROWID);
3249
+ // }
3235
3250
 
3236
- await func.datasource.render_fields_form(
3237
- SESSION_ID,
3238
- dataSourceSession,
3239
- raw_data_row
3240
- );
3241
- const init_count = await func.datasource.get_field_init_count(
3242
- SESSION_ID,
3243
- dataSourceSession,
3244
- _ROWID,
3245
- false,
3246
- _ds.oninit_triggers_to_run
3247
- );
3248
- if (init_count > 0) {
3249
- await func.datasource.execute_field_init_events(
3250
- SESSION_ID,
3251
- dataSourceSession,
3252
- "form",
3253
- _ds.data_feed.rows[idx]._ROWID
3254
- );
3255
- }
3256
- // await form_continue();
3257
- };
3251
+ // _ds.currentRecordId = _ROWID; // set temporary to allow expression decoder work
3252
+
3253
+ // await func.datasource.render_fields_form(
3254
+ // SESSION_ID,
3255
+ // dataSourceSession,
3256
+ // raw_data_row
3257
+ // );
3258
+ // const init_count = await func.datasource.get_field_init_count(
3259
+ // SESSION_ID,
3260
+ // dataSourceSession,
3261
+ // _ROWID,
3262
+ // false,
3263
+ // _ds.oninit_triggers_to_run
3264
+ // );
3265
+ // if (init_count > 0) {
3266
+ // await func.datasource.execute_field_init_events(
3267
+ // SESSION_ID,
3268
+ // dataSourceSession,
3269
+ // "form",
3270
+ // _ds.data_feed.rows[idx]._ROWID
3271
+ // );
3272
+ // }
3273
+ // // await form_continue();
3274
+ // };
3258
3275
 
3259
3276
  func.datasource.execute_field_init_events = async function (
3260
3277
  SESSION_ID,
@@ -3333,6 +3350,7 @@ func.datasource.execute_field_init_events = async function (
3333
3350
  }
3334
3351
  }
3335
3352
  };
3353
+
3336
3354
  func.datasource.get_field_init_count = async function (
3337
3355
  SESSION_ID,
3338
3356
  dataSourceSession,
@@ -3427,6 +3445,7 @@ func.datasource.get_field_init_count = async function (
3427
3445
  // }
3428
3446
  return ret;
3429
3447
  };
3448
+
3430
3449
  func.datasource.get_view_events_count = async function (
3431
3450
  SESSION_ID,
3432
3451
  dataSourceSession,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.883",
3
+ "version": "1.3.885",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {