datastake-daf 0.6.509 → 0.6.511
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.
package/dist/components/index.js
CHANGED
|
@@ -36687,6 +36687,42 @@ function AjaxSelectMain(_ref) {
|
|
|
36687
36687
|
getAppHeader,
|
|
36688
36688
|
getApiBaseUrl
|
|
36689
36689
|
} = _ref;
|
|
36690
|
+
console.log("AJAX SELECT MAIN");
|
|
36691
|
+
console.log({
|
|
36692
|
+
preSelected,
|
|
36693
|
+
props,
|
|
36694
|
+
size,
|
|
36695
|
+
input,
|
|
36696
|
+
groupFormId,
|
|
36697
|
+
formsValue,
|
|
36698
|
+
call,
|
|
36699
|
+
value,
|
|
36700
|
+
repeatIndex,
|
|
36701
|
+
changeInputMeta,
|
|
36702
|
+
repeatValues,
|
|
36703
|
+
mainForm,
|
|
36704
|
+
onNewSetValue,
|
|
36705
|
+
inputMeta,
|
|
36706
|
+
className,
|
|
36707
|
+
multiple,
|
|
36708
|
+
setFormValues,
|
|
36709
|
+
updateOptions,
|
|
36710
|
+
unique,
|
|
36711
|
+
meta,
|
|
36712
|
+
name,
|
|
36713
|
+
inputName,
|
|
36714
|
+
getFromLinking,
|
|
36715
|
+
allowClear,
|
|
36716
|
+
onChange,
|
|
36717
|
+
onOptions,
|
|
36718
|
+
changeAjaxOptions,
|
|
36719
|
+
app,
|
|
36720
|
+
t,
|
|
36721
|
+
user,
|
|
36722
|
+
getAppHeader,
|
|
36723
|
+
getApiBaseUrl
|
|
36724
|
+
});
|
|
36725
|
+
console.log("AJAX SELECT MAIN END");
|
|
36690
36726
|
const inst = /*#__PURE__*/React.createRef();
|
|
36691
36727
|
const [modelValue, setModelValue] = React.useState(value ? value : multiple ? [] : null);
|
|
36692
36728
|
const [model, setModel] = React.useState([]);
|
|
@@ -36706,21 +36742,20 @@ function AjaxSelectMain(_ref) {
|
|
|
36706
36742
|
};
|
|
36707
36743
|
const endpoint = meta !== null && meta !== void 0 && meta.endpoint ? "".concat(url).concat(meta === null || meta === void 0 ? void 0 : meta.endpoint) : meta.application && !queryOptionsApps.includes(app) ? "".concat(url, "/query/").concat(app, "/options") : "".concat(url, "/").concat(queryOptionsAppEndpoints[app] || "query/options");
|
|
36708
36744
|
React.useEffect(() => {
|
|
36709
|
-
if (
|
|
36710
|
-
|
|
36711
|
-
|
|
36712
|
-
|
|
36713
|
-
|
|
36714
|
-
|
|
36745
|
+
// Check if this is a new item (not in the fetched model from server)
|
|
36746
|
+
const isNewItem = value && typeof value === 'string' && !model.find(m => m.value === value);
|
|
36747
|
+
if (isNewItem && value) {
|
|
36748
|
+
// Add the new item to the model with its actual value
|
|
36749
|
+
if (!model.find(m => m.value === value)) {
|
|
36750
|
+
const newOption = {
|
|
36751
|
+
label: value,
|
|
36752
|
+
value: value
|
|
36753
|
+
};
|
|
36754
|
+
setModel(model.concat(newOption));
|
|
36715
36755
|
if (updateOptions) {
|
|
36716
|
-
onOptions(model.concat(
|
|
36717
|
-
label: searchValue || t("New"),
|
|
36718
|
-
value: "new"
|
|
36719
|
-
}));
|
|
36756
|
+
onOptions(model.concat(newOption));
|
|
36720
36757
|
}
|
|
36721
36758
|
}
|
|
36722
|
-
} else {
|
|
36723
|
-
setModel(model.filter(v => v.value !== "new"));
|
|
36724
36759
|
}
|
|
36725
36760
|
setModelValue(value ? value : multiple ? [] : null);
|
|
36726
36761
|
setSearchValue(value);
|
|
@@ -36819,16 +36854,18 @@ function AjaxSelectMain(_ref) {
|
|
|
36819
36854
|
let {
|
|
36820
36855
|
data
|
|
36821
36856
|
} = _ref2;
|
|
36822
|
-
//? FUTURE ILVI KEEP THIS IN MIND
|
|
36823
36857
|
if (meta.saveAjaxOptions) {
|
|
36824
36858
|
changeAjaxOptions(name, data);
|
|
36825
36859
|
}
|
|
36826
|
-
|
|
36827
|
-
|
|
36828
|
-
|
|
36829
|
-
|
|
36830
|
-
|
|
36831
|
-
|
|
36860
|
+
|
|
36861
|
+
// Check if current value is a new item (not in fetched data)
|
|
36862
|
+
const isNewItem = modelValue && !data.find(d => d.value === modelValue);
|
|
36863
|
+
if (isNewItem) {
|
|
36864
|
+
// Preserve the new item in the options
|
|
36865
|
+
const newItem = model.find(m => m.value === modelValue);
|
|
36866
|
+
if (newItem) {
|
|
36867
|
+
data = data.concat([newItem]);
|
|
36868
|
+
}
|
|
36832
36869
|
} else {
|
|
36833
36870
|
updateLabel(data, undefined, true);
|
|
36834
36871
|
setTimeout(() => {
|
|
@@ -37032,7 +37069,7 @@ function AjaxSelectMain(_ref) {
|
|
|
37032
37069
|
marginTop: 4
|
|
37033
37070
|
}
|
|
37034
37071
|
}),
|
|
37035
|
-
disabled: !searchValue || typeof searchValue === "string" && searchValue.trim() === "" ||
|
|
37072
|
+
disabled: !searchValue || typeof searchValue === "string" && searchValue.trim() === "" || model.find(m => m.value === searchValue) && asOption,
|
|
37036
37073
|
type: "link primary",
|
|
37037
37074
|
onClick: () => {
|
|
37038
37075
|
const oldValue = searchValue;
|
|
@@ -37139,14 +37176,11 @@ function AjaxSelectMain(_ref) {
|
|
|
37139
37176
|
setModelValue(value);
|
|
37140
37177
|
}
|
|
37141
37178
|
}
|
|
37142
|
-
if (!value) {
|
|
37143
|
-
setModel([...(model || []).filter(m => m.value !== "new")]);
|
|
37144
|
-
}
|
|
37145
37179
|
};
|
|
37146
37180
|
const addNewData = oldValue => {
|
|
37147
37181
|
if (onNewSetValue) {
|
|
37148
37182
|
if (repeatIndex !== null && repeatValues) {
|
|
37149
|
-
repeatValues[inputName] =
|
|
37183
|
+
repeatValues[inputName] = oldValue;
|
|
37150
37184
|
repeatValues[onNewSetValue] = oldValue;
|
|
37151
37185
|
if (!formsValue[name]) {
|
|
37152
37186
|
formsValue[name] = [];
|
|
@@ -37156,10 +37190,12 @@ function AjaxSelectMain(_ref) {
|
|
|
37156
37190
|
// mainForm.scrollToField([name, repeatIndex, onNewSetValue]);
|
|
37157
37191
|
}
|
|
37158
37192
|
}
|
|
37159
|
-
|
|
37193
|
+
|
|
37194
|
+
// Use the actual value instead of "new"
|
|
37195
|
+
const newModelInd = model.findIndex(m => m.value === oldValue);
|
|
37160
37196
|
let newModel = {
|
|
37161
37197
|
label: oldValue,
|
|
37162
|
-
value:
|
|
37198
|
+
value: oldValue
|
|
37163
37199
|
};
|
|
37164
37200
|
if (newModelInd >= 0) {
|
|
37165
37201
|
model[newModelInd] = newModel;
|
|
@@ -37170,17 +37206,17 @@ function AjaxSelectMain(_ref) {
|
|
|
37170
37206
|
if (updateOptions) {
|
|
37171
37207
|
onOptions(model.concat({
|
|
37172
37208
|
label: oldValue || t("New"),
|
|
37173
|
-
value:
|
|
37209
|
+
value: oldValue
|
|
37174
37210
|
}));
|
|
37175
37211
|
}
|
|
37176
|
-
setModelValue(
|
|
37212
|
+
setModelValue(oldValue);
|
|
37177
37213
|
inst.current.blur();
|
|
37178
37214
|
if (!onNewSetValue) {
|
|
37179
37215
|
const otherValues = onNewSetValue ? {
|
|
37180
37216
|
[onNewSetValue]: searchValue,
|
|
37181
|
-
[name]:
|
|
37217
|
+
[name]: oldValue
|
|
37182
37218
|
} : {
|
|
37183
|
-
[name]:
|
|
37219
|
+
[name]: oldValue
|
|
37184
37220
|
};
|
|
37185
37221
|
|
|
37186
37222
|
// remove keys, because can be from prev selection
|
|
@@ -37221,7 +37257,7 @@ function AjaxSelectMain(_ref) {
|
|
|
37221
37257
|
return;
|
|
37222
37258
|
}
|
|
37223
37259
|
setTimeout(() => {
|
|
37224
|
-
onChange(
|
|
37260
|
+
onChange(oldValue, model || []);
|
|
37225
37261
|
addNewValueKey(searchValue);
|
|
37226
37262
|
}, 200);
|
|
37227
37263
|
};
|
|
@@ -37286,6 +37322,9 @@ function AjaxSelect(props) {
|
|
|
37286
37322
|
getAppHeader,
|
|
37287
37323
|
getApiBaseUrl
|
|
37288
37324
|
} = useEditContext();
|
|
37325
|
+
console.log({
|
|
37326
|
+
props
|
|
37327
|
+
});
|
|
37289
37328
|
return /*#__PURE__*/jsxRuntime.jsx(AjaxSelectMain, _objectSpread2({
|
|
37290
37329
|
changeAjaxOptions: changeAjaxOptions,
|
|
37291
37330
|
app: app,
|
|
@@ -38562,6 +38601,35 @@ const inputTypeComponent = {
|
|
|
38562
38601
|
meta,
|
|
38563
38602
|
setFormValues
|
|
38564
38603
|
}) => {
|
|
38604
|
+
console.log("AJAX SELECT");
|
|
38605
|
+
console.log({
|
|
38606
|
+
call,
|
|
38607
|
+
automaticallyLink,
|
|
38608
|
+
name,
|
|
38609
|
+
inputName,
|
|
38610
|
+
props,
|
|
38611
|
+
formsValue,
|
|
38612
|
+
onNewSetValue,
|
|
38613
|
+
multiple,
|
|
38614
|
+
updateOptions,
|
|
38615
|
+
repeatValues,
|
|
38616
|
+
repeatIndex,
|
|
38617
|
+
value,
|
|
38618
|
+
unique,
|
|
38619
|
+
address,
|
|
38620
|
+
addressData,
|
|
38621
|
+
input
|
|
38622
|
+
});
|
|
38623
|
+
console.log({
|
|
38624
|
+
form,
|
|
38625
|
+
forms,
|
|
38626
|
+
setAddress,
|
|
38627
|
+
changeInputMeta,
|
|
38628
|
+
inputMeta,
|
|
38629
|
+
meta,
|
|
38630
|
+
setFormValues
|
|
38631
|
+
});
|
|
38632
|
+
console.log("AJAX SELECT END");
|
|
38565
38633
|
return /*#__PURE__*/jsxRuntime.jsx(AjaxSelect, {
|
|
38566
38634
|
preSelected: preSelected,
|
|
38567
38635
|
input: input,
|
package/package.json
CHANGED
|
@@ -1422,6 +1422,10 @@ export const inputTypeComponent = {
|
|
|
1422
1422
|
},
|
|
1423
1423
|
{ form, forms, setAddress, changeInputMeta, inputMeta = {}, meta, setFormValues },
|
|
1424
1424
|
) => {
|
|
1425
|
+
console.log("AJAX SELECT")
|
|
1426
|
+
console.log({call, automaticallyLink, name, inputName, props, formsValue, onNewSetValue, multiple, updateOptions, repeatValues, repeatIndex, value, unique, address, addressData, input})
|
|
1427
|
+
console.log({form, forms, setAddress, changeInputMeta, inputMeta, meta, setFormValues})
|
|
1428
|
+
console.log("AJAX SELECT END")
|
|
1425
1429
|
return (
|
|
1426
1430
|
<AjaxSelect
|
|
1427
1431
|
preSelected={preSelected}
|
|
@@ -50,6 +50,9 @@ export function AjaxSelectMain({
|
|
|
50
50
|
getAppHeader,
|
|
51
51
|
getApiBaseUrl,
|
|
52
52
|
}) {
|
|
53
|
+
console.log("AJAX SELECT MAIN")
|
|
54
|
+
console.log({preSelected, props, size, input, groupFormId, formsValue, call, value, repeatIndex, changeInputMeta, repeatValues, mainForm, onNewSetValue, inputMeta, className, multiple, setFormValues, updateOptions, unique, meta, name, inputName, getFromLinking, allowClear, onChange, onOptions, changeAjaxOptions, app, t, user, getAppHeader, getApiBaseUrl})
|
|
55
|
+
console.log("AJAX SELECT MAIN END")
|
|
53
56
|
const inst = createRef();
|
|
54
57
|
const [modelValue, setModelValue] = useState(value ? value : multiple ? [] : null);
|
|
55
58
|
const [model, setModel] = useState([]);
|
|
@@ -85,15 +88,18 @@ export function AjaxSelectMain({
|
|
|
85
88
|
: `${url}/${queryOptionsAppEndpoints[app] || "query/options"}`;
|
|
86
89
|
|
|
87
90
|
useEffect(() => {
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
// Check if this is a new item (not in the fetched model from server)
|
|
92
|
+
const isNewItem = value && typeof value === 'string' && !model.find((m) => m.value === value);
|
|
93
|
+
|
|
94
|
+
if (isNewItem && value) {
|
|
95
|
+
// Add the new item to the model with its actual value
|
|
96
|
+
if (!model.find((m) => m.value === value)) {
|
|
97
|
+
const newOption = { label: value, value: value };
|
|
98
|
+
setModel(model.concat(newOption));
|
|
91
99
|
if (updateOptions) {
|
|
92
|
-
onOptions(model.concat(
|
|
100
|
+
onOptions(model.concat(newOption));
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
|
-
} else {
|
|
96
|
-
setModel(model.filter((v) => v.value !== "new"));
|
|
97
103
|
}
|
|
98
104
|
setModelValue(value ? value : multiple ? [] : null);
|
|
99
105
|
setSearchValue(value);
|
|
@@ -211,19 +217,18 @@ export function AjaxSelectMain({
|
|
|
211
217
|
},
|
|
212
218
|
)
|
|
213
219
|
.then(({ data }) => {
|
|
214
|
-
//? FUTURE ILVI KEEP THIS IN MIND
|
|
215
220
|
if (meta.saveAjaxOptions) {
|
|
216
221
|
changeAjaxOptions(name, data);
|
|
217
222
|
}
|
|
218
223
|
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
// Check if current value is a new item (not in fetched data)
|
|
225
|
+
const isNewItem = modelValue && !data.find((d) => d.value === modelValue);
|
|
226
|
+
if (isNewItem) {
|
|
227
|
+
// Preserve the new item in the options
|
|
228
|
+
const newItem = model.find((m) => m.value === modelValue);
|
|
229
|
+
if (newItem) {
|
|
230
|
+
data = data.concat([newItem]);
|
|
231
|
+
}
|
|
227
232
|
} else {
|
|
228
233
|
updateLabel(data, undefined, true);
|
|
229
234
|
setTimeout(() => {
|
|
@@ -442,10 +447,7 @@ export function AjaxSelectMain({
|
|
|
442
447
|
disabled={
|
|
443
448
|
!searchValue ||
|
|
444
449
|
(typeof searchValue === "string" && searchValue.trim() === "") ||
|
|
445
|
-
(((
|
|
446
|
-
(modelValue === "new" &&
|
|
447
|
-
model.filter((m) => m.value === "new" && m.label === searchValue))) &&
|
|
448
|
-
asOption)
|
|
450
|
+
(model.find((m) => m.value === searchValue) && asOption)
|
|
449
451
|
}
|
|
450
452
|
type="link primary"
|
|
451
453
|
onClick={() => {
|
|
@@ -572,15 +574,12 @@ export function AjaxSelectMain({
|
|
|
572
574
|
setModelValue(value);
|
|
573
575
|
}
|
|
574
576
|
}
|
|
575
|
-
if (!value) {
|
|
576
|
-
setModel([...(model || []).filter((m) => m.value !== "new")]);
|
|
577
|
-
}
|
|
578
577
|
};
|
|
579
578
|
|
|
580
579
|
const addNewData = (oldValue) => {
|
|
581
580
|
if (onNewSetValue) {
|
|
582
581
|
if (repeatIndex !== null && repeatValues) {
|
|
583
|
-
repeatValues[inputName] =
|
|
582
|
+
repeatValues[inputName] = oldValue;
|
|
584
583
|
repeatValues[onNewSetValue] = oldValue;
|
|
585
584
|
if (!formsValue[name]) {
|
|
586
585
|
formsValue[name] = [];
|
|
@@ -593,8 +592,10 @@ export function AjaxSelectMain({
|
|
|
593
592
|
// mainForm.scrollToField(onNewSetValue);
|
|
594
593
|
}
|
|
595
594
|
}
|
|
596
|
-
|
|
597
|
-
|
|
595
|
+
|
|
596
|
+
// Use the actual value instead of "new"
|
|
597
|
+
const newModelInd = model.findIndex((m) => m.value === oldValue);
|
|
598
|
+
let newModel = { label: oldValue, value: oldValue };
|
|
598
599
|
if (newModelInd >= 0) {
|
|
599
600
|
model[newModelInd] = newModel;
|
|
600
601
|
} else {
|
|
@@ -603,17 +604,17 @@ export function AjaxSelectMain({
|
|
|
603
604
|
|
|
604
605
|
setModel([...model]);
|
|
605
606
|
if (updateOptions) {
|
|
606
|
-
onOptions(model.concat({ label: oldValue || t("New"), value:
|
|
607
|
+
onOptions(model.concat({ label: oldValue || t("New"), value: oldValue }));
|
|
607
608
|
}
|
|
608
|
-
setModelValue(
|
|
609
|
+
setModelValue(oldValue);
|
|
609
610
|
inst.current.blur();
|
|
610
611
|
if (!onNewSetValue) {
|
|
611
612
|
const otherValues = onNewSetValue
|
|
612
613
|
? {
|
|
613
614
|
[onNewSetValue]: searchValue,
|
|
614
|
-
[name]:
|
|
615
|
+
[name]: oldValue,
|
|
615
616
|
}
|
|
616
|
-
: { [name]:
|
|
617
|
+
: { [name]: oldValue };
|
|
617
618
|
|
|
618
619
|
// remove keys, because can be from prev selection
|
|
619
620
|
toRemoveKeysOnNew.forEach((k) => {
|
|
@@ -661,7 +662,7 @@ export function AjaxSelectMain({
|
|
|
661
662
|
}
|
|
662
663
|
|
|
663
664
|
setTimeout(() => {
|
|
664
|
-
onChange(
|
|
665
|
+
onChange(oldValue, model || []);
|
|
665
666
|
addNewValueKey(searchValue, true);
|
|
666
667
|
}, 200);
|
|
667
668
|
};
|
|
@@ -739,6 +740,7 @@ export function AjaxSelectMain({
|
|
|
739
740
|
|
|
740
741
|
function AjaxSelect(props) {
|
|
741
742
|
const { changeAjaxOptions, app, t, user, getAppHeader, getApiBaseUrl } = useEditContext();
|
|
743
|
+
console.log({props})
|
|
742
744
|
|
|
743
745
|
return (
|
|
744
746
|
<AjaxSelectMain
|