@acvl/frontend-components 0.0.32 → 0.0.33
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/cjs/index.js +134 -141
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/v1/buttons/MoreOptions/index.d.ts +10 -0
- package/dist/cjs/types/src/components/v1/buttons/index.d.ts +7 -6
- package/dist/cjs/types/src/components/v1/forms/utils.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/inputs/controlled/ControlledFileField/index.d.ts +15 -0
- package/dist/cjs/types/src/components/v1/inputs/controlled/index.d.ts +13 -13
- package/dist/cjs/types/src/components/v1/layout/pages/DetailPage/index.d.ts +2 -1
- package/dist/esm/index.js +140 -147
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/v1/buttons/MoreOptions/index.d.ts +10 -0
- package/dist/esm/types/src/components/v1/buttons/index.d.ts +7 -6
- package/dist/esm/types/src/components/v1/forms/utils.d.ts +2 -2
- package/dist/esm/types/src/components/v1/inputs/controlled/ControlledFileField/index.d.ts +15 -0
- package/dist/esm/types/src/components/v1/inputs/controlled/index.d.ts +13 -13
- package/dist/esm/types/src/components/v1/layout/pages/DetailPage/index.d.ts +2 -1
- package/dist/index.d.ts +23 -5
- package/package.json +1 -1
- package/dist/cjs/types/src/components/v1/inputs/controlled/ControlledPhotoField/index.d.ts +0 -6
- package/dist/esm/types/src/components/v1/inputs/controlled/ControlledPhotoField/index.d.ts +0 -6
package/dist/cjs/index.js
CHANGED
|
@@ -47,10 +47,7 @@ var immer = require('immer');
|
|
|
47
47
|
var set = require('lodash/set');
|
|
48
48
|
var get = require('lodash/get');
|
|
49
49
|
var isEmpty = require('lodash/isEmpty');
|
|
50
|
-
var isNull = require('lodash/isNull');
|
|
51
50
|
var isEqual = require('lodash/isEqual');
|
|
52
|
-
var forEach = require('lodash/forEach');
|
|
53
|
-
var includes = require('lodash/includes');
|
|
54
51
|
var CancelIcon = require('@mui/icons-material/Cancel');
|
|
55
52
|
var HistoryIcon = require('@mui/icons-material/History');
|
|
56
53
|
var lab = require('@mui/lab');
|
|
@@ -70,20 +67,21 @@ var CheckBoxOutlineBlankIcon = require('@mui/icons-material/CheckBoxOutlineBlank
|
|
|
70
67
|
var CheckBoxIcon = require('@mui/icons-material/CheckBox');
|
|
71
68
|
var iconsMaterial = require('@mui/icons-material');
|
|
72
69
|
var merge$1 = require('lodash/merge');
|
|
70
|
+
var UploadFileIcon = require('@mui/icons-material/UploadFile');
|
|
71
|
+
var ClearIcon$1 = require('@mui/icons-material/Clear');
|
|
73
72
|
var SaveIcon = require('@mui/icons-material/Save');
|
|
74
73
|
var AddIcon = require('@mui/icons-material/Add');
|
|
75
74
|
var KeyboardArrowDownIcon = require('@mui/icons-material/KeyboardArrowDown');
|
|
76
75
|
var LinearProgress = require('@mui/material/LinearProgress');
|
|
77
76
|
var AttachFileIcon = require('@mui/icons-material/AttachFile');
|
|
77
|
+
var MoreVertIcon = require('@mui/icons-material/MoreVert');
|
|
78
78
|
var xDataGrid = require('@mui/x-data-grid');
|
|
79
79
|
var Tooltip = require('@mui/material/Tooltip');
|
|
80
80
|
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
|
81
81
|
var ExpandLessIcon = require('@mui/icons-material/ExpandLess');
|
|
82
82
|
var Menu = require('@mui/material/Menu');
|
|
83
|
-
var MoreVertIcon = require('@mui/icons-material/MoreVert');
|
|
84
83
|
var SearchIcon = require('@mui/icons-material/Search');
|
|
85
84
|
var FilterListIcon = require('@mui/icons-material/FilterList');
|
|
86
|
-
var ClearIcon$1 = require('@mui/icons-material/Clear');
|
|
87
85
|
var FilterAltIcon = require('@mui/icons-material/FilterAlt');
|
|
88
86
|
var FilterNoneIcon = require('@mui/icons-material/FilterNone');
|
|
89
87
|
var CheckIcon = require('@mui/icons-material/Check');
|
|
@@ -25668,68 +25666,65 @@ dayjs.locale(es);
|
|
|
25668
25666
|
dayjs.extend(duration);
|
|
25669
25667
|
|
|
25670
25668
|
// ==============================|| JSON ||============================== //
|
|
25669
|
+
const setValue = (formType, form, key, value) => {
|
|
25670
|
+
if (formType === "json")
|
|
25671
|
+
set(form, key, value);
|
|
25672
|
+
else
|
|
25673
|
+
form.append(key, value);
|
|
25674
|
+
};
|
|
25671
25675
|
const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, data, props, formType, }) => {
|
|
25672
25676
|
const ignore = get(props, `${base_key}.ignore`, false);
|
|
25673
25677
|
if (ignore || ["obj_permissions", "has_history"].includes(base_key))
|
|
25674
25678
|
return;
|
|
25675
|
-
const altered_key =
|
|
25679
|
+
const altered_key = props?.[base_key]?.alter_key?.(base_key);
|
|
25676
25680
|
const key = altered_key || base_key;
|
|
25677
|
-
const altered_obj =
|
|
25681
|
+
const altered_obj = props?.[base_key]?.alter_value?.(base_object, submitData);
|
|
25678
25682
|
const object = altered_obj || base_object;
|
|
25679
|
-
const setValue = (form, key, value) => {
|
|
25680
|
-
if (formType === "json") {
|
|
25681
|
-
set(form, key, value);
|
|
25682
|
-
}
|
|
25683
|
-
else if (formType === "formData") {
|
|
25684
|
-
form.append(key, value);
|
|
25685
|
-
}
|
|
25686
|
-
};
|
|
25687
25683
|
switch (typeof object) {
|
|
25688
25684
|
case "string":
|
|
25689
|
-
if (
|
|
25685
|
+
if (props?.[base_key]?.extra_validation?.(object))
|
|
25690
25686
|
return;
|
|
25691
|
-
setValue(response, key, isEmpty(object) ? "" : object);
|
|
25687
|
+
setValue(formType, response, key, isEmpty(object) ? "" : object);
|
|
25692
25688
|
break;
|
|
25693
25689
|
case "number":
|
|
25694
|
-
setValue(response, key, object);
|
|
25690
|
+
setValue(formType, response, key, object);
|
|
25695
25691
|
break;
|
|
25696
25692
|
case "boolean":
|
|
25697
|
-
setValue(response, key, object);
|
|
25693
|
+
setValue(formType, response, key, object);
|
|
25698
25694
|
break;
|
|
25699
25695
|
case "object":
|
|
25700
|
-
if (
|
|
25701
|
-
if (includes(
|
|
25702
|
-
setValue(response, key, "");
|
|
25696
|
+
if (object === null || isEmpty(object)) {
|
|
25697
|
+
if (key.includes("after") || key.includes("before"))
|
|
25698
|
+
setValue(formType, response, key, "");
|
|
25703
25699
|
else
|
|
25704
|
-
setValue(response, key, object);
|
|
25700
|
+
setValue(formType, response, key, object);
|
|
25705
25701
|
}
|
|
25706
25702
|
else if (object instanceof File) {
|
|
25707
|
-
setValue(response, key, object);
|
|
25703
|
+
setValue(formType, response, key, object);
|
|
25708
25704
|
}
|
|
25709
25705
|
else if (dayjs.isDayjs(object)) {
|
|
25710
|
-
setValue(response, key, object.format(get(props, `${key}.format`, "YYYY-MM-DD")));
|
|
25706
|
+
setValue(formType, response, key, object.format(get(props, `${key}.format`, "YYYY-MM-DD")));
|
|
25711
25707
|
}
|
|
25712
25708
|
else if ("label" in object && "value" in object) {
|
|
25713
25709
|
if (useLabel)
|
|
25714
|
-
setValue(response, key, object["label"]);
|
|
25710
|
+
setValue(formType, response, key, object["label"]);
|
|
25715
25711
|
else
|
|
25716
|
-
setValue(response, key, object["value"]);
|
|
25712
|
+
setValue(formType, response, key, object["value"]);
|
|
25717
25713
|
}
|
|
25718
25714
|
else if (Array.isArray(object)) {
|
|
25719
|
-
// it is an array
|
|
25720
25715
|
if (object.length &&
|
|
25721
|
-
typeof object[0]
|
|
25716
|
+
typeof object[0] === "object" &&
|
|
25722
25717
|
!Array.isArray(object[0]) &&
|
|
25723
25718
|
"value" in object[0] &&
|
|
25724
|
-
object[0]["value"]
|
|
25719
|
+
object[0]["value"] === "all") {
|
|
25725
25720
|
// for data grid filters
|
|
25726
|
-
setValue(response, key, "");
|
|
25721
|
+
setValue(formType, response, key, "");
|
|
25727
25722
|
}
|
|
25728
25723
|
else {
|
|
25729
|
-
forEach(
|
|
25730
|
-
if (typeof arrayItem
|
|
25724
|
+
object.forEach((arrayItem, idx) => {
|
|
25725
|
+
if (typeof arrayItem === "object") {
|
|
25731
25726
|
if ("label" in arrayItem) {
|
|
25732
|
-
setValue(response, `${key}.${idx}`, function (item) {
|
|
25727
|
+
setValue(formType, response, `${key}.${idx}`, function (item) {
|
|
25733
25728
|
if (useLabel)
|
|
25734
25729
|
return item.label;
|
|
25735
25730
|
else
|
|
@@ -25738,7 +25733,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25738
25733
|
}
|
|
25739
25734
|
typeSwitch({
|
|
25740
25735
|
base_object: arrayItem,
|
|
25741
|
-
base_key: `${key}.${idx}`,
|
|
25736
|
+
base_key: formType === "json" ? `${key}.${idx}` : `${key}[${idx}]`,
|
|
25742
25737
|
response: response,
|
|
25743
25738
|
useLabel: useLabel,
|
|
25744
25739
|
data: data,
|
|
@@ -25752,21 +25747,21 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25752
25747
|
if (keyArray)
|
|
25753
25748
|
keyArray.push(arrayItem);
|
|
25754
25749
|
else
|
|
25755
|
-
setValue(response, key, [arrayItem]);
|
|
25750
|
+
setValue(formType, response, key, [arrayItem]);
|
|
25756
25751
|
}
|
|
25757
25752
|
});
|
|
25758
25753
|
}
|
|
25759
25754
|
}
|
|
25760
25755
|
else if (object instanceof Set) {
|
|
25761
|
-
setValue(response, key, Array.from(object));
|
|
25756
|
+
setValue(formType, response, key, Array.from(object));
|
|
25762
25757
|
}
|
|
25763
25758
|
else {
|
|
25764
|
-
forEach(
|
|
25759
|
+
Object.entries(object).forEach(([key2, value]) => {
|
|
25765
25760
|
if (key2 !== "id" && isEqual(get(data, `${key}.${key2}`), value))
|
|
25766
25761
|
return;
|
|
25767
25762
|
typeSwitch({
|
|
25768
25763
|
base_object: value,
|
|
25769
|
-
base_key: `${key}.${key2}`,
|
|
25764
|
+
base_key: formType === "json" ? `${key}.${key2}` : `${key}${key2}`,
|
|
25770
25765
|
response: response,
|
|
25771
25766
|
useLabel: useLabel,
|
|
25772
25767
|
data: data,
|
|
@@ -25778,14 +25773,15 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25778
25773
|
}
|
|
25779
25774
|
break;
|
|
25780
25775
|
default:
|
|
25781
|
-
setValue(response, key, object);
|
|
25776
|
+
setValue(formType, response, key, object);
|
|
25782
25777
|
break;
|
|
25783
25778
|
}
|
|
25784
25779
|
};
|
|
25785
|
-
const
|
|
25786
|
-
const
|
|
25787
|
-
|
|
25788
|
-
|
|
25780
|
+
const formParser = ({ type, submitData, data, useLabel, props }) => {
|
|
25781
|
+
const t = type || "json";
|
|
25782
|
+
const response = t === "json" ? {} : new FormData();
|
|
25783
|
+
Object.entries(submitData).forEach(([key, value]) => {
|
|
25784
|
+
if (key !== "id" && isEqual(get(data, key), value))
|
|
25789
25785
|
return;
|
|
25790
25786
|
typeSwitch({
|
|
25791
25787
|
base_object: value,
|
|
@@ -25795,29 +25791,11 @@ const jsonForm = ({ submitData, data, useLabel, props }) => {
|
|
|
25795
25791
|
data: data,
|
|
25796
25792
|
props: props,
|
|
25797
25793
|
submitData: submitData,
|
|
25798
|
-
formType:
|
|
25794
|
+
formType: t,
|
|
25799
25795
|
});
|
|
25800
25796
|
});
|
|
25801
25797
|
return response;
|
|
25802
25798
|
};
|
|
25803
|
-
const formDataForm = ({ submitData, data, useLabel, props }) => {
|
|
25804
|
-
const formData = new FormData();
|
|
25805
|
-
forEach(submitData, function (value, key) {
|
|
25806
|
-
if (key != "id" && isEqual(get(data, key), value))
|
|
25807
|
-
return;
|
|
25808
|
-
typeSwitch({
|
|
25809
|
-
base_object: value,
|
|
25810
|
-
base_key: key,
|
|
25811
|
-
response: formData,
|
|
25812
|
-
useLabel: useLabel,
|
|
25813
|
-
data: data,
|
|
25814
|
-
props: props,
|
|
25815
|
-
submitData: submitData,
|
|
25816
|
-
formType: "formData",
|
|
25817
|
-
});
|
|
25818
|
-
});
|
|
25819
|
-
return formData;
|
|
25820
|
-
};
|
|
25821
25799
|
// ==============================|| ERRORS ||============================== //
|
|
25822
25800
|
const setErrors = (form, error) => {
|
|
25823
25801
|
if ("invalid_params" in error.data) {
|
|
@@ -25954,7 +25932,7 @@ const FileBox = (props) => {
|
|
|
25954
25932
|
return (jsxRuntime.jsxs(material.Box, { bgcolor: colors.grey[200], borderRadius: '12px', p: 2, display: 'flex', children: [jsxRuntime.jsx(material.Box, { flexGrow: 0.8, display: 'flex', justifyContent: 'left', alignItems: 'center', children: jsxRuntime.jsx(material.Typography, { fontWeight: 'bold', children: props.file.name.split('.')[0] }) }), jsxRuntime.jsx(material.Box, { flexGrow: 0.2, display: 'flex', justifyContent: 'right', alignItems: 'center', children: props.loadingRemove ? (jsxRuntime.jsx(material.CircularProgress, { size: '18px' })) : (jsxRuntime.jsx(material.Tooltip, { title: 'Remove', children: jsxRuntime.jsx(material.IconButton, { color: 'error', sx: { p: 0 }, onClick: props.handleRemove, children: jsxRuntime.jsx(DeleteIcon, {}) }) })) })] }));
|
|
25955
25933
|
};
|
|
25956
25934
|
|
|
25957
|
-
const VisuallyHiddenInput = material.styled("input")({
|
|
25935
|
+
const VisuallyHiddenInput$1 = material.styled("input")({
|
|
25958
25936
|
clipPath: "inset(50%)",
|
|
25959
25937
|
height: 1,
|
|
25960
25938
|
overflow: "hidden",
|
|
@@ -25973,7 +25951,7 @@ const FileUploadBox = (props) => {
|
|
|
25973
25951
|
const Dropzone = ({ onChange, value }) => {
|
|
25974
25952
|
const onDrop = React.useCallback((acceptedFiles) => {
|
|
25975
25953
|
acceptedFiles.map((file) => {
|
|
25976
|
-
const data =
|
|
25954
|
+
const data = formParser({ type: "formData", submitData: { archivo: file } });
|
|
25977
25955
|
validarCSV({
|
|
25978
25956
|
endpoint: props.csvProps.endpoint || "",
|
|
25979
25957
|
data: data,
|
|
@@ -26024,7 +26002,7 @@ const FileUploadBox = (props) => {
|
|
|
26024
26002
|
return;
|
|
26025
26003
|
return Object.entries(rows).map(([row, errors]) => (jsxRuntime.jsx(RowErrors, { row: row, data: errors }, row)));
|
|
26026
26004
|
};
|
|
26027
|
-
return (jsxRuntime.jsx(Box, { width: 1, children: jsxRuntime.jsxs(material.Stack, { spacing: 2, children: [!file && !isLoading && (jsxRuntime.jsxs(Box, { component: "div", width: 1, display: "flex", justifyContent: "center", alignItems: "center", border: "1.5px dashed", borderRadius: "12px", py: 4, px: 2, borderColor: colors.grey[800], bgcolor: colors.grey[50], ...getRootProps(), children: [jsxRuntime.jsx(VisuallyHiddenInput, { id: "file-upload", type: "file", ...getInputProps() }), jsxRuntime.jsx(FileUploadIcon, { sx: {
|
|
26005
|
+
return (jsxRuntime.jsx(Box, { width: 1, children: jsxRuntime.jsxs(material.Stack, { spacing: 2, children: [!file && !isLoading && (jsxRuntime.jsxs(Box, { component: "div", width: 1, display: "flex", justifyContent: "center", alignItems: "center", border: "1.5px dashed", borderRadius: "12px", py: 4, px: 2, borderColor: colors.grey[800], bgcolor: colors.grey[50], ...getRootProps(), children: [jsxRuntime.jsx(VisuallyHiddenInput$1, { id: "file-upload", type: "file", ...getInputProps() }), jsxRuntime.jsx(FileUploadIcon, { sx: {
|
|
26028
26006
|
color: colors.grey[800],
|
|
26029
26007
|
pr: 1,
|
|
26030
26008
|
} }), jsxRuntime.jsx(Typography, { variant: "body2", sx: { color: colors.grey[800] }, children: isDragActive
|
|
@@ -26060,7 +26038,7 @@ const CSVUpload = (props) => {
|
|
|
26060
26038
|
};
|
|
26061
26039
|
const tag = React.useMemo(() => endpoint.split("/").at(-1), [endpoint]);
|
|
26062
26040
|
const onSubmitHandler = (submitData) => {
|
|
26063
|
-
const data =
|
|
26041
|
+
const data = formParser({ type: "formData", submitData });
|
|
26064
26042
|
subirCSV({ endpoint, tagType: tag, data, custom: props.data?.custom })
|
|
26065
26043
|
.unwrap()
|
|
26066
26044
|
.then((response) => {
|
|
@@ -26111,10 +26089,10 @@ const mergeSettings = (baseSettings, mergingSettings) => {
|
|
|
26111
26089
|
};
|
|
26112
26090
|
const val = (value) => {
|
|
26113
26091
|
if (Array.isArray(value)) {
|
|
26114
|
-
return value.join(
|
|
26092
|
+
return value.join(",");
|
|
26115
26093
|
}
|
|
26116
|
-
else if (typeof value ==
|
|
26117
|
-
return value ?
|
|
26094
|
+
else if (typeof value == "boolean") {
|
|
26095
|
+
return value ? "true" : "false";
|
|
26118
26096
|
}
|
|
26119
26097
|
else {
|
|
26120
26098
|
return value;
|
|
@@ -26130,13 +26108,14 @@ const filterQuery = ({ filters }) => {
|
|
|
26130
26108
|
return queryParams;
|
|
26131
26109
|
};
|
|
26132
26110
|
const filterGrid = ({ page, pageSize, filterModel, sortModel, ignoreSort }) => {
|
|
26111
|
+
//GridArgs
|
|
26133
26112
|
const queryParams = [];
|
|
26134
26113
|
if (page)
|
|
26135
26114
|
queryParams.push(`page=${page + 1}`);
|
|
26136
26115
|
if (pageSize)
|
|
26137
26116
|
queryParams.push(`page_size=${pageSize}`);
|
|
26138
26117
|
if (filterModel.items) {
|
|
26139
|
-
const jsonFilters =
|
|
26118
|
+
const jsonFilters = formParser({ submitData: filterModel.items });
|
|
26140
26119
|
lodash.forEach(jsonFilters, function (value, key) {
|
|
26141
26120
|
queryParams.push(`${key}=${val(value)}`);
|
|
26142
26121
|
});
|
|
@@ -26145,28 +26124,28 @@ const filterGrid = ({ page, pageSize, filterModel, sortModel, ignoreSort }) => {
|
|
|
26145
26124
|
queryParams.push(`search=${filterModel.quickFilterValues}`);
|
|
26146
26125
|
}
|
|
26147
26126
|
if (sortModel.length && !ignoreSort) {
|
|
26148
|
-
const val = `${sortModel[0]?.sort ==
|
|
26127
|
+
const val = `${sortModel[0]?.sort == "asc" ? "" : "-"}${sortModel[0]?.field}`;
|
|
26149
26128
|
queryParams.push(`ordering=${val}`);
|
|
26150
26129
|
}
|
|
26151
26130
|
return queryParams;
|
|
26152
26131
|
};
|
|
26153
26132
|
const query = (data, url, type) => {
|
|
26154
26133
|
switch (type) {
|
|
26155
|
-
case
|
|
26156
|
-
return `${url}?${filterGrid(data).join(
|
|
26157
|
-
case
|
|
26158
|
-
return `${url}?${filterQuery(data).join(
|
|
26159
|
-
case
|
|
26134
|
+
case "grid":
|
|
26135
|
+
return `${url}?${filterGrid(data).join("&")}`;
|
|
26136
|
+
case "simpleFilter":
|
|
26137
|
+
return `${url}?${filterQuery(data).join("&")}`;
|
|
26138
|
+
case "single":
|
|
26160
26139
|
return `${url}/${data.id}`;
|
|
26161
26140
|
}
|
|
26162
26141
|
};
|
|
26163
26142
|
const tags = (result, type, invalidate) => {
|
|
26164
26143
|
if (result) {
|
|
26165
26144
|
if (!invalidate) {
|
|
26166
|
-
if (
|
|
26145
|
+
if ("results" in result) {
|
|
26167
26146
|
return [
|
|
26168
26147
|
...result.results.map(({ id }) => ({ type: type, id })),
|
|
26169
|
-
{ type: type, id:
|
|
26148
|
+
{ type: type, id: "LIST" },
|
|
26170
26149
|
];
|
|
26171
26150
|
}
|
|
26172
26151
|
else {
|
|
@@ -26174,14 +26153,12 @@ const tags = (result, type, invalidate) => {
|
|
|
26174
26153
|
}
|
|
26175
26154
|
}
|
|
26176
26155
|
else {
|
|
26177
|
-
return invalidate.request ==
|
|
26178
|
-
[{ type: type, id: 'LIST' }] :
|
|
26179
|
-
[]; // { type: type, id: result.id }
|
|
26156
|
+
return invalidate.request == "post" ? [{ type: type, id: "LIST" }] : []; // { type: type, id: result.id }
|
|
26180
26157
|
}
|
|
26181
26158
|
}
|
|
26182
26159
|
else {
|
|
26183
26160
|
if (!invalidate) {
|
|
26184
|
-
return [{ type: type, id:
|
|
26161
|
+
return [{ type: type, id: "LIST" }];
|
|
26185
26162
|
}
|
|
26186
26163
|
else {
|
|
26187
26164
|
return [];
|
|
@@ -26192,15 +26169,15 @@ async function manualCacheRefresh(api, id, dispatch, queryFulfilled, endpoints)
|
|
|
26192
26169
|
try {
|
|
26193
26170
|
const { data } = await queryFulfilled;
|
|
26194
26171
|
if (endpoints.single) {
|
|
26195
|
-
dispatch(api.util.updateQueryData(endpoints.single, { id: id.toString(), type:
|
|
26196
|
-
Object.assign(draft, data[
|
|
26172
|
+
dispatch(api.util.updateQueryData(endpoints.single, { id: id.toString(), type: "single" }, (draft) => {
|
|
26173
|
+
Object.assign(draft, data["detail"]);
|
|
26197
26174
|
}));
|
|
26198
26175
|
}
|
|
26199
26176
|
if (endpoints.multiple) {
|
|
26200
|
-
dispatch(api.util.updateQueryData(endpoints.multiple, { type:
|
|
26201
|
-
const index = lodash.findIndex(draft.results, [
|
|
26177
|
+
dispatch(api.util.updateQueryData(endpoints.multiple, { type: "all" }, (draft) => {
|
|
26178
|
+
const index = lodash.findIndex(draft.results, ["id", id]);
|
|
26202
26179
|
if (index > -1)
|
|
26203
|
-
Object.assign(draft.results[index], data[
|
|
26180
|
+
Object.assign(draft.results[index], data["list"]);
|
|
26204
26181
|
}));
|
|
26205
26182
|
}
|
|
26206
26183
|
}
|
|
@@ -26530,10 +26507,23 @@ const ControlledTimePicker = (props) => {
|
|
|
26530
26507
|
} }));
|
|
26531
26508
|
};
|
|
26532
26509
|
|
|
26533
|
-
const
|
|
26534
|
-
|
|
26510
|
+
const VisuallyHiddenInput = material.styled("input")({
|
|
26511
|
+
clip: "rect(0 0 0 0)",
|
|
26512
|
+
clipPath: "inset(50%)",
|
|
26513
|
+
height: 1,
|
|
26514
|
+
overflow: "hidden",
|
|
26515
|
+
position: "absolute",
|
|
26516
|
+
bottom: 0,
|
|
26517
|
+
left: 0,
|
|
26518
|
+
whiteSpace: "nowrap",
|
|
26519
|
+
width: 1,
|
|
26520
|
+
});
|
|
26521
|
+
const ControlledFileField = (props) => {
|
|
26522
|
+
return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.name, render: ({ field: { value, onChange, onBlur, ref }, fieldState: { error } }) => {
|
|
26523
|
+
return (jsxRuntime.jsxs(material.FormGroup, { sx: { width: 1 }, color: "secondary", children: [value ? (jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, width: 1, alignItems: "center", children: [jsxRuntime.jsx(material.Typography, { children: value.name }), jsxRuntime.jsx(material.IconButton, { onClick: () => onChange(null), children: jsxRuntime.jsx(ClearIcon$1, { color: "error" }) })] })) : (jsxRuntime.jsxs(material.Button, { component: "label", variant: "contained", startIcon: jsxRuntime.jsx(UploadFileIcon, {}), sx: { maxWidth: 200 }, ...props.extraProps?.slotProps?.button, children: ["Cargar", jsxRuntime.jsx(VisuallyHiddenInput, { type: "file", accept: "image/*", ref: ref, onBlur: onBlur, onChange: (e) => onChange(e.target.files && e.target.files[0]), ...props.extraProps?.slotProps?.input })] })), jsxRuntime.jsx(material.FormHelperText, { error: !!error, children: error ? error.message : " " })] }));
|
|
26524
|
+
} }));
|
|
26535
26525
|
};
|
|
26536
|
-
|
|
26526
|
+
ControlledFileField.displayName = "ControlledFileField";
|
|
26537
26527
|
|
|
26538
26528
|
// ==============================|| DESLIZADOR CONTROLADO ||============================== //
|
|
26539
26529
|
const ControlledSlider = (props) => {
|
|
@@ -26546,7 +26536,8 @@ const ControlledSlider = (props) => {
|
|
|
26546
26536
|
|
|
26547
26537
|
const DeleteConfirmationDialog = (props) => {
|
|
26548
26538
|
const notifications = core.useNotifications();
|
|
26549
|
-
const pathname =
|
|
26539
|
+
const { pathname } = reactRouterDom.useLocation();
|
|
26540
|
+
const navigate = reactRouterDom.useNavigate();
|
|
26550
26541
|
const id = React.useMemo(() => props.id || pathname.split("/").at(-1), [pathname, props.id]);
|
|
26551
26542
|
const [mutation] = props.mutation();
|
|
26552
26543
|
const schema = zod.object({ confirmation: zod.string() });
|
|
@@ -26568,7 +26559,7 @@ const DeleteConfirmationDialog = (props) => {
|
|
|
26568
26559
|
handleClose();
|
|
26569
26560
|
}
|
|
26570
26561
|
else {
|
|
26571
|
-
|
|
26562
|
+
navigate(-1);
|
|
26572
26563
|
form.reset();
|
|
26573
26564
|
}
|
|
26574
26565
|
notifications.show("Objeto removido exitosamente!", { severity: "success" });
|
|
@@ -26800,6 +26791,18 @@ const ButtonWithDrawer = (props) => {
|
|
|
26800
26791
|
}) })] }));
|
|
26801
26792
|
};
|
|
26802
26793
|
|
|
26794
|
+
const MoreOptions = (props) => {
|
|
26795
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
26796
|
+
const open = Boolean(anchorEl);
|
|
26797
|
+
const handleClick = () => {
|
|
26798
|
+
setAnchorEl(document.getElementById("extra-options"));
|
|
26799
|
+
};
|
|
26800
|
+
const handleClose = () => {
|
|
26801
|
+
setAnchorEl(null);
|
|
26802
|
+
};
|
|
26803
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.IconButton, { id: "extra-options", onClick: handleClick, children: jsxRuntime.jsx(MoreVertIcon, {}) }, "extra-options"), jsxRuntime.jsx(StyledMenu, { anchorEl: anchorEl, open: open, onClose: handleClose, children: props.options.map((option) => (jsxRuntime.jsxs(material.MenuItem, { onClick: option.onClick, children: [jsxRuntime.jsx(material.ListItemIcon, { children: option.icon }), option.title] }))) })] }));
|
|
26804
|
+
};
|
|
26805
|
+
|
|
26803
26806
|
const StatusBadge = (props) => {
|
|
26804
26807
|
const color = React.useMemo(() => {
|
|
26805
26808
|
switch (props?.severity) {
|
|
@@ -27347,8 +27350,8 @@ const EditGridWrapper = (props) => {
|
|
|
27347
27350
|
setEdit((prevState) => !prevState);
|
|
27348
27351
|
};
|
|
27349
27352
|
const processRowUpdate = async (newRow, originalRow) => {
|
|
27350
|
-
const original_data =
|
|
27351
|
-
const data =
|
|
27353
|
+
const original_data = formParser({ submitData: originalRow });
|
|
27354
|
+
const data = formParser({
|
|
27352
27355
|
submitData: newRow,
|
|
27353
27356
|
...(props.parser ? { props: props.parser } : []),
|
|
27354
27357
|
});
|
|
@@ -28000,45 +28003,31 @@ const LinkField = ({ url, value, text }) => {
|
|
|
28000
28003
|
const DetailField = (props) => {
|
|
28001
28004
|
const hasLinkToViewPermission = useHasPermission(`${props.navigation?.permission}.view`);
|
|
28002
28005
|
const value = React.useCallback(() => {
|
|
28003
|
-
|
|
28004
|
-
|
|
28005
|
-
|
|
28006
|
-
|
|
28007
|
-
|
|
28008
|
-
|
|
28009
|
-
|
|
28010
|
-
|
|
28011
|
-
|
|
28012
|
-
|
|
28013
|
-
|
|
28014
|
-
|
|
28015
|
-
|
|
28016
|
-
|
|
28017
|
-
|
|
28018
|
-
|
|
28019
|
-
|
|
28020
|
-
|
|
28021
|
-
|
|
28022
|
-
|
|
28023
|
-
|
|
28024
|
-
|
|
28025
|
-
}
|
|
28026
|
-
}
|
|
28027
|
-
else if (props.type.displayName == "ControlledPhotoField") {
|
|
28028
|
-
if (props.fieldData)
|
|
28029
|
-
return "Imagen";
|
|
28030
|
-
}
|
|
28031
|
-
else {
|
|
28032
|
-
if (props.fieldData) {
|
|
28033
|
-
if (props.detail_name) {
|
|
28034
|
-
return lodash.get(props.fieldData, props.detail_name);
|
|
28035
|
-
}
|
|
28036
|
-
return props.fieldData;
|
|
28037
|
-
}
|
|
28006
|
+
const { fieldData, type, extraProps, detail_name } = props;
|
|
28007
|
+
if (typeof fieldData === "boolean")
|
|
28008
|
+
return fieldData ? "Si" : "No";
|
|
28009
|
+
if (typeof fieldData === "number")
|
|
28010
|
+
return fieldData.toString();
|
|
28011
|
+
switch (type?.displayName) {
|
|
28012
|
+
case "ControlledSelect":
|
|
28013
|
+
return fieldData
|
|
28014
|
+
? fieldData.map((item) => item.label).join(", ")
|
|
28015
|
+
: "N/A";
|
|
28016
|
+
case "ControlledDate":
|
|
28017
|
+
if (!fieldData)
|
|
28018
|
+
return "N/A";
|
|
28019
|
+
return extraProps?.type === "datetime"
|
|
28020
|
+
? dayjs(fieldData).format("YYYY-MM-DD HH:mm")
|
|
28021
|
+
: dayjs(fieldData).format("YYYY-MM-DD");
|
|
28022
|
+
case "ControlledFileField":
|
|
28023
|
+
return fieldData ? "Archivo" : "N/A";
|
|
28024
|
+
default:
|
|
28025
|
+
if (!fieldData)
|
|
28026
|
+
return "N/A";
|
|
28027
|
+
return detail_name ? lodash.get(fieldData, detail_name) : fieldData;
|
|
28038
28028
|
}
|
|
28039
|
-
|
|
28040
|
-
|
|
28041
|
-
const content = `${props.detailFieldProps?.preValue ? props.detailFieldProps.preValue : ""} ${value()} ${props.detailFieldProps?.postValue ? props.detailFieldProps.postValue : ""}`;
|
|
28029
|
+
}, [props.detail_name, props.extraProps, props.fieldData, props.type?.displayName]);
|
|
28030
|
+
const content = `${props.detailFieldProps?.preValue || ""} ${value()} ${props.detailFieldProps?.postValue || ""}`.trim();
|
|
28042
28031
|
if (props.navigation &&
|
|
28043
28032
|
hasLinkToViewPermission &&
|
|
28044
28033
|
props.fieldData &&
|
|
@@ -28048,8 +28037,8 @@ const DetailField = (props) => {
|
|
|
28048
28037
|
}
|
|
28049
28038
|
return (jsxRuntime.jsx(LinkField, { url: props.navigation.url, value: lodash.get(props.fieldData, "value"), text: content }));
|
|
28050
28039
|
}
|
|
28051
|
-
else if (props.type.displayName == "
|
|
28052
|
-
return (jsxRuntime.jsx(material.Link, { href: props.fieldData,
|
|
28040
|
+
else if (props.type.displayName == "ControlledFileField" && content !== "N/A") {
|
|
28041
|
+
return (jsxRuntime.jsx(material.Link, { href: props.fieldData, target: "_blank", rel: "noopener noreferrer", children: content }));
|
|
28053
28042
|
}
|
|
28054
28043
|
else {
|
|
28055
28044
|
if (Array.isArray(props.fieldData)) {
|
|
@@ -28135,8 +28124,8 @@ const FieldArrayField = (props) => {
|
|
|
28135
28124
|
remove(getIndex(id));
|
|
28136
28125
|
};
|
|
28137
28126
|
const processRowUpdate = async (newRow, originalRow) => {
|
|
28138
|
-
const original_data =
|
|
28139
|
-
const data =
|
|
28127
|
+
const original_data = formParser({ submitData: originalRow, props: props.parser });
|
|
28128
|
+
const data = formParser({ submitData: newRow, props: props.parser });
|
|
28140
28129
|
if (lodash.isEqual(data, original_data))
|
|
28141
28130
|
return originalRow;
|
|
28142
28131
|
const index = getIndex(data._id);
|
|
@@ -28410,6 +28399,9 @@ function DetailPage(props) {
|
|
|
28410
28399
|
resolver: zod$1.zodResolver(props.edit.schema),
|
|
28411
28400
|
defaultValues: props.edit?.defaultValues,
|
|
28412
28401
|
});
|
|
28402
|
+
React.useImperativeHandle(props.ref, () => ({
|
|
28403
|
+
form: form,
|
|
28404
|
+
}));
|
|
28413
28405
|
const { data, isLoading, isFetching, error: fetchError, } = props.api.data.query(!props.api.data.skipToken ? props.api.data.args : query$1.skipToken);
|
|
28414
28406
|
React.useEffect(() => {
|
|
28415
28407
|
if (data) {
|
|
@@ -28442,11 +28434,12 @@ function DetailPage(props) {
|
|
|
28442
28434
|
const onSubmitHandler = (submitedData) => {
|
|
28443
28435
|
const formData = "nativeEvent" in submitedData ? form.getValues() : submitedData;
|
|
28444
28436
|
const params = {
|
|
28437
|
+
type: props.edit.useFormData ? "formData" : "json",
|
|
28445
28438
|
submitData: formData,
|
|
28446
28439
|
data: data,
|
|
28447
28440
|
props: props.slotProps?.parser,
|
|
28448
28441
|
};
|
|
28449
|
-
const dataToSend =
|
|
28442
|
+
const dataToSend = formParser(params);
|
|
28450
28443
|
mutation(props.edit.useFormData ? dataToSend : { ...dataToSend, ...props.api.mutate.args })
|
|
28451
28444
|
.unwrap()
|
|
28452
28445
|
.then(() => {
|
|
@@ -28839,10 +28832,10 @@ exports.CSVUpload = CSVUpload;
|
|
|
28839
28832
|
exports.ContentLayout = ContentLayout;
|
|
28840
28833
|
exports.ControlledDate = ControlledDate;
|
|
28841
28834
|
exports.ControlledDropdown = ControlledDropdown;
|
|
28835
|
+
exports.ControlledFileField = ControlledFileField;
|
|
28842
28836
|
exports.ControlledFileUploadBox = FileUploadBox;
|
|
28843
28837
|
exports.ControlledNumber = ControlledNumber;
|
|
28844
28838
|
exports.ControlledPhoneNumber = ControlledPhoneNumber;
|
|
28845
|
-
exports.ControlledPhotoField = ControlledPhotoField;
|
|
28846
28839
|
exports.ControlledSelect = ControlledSelect;
|
|
28847
28840
|
exports.ControlledSimpleSlider = ControlledSlider;
|
|
28848
28841
|
exports.ControlledSlider = ControlledSlider$1;
|
|
@@ -28866,6 +28859,7 @@ exports.Logo = Logo;
|
|
|
28866
28859
|
exports.MainDrawer = MainDrawer;
|
|
28867
28860
|
exports.MenuItemWithLoading = MenuItemWithLoading;
|
|
28868
28861
|
exports.ModuleCard = ModuleCard;
|
|
28862
|
+
exports.MoreOptions = MoreOptions;
|
|
28869
28863
|
exports.MyGridEditSingleSelect = MyGridEditSingleSelect;
|
|
28870
28864
|
exports.NavigationContext = NavigationContext;
|
|
28871
28865
|
exports.NavigationProvider = NavigationProvider;
|
|
@@ -28885,9 +28879,8 @@ exports.dayjs = dayjs;
|
|
|
28885
28879
|
exports.deleteColumn = deleteColumn;
|
|
28886
28880
|
exports.editColumn = editColumn;
|
|
28887
28881
|
exports.filterQuery = filterQuery;
|
|
28888
|
-
exports.
|
|
28882
|
+
exports.formParser = formParser;
|
|
28889
28883
|
exports.headerReducer = header;
|
|
28890
|
-
exports.jsonForm = jsonForm;
|
|
28891
28884
|
exports.manualCacheRefresh = manualCacheRefresh;
|
|
28892
28885
|
exports.mergeSettings = mergeSettings;
|
|
28893
28886
|
exports.openProgressSnack = openProgressSnack;
|