datastake-daf 0.6.513 → 0.6.514
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 +33 -72
- package/dist/layouts/index.js +3 -1
- package/package.json +1 -1
- package/src/@daf/core/components/DynamicForm/helper.js +1 -1
- package/src/@daf/core/components/EditForm/components/ajaxSelect.js +30 -32
- package/src/@daf/layouts/AppLayout/components/Sidenav/index.js +3 -1
package/dist/components/index.js
CHANGED
|
@@ -36687,42 +36687,6 @@ 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");
|
|
36726
36690
|
const inst = /*#__PURE__*/React.createRef();
|
|
36727
36691
|
const [modelValue, setModelValue] = React.useState(value ? value : multiple ? [] : null);
|
|
36728
36692
|
const [model, setModel] = React.useState([]);
|
|
@@ -36742,20 +36706,21 @@ function AjaxSelectMain(_ref) {
|
|
|
36742
36706
|
};
|
|
36743
36707
|
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");
|
|
36744
36708
|
React.useEffect(() => {
|
|
36745
|
-
|
|
36746
|
-
|
|
36747
|
-
|
|
36748
|
-
|
|
36749
|
-
|
|
36750
|
-
|
|
36751
|
-
label: value,
|
|
36752
|
-
value: value
|
|
36753
|
-
};
|
|
36754
|
-
setModel(model.concat(newOption));
|
|
36709
|
+
if (value === "new") {
|
|
36710
|
+
if (!model.find(m => m.value === "new")) {
|
|
36711
|
+
setModel(model.concat({
|
|
36712
|
+
label: searchValue || t("New"),
|
|
36713
|
+
value: "new"
|
|
36714
|
+
}));
|
|
36755
36715
|
if (updateOptions) {
|
|
36756
|
-
onOptions(model.concat(
|
|
36716
|
+
onOptions(model.concat({
|
|
36717
|
+
label: searchValue || t("New"),
|
|
36718
|
+
value: "new"
|
|
36719
|
+
}));
|
|
36757
36720
|
}
|
|
36758
36721
|
}
|
|
36722
|
+
} else {
|
|
36723
|
+
setModel(model.filter(v => v.value !== "new"));
|
|
36759
36724
|
}
|
|
36760
36725
|
setModelValue(value ? value : multiple ? [] : null);
|
|
36761
36726
|
setSearchValue(value);
|
|
@@ -36854,18 +36819,16 @@ function AjaxSelectMain(_ref) {
|
|
|
36854
36819
|
let {
|
|
36855
36820
|
data
|
|
36856
36821
|
} = _ref2;
|
|
36822
|
+
//? FUTURE ILVI KEEP THIS IN MIND
|
|
36857
36823
|
if (meta.saveAjaxOptions) {
|
|
36858
36824
|
changeAjaxOptions(name, data);
|
|
36859
36825
|
}
|
|
36860
|
-
|
|
36861
|
-
|
|
36862
|
-
|
|
36863
|
-
|
|
36864
|
-
|
|
36865
|
-
|
|
36866
|
-
if (newItem) {
|
|
36867
|
-
data = data.concat([newItem]);
|
|
36868
|
-
}
|
|
36826
|
+
if (modelValue === "new") {
|
|
36827
|
+
const newData = model.find(m => m.value === "new");
|
|
36828
|
+
data = data.concat([newData || {
|
|
36829
|
+
label: (inputMeta === null || inputMeta === void 0 ? void 0 : inputMeta.name) || searchValue || t("New"),
|
|
36830
|
+
value: "new"
|
|
36831
|
+
}]);
|
|
36869
36832
|
} else {
|
|
36870
36833
|
updateLabel(data, undefined, true);
|
|
36871
36834
|
setTimeout(() => {
|
|
@@ -37069,7 +37032,7 @@ function AjaxSelectMain(_ref) {
|
|
|
37069
37032
|
marginTop: 4
|
|
37070
37033
|
}
|
|
37071
37034
|
}),
|
|
37072
|
-
disabled: !searchValue || typeof searchValue === "string" && searchValue.trim() === "" || model.
|
|
37035
|
+
disabled: !searchValue || typeof searchValue === "string" && searchValue.trim() === "" || (typeof modelValue === "string" && modelValue !== "new" || modelValue === "new" && model.filter(m => m.value === "new" && m.label === searchValue)) && asOption,
|
|
37073
37036
|
type: "link primary",
|
|
37074
37037
|
onClick: () => {
|
|
37075
37038
|
const oldValue = searchValue;
|
|
@@ -37176,11 +37139,14 @@ function AjaxSelectMain(_ref) {
|
|
|
37176
37139
|
setModelValue(value);
|
|
37177
37140
|
}
|
|
37178
37141
|
}
|
|
37142
|
+
if (!value) {
|
|
37143
|
+
setModel([...(model || []).filter(m => m.value !== "new")]);
|
|
37144
|
+
}
|
|
37179
37145
|
};
|
|
37180
37146
|
const addNewData = oldValue => {
|
|
37181
37147
|
if (onNewSetValue) {
|
|
37182
37148
|
if (repeatIndex !== null && repeatValues) {
|
|
37183
|
-
repeatValues[inputName] =
|
|
37149
|
+
repeatValues[inputName] = "new";
|
|
37184
37150
|
repeatValues[onNewSetValue] = oldValue;
|
|
37185
37151
|
if (!formsValue[name]) {
|
|
37186
37152
|
formsValue[name] = [];
|
|
@@ -37190,12 +37156,10 @@ function AjaxSelectMain(_ref) {
|
|
|
37190
37156
|
// mainForm.scrollToField([name, repeatIndex, onNewSetValue]);
|
|
37191
37157
|
}
|
|
37192
37158
|
}
|
|
37193
|
-
|
|
37194
|
-
// Use the actual value instead of "new"
|
|
37195
|
-
const newModelInd = model.findIndex(m => m.value === oldValue);
|
|
37159
|
+
const newModelInd = model.findIndex(m => m.value === "new");
|
|
37196
37160
|
let newModel = {
|
|
37197
37161
|
label: oldValue,
|
|
37198
|
-
value:
|
|
37162
|
+
value: "new"
|
|
37199
37163
|
};
|
|
37200
37164
|
if (newModelInd >= 0) {
|
|
37201
37165
|
model[newModelInd] = newModel;
|
|
@@ -37206,17 +37170,17 @@ function AjaxSelectMain(_ref) {
|
|
|
37206
37170
|
if (updateOptions) {
|
|
37207
37171
|
onOptions(model.concat({
|
|
37208
37172
|
label: oldValue || t("New"),
|
|
37209
|
-
value:
|
|
37173
|
+
value: "new"
|
|
37210
37174
|
}));
|
|
37211
37175
|
}
|
|
37212
|
-
setModelValue(
|
|
37176
|
+
setModelValue("new");
|
|
37213
37177
|
inst.current.blur();
|
|
37214
37178
|
if (!onNewSetValue) {
|
|
37215
37179
|
const otherValues = onNewSetValue ? {
|
|
37216
37180
|
[onNewSetValue]: searchValue,
|
|
37217
|
-
[name]:
|
|
37181
|
+
[name]: "new"
|
|
37218
37182
|
} : {
|
|
37219
|
-
[name]:
|
|
37183
|
+
[name]: "new"
|
|
37220
37184
|
};
|
|
37221
37185
|
|
|
37222
37186
|
// remove keys, because can be from prev selection
|
|
@@ -37257,7 +37221,7 @@ function AjaxSelectMain(_ref) {
|
|
|
37257
37221
|
return;
|
|
37258
37222
|
}
|
|
37259
37223
|
setTimeout(() => {
|
|
37260
|
-
onChange(
|
|
37224
|
+
onChange("new", model || []);
|
|
37261
37225
|
addNewValueKey(searchValue);
|
|
37262
37226
|
}, 200);
|
|
37263
37227
|
};
|
|
@@ -37322,9 +37286,6 @@ function AjaxSelect(props) {
|
|
|
37322
37286
|
getAppHeader,
|
|
37323
37287
|
getApiBaseUrl
|
|
37324
37288
|
} = useEditContext();
|
|
37325
|
-
console.log({
|
|
37326
|
-
props
|
|
37327
|
-
});
|
|
37328
37289
|
return /*#__PURE__*/jsxRuntime.jsx(AjaxSelectMain, _objectSpread2({
|
|
37329
37290
|
changeAjaxOptions: changeAjaxOptions,
|
|
37330
37291
|
app: app,
|
|
@@ -37686,8 +37647,8 @@ const inputTypeComponent = {
|
|
|
37686
37647
|
onChange: val => {
|
|
37687
37648
|
formsValue[name] = val;
|
|
37688
37649
|
setFormValues({
|
|
37689
|
-
|
|
37690
|
-
|
|
37650
|
+
[name]: val,
|
|
37651
|
+
...formsValue
|
|
37691
37652
|
});
|
|
37692
37653
|
},
|
|
37693
37654
|
searchValue: search
|
package/dist/layouts/index.js
CHANGED
|
@@ -5311,7 +5311,9 @@ const Sidenav = ({
|
|
|
5311
5311
|
children: [renderModule({
|
|
5312
5312
|
module: userModule,
|
|
5313
5313
|
isCollapsed,
|
|
5314
|
-
onClick: () => checkOnClick(
|
|
5314
|
+
onClick: () => checkOnClick({
|
|
5315
|
+
event: () => goTo(getRedirectLink(`/app`))
|
|
5316
|
+
}),
|
|
5315
5317
|
mod,
|
|
5316
5318
|
user,
|
|
5317
5319
|
userHelpers
|
package/package.json
CHANGED
|
@@ -50,9 +50,6 @@ 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")
|
|
56
53
|
const inst = createRef();
|
|
57
54
|
const [modelValue, setModelValue] = useState(value ? value : multiple ? [] : null);
|
|
58
55
|
const [model, setModel] = useState([]);
|
|
@@ -88,18 +85,15 @@ export function AjaxSelectMain({
|
|
|
88
85
|
: `${url}/${queryOptionsAppEndpoints[app] || "query/options"}`;
|
|
89
86
|
|
|
90
87
|
useEffect(() => {
|
|
91
|
-
|
|
92
|
-
|
|
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));
|
|
88
|
+
if (value === "new") {
|
|
89
|
+
if (!model.find((m) => m.value === "new")) {
|
|
90
|
+
setModel(model.concat({ label: searchValue || t("New"), value: "new" }));
|
|
99
91
|
if (updateOptions) {
|
|
100
|
-
onOptions(model.concat(
|
|
92
|
+
onOptions(model.concat({ label: searchValue || t("New"), value: "new" }));
|
|
101
93
|
}
|
|
102
94
|
}
|
|
95
|
+
} else {
|
|
96
|
+
setModel(model.filter((v) => v.value !== "new"));
|
|
103
97
|
}
|
|
104
98
|
setModelValue(value ? value : multiple ? [] : null);
|
|
105
99
|
setSearchValue(value);
|
|
@@ -217,18 +211,19 @@ export function AjaxSelectMain({
|
|
|
217
211
|
},
|
|
218
212
|
)
|
|
219
213
|
.then(({ data }) => {
|
|
214
|
+
//? FUTURE ILVI KEEP THIS IN MIND
|
|
220
215
|
if (meta.saveAjaxOptions) {
|
|
221
216
|
changeAjaxOptions(name, data);
|
|
222
217
|
}
|
|
223
218
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
if (modelValue === "new") {
|
|
220
|
+
const newData = model.find((m) => m.value === "new");
|
|
221
|
+
data = data.concat([
|
|
222
|
+
newData || {
|
|
223
|
+
label: inputMeta?.name || searchValue || t("New"),
|
|
224
|
+
value: "new",
|
|
225
|
+
},
|
|
226
|
+
]);
|
|
232
227
|
} else {
|
|
233
228
|
updateLabel(data, undefined, true);
|
|
234
229
|
setTimeout(() => {
|
|
@@ -447,7 +442,10 @@ export function AjaxSelectMain({
|
|
|
447
442
|
disabled={
|
|
448
443
|
!searchValue ||
|
|
449
444
|
(typeof searchValue === "string" && searchValue.trim() === "") ||
|
|
450
|
-
(
|
|
445
|
+
(((typeof modelValue === "string" && modelValue !== "new") ||
|
|
446
|
+
(modelValue === "new" &&
|
|
447
|
+
model.filter((m) => m.value === "new" && m.label === searchValue))) &&
|
|
448
|
+
asOption)
|
|
451
449
|
}
|
|
452
450
|
type="link primary"
|
|
453
451
|
onClick={() => {
|
|
@@ -574,12 +572,15 @@ export function AjaxSelectMain({
|
|
|
574
572
|
setModelValue(value);
|
|
575
573
|
}
|
|
576
574
|
}
|
|
575
|
+
if (!value) {
|
|
576
|
+
setModel([...(model || []).filter((m) => m.value !== "new")]);
|
|
577
|
+
}
|
|
577
578
|
};
|
|
578
579
|
|
|
579
580
|
const addNewData = (oldValue) => {
|
|
580
581
|
if (onNewSetValue) {
|
|
581
582
|
if (repeatIndex !== null && repeatValues) {
|
|
582
|
-
repeatValues[inputName] =
|
|
583
|
+
repeatValues[inputName] = "new";
|
|
583
584
|
repeatValues[onNewSetValue] = oldValue;
|
|
584
585
|
if (!formsValue[name]) {
|
|
585
586
|
formsValue[name] = [];
|
|
@@ -592,10 +593,8 @@ export function AjaxSelectMain({
|
|
|
592
593
|
// mainForm.scrollToField(onNewSetValue);
|
|
593
594
|
}
|
|
594
595
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
const newModelInd = model.findIndex((m) => m.value === oldValue);
|
|
598
|
-
let newModel = { label: oldValue, value: oldValue };
|
|
596
|
+
const newModelInd = model.findIndex((m) => m.value === "new");
|
|
597
|
+
let newModel = { label: oldValue, value: "new" };
|
|
599
598
|
if (newModelInd >= 0) {
|
|
600
599
|
model[newModelInd] = newModel;
|
|
601
600
|
} else {
|
|
@@ -604,17 +603,17 @@ export function AjaxSelectMain({
|
|
|
604
603
|
|
|
605
604
|
setModel([...model]);
|
|
606
605
|
if (updateOptions) {
|
|
607
|
-
onOptions(model.concat({ label: oldValue || t("New"), value:
|
|
606
|
+
onOptions(model.concat({ label: oldValue || t("New"), value: "new" }));
|
|
608
607
|
}
|
|
609
|
-
setModelValue(
|
|
608
|
+
setModelValue("new");
|
|
610
609
|
inst.current.blur();
|
|
611
610
|
if (!onNewSetValue) {
|
|
612
611
|
const otherValues = onNewSetValue
|
|
613
612
|
? {
|
|
614
613
|
[onNewSetValue]: searchValue,
|
|
615
|
-
[name]:
|
|
614
|
+
[name]: "new",
|
|
616
615
|
}
|
|
617
|
-
: { [name]:
|
|
616
|
+
: { [name]: "new" };
|
|
618
617
|
|
|
619
618
|
// remove keys, because can be from prev selection
|
|
620
619
|
toRemoveKeysOnNew.forEach((k) => {
|
|
@@ -662,7 +661,7 @@ export function AjaxSelectMain({
|
|
|
662
661
|
}
|
|
663
662
|
|
|
664
663
|
setTimeout(() => {
|
|
665
|
-
onChange(
|
|
664
|
+
onChange("new", model || []);
|
|
666
665
|
addNewValueKey(searchValue, true);
|
|
667
666
|
}, 200);
|
|
668
667
|
};
|
|
@@ -740,7 +739,6 @@ export function AjaxSelectMain({
|
|
|
740
739
|
|
|
741
740
|
function AjaxSelect(props) {
|
|
742
741
|
const { changeAjaxOptions, app, t, user, getAppHeader, getApiBaseUrl } = useEditContext();
|
|
743
|
-
console.log({props})
|
|
744
742
|
|
|
745
743
|
return (
|
|
746
744
|
<AjaxSelectMain
|
|
@@ -241,7 +241,9 @@ const Sidenav = ({
|
|
|
241
241
|
{renderModule({
|
|
242
242
|
module: userModule,
|
|
243
243
|
isCollapsed,
|
|
244
|
-
onClick: () => checkOnClick(
|
|
244
|
+
onClick: () => checkOnClick({
|
|
245
|
+
event: () => goTo(getRedirectLink(`/app`))
|
|
246
|
+
}),
|
|
245
247
|
mod,
|
|
246
248
|
user,
|
|
247
249
|
userHelpers
|