@xuda.io/runtime-bundle 1.0.251 → 1.0.252
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.
|
@@ -33767,6 +33767,9 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
33767
33767
|
let is_dynamic_field = false
|
|
33768
33768
|
let field_prop
|
|
33769
33769
|
|
|
33770
|
+
const iterate_info = $elm?.data()?.xuData?.iterate_info
|
|
33771
|
+
const reference_source_obj = iterate_info?.reference_source_obj
|
|
33772
|
+
|
|
33770
33773
|
if (["_FOR_VAL", "_FOR_KEY"].includes(view_field_id)) {
|
|
33771
33774
|
is_dynamic_field = true
|
|
33772
33775
|
field_prop = _ds.dynamic_fields[view_field_id]
|
|
@@ -34047,12 +34050,12 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34047
34050
|
"xu-for": async function ($elm, data) {
|
|
34048
34051
|
if (parent_infoP?.iterate_info || !data.value) return {};
|
|
34049
34052
|
try {
|
|
34050
|
-
|
|
34053
|
+
// data.value (xu-for) can store actual values such as an array, a CSV, or a field_id that references a specific field within the dataset, initialized with values for the iteration.
|
|
34051
34054
|
let arr = data.value;
|
|
34052
34055
|
|
|
34053
34056
|
// find reference source field
|
|
34054
34057
|
let reference_source_obj
|
|
34055
|
-
|
|
34058
|
+
|
|
34056
34059
|
const _progFields = await func.datasource.get_progFields(
|
|
34057
34060
|
SESSION_ID,
|
|
34058
34061
|
paramsP.dsSessionP
|
|
@@ -34063,28 +34066,13 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34063
34066
|
"field_id",
|
|
34064
34067
|
data.value
|
|
34065
34068
|
);
|
|
34069
|
+
// detect if data.value (xu-for) is reference field_id by checking if exist in the dataset
|
|
34066
34070
|
if (view_field_obj) {
|
|
34067
|
-
//
|
|
34068
|
-
// try {
|
|
34069
|
-
// const row_idx = func.common.find_ROWID_idx(
|
|
34070
|
-
// _ds,
|
|
34071
|
-
// currentRecordId
|
|
34072
|
-
// );
|
|
34073
|
-
// reference_source_field = data.value
|
|
34074
|
-
|
|
34075
|
-
// arr = await func.datasource.get_value(SESSION_ID, paramsP.dsSessionP, reference_source_field)
|
|
34076
|
-
// } catch (err) {
|
|
34077
|
-
|
|
34078
|
-
// }
|
|
34079
|
-
// reference_source_field_id = data.value
|
|
34080
|
-
// reference_source_field_type=
|
|
34081
|
-
|
|
34071
|
+
// xu-for is reference field_id
|
|
34082
34072
|
reference_source_obj = await func.datasource.get_value(SESSION_ID, data.value, paramsP.dsSessionP)
|
|
34083
34073
|
arr = reference_source_obj?.ret?.value
|
|
34084
34074
|
} else {
|
|
34085
|
-
//
|
|
34086
|
-
|
|
34087
|
-
|
|
34075
|
+
// xu-for is actual data
|
|
34088
34076
|
if (typeof data.value === "string") {
|
|
34089
34077
|
arr = eval(data.value.replaceAll("\\", ""));
|
|
34090
34078
|
}
|
|
@@ -34092,43 +34080,41 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34092
34080
|
arr = Array.from(Array(arr).keys());
|
|
34093
34081
|
}
|
|
34094
34082
|
}
|
|
34095
|
-
// } catch (err) {
|
|
34096
|
-
|
|
34097
|
-
// }
|
|
34098
|
-
|
|
34099
|
-
|
|
34100
|
-
|
|
34101
34083
|
|
|
34084
|
+
const custom_iterator_key = $elm.data().xuData.iterator_key
|
|
34085
|
+
const custom_iterator_val = $elm.data().xuData.iterator_val
|
|
34102
34086
|
|
|
34087
|
+
let iterator_key = custom_iterator_key
|
|
34088
|
+
let iterator_val = custom_iterator_val
|
|
34103
34089
|
|
|
34090
|
+
// custom FOR_VAL name or namespaced default name
|
|
34091
|
+
if (!custom_iterator_key) {
|
|
34092
|
+
is_key_dynamic_field = true
|
|
34093
|
+
iterator_key = (reference_source_obj?.fieldIdP || "") + "_FOR_KEY";
|
|
34094
|
+
}
|
|
34104
34095
|
|
|
34096
|
+
if (!custom_iterator_val) {
|
|
34097
|
+
is_val_dynamic_field = true
|
|
34098
|
+
iterator_val = (reference_source_obj?.fieldIdP || "") + "_FOR_VAL";
|
|
34099
|
+
}
|
|
34105
34100
|
|
|
34106
|
-
// if (typeof data.value === "string") {
|
|
34107
|
-
// arr = eval(data.value.replaceAll("\\", ""));
|
|
34108
|
-
// }
|
|
34109
|
-
// if (typeof arr === "number") {
|
|
34110
|
-
// arr = Array.from(Array(arr).keys());
|
|
34111
|
-
// }
|
|
34112
|
-
let iterator_val = $elm.data().xuData.iterator_val;
|
|
34113
|
-
let iterator_key = $elm.data().xuData.iterator_key;
|
|
34114
34101
|
var i = 0;
|
|
34115
34102
|
for await (let [_key, _val] of Object.entries(arr)) {
|
|
34116
34103
|
|
|
34117
34104
|
if (_.isArray(arr)) { _key = Number(_key) }
|
|
34118
34105
|
|
|
34119
|
-
const set_value = async function (currentRecordId, field_id, value) {
|
|
34120
|
-
let is_dynamic_field = false;
|
|
34106
|
+
const set_value = async function (is_dynamic_field, currentRecordId, field_id, value) {
|
|
34121
34107
|
|
|
34122
34108
|
|
|
34109
|
+
if (is_dynamic_field) {
|
|
34123
34110
|
|
|
34124
|
-
if (["_FOR_VAL", "_FOR_KEY"].includes(field_id)) {
|
|
34125
|
-
is_dynamic_field = true;
|
|
34126
34111
|
func.datasource.add_dynamic_field_to_ds(
|
|
34127
34112
|
SESSION_ID,
|
|
34128
34113
|
paramsP.dsSessionP,
|
|
34129
34114
|
field_id,
|
|
34130
34115
|
value
|
|
34131
34116
|
);
|
|
34117
|
+
|
|
34132
34118
|
} else {
|
|
34133
34119
|
|
|
34134
34120
|
const _progFields = await func.datasource.get_progFields(
|
|
@@ -34157,7 +34143,7 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34157
34143
|
}
|
|
34158
34144
|
}
|
|
34159
34145
|
|
|
34160
|
-
|
|
34146
|
+
|
|
34161
34147
|
};
|
|
34162
34148
|
|
|
34163
34149
|
var currentRecordId =
|
|
@@ -34165,17 +34151,16 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34165
34151
|
paramsP.dsSessionP
|
|
34166
34152
|
].currentRecordId.toString();
|
|
34167
34153
|
|
|
34168
|
-
|
|
34169
|
-
|
|
34170
|
-
|
|
34154
|
+
await set_value(is_key_dynamic_field, currentRecordId, iterator_key, _key);
|
|
34155
|
+
await set_value(is_val_dynamic_field, currentRecordId, iterator_val, _val);
|
|
34171
34156
|
|
|
34172
34157
|
var iterate_info = {
|
|
34173
34158
|
_val,
|
|
34174
34159
|
_key,
|
|
34175
|
-
iterator_key
|
|
34176
|
-
iterator_val
|
|
34177
|
-
is_val_dynamic_field,
|
|
34160
|
+
iterator_key,
|
|
34161
|
+
iterator_val,
|
|
34178
34162
|
is_key_dynamic_field,
|
|
34163
|
+
is_val_dynamic_field,
|
|
34179
34164
|
reference_source_obj
|
|
34180
34165
|
};
|
|
34181
34166
|
if (parent_infoP) {
|
|
@@ -34205,10 +34190,6 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34205
34190
|
$(val).data().xuData.iterate_info = iterate_info;
|
|
34206
34191
|
}
|
|
34207
34192
|
});
|
|
34208
|
-
// // set values in _FOR record
|
|
34209
|
-
// currentRecordId = $divP.data().xuData.ui_id;
|
|
34210
|
-
// set_value(currentRecordId, iterator_key || "_FOR_KEY", _key);
|
|
34211
|
-
// set_value(currentRecordId, iterator_val || "_FOR_VAL", _val);
|
|
34212
34193
|
|
|
34213
34194
|
i++;
|
|
34214
34195
|
}
|