@acvl/frontend-components 0.0.24 → 0.0.26
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 +639 -529
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/v1/buttons/CreateButton/CreateButtonWithMenuOptions.d.ts +3 -2
- package/dist/cjs/types/src/components/v1/buttons/DeleteButton/DeleteButton.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/buttons/NormalOrIcon/NormalOrIcon.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/Base/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/columns/deleteColumn.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/columns/editColumn.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/custom_slots/CustomToolbar/index.d.ts +3 -3
- package/dist/cjs/types/src/components/v1/datagrids/custom_slots/CustomToolbar/slots/ExportButton/ExportCSV.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/datagrids/custom_slots/CustomToolbar/slots/ExportButton/index.d.ts +3 -3
- package/dist/cjs/types/src/components/v1/datagrids/custom_slots/CustomToolbar/slots/FiltersButton/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/custom_slots/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/wrappers/CreateGridWrapper.d.ts +1 -0
- package/dist/cjs/types/src/components/v1/datagrids/wrappers/EditGridWrapper.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/drawers/HistorialDrawer/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/layout/pages/DetailPage/FieldArrayField/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/layout/pages/DetailPage/index.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/layout/shared/Tabs/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/lib/slices/snackProgress.d.ts +1 -1
- package/dist/esm/index.js +642 -532
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/v1/buttons/CreateButton/CreateButtonWithMenuOptions.d.ts +3 -2
- package/dist/esm/types/src/components/v1/buttons/DeleteButton/DeleteButton.d.ts +1 -1
- package/dist/esm/types/src/components/v1/buttons/NormalOrIcon/NormalOrIcon.d.ts +1 -1
- package/dist/esm/types/src/components/v1/datagrids/Base/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/datagrids/columns/deleteColumn.d.ts +1 -1
- package/dist/esm/types/src/components/v1/datagrids/columns/editColumn.d.ts +1 -1
- package/dist/esm/types/src/components/v1/datagrids/custom_slots/CustomToolbar/index.d.ts +3 -3
- package/dist/esm/types/src/components/v1/datagrids/custom_slots/CustomToolbar/slots/ExportButton/ExportCSV.d.ts +2 -2
- package/dist/esm/types/src/components/v1/datagrids/custom_slots/CustomToolbar/slots/ExportButton/index.d.ts +3 -3
- package/dist/esm/types/src/components/v1/datagrids/custom_slots/CustomToolbar/slots/FiltersButton/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/datagrids/custom_slots/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/datagrids/wrappers/CreateGridWrapper.d.ts +1 -0
- package/dist/esm/types/src/components/v1/datagrids/wrappers/EditGridWrapper.d.ts +2 -2
- package/dist/esm/types/src/components/v1/drawers/HistorialDrawer/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/layout/pages/DetailPage/FieldArrayField/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/layout/pages/DetailPage/index.d.ts +2 -2
- package/dist/esm/types/src/components/v1/layout/shared/Tabs/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/lib/slices/snackProgress.d.ts +1 -1
- package/dist/index.d.ts +33 -16
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -74,6 +74,7 @@ var SaveIcon = require('@mui/icons-material/Save');
|
|
|
74
74
|
var AddIcon = require('@mui/icons-material/Add');
|
|
75
75
|
var KeyboardArrowDownIcon = require('@mui/icons-material/KeyboardArrowDown');
|
|
76
76
|
var LinearProgress = require('@mui/material/LinearProgress');
|
|
77
|
+
var AttachFileIcon = require('@mui/icons-material/AttachFile');
|
|
77
78
|
var xDataGrid = require('@mui/x-data-grid');
|
|
78
79
|
var Tooltip = require('@mui/material/Tooltip');
|
|
79
80
|
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
|
@@ -95,6 +96,7 @@ var sortable = require('@dnd-kit/sortable');
|
|
|
95
96
|
var utilities = require('@dnd-kit/utilities');
|
|
96
97
|
var core$1 = require('@dnd-kit/core');
|
|
97
98
|
var modifiers = require('@dnd-kit/modifiers');
|
|
99
|
+
var DrawIcon = require('@mui/icons-material/Draw');
|
|
98
100
|
var CloseIcon = require('@mui/icons-material/Close');
|
|
99
101
|
var ErrorOutlineIcon = require('@mui/icons-material/ErrorOutline');
|
|
100
102
|
var query$1 = require('@reduxjs/toolkit/query');
|
|
@@ -124,10 +126,10 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
124
126
|
|
|
125
127
|
const NormalOrIcon = (props) => {
|
|
126
128
|
const theme = material.useTheme();
|
|
127
|
-
const belowLG = material.useMediaQuery(theme.breakpoints.down(
|
|
128
|
-
if ((belowLG && !(props.type ==
|
|
129
|
+
const belowLG = material.useMediaQuery(theme.breakpoints.down("lg"));
|
|
130
|
+
if ((belowLG && !(props.type == "button")) || props.type == "icon")
|
|
129
131
|
return (jsxRuntime.jsx(material.Tooltip, { title: props.buttonProps.children, children: jsxRuntime.jsx(material.IconButton, { ...props.buttonProps, children: props.buttonProps.startIcon }) }));
|
|
130
|
-
return
|
|
132
|
+
return jsxRuntime.jsx(material.Button, { ...props.buttonProps });
|
|
131
133
|
};
|
|
132
134
|
|
|
133
135
|
const EditButton = () => {
|
|
@@ -137,23 +139,23 @@ const EditButton = () => {
|
|
|
137
139
|
}, [navigate]);
|
|
138
140
|
// ===== || KEYDOWN || ===== //
|
|
139
141
|
const handleKeyPress = React.useCallback((event) => {
|
|
140
|
-
if (event.ctrlKey && event.key ===
|
|
142
|
+
if (event.ctrlKey && event.key === "e") {
|
|
141
143
|
event.preventDefault();
|
|
142
144
|
handleClick();
|
|
143
145
|
}
|
|
144
146
|
}, [handleClick]);
|
|
145
147
|
React.useEffect(() => {
|
|
146
|
-
document.addEventListener(
|
|
148
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
147
149
|
return () => {
|
|
148
|
-
document.removeEventListener(
|
|
150
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
149
151
|
};
|
|
150
152
|
}, [handleKeyPress]);
|
|
151
153
|
return (jsxRuntime.jsx(NormalOrIcon, { buttonProps: {
|
|
152
|
-
color:
|
|
153
|
-
variant:
|
|
154
|
+
color: "secondary",
|
|
155
|
+
variant: "contained",
|
|
154
156
|
startIcon: jsxRuntime.jsx(EditIcon, {}),
|
|
155
157
|
onClick: handleClick,
|
|
156
|
-
children:
|
|
158
|
+
children: "Editar",
|
|
157
159
|
} }));
|
|
158
160
|
};
|
|
159
161
|
|
|
@@ -25664,9 +25666,9 @@ dayjs.locale(es);
|
|
|
25664
25666
|
dayjs.extend(duration);
|
|
25665
25667
|
|
|
25666
25668
|
// ==============================|| JSON ||============================== //
|
|
25667
|
-
const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, data, props, formType }) => {
|
|
25669
|
+
const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, data, props, formType, }) => {
|
|
25668
25670
|
const ignore = get(props, `${base_key}.ignore`, false);
|
|
25669
|
-
if (ignore || [
|
|
25671
|
+
if (ignore || ["obj_permissions", "has_history"].includes(base_key))
|
|
25670
25672
|
return;
|
|
25671
25673
|
const altered_key = lodash.invoke(props, `${base_key}.alter_key`, base_key);
|
|
25672
25674
|
const key = altered_key || base_key;
|
|
@@ -25684,7 +25686,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25684
25686
|
case "string":
|
|
25685
25687
|
if (lodash.invoke(props, `${base_key}.extra_validation`, object))
|
|
25686
25688
|
return;
|
|
25687
|
-
setValue(response, key, isEmpty(object) ?
|
|
25689
|
+
setValue(response, key, isEmpty(object) ? "" : object);
|
|
25688
25690
|
break;
|
|
25689
25691
|
case "number":
|
|
25690
25692
|
setValue(response, key, object);
|
|
@@ -25694,28 +25696,37 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25694
25696
|
break;
|
|
25695
25697
|
case "object":
|
|
25696
25698
|
if (isNull(object) || isEmpty(object)) {
|
|
25697
|
-
if (includes(key,
|
|
25698
|
-
setValue(response, key,
|
|
25699
|
+
if (includes(key, "after") || includes(key, "before"))
|
|
25700
|
+
setValue(response, key, "");
|
|
25699
25701
|
else
|
|
25700
25702
|
setValue(response, key, object);
|
|
25701
25703
|
}
|
|
25704
|
+
else if (object instanceof File) {
|
|
25705
|
+
setValue(response, key, object);
|
|
25706
|
+
}
|
|
25702
25707
|
else if (object instanceof dayjs) {
|
|
25703
|
-
setValue(response, key, object.format(get(props, `${key}.format`,
|
|
25708
|
+
setValue(response, key, object.format(get(props, `${key}.format`, "YYYY-MM-DD")));
|
|
25704
25709
|
}
|
|
25705
|
-
else if (
|
|
25710
|
+
else if ("label" in object && "value" in object) {
|
|
25706
25711
|
if (useLabel)
|
|
25707
|
-
setValue(response, key, object[
|
|
25712
|
+
setValue(response, key, object["label"]);
|
|
25708
25713
|
else
|
|
25709
|
-
setValue(response, key, object[
|
|
25714
|
+
setValue(response, key, object["value"]);
|
|
25710
25715
|
}
|
|
25711
|
-
else if (Array.isArray(object)) {
|
|
25712
|
-
|
|
25713
|
-
|
|
25716
|
+
else if (Array.isArray(object)) {
|
|
25717
|
+
// it is an array
|
|
25718
|
+
if (object.length &&
|
|
25719
|
+
typeof object[0] == "object" &&
|
|
25720
|
+
!Array.isArray(object[0]) &&
|
|
25721
|
+
"value" in object[0] &&
|
|
25722
|
+
object[0]["value"] == "all") {
|
|
25723
|
+
// for data grid filters
|
|
25724
|
+
setValue(response, key, "");
|
|
25714
25725
|
}
|
|
25715
25726
|
else {
|
|
25716
25727
|
forEach(object, (arrayItem, idx) => {
|
|
25717
|
-
if (typeof arrayItem ==
|
|
25718
|
-
if (
|
|
25728
|
+
if (typeof arrayItem == "object") {
|
|
25729
|
+
if ("label" in arrayItem) {
|
|
25719
25730
|
setValue(response, `${key}.${idx}`, function (item) {
|
|
25720
25731
|
if (useLabel)
|
|
25721
25732
|
return item.label;
|
|
@@ -25723,7 +25734,16 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25723
25734
|
return item.value;
|
|
25724
25735
|
});
|
|
25725
25736
|
}
|
|
25726
|
-
typeSwitch({
|
|
25737
|
+
typeSwitch({
|
|
25738
|
+
base_object: arrayItem,
|
|
25739
|
+
base_key: `${key}.${idx}`,
|
|
25740
|
+
response: response,
|
|
25741
|
+
useLabel: useLabel,
|
|
25742
|
+
data: data,
|
|
25743
|
+
submitData: submitData,
|
|
25744
|
+
props: props,
|
|
25745
|
+
formType: formType,
|
|
25746
|
+
});
|
|
25727
25747
|
}
|
|
25728
25748
|
else {
|
|
25729
25749
|
const keyArray = get(response, key);
|
|
@@ -25740,9 +25760,19 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25740
25760
|
}
|
|
25741
25761
|
else {
|
|
25742
25762
|
forEach(object, (value, key2) => {
|
|
25743
|
-
if (!includes([
|
|
25763
|
+
if (!includes(["id", "transporte.tarifa.cargos_adicionales"], key) &&
|
|
25764
|
+
isEqual(get(data, `${key}.${key2}`), value))
|
|
25744
25765
|
return;
|
|
25745
|
-
typeSwitch({
|
|
25766
|
+
typeSwitch({
|
|
25767
|
+
base_object: value,
|
|
25768
|
+
base_key: `${key}.${key2}`,
|
|
25769
|
+
response: response,
|
|
25770
|
+
useLabel: useLabel,
|
|
25771
|
+
data: data,
|
|
25772
|
+
submitData: submitData,
|
|
25773
|
+
props: props,
|
|
25774
|
+
formType: formType,
|
|
25775
|
+
});
|
|
25746
25776
|
});
|
|
25747
25777
|
}
|
|
25748
25778
|
break;
|
|
@@ -25754,7 +25784,7 @@ const typeSwitch = ({ base_object, base_key, response, submitData, useLabel, dat
|
|
|
25754
25784
|
const jsonForm = ({ submitData, data, useLabel, props }) => {
|
|
25755
25785
|
const response = {};
|
|
25756
25786
|
forEach(submitData, function (value, key) {
|
|
25757
|
-
if (key !=
|
|
25787
|
+
if (key != "id" && isEqual(get(data, key), value))
|
|
25758
25788
|
return;
|
|
25759
25789
|
typeSwitch({
|
|
25760
25790
|
base_object: value,
|
|
@@ -25764,7 +25794,7 @@ const jsonForm = ({ submitData, data, useLabel, props }) => {
|
|
|
25764
25794
|
data: data,
|
|
25765
25795
|
props: props,
|
|
25766
25796
|
submitData: submitData,
|
|
25767
|
-
formType:
|
|
25797
|
+
formType: "json",
|
|
25768
25798
|
});
|
|
25769
25799
|
});
|
|
25770
25800
|
return response;
|
|
@@ -25772,7 +25802,7 @@ const jsonForm = ({ submitData, data, useLabel, props }) => {
|
|
|
25772
25802
|
const formDataForm = ({ submitData, data, useLabel, props }) => {
|
|
25773
25803
|
const formData = new FormData();
|
|
25774
25804
|
forEach(submitData, function (value, key) {
|
|
25775
|
-
if (key !=
|
|
25805
|
+
if (key != "id" && isEqual(get(data, key), value))
|
|
25776
25806
|
return;
|
|
25777
25807
|
typeSwitch({
|
|
25778
25808
|
base_object: value,
|
|
@@ -25782,16 +25812,16 @@ const formDataForm = ({ submitData, data, useLabel, props }) => {
|
|
|
25782
25812
|
data: data,
|
|
25783
25813
|
props: props,
|
|
25784
25814
|
submitData: submitData,
|
|
25785
|
-
formType:
|
|
25815
|
+
formType: "formData",
|
|
25786
25816
|
});
|
|
25787
25817
|
});
|
|
25788
25818
|
return formData;
|
|
25789
25819
|
};
|
|
25790
25820
|
// ==============================|| ERRORS ||============================== //
|
|
25791
25821
|
const setErrors = (form, error) => {
|
|
25792
|
-
if (
|
|
25822
|
+
if ("invalid_params" in error.data) {
|
|
25793
25823
|
Object.values(error.data.invalid_params).forEach((entry) => {
|
|
25794
|
-
form.setError(entry.name, { message: entry.reason.join(
|
|
25824
|
+
form.setError(entry.name, { message: entry.reason.join(", ") });
|
|
25795
25825
|
});
|
|
25796
25826
|
}
|
|
25797
25827
|
};
|
|
@@ -25803,18 +25833,18 @@ const valueLabel = zod.object({
|
|
|
25803
25833
|
|
|
25804
25834
|
const MainDrawer = (props) => {
|
|
25805
25835
|
const theme = material.useTheme();
|
|
25806
|
-
return (jsxRuntime.jsx(material.Drawer, { variant:
|
|
25836
|
+
return (jsxRuntime.jsx(material.Drawer, { variant: "temporary", anchor: "right", open: props.open, onClose: props.drawerToggle, sx: {
|
|
25807
25837
|
zIndex: 1202,
|
|
25808
|
-
|
|
25809
|
-
width:
|
|
25838
|
+
"& .MuiDrawer-paper": {
|
|
25839
|
+
width: "100%",
|
|
25810
25840
|
maxWidth: props.width ? props.width : 600,
|
|
25811
25841
|
background: theme.palette.background.default,
|
|
25812
25842
|
color: theme.palette.text.primary,
|
|
25813
|
-
borderRight:
|
|
25814
|
-
borderTopLeftRadius:
|
|
25815
|
-
borderBottomLeftRadius:
|
|
25816
|
-
}
|
|
25817
|
-
}, color:
|
|
25843
|
+
borderRight: "none",
|
|
25844
|
+
borderTopLeftRadius: "12px",
|
|
25845
|
+
borderBottomLeftRadius: "12px",
|
|
25846
|
+
},
|
|
25847
|
+
}, color: "inherit", ...props.drawerProps, children: jsxRuntime.jsxs(material.Grid, { container: true, direction: "column", px: 4, py: 2, spacing: 2, children: [jsxRuntime.jsx(material.Grid, { display: "flex", justifyContent: "right", pb: 0, children: props.slots?.button ? (props.slots.button) : (jsxRuntime.jsx(material.Button, { color: "error", startIcon: jsxRuntime.jsx(CancelIcon, {}), onClick: props.drawerToggle, children: "Cerrar" })) }), jsxRuntime.jsx(material.Grid, { children: jsxRuntime.jsx(core.PageHeader, { breadcrumbs: [], title: props.title }) }), jsxRuntime.jsx(material.Grid, { size: 12, container: true, position: "relative", children: props.children })] }) }));
|
|
25818
25848
|
};
|
|
25819
25849
|
|
|
25820
25850
|
const LoadingComponent = (props) => {
|
|
@@ -25873,60 +25903,49 @@ const _HistorialDrawer = (props) => {
|
|
|
25873
25903
|
const HistorialDrawer = (props) => {
|
|
25874
25904
|
const [open, setOpen] = React.useState(false);
|
|
25875
25905
|
const handleDrawer = React.useCallback(() => {
|
|
25876
|
-
setOpen(prevState => !prevState);
|
|
25906
|
+
setOpen((prevState) => !prevState);
|
|
25877
25907
|
}, []);
|
|
25878
25908
|
// ===== || KEYDOWN || ===== //
|
|
25879
25909
|
const handleKeyPress = React.useCallback((event) => {
|
|
25880
|
-
if (event.ctrlKey && event.shiftKey && event.key ===
|
|
25910
|
+
if (event.ctrlKey && event.shiftKey && event.key === "H") {
|
|
25881
25911
|
event.preventDefault();
|
|
25882
25912
|
handleDrawer();
|
|
25883
25913
|
}
|
|
25884
25914
|
}, [handleDrawer]);
|
|
25885
25915
|
React.useEffect(() => {
|
|
25886
|
-
document.addEventListener(
|
|
25916
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
25887
25917
|
return () => {
|
|
25888
|
-
document.removeEventListener(
|
|
25918
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
25889
25919
|
};
|
|
25890
25920
|
}, [handleKeyPress]);
|
|
25891
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Tooltip, { title:
|
|
25892
|
-
position:
|
|
25921
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Tooltip, { title: "Historial", children: jsxRuntime.jsx(material.IconButton, { color: "primary", onClick: handleDrawer, sx: {
|
|
25922
|
+
position: "absolute",
|
|
25893
25923
|
right: 0,
|
|
25894
25924
|
}, ...props.iconButtonProps, children: jsxRuntime.jsx(HistoryIcon, {}) }) }), jsxRuntime.jsx(_HistorialDrawer, { open: open, handleDrawer: handleDrawer, endpoint: props.endpoint })] }));
|
|
25895
25925
|
};
|
|
25896
25926
|
|
|
25897
|
-
const buildListItems = (content) => {
|
|
25898
|
-
const items = [];
|
|
25899
|
-
const loop = (content, error_title) => {
|
|
25900
|
-
if (Array.isArray(content)) {
|
|
25901
|
-
items.push({ title: error_title ? (error_title.charAt(0).toUpperCase() + error_title.slice(1)).split('_').join(' ') : 'N/A', content: content.join(', ') });
|
|
25902
|
-
}
|
|
25903
|
-
else {
|
|
25904
|
-
Object.keys(content).map((row_error) => {
|
|
25905
|
-
loop(content[row_error], row_error);
|
|
25906
|
-
});
|
|
25907
|
-
}
|
|
25908
|
-
};
|
|
25909
|
-
loop(content);
|
|
25910
|
-
return items;
|
|
25911
|
-
};
|
|
25912
25927
|
const RowErrors = (props) => {
|
|
25913
25928
|
return (jsxRuntime.jsx(material.List, { subheader: jsxRuntime.jsx(material.ListSubheader, { sx: {
|
|
25914
25929
|
bgcolor: colors.red[50],
|
|
25915
25930
|
color: colors.red[800],
|
|
25916
|
-
fontWeight:
|
|
25917
|
-
borderRadius:
|
|
25918
|
-
lineHeight:
|
|
25931
|
+
fontWeight: "bold",
|
|
25932
|
+
borderRadius: "12px",
|
|
25933
|
+
lineHeight: "40px",
|
|
25919
25934
|
}, children: `Hilera ${props.row}` }), sx: {
|
|
25920
25935
|
bgcolor: colors.red[50],
|
|
25921
|
-
borderRadius:
|
|
25922
|
-
}, children:
|
|
25936
|
+
borderRadius: "12px",
|
|
25937
|
+
}, children: props.data.map((item) => {
|
|
25938
|
+
const pre_name = item.name.split(".").at(-1);
|
|
25939
|
+
const name = (pre_name.charAt(0).toUpperCase() + pre_name.slice(1))
|
|
25940
|
+
.split("_")
|
|
25941
|
+
.join(" ");
|
|
25923
25942
|
return (jsxRuntime.jsx(material.ListItem, { sx: {
|
|
25924
|
-
py: 0
|
|
25925
|
-
}, children: jsxRuntime.jsx(ListItemText, { primary: jsxRuntime.jsxs(material.Box, { children: [jsxRuntime.jsx(material.Typography, { variant:
|
|
25943
|
+
py: 0,
|
|
25944
|
+
}, children: jsxRuntime.jsx(ListItemText, { primary: jsxRuntime.jsxs(material.Box, { children: [jsxRuntime.jsx(material.Typography, { variant: "caption", pr: 0.5, sx: {
|
|
25926
25945
|
color: colors.red[800],
|
|
25927
|
-
}, children: `${
|
|
25946
|
+
}, children: `${name}:` }), jsxRuntime.jsx(material.Typography, { variant: "caption", sx: {
|
|
25928
25947
|
color: colors.red[800],
|
|
25929
|
-
}, children: item.
|
|
25948
|
+
}, children: item.reason.join(", ") })] }) }) }));
|
|
25930
25949
|
}) }));
|
|
25931
25950
|
};
|
|
25932
25951
|
|
|
@@ -25934,14 +25953,14 @@ const FileBox = (props) => {
|
|
|
25934
25953
|
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, {}) }) })) })] }));
|
|
25935
25954
|
};
|
|
25936
25955
|
|
|
25937
|
-
const VisuallyHiddenInput = material.styled(
|
|
25938
|
-
clipPath:
|
|
25956
|
+
const VisuallyHiddenInput = material.styled("input")({
|
|
25957
|
+
clipPath: "inset(50%)",
|
|
25939
25958
|
height: 1,
|
|
25940
|
-
overflow:
|
|
25941
|
-
position:
|
|
25959
|
+
overflow: "hidden",
|
|
25960
|
+
position: "absolute",
|
|
25942
25961
|
bottom: 0,
|
|
25943
25962
|
left: 0,
|
|
25944
|
-
whiteSpace:
|
|
25963
|
+
whiteSpace: "nowrap",
|
|
25945
25964
|
width: 1,
|
|
25946
25965
|
});
|
|
25947
25966
|
const FileUploadBox = (props) => {
|
|
@@ -25952,68 +25971,78 @@ const FileUploadBox = (props) => {
|
|
|
25952
25971
|
const [removerCSV, { isLoading: removerLoading }] = api.useRemoverCSVMutation();
|
|
25953
25972
|
const Dropzone = ({ onChange, value }) => {
|
|
25954
25973
|
const onDrop = React.useCallback((acceptedFiles) => {
|
|
25955
|
-
acceptedFiles.map(file => {
|
|
25956
|
-
const data = formDataForm({ });
|
|
25957
|
-
validarCSV({
|
|
25974
|
+
acceptedFiles.map((file) => {
|
|
25975
|
+
const data = formDataForm({ submitData: { archivo: file } });
|
|
25976
|
+
validarCSV({
|
|
25977
|
+
endpoint: props.csvProps.endpoint || "",
|
|
25978
|
+
data: data,
|
|
25979
|
+
custom: props.csvProps.custom,
|
|
25980
|
+
})
|
|
25981
|
+
.unwrap()
|
|
25958
25982
|
.then((response) => {
|
|
25959
|
-
onChange(
|
|
25983
|
+
onChange("archivo" in response ? response.archivo : acceptedFiles[0]);
|
|
25960
25984
|
setFile(acceptedFiles[0]);
|
|
25961
25985
|
props.setValid(true);
|
|
25962
25986
|
})
|
|
25963
25987
|
.catch((e) => {
|
|
25964
|
-
|
|
25965
|
-
|
|
25966
|
-
notifications.show(columnas_inv, { severity: 'error' });
|
|
25988
|
+
if (e.data?.detail?.length > 0)
|
|
25989
|
+
notifications.show(e.data.detail[0], { severity: "error" });
|
|
25967
25990
|
props.setValid(false);
|
|
25968
25991
|
});
|
|
25969
25992
|
});
|
|
25970
25993
|
}, []);
|
|
25971
25994
|
const onDropRejected = React.useCallback(() => {
|
|
25972
|
-
notifications.show(
|
|
25995
|
+
notifications.show("Tipo de archivo inválido. Solo se aceptan CSVs.", {
|
|
25996
|
+
severity: "error",
|
|
25997
|
+
});
|
|
25973
25998
|
}, []);
|
|
25974
|
-
const { getRootProps, getInputProps, isDragActive
|
|
25999
|
+
const { getRootProps, getInputProps, isDragActive } = reactDropzone.useDropzone({
|
|
25975
26000
|
onDrop,
|
|
25976
26001
|
onDropRejected,
|
|
25977
26002
|
accept: {
|
|
25978
|
-
|
|
25979
|
-
|
|
26003
|
+
"text/csv": [".csv"],
|
|
26004
|
+
"application/vnd.ms-excel": [".csv"],
|
|
25980
26005
|
},
|
|
25981
26006
|
maxFiles: 1,
|
|
25982
26007
|
multiple: false,
|
|
25983
26008
|
});
|
|
25984
26009
|
const handleRemove = () => {
|
|
25985
|
-
if (typeof value ==
|
|
26010
|
+
if (typeof value == "number") {
|
|
25986
26011
|
removerCSV({ id: value });
|
|
25987
26012
|
}
|
|
25988
26013
|
onChange(null);
|
|
25989
26014
|
setFile(null);
|
|
25990
26015
|
};
|
|
25991
|
-
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
|
|
25995
|
-
|
|
25996
|
-
|
|
25997
|
-
|
|
25998
|
-
|
|
25999
|
-
|
|
26000
|
-
|
|
26001
|
-
|
|
26002
|
-
|
|
26003
|
-
|
|
26004
|
-
|
|
26016
|
+
const renderErrorRows = () => {
|
|
26017
|
+
if (!error?.data?.invalid_params)
|
|
26018
|
+
return;
|
|
26019
|
+
const rows = lodash.groupBy(error?.data?.invalid_params, function (e) {
|
|
26020
|
+
return e.name.split(".")[0];
|
|
26021
|
+
});
|
|
26022
|
+
if (!rows)
|
|
26023
|
+
return;
|
|
26024
|
+
return Object.entries(rows).map(([row, errors]) => (jsxRuntime.jsx(RowErrors, { row: row, data: errors }, row)));
|
|
26025
|
+
};
|
|
26026
|
+
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: {
|
|
26027
|
+
color: colors.grey[800],
|
|
26028
|
+
pr: 1,
|
|
26029
|
+
} }), jsxRuntime.jsx(Typography, { variant: "body2", sx: { color: colors.grey[800] }, children: isDragActive
|
|
26030
|
+
? "Soltar archivo aquí."
|
|
26031
|
+
: "Arrastra un archivo aquí o haz clic para seleccionar uno." })] })), isLoading && (jsxRuntime.jsx(Box, { children: jsxRuntime.jsx(material.LinearProgress, { sx: { height: 5 } }) })), file && (jsxRuntime.jsx(FileBox, { file: file, handleRemove: handleRemove, loadingRemove: removerLoading })), renderErrorRows()] }) }));
|
|
26005
26032
|
};
|
|
26006
26033
|
return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { onChange, value } }) => {
|
|
26007
|
-
return
|
|
26034
|
+
return jsxRuntime.jsx(Dropzone, { onChange: onChange, value: value });
|
|
26008
26035
|
} }));
|
|
26009
26036
|
};
|
|
26010
26037
|
|
|
26011
26038
|
const schema = zod.z.object({
|
|
26012
|
-
archivo: zod.z.any()
|
|
26039
|
+
archivo: zod.z.any(),
|
|
26013
26040
|
});
|
|
26014
26041
|
const CSVUpload = (props) => {
|
|
26015
26042
|
const api = useAPI();
|
|
26016
26043
|
const notifications = core.useNotifications();
|
|
26044
|
+
const { pathname } = reactRouterDom.useLocation();
|
|
26045
|
+
const endpoint = props.data?.endpoint || pathname;
|
|
26017
26046
|
const [valid, setValid] = React.useState(false);
|
|
26018
26047
|
const defaultValues = {
|
|
26019
26048
|
archivo: null,
|
|
@@ -26022,29 +26051,30 @@ const CSVUpload = (props) => {
|
|
|
26022
26051
|
resolver: zod$1.zodResolver(schema),
|
|
26023
26052
|
defaultValues: defaultValues,
|
|
26024
26053
|
});
|
|
26025
|
-
const archivo = form.watch(
|
|
26054
|
+
const archivo = form.watch("archivo");
|
|
26026
26055
|
const [subirCSV, { isLoading }] = api.useSubirCSVMutation();
|
|
26027
26056
|
const handleClose = () => {
|
|
26028
26057
|
props.drawerToggle();
|
|
26029
26058
|
form.reset();
|
|
26030
26059
|
};
|
|
26031
|
-
const tag = React.useMemo(() =>
|
|
26060
|
+
const tag = React.useMemo(() => endpoint.split("/").at(-1), [endpoint]);
|
|
26032
26061
|
const onSubmitHandler = (submitData) => {
|
|
26033
|
-
const data = formDataForm(submitData);
|
|
26034
|
-
subirCSV({ endpoint
|
|
26062
|
+
const data = formDataForm({ submitData });
|
|
26063
|
+
subirCSV({ endpoint, tagType: tag, data, custom: props.data?.custom })
|
|
26064
|
+
.unwrap()
|
|
26035
26065
|
.then((response) => {
|
|
26036
26066
|
if (props.postAction)
|
|
26037
26067
|
props.postAction(response);
|
|
26038
26068
|
handleClose();
|
|
26039
|
-
notifications.show(
|
|
26069
|
+
notifications.show("Archivo subido exitosamente!", { severity: "success" });
|
|
26040
26070
|
})
|
|
26041
26071
|
.catch(() => {
|
|
26042
|
-
notifications.show(
|
|
26072
|
+
notifications.show("Error!", { severity: "error" });
|
|
26043
26073
|
});
|
|
26044
26074
|
};
|
|
26045
26075
|
const onError = (errors) => {
|
|
26046
26076
|
console.log(errors);
|
|
26047
|
-
notifications.show(`Error en: ${Object.keys(errors).join(
|
|
26077
|
+
notifications.show(`Error en: ${Object.keys(errors).join(", ")}!`, { severity: "error" });
|
|
26048
26078
|
};
|
|
26049
26079
|
const handleDownload = () => {
|
|
26050
26080
|
const link = document.createElement("a");
|
|
@@ -26052,7 +26082,7 @@ const CSVUpload = (props) => {
|
|
|
26052
26082
|
link.href = `/plantillas/plantilla_${tag}.xlsx`;
|
|
26053
26083
|
link.click();
|
|
26054
26084
|
};
|
|
26055
|
-
return (jsxRuntime.jsxs(MainDrawer, { open: props.open, drawerToggle: handleClose, title: props.data?.title ||
|
|
26085
|
+
return (jsxRuntime.jsxs(MainDrawer, { open: props.open, drawerToggle: handleClose, title: props.data?.title || "CSV", slots: {
|
|
26056
26086
|
button: (jsxRuntime.jsx(SaveCancelButton, { slotProps: {
|
|
26057
26087
|
saveBtn: {
|
|
26058
26088
|
loading: isLoading,
|
|
@@ -26060,11 +26090,11 @@ const CSVUpload = (props) => {
|
|
|
26060
26090
|
},
|
|
26061
26091
|
cancelBtn: {
|
|
26062
26092
|
onClick: handleClose,
|
|
26063
|
-
}
|
|
26064
|
-
} }))
|
|
26065
|
-
}, children: [jsxRuntime.jsxs(material.Box, { px: 2, py: 3, bgcolor: colors.grey[50], borderRadius:
|
|
26066
|
-
minWidth: 120
|
|
26067
|
-
}, children: "Descargar" })] })] }), jsxRuntime.jsx(material.Box, { id:
|
|
26093
|
+
},
|
|
26094
|
+
} })),
|
|
26095
|
+
}, children: [jsxRuntime.jsxs(material.Box, { px: 2, py: 3, bgcolor: colors.grey[50], borderRadius: "12px", children: [jsxRuntime.jsx(material.Typography, { fontWeight: "bold", children: "Archivo de Muestra" }), jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 2, children: [jsxRuntime.jsx(material.Typography, { variant: "body2", children: "Puede descargar el ejemplo adjunto y utilizarlo como punto de partida para su propio archivo." }), jsxRuntime.jsx(material.Button, { variant: "contained", startIcon: jsxRuntime.jsx(DownloadIcon, {}), onClick: handleDownload, sx: {
|
|
26096
|
+
minWidth: 120,
|
|
26097
|
+
}, children: "Descargar" })] })] }), jsxRuntime.jsx(material.Box, { id: "formulario", component: "form", width: 1, autoComplete: "off", noValidate: true, onSubmit: form.handleSubmit(onSubmitHandler, onError), children: jsxRuntime.jsx(FileUploadBox, { name: "archivo", control: form.control, setValid: setValid, csvProps: props.data }) })] }));
|
|
26068
26098
|
};
|
|
26069
26099
|
|
|
26070
26100
|
const mergeSettings = (baseSettings, mergingSettings) => {
|
|
@@ -26183,7 +26213,7 @@ async function manualCacheRefresh(api, id, dispatch, queryFulfilled, endpoints)
|
|
|
26183
26213
|
const initialState$1 = {};
|
|
26184
26214
|
// == crea el slice == //
|
|
26185
26215
|
const snackProgress = toolkit.createSlice({
|
|
26186
|
-
name:
|
|
26216
|
+
name: "snackProgress",
|
|
26187
26217
|
initialState: initialState$1,
|
|
26188
26218
|
// declarar acciones que se le pueden hacer a esta sección de la tienda
|
|
26189
26219
|
reducers: {
|
|
@@ -26199,7 +26229,7 @@ const snackProgress = toolkit.createSlice({
|
|
|
26199
26229
|
closeProgressSnack(state, action) {
|
|
26200
26230
|
return lodash.omit(state, action.payload);
|
|
26201
26231
|
},
|
|
26202
|
-
}
|
|
26232
|
+
},
|
|
26203
26233
|
});
|
|
26204
26234
|
// exportar acciones
|
|
26205
26235
|
const { openProgressSnack, updateProgressSnackData, closeProgressSnack } = snackProgress.actions;
|
|
@@ -26225,12 +26255,14 @@ const { changeTitle, } = settings.actions;
|
|
|
26225
26255
|
var header = settings.reducer;
|
|
26226
26256
|
|
|
26227
26257
|
const ControlledDropdown = (props) => {
|
|
26228
|
-
const [inputValue, setInputValue] = React.useState(
|
|
26258
|
+
const [inputValue, setInputValue] = React.useState("");
|
|
26229
26259
|
const [options, setOptions] = React.useState(props.extraProps?.options ? props.extraProps?.options : []);
|
|
26230
26260
|
const args = React.useMemo(() => {
|
|
26231
26261
|
if (!props.extraProps?.queryArgs)
|
|
26232
26262
|
return undefined;
|
|
26233
|
-
return mergeSettings(props.extraProps?.queryArgs, {
|
|
26263
|
+
return mergeSettings(props.extraProps?.queryArgs, {
|
|
26264
|
+
filters: { nombre__icontains: inputValue },
|
|
26265
|
+
});
|
|
26234
26266
|
}, [inputValue, props.extraProps?.queryArgs]);
|
|
26235
26267
|
const api = useAPI();
|
|
26236
26268
|
const [getOpciones, { isLoading, isFetching, isError }] = api.useLazyGetComoOpcionesQuery();
|
|
@@ -26243,7 +26275,8 @@ const ControlledDropdown = (props) => {
|
|
|
26243
26275
|
};
|
|
26244
26276
|
const handleSearch = React.useCallback(debounce((args, callback) => {
|
|
26245
26277
|
setOptions([]);
|
|
26246
|
-
getOpciones(args)
|
|
26278
|
+
getOpciones(args)
|
|
26279
|
+
.unwrap()
|
|
26247
26280
|
.then(callback)
|
|
26248
26281
|
.catch(() => {
|
|
26249
26282
|
//
|
|
@@ -26256,7 +26289,7 @@ const ControlledDropdown = (props) => {
|
|
|
26256
26289
|
});
|
|
26257
26290
|
}
|
|
26258
26291
|
}, [args, handleSearch, open]);
|
|
26259
|
-
return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { value, onChange
|
|
26292
|
+
return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { value, onChange }, fieldState: { error } }) => {
|
|
26260
26293
|
const handleChange = (_event, newValue) => {
|
|
26261
26294
|
onChange(newValue);
|
|
26262
26295
|
};
|
|
@@ -26264,10 +26297,10 @@ const ControlledDropdown = (props) => {
|
|
|
26264
26297
|
setInputValue(newInputValue);
|
|
26265
26298
|
}, isOptionEqualToValue: (option, value) => {
|
|
26266
26299
|
return option.value === value.value;
|
|
26267
|
-
}, filterOptions: props.extraProps.queryArgs ? (x) => x : undefined, fullWidth: true, size:
|
|
26300
|
+
}, filterOptions: props.extraProps.queryArgs ? (x) => x : undefined, fullWidth: true, size: "small", disabled: !options || isError, renderInput: (params) => (jsxRuntime.jsx(TextField, { ...params, label: props.label, error: !!error, helperText: error ? error.message : props.extraProps?.disableHT ? "" : " ", slotProps: {
|
|
26268
26301
|
input: {
|
|
26269
26302
|
...params.InputProps,
|
|
26270
|
-
endAdornment: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
26303
|
+
endAdornment: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isLoading || isFetching ? (jsxRuntime.jsx(material.CircularProgress, { color: "inherit", size: 20 })) : null, params.InputProps.endAdornment] })),
|
|
26271
26304
|
},
|
|
26272
26305
|
} })), ...props.fieldProps }));
|
|
26273
26306
|
} }));
|
|
@@ -26296,13 +26329,15 @@ const ControlledPhoneNumber = (props) => {
|
|
|
26296
26329
|
};
|
|
26297
26330
|
|
|
26298
26331
|
const ControlledSelect = (props) => {
|
|
26299
|
-
const [inputValue, setInputValue] = React.useState(
|
|
26332
|
+
const [inputValue, setInputValue] = React.useState("");
|
|
26300
26333
|
const [options, setOptions] = React.useState(props.extraProps?.options ? props.extraProps?.options : []);
|
|
26301
26334
|
const [selectedAll, setSelectedAll] = React.useState(false);
|
|
26302
26335
|
const args = React.useMemo(() => {
|
|
26303
26336
|
if (!props.extraProps?.queryArgs)
|
|
26304
26337
|
return undefined;
|
|
26305
|
-
return mergeSettings(props.extraProps?.queryArgs, {
|
|
26338
|
+
return mergeSettings(props.extraProps?.queryArgs, {
|
|
26339
|
+
filters: { nombre__icontains: inputValue },
|
|
26340
|
+
});
|
|
26306
26341
|
}, [inputValue, props.extraProps?.queryArgs]);
|
|
26307
26342
|
const api = useAPI();
|
|
26308
26343
|
const [getOpciones, { isLoading, isFetching, isError }] = api.useLazyGetComoOpcionesQuery();
|
|
@@ -26317,7 +26352,8 @@ const ControlledSelect = (props) => {
|
|
|
26317
26352
|
};
|
|
26318
26353
|
const handleSearch = React.useCallback(debounce((args, callback) => {
|
|
26319
26354
|
setOptions([]);
|
|
26320
|
-
getOpciones(args)
|
|
26355
|
+
getOpciones(args)
|
|
26356
|
+
.unwrap()
|
|
26321
26357
|
.then(callback)
|
|
26322
26358
|
.catch(() => {
|
|
26323
26359
|
//
|
|
@@ -26326,12 +26362,14 @@ const ControlledSelect = (props) => {
|
|
|
26326
26362
|
React.useEffect(() => {
|
|
26327
26363
|
if (args && open)
|
|
26328
26364
|
handleSearch(args, (filteredOptions) => {
|
|
26329
|
-
setOptions([{ value:
|
|
26365
|
+
setOptions([{ value: "all", label: "All" }].concat(filteredOptions));
|
|
26330
26366
|
});
|
|
26331
26367
|
}, [args, handleSearch, open]);
|
|
26332
26368
|
return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { value, onChange }, fieldState: { error } }) => {
|
|
26333
26369
|
const handleChange = (_event, newValue) => {
|
|
26334
|
-
if (lodash.find(newValue, function (val) {
|
|
26370
|
+
if (lodash.find(newValue, function (val) {
|
|
26371
|
+
return val.value == "all";
|
|
26372
|
+
})) {
|
|
26335
26373
|
if (selectedAll) {
|
|
26336
26374
|
setSelectedAll(false);
|
|
26337
26375
|
onChange(newValue.slice(1));
|
|
@@ -26355,10 +26393,10 @@ const ControlledSelect = (props) => {
|
|
|
26355
26393
|
setInputValue(newInputValue);
|
|
26356
26394
|
}, isOptionEqualToValue: (option, value) => {
|
|
26357
26395
|
return option.value === value.value;
|
|
26358
|
-
}, filterOptions: props.extraProps.queryArgs ? (x) => x : undefined, multiple: true, disableCloseOnSelect: true, limitTags: 1, fullWidth: true, size:
|
|
26396
|
+
}, filterOptions: props.extraProps.queryArgs ? (x) => x : undefined, multiple: true, disableCloseOnSelect: true, limitTags: 1, fullWidth: true, size: "small", disabled: !options || isError, renderInput: (params) => (jsxRuntime.jsx(TextField, { ...params, label: props.label, error: !!error, helperText: error ? error.message : "", slotProps: {
|
|
26359
26397
|
input: {
|
|
26360
26398
|
...params.InputProps,
|
|
26361
|
-
endAdornment: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
26399
|
+
endAdornment: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isLoading || isFetching ? (jsxRuntime.jsx(material.CircularProgress, { color: "inherit", size: 20 })) : null, params.InputProps.endAdornment] })),
|
|
26362
26400
|
},
|
|
26363
26401
|
} })), ...props.fieldProps, renderOption: (props, option, { selected }) => {
|
|
26364
26402
|
const { key, ...optionProps } = props;
|
|
@@ -26366,7 +26404,7 @@ const ControlledSelect = (props) => {
|
|
|
26366
26404
|
} }));
|
|
26367
26405
|
} }));
|
|
26368
26406
|
};
|
|
26369
|
-
ControlledSelect.displayName =
|
|
26407
|
+
ControlledSelect.displayName = "ControlledSelect";
|
|
26370
26408
|
|
|
26371
26409
|
// ==============================|| DESLIZADOR CONTROLADO ||============================== //
|
|
26372
26410
|
const ControlledSlider$1 = (props) => {
|
|
@@ -26399,19 +26437,27 @@ const ControlledText = (props) => {
|
|
|
26399
26437
|
};
|
|
26400
26438
|
return (
|
|
26401
26439
|
// controlador
|
|
26402
|
-
jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { onChange, value }, fieldState: { error }
|
|
26440
|
+
jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
26403
26441
|
return (
|
|
26404
26442
|
// campo de texto
|
|
26405
|
-
jsxRuntime.jsx(TextField, { variant:
|
|
26443
|
+
jsxRuntime.jsx(TextField, { variant: "outlined", size: "small", id: props.name, label: props.label, value: value ? value.toString() : "", onChange: onChange, error: !!error, type: props.extraProps?.password
|
|
26444
|
+
? showPassword
|
|
26445
|
+
? "text"
|
|
26446
|
+
: "password"
|
|
26447
|
+
: "text", helperText: error
|
|
26448
|
+
? error.message
|
|
26449
|
+
: props.fieldProps?.helperText
|
|
26450
|
+
? props.fieldProps.helperText
|
|
26451
|
+
: " ", fullWidth: true, slotProps: {
|
|
26406
26452
|
input: {
|
|
26407
26453
|
// ícono de mostar u ocultar si es campo de contarseña
|
|
26408
|
-
endAdornment: props.extraProps?.password && (jsxRuntime.jsx(material.InputAdornment, { position:
|
|
26409
|
-
color:
|
|
26410
|
-
|
|
26411
|
-
color:
|
|
26412
|
-
}
|
|
26413
|
-
}, children: showPassword ? jsxRuntime.jsx(iconsMaterial.Visibility, {}) : jsxRuntime.jsx(iconsMaterial.VisibilityOff, {}) }) }))
|
|
26414
|
-
}
|
|
26454
|
+
endAdornment: props.extraProps?.password && (jsxRuntime.jsx(material.InputAdornment, { position: "end", children: jsxRuntime.jsx(material.IconButton, { "aria-label": "toggle password visibility", tabIndex: -1, onClick: handleShowPassword, edge: "end", size: "large", sx: {
|
|
26455
|
+
color: "secondary.darker",
|
|
26456
|
+
"&:hover": {
|
|
26457
|
+
color: "secondary.main",
|
|
26458
|
+
},
|
|
26459
|
+
}, children: showPassword ? jsxRuntime.jsx(iconsMaterial.Visibility, {}) : jsxRuntime.jsx(iconsMaterial.VisibilityOff, {}) }) })),
|
|
26460
|
+
},
|
|
26415
26461
|
}, ...props.fieldProps }));
|
|
26416
26462
|
} }));
|
|
26417
26463
|
};
|
|
@@ -26471,16 +26517,15 @@ const ControlledTimePicker = (props) => {
|
|
|
26471
26517
|
const filedProps = React.useMemo(() => {
|
|
26472
26518
|
const defaultProps = {
|
|
26473
26519
|
slotProps: {
|
|
26474
|
-
textField: { size:
|
|
26475
|
-
field: { clearable: true
|
|
26476
|
-
}
|
|
26520
|
+
textField: { size: "small" },
|
|
26521
|
+
field: { clearable: true },
|
|
26522
|
+
},
|
|
26477
26523
|
};
|
|
26478
26524
|
return merge$1({}, defaultProps, props.fieldProps);
|
|
26479
26525
|
}, [props.fieldProps]);
|
|
26480
|
-
return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { onChange, value }, fieldState: { error }
|
|
26481
|
-
const val = convertValueToDayjs(value,
|
|
26482
|
-
return (jsxRuntime.jsxs(material.FormGroup, { sx: { width: 1 }, color:
|
|
26483
|
-
jsxRuntime.jsx(material.FormHelperText, { error: !!error, children: error ? error.message : ' ' })] }));
|
|
26526
|
+
return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.name, control: props.control, render: ({ field: { onChange, value }, fieldState: { error } }) => {
|
|
26527
|
+
const val = convertValueToDayjs(value, "time");
|
|
26528
|
+
return (jsxRuntime.jsxs(material.FormGroup, { sx: { width: 1 }, color: "secondary", children: [jsxRuntime.jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: jsxRuntime.jsx(TimePicker, { label: props.label, onChange: (v) => handleChange(v, "time", onChange), value: val || null, ...filedProps }) }), !props.extraProps?.disableHT && (jsxRuntime.jsx(material.FormHelperText, { error: !!error, children: error ? error.message : " " }))] }));
|
|
26484
26529
|
} }));
|
|
26485
26530
|
};
|
|
26486
26531
|
|
|
@@ -26500,22 +26545,23 @@ const ControlledSlider = (props) => {
|
|
|
26500
26545
|
|
|
26501
26546
|
const DeleteConfirmationDialog = (props) => {
|
|
26502
26547
|
const notifications = core.useNotifications();
|
|
26503
|
-
const pathname =
|
|
26504
|
-
const id = React.useMemo(() => props.id || pathname.split(
|
|
26548
|
+
const pathname = "temp";
|
|
26549
|
+
const id = React.useMemo(() => props.id || pathname.split("/").at(-1), [pathname, props.id]);
|
|
26505
26550
|
const [mutation] = props.mutation();
|
|
26506
26551
|
const schema = zod.object({ confirmation: zod.string() });
|
|
26507
26552
|
const form = reactHookForm.useForm({
|
|
26508
26553
|
resolver: zod$1.zodResolver(schema),
|
|
26509
|
-
defaultValues: { confirmation:
|
|
26554
|
+
defaultValues: { confirmation: "" },
|
|
26510
26555
|
});
|
|
26511
26556
|
const handleClose = () => {
|
|
26512
26557
|
props.handleClose();
|
|
26513
26558
|
form.reset();
|
|
26514
26559
|
};
|
|
26515
|
-
const confirmation = form.watch(
|
|
26516
|
-
const disabled = React.useMemo(() => confirmation !=
|
|
26560
|
+
const confirmation = form.watch("confirmation").toUpperCase();
|
|
26561
|
+
const disabled = React.useMemo(() => confirmation != "ELIMINAR", [confirmation]);
|
|
26517
26562
|
const onSubmitHandler = () => {
|
|
26518
|
-
mutation({ id: id })
|
|
26563
|
+
mutation({ id: id })
|
|
26564
|
+
.unwrap()
|
|
26519
26565
|
.then(() => {
|
|
26520
26566
|
if (props.disableNavBack) {
|
|
26521
26567
|
handleClose();
|
|
@@ -26524,25 +26570,25 @@ const DeleteConfirmationDialog = (props) => {
|
|
|
26524
26570
|
// props.navigate(-1);
|
|
26525
26571
|
form.reset();
|
|
26526
26572
|
}
|
|
26527
|
-
notifications.show(
|
|
26573
|
+
notifications.show("Objeto removido exitosamente!", { severity: "success" });
|
|
26528
26574
|
})
|
|
26529
26575
|
.catch((error) => {
|
|
26530
26576
|
console.log(error);
|
|
26531
|
-
notifications.show(
|
|
26577
|
+
notifications.show("Error", { severity: "error" });
|
|
26532
26578
|
});
|
|
26533
26579
|
};
|
|
26534
26580
|
const handleKeyDown = (event) => {
|
|
26535
|
-
if (event.key ===
|
|
26581
|
+
if (event.key === "Enter" && !disabled)
|
|
26536
26582
|
onSubmitHandler();
|
|
26537
26583
|
};
|
|
26538
|
-
return (jsxRuntime.jsxs(material.Dialog, { open: props.open, onClose: handleClose, children: [jsxRuntime.jsx(material.DialogTitle, { variant:
|
|
26584
|
+
return (jsxRuntime.jsxs(material.Dialog, { open: props.open, onClose: handleClose, children: [jsxRuntime.jsx(material.DialogTitle, { variant: "h5", children: "Eliminar" }), jsxRuntime.jsxs(material.DialogContent, { children: [jsxRuntime.jsx(material.DialogContentText, { sx: { pb: 2 }, children: "\u00BFEst\u00E1 seguro que quiere eliminar el objeto?" }), jsxRuntime.jsx(material.Box, { id: "eliminar-formulario", width: "100%", position: "relative", children: jsxRuntime.jsx(ControlledText, { name: "confirmation", control: form.control, fieldProps: {
|
|
26539
26585
|
autoFocus: true,
|
|
26540
26586
|
required: true,
|
|
26541
|
-
margin:
|
|
26587
|
+
margin: "dense",
|
|
26542
26588
|
label: "Escribir 'ELIMINAR' para confirmar.",
|
|
26543
26589
|
fullWidth: true,
|
|
26544
|
-
variant:
|
|
26545
|
-
helperText:
|
|
26590
|
+
variant: "standard",
|
|
26591
|
+
helperText: "",
|
|
26546
26592
|
onKeyDown: handleKeyDown,
|
|
26547
26593
|
} }) })] }), jsxRuntime.jsxs(material.DialogActions, { children: [jsxRuntime.jsx(material.Button, { onClick: handleClose, children: "Cancelar" }), jsxRuntime.jsx(material.Button, { onClick: onSubmitHandler, disabled: disabled, children: "Eliminar" })] })] }));
|
|
26548
26594
|
};
|
|
@@ -26557,23 +26603,23 @@ const DeleteButton = (props) => {
|
|
|
26557
26603
|
};
|
|
26558
26604
|
// ===== || KEYDOWN || ===== //
|
|
26559
26605
|
const handleKeyPress = React.useCallback((event) => {
|
|
26560
|
-
if (event.ctrlKey && event.key ===
|
|
26606
|
+
if (event.ctrlKey && event.key === "d") {
|
|
26561
26607
|
event.preventDefault();
|
|
26562
26608
|
handleClick();
|
|
26563
26609
|
}
|
|
26564
26610
|
}, [handleClick]);
|
|
26565
26611
|
React.useEffect(() => {
|
|
26566
|
-
document.addEventListener(
|
|
26612
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
26567
26613
|
return () => {
|
|
26568
|
-
document.removeEventListener(
|
|
26614
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
26569
26615
|
};
|
|
26570
26616
|
}, [handleKeyPress]);
|
|
26571
26617
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(NormalOrIcon, { buttonProps: {
|
|
26572
|
-
color:
|
|
26573
|
-
variant:
|
|
26618
|
+
color: "error",
|
|
26619
|
+
variant: "contained",
|
|
26574
26620
|
startIcon: jsxRuntime.jsx(DeleteIcon, {}),
|
|
26575
26621
|
onClick: handleClick,
|
|
26576
|
-
children:
|
|
26622
|
+
children: "Eliminar",
|
|
26577
26623
|
} }), jsxRuntime.jsx(DeleteConfirmationDialog, { open: open, handleClose: handleClose, ...props })] }));
|
|
26578
26624
|
};
|
|
26579
26625
|
|
|
@@ -26584,115 +26630,114 @@ const SaveCancelButton = (props) => {
|
|
|
26584
26630
|
};
|
|
26585
26631
|
// ===== || KEYDOWN || ===== //
|
|
26586
26632
|
const handleKeyPress = React.useCallback((event) => {
|
|
26587
|
-
if (event.key ===
|
|
26633
|
+
if (event.key === "Escape") {
|
|
26588
26634
|
event.preventDefault();
|
|
26589
26635
|
handleCancel();
|
|
26590
26636
|
}
|
|
26591
26637
|
}, [handleCancel]);
|
|
26592
26638
|
React.useEffect(() => {
|
|
26593
|
-
document.addEventListener(
|
|
26639
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
26594
26640
|
return () => {
|
|
26595
|
-
document.removeEventListener(
|
|
26641
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
26596
26642
|
};
|
|
26597
26643
|
}, [handleKeyPress]);
|
|
26598
26644
|
return (jsxRuntime.jsxs(material.ButtonGroup, { sx: {
|
|
26599
26645
|
maxHeight: 40,
|
|
26600
26646
|
}, ...props.slotProps?.buttonGroup, children: [jsxRuntime.jsx(NormalOrIcon, { buttonProps: {
|
|
26601
|
-
color:
|
|
26602
|
-
variant:
|
|
26647
|
+
color: "error",
|
|
26648
|
+
variant: "contained",
|
|
26603
26649
|
startIcon: jsxRuntime.jsx(CancelIcon, {}),
|
|
26604
26650
|
onClick: handleCancel,
|
|
26605
26651
|
sx: { height: 1 },
|
|
26606
|
-
children:
|
|
26607
|
-
...props.slotProps?.cancelBtn
|
|
26652
|
+
children: "Cancelar",
|
|
26653
|
+
...props.slotProps?.cancelBtn,
|
|
26608
26654
|
} }), jsxRuntime.jsx(NormalOrIcon, { buttonProps: {
|
|
26609
|
-
color:
|
|
26610
|
-
variant:
|
|
26655
|
+
color: "secondary",
|
|
26656
|
+
variant: "contained",
|
|
26611
26657
|
startIcon: jsxRuntime.jsx(SaveIcon, {}),
|
|
26612
|
-
type:
|
|
26613
|
-
form:
|
|
26658
|
+
type: "submit",
|
|
26659
|
+
form: "formulario",
|
|
26614
26660
|
sx: { height: 1 },
|
|
26615
|
-
children:
|
|
26616
|
-
...props.slotProps?.saveBtn
|
|
26661
|
+
children: "Guardar",
|
|
26662
|
+
...props.slotProps?.saveBtn,
|
|
26617
26663
|
} })] }));
|
|
26618
26664
|
};
|
|
26619
26665
|
|
|
26620
26666
|
const CreateButtonBase = (props) => {
|
|
26621
26667
|
// ===== || KEYDOWN || ===== //
|
|
26622
26668
|
const handleKeyPress = React.useCallback((event) => {
|
|
26623
|
-
if (event.ctrlKey && event.key ===
|
|
26669
|
+
if (event.ctrlKey && event.key === "e") {
|
|
26624
26670
|
event.preventDefault();
|
|
26625
26671
|
props.handleClick();
|
|
26626
26672
|
}
|
|
26627
26673
|
}, []);
|
|
26628
26674
|
React.useEffect(() => {
|
|
26629
|
-
document.addEventListener(
|
|
26675
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
26630
26676
|
return () => {
|
|
26631
|
-
document.removeEventListener(
|
|
26677
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
26632
26678
|
};
|
|
26633
26679
|
}, [handleKeyPress]);
|
|
26634
26680
|
return (jsxRuntime.jsx(NormalOrIcon, { buttonProps: {
|
|
26635
|
-
id:
|
|
26636
|
-
variant:
|
|
26637
|
-
color:
|
|
26681
|
+
id: "create-button",
|
|
26682
|
+
variant: "contained",
|
|
26683
|
+
color: "secondary",
|
|
26638
26684
|
startIcon: jsxRuntime.jsx(AddIcon, {}),
|
|
26639
26685
|
onClick: props.handleClick,
|
|
26640
|
-
|
|
26641
|
-
|
|
26642
|
-
|
|
26686
|
+
"aria-controls": props.open ? "create-menu" : undefined,
|
|
26687
|
+
"aria-haspopup": true,
|
|
26688
|
+
"aria-expanded": props.open ? "true" : undefined,
|
|
26643
26689
|
endIcon: jsxRuntime.jsx(KeyboardArrowDownIcon, {}),
|
|
26644
|
-
children:
|
|
26690
|
+
children: "Crear",
|
|
26645
26691
|
...props.buttonProps,
|
|
26646
26692
|
} }));
|
|
26647
26693
|
};
|
|
26648
26694
|
|
|
26649
26695
|
const MenuItemWithLoading = (props) => {
|
|
26650
26696
|
return (jsxRuntime.jsxs(MenuItem, { onClick: props.handleClick, sx: {
|
|
26651
|
-
position:
|
|
26652
|
-
}, disabled: props.disabled || props.isLoading, children: [props.children, props.isLoading &&
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
}, px: 2, children: jsxRuntime.jsx(LinearProgress, {}) })] }));
|
|
26697
|
+
position: "relative",
|
|
26698
|
+
}, disabled: props.disabled || props.isLoading, children: [props.children, props.isLoading && (jsxRuntime.jsx(material.Box, { position: "absolute", width: 1, top: "50%", left: "50%", sx: {
|
|
26699
|
+
transform: "translate(-50%, -50%)",
|
|
26700
|
+
}, px: 2, children: jsxRuntime.jsx(LinearProgress, {}) }))] }));
|
|
26656
26701
|
};
|
|
26657
26702
|
|
|
26658
26703
|
const StyledMenu = material.styled((props) => (jsxRuntime.jsx(material.Menu, { elevation: 0, anchorOrigin: {
|
|
26659
|
-
vertical:
|
|
26660
|
-
horizontal:
|
|
26704
|
+
vertical: "bottom",
|
|
26705
|
+
horizontal: "right",
|
|
26661
26706
|
}, transformOrigin: {
|
|
26662
|
-
vertical:
|
|
26663
|
-
horizontal:
|
|
26707
|
+
vertical: "top",
|
|
26708
|
+
horizontal: "right",
|
|
26664
26709
|
}, ...props })))(({ theme }) => ({
|
|
26665
|
-
|
|
26710
|
+
"& .MuiPaper-root": {
|
|
26666
26711
|
borderRadius: 6,
|
|
26667
26712
|
marginTop: theme.spacing(1),
|
|
26668
26713
|
minWidth: 180,
|
|
26669
|
-
color:
|
|
26670
|
-
|
|
26671
|
-
|
|
26672
|
-
|
|
26714
|
+
color: "rgb(55, 65, 81)",
|
|
26715
|
+
backgroundColor: theme.palette.primary.lighter,
|
|
26716
|
+
boxShadow: "rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px",
|
|
26717
|
+
"& .MuiMenu-list": {
|
|
26718
|
+
padding: "4px 0",
|
|
26673
26719
|
},
|
|
26674
|
-
|
|
26675
|
-
|
|
26676
|
-
|
|
26677
|
-
|
|
26678
|
-
|
|
26679
|
-
|
|
26680
|
-
|
|
26681
|
-
|
|
26720
|
+
"& .MuiMenuItem-root": {
|
|
26721
|
+
borderRadius: 12,
|
|
26722
|
+
"&:hover": {
|
|
26723
|
+
backgroundColor: theme.palette.primary.main,
|
|
26724
|
+
color: "white",
|
|
26725
|
+
"& .MuiSvgIcon-root": {
|
|
26726
|
+
color: "white",
|
|
26727
|
+
},
|
|
26682
26728
|
},
|
|
26683
26729
|
},
|
|
26684
|
-
...theme.applyStyles(
|
|
26730
|
+
...theme.applyStyles("dark", {
|
|
26685
26731
|
color: theme.palette.grey[300],
|
|
26686
26732
|
}),
|
|
26687
26733
|
},
|
|
26688
26734
|
}));
|
|
26689
26735
|
|
|
26690
26736
|
const CreateButtonWithMenuOptions = (props) => {
|
|
26691
|
-
// const permission = useHasPermission_v2(`${props.permission}.add`);
|
|
26692
26737
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
26693
26738
|
const open = Boolean(anchorEl);
|
|
26694
26739
|
const handleClick = () => {
|
|
26695
|
-
setAnchorEl(document.getElementById(
|
|
26740
|
+
setAnchorEl(document.getElementById("create-button"));
|
|
26696
26741
|
};
|
|
26697
26742
|
const handleClose = () => {
|
|
26698
26743
|
setAnchorEl(null);
|
|
@@ -26704,21 +26749,24 @@ const CreateButtonWithMenuOptions = (props) => {
|
|
|
26704
26749
|
const handleToggleClose = () => {
|
|
26705
26750
|
setCSV({ open: false });
|
|
26706
26751
|
};
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
|
|
26710
|
-
|
|
26711
|
-
|
|
26712
|
-
|
|
26713
|
-
|
|
26714
|
-
|
|
26715
|
-
|
|
26716
|
-
|
|
26717
|
-
|
|
26718
|
-
|
|
26719
|
-
|
|
26720
|
-
|
|
26721
|
-
|
|
26752
|
+
if (!props.permission)
|
|
26753
|
+
return null;
|
|
26754
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CreateButtonBase, { open: open, handleClick: handleClick }), jsxRuntime.jsxs(StyledMenu, { id: "create-menu", MenuListProps: {
|
|
26755
|
+
"aria-labelledby": "create-menu-button",
|
|
26756
|
+
}, anchorEl: anchorEl, open: open, onClose: handleClose, children: [props.csv_upload?.enable &&
|
|
26757
|
+
[
|
|
26758
|
+
{
|
|
26759
|
+
title: "CSV",
|
|
26760
|
+
endpoint: props.pathname,
|
|
26761
|
+
icon: AttachFileIcon,
|
|
26762
|
+
},
|
|
26763
|
+
...(props.csv_upload.extraOptions || []),
|
|
26764
|
+
].map((option, index) => {
|
|
26765
|
+
return (jsxRuntime.jsxs(MenuItem, { onClick: () => {
|
|
26766
|
+
handleToggleOpen(option);
|
|
26767
|
+
handleClose();
|
|
26768
|
+
}, disableRipple: true, children: [option.icon && (jsxRuntime.jsx(material.ListItemIcon, { children: jsxRuntime.jsx(AttachFileIcon, {}) })), option.title] }, index));
|
|
26769
|
+
}), jsxRuntime.jsx(MenuItem, { onClick: () => {
|
|
26722
26770
|
props.navigate(`crear`);
|
|
26723
26771
|
handleClose();
|
|
26724
26772
|
}, disableRipple: true, children: "Manual" })] }), props.csv_upload?.enable && (jsxRuntime.jsx(CSVUpload, { open: csv.open, drawerToggle: handleToggleClose, data: csv.data }))] }));
|
|
@@ -26731,12 +26779,12 @@ const ButtonWithDrawer = (props) => {
|
|
|
26731
26779
|
let setFunc = setInternalOpen;
|
|
26732
26780
|
if (props.setOpen)
|
|
26733
26781
|
setFunc = props.setOpen;
|
|
26734
|
-
setFunc(prevState => !prevState);
|
|
26782
|
+
setFunc((prevState) => !prevState);
|
|
26735
26783
|
};
|
|
26736
26784
|
const configuracionBase = {
|
|
26737
|
-
variant:
|
|
26785
|
+
variant: "contained",
|
|
26738
26786
|
fullWidth: true,
|
|
26739
|
-
color:
|
|
26787
|
+
color: "primary",
|
|
26740
26788
|
};
|
|
26741
26789
|
const renderButton = () => {
|
|
26742
26790
|
if (props.slots.button)
|
|
@@ -26745,7 +26793,10 @@ const ButtonWithDrawer = (props) => {
|
|
|
26745
26793
|
};
|
|
26746
26794
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderButton(), jsxRuntime.jsx(MainDrawer, { open: open, drawerToggle: handleClick, title: props.slots.drawer.title, slots: {
|
|
26747
26795
|
button: props.slots.drawer.button,
|
|
26748
|
-
}, children: props.slots.drawer.content({
|
|
26796
|
+
}, children: props.slots.drawer.content({
|
|
26797
|
+
...props.slotProps?.drawer?.content,
|
|
26798
|
+
handleClose: handleClick,
|
|
26799
|
+
}) })] }));
|
|
26749
26800
|
};
|
|
26750
26801
|
|
|
26751
26802
|
const StatusBadge = (props) => {
|
|
@@ -26934,16 +26985,16 @@ const UncontrolledText = (props) => {
|
|
|
26934
26985
|
const handleShowPassword = () => {
|
|
26935
26986
|
setShowPassword(!showPassword);
|
|
26936
26987
|
};
|
|
26937
|
-
return (jsxRuntime.jsx(TextField, { variant:
|
|
26988
|
+
return (jsxRuntime.jsx(TextField, { variant: "outlined", id: props.name, name: props.name, label: props.label, type: props.password ? (showPassword ? "text" : "password") : "text", helperText: props.textFieldProps?.helperText ? props.textFieldProps.helperText : " ", slotProps: {
|
|
26938
26989
|
input: {
|
|
26939
26990
|
// ícono de mostar u ocultar si es campo de contarseña
|
|
26940
|
-
endAdornment: props.password && (jsxRuntime.jsx(material.InputAdornment, { position:
|
|
26941
|
-
color:
|
|
26942
|
-
|
|
26943
|
-
color:
|
|
26944
|
-
}
|
|
26945
|
-
}, children: showPassword ? jsxRuntime.jsx(iconsMaterial.Visibility, {}) : jsxRuntime.jsx(iconsMaterial.VisibilityOff, {}) }) }))
|
|
26946
|
-
}
|
|
26991
|
+
endAdornment: props.password && (jsxRuntime.jsx(material.InputAdornment, { position: "end", children: jsxRuntime.jsx(material.IconButton, { "aria-label": "toggle password visibility", tabIndex: -1, onClick: handleShowPassword, edge: "end", size: "large", sx: {
|
|
26992
|
+
color: "secondary.darker",
|
|
26993
|
+
"&:hover": {
|
|
26994
|
+
color: "secondary.main",
|
|
26995
|
+
},
|
|
26996
|
+
}, children: showPassword ? jsxRuntime.jsx(iconsMaterial.Visibility, {}) : jsxRuntime.jsx(iconsMaterial.VisibilityOff, {}) }) })),
|
|
26997
|
+
},
|
|
26947
26998
|
}, ...props.textFieldProps }));
|
|
26948
26999
|
};
|
|
26949
27000
|
|
|
@@ -27015,9 +27066,8 @@ const generateSchema = (columns, columnsFilter, id) => {
|
|
|
27015
27066
|
};
|
|
27016
27067
|
|
|
27017
27068
|
const FiltersPopper = (props) => {
|
|
27018
|
-
|
|
27019
|
-
|
|
27020
|
-
const id = 1;
|
|
27069
|
+
const params = reactRouterDom.useLoaderData();
|
|
27070
|
+
const id = params?.id;
|
|
27021
27071
|
const columns = xDataGrid.useGridApiContext().current.getAllColumns();
|
|
27022
27072
|
const [schema, defaultValues] = React.useMemo(() => generateSchema(columns, props.columnsFilter, id), [columns, id, props.columnsFilter]);
|
|
27023
27073
|
const form = reactHookForm.useForm({
|
|
@@ -27027,14 +27077,16 @@ const FiltersPopper = (props) => {
|
|
|
27027
27077
|
const [dirty, setDirty] = React.useState(false);
|
|
27028
27078
|
React.useEffect(() => {
|
|
27029
27079
|
if (props.filters.filterModel.items) {
|
|
27030
|
-
if (!lodash.every(props.filters.filterModel.items, function (_value, key) {
|
|
27080
|
+
if (!lodash.every(props.filters.filterModel.items, function (_value, key) {
|
|
27081
|
+
return lodash.includes(props.protectFilters, key);
|
|
27082
|
+
})) {
|
|
27031
27083
|
setDirty(true);
|
|
27032
27084
|
}
|
|
27033
27085
|
form.reset(lodash.merge({}, defaultValues, props.filters.filterModel.items));
|
|
27034
27086
|
}
|
|
27035
27087
|
}, [defaultValues, props.filters.filterModel.items, form, props.protectFilters]);
|
|
27036
27088
|
const handleClose = (event) => {
|
|
27037
|
-
if (props.menuRef.current && event?.target.tagName ==
|
|
27089
|
+
if (props.menuRef.current && event?.target.tagName == "BODY")
|
|
27038
27090
|
return;
|
|
27039
27091
|
props.setOpen(false);
|
|
27040
27092
|
};
|
|
@@ -27042,9 +27094,9 @@ const FiltersPopper = (props) => {
|
|
|
27042
27094
|
setDirty(false);
|
|
27043
27095
|
props.filters.setFilterModel(immer.produce((draft) => {
|
|
27044
27096
|
lodash.forEach(props.filters.filterModel.items, function (_value, key) {
|
|
27045
|
-
if ([
|
|
27097
|
+
if (["ordering", "search"].concat(props.protectFilters || []).includes(key))
|
|
27046
27098
|
return;
|
|
27047
|
-
delete draft[
|
|
27099
|
+
delete draft["items"][key];
|
|
27048
27100
|
});
|
|
27049
27101
|
}));
|
|
27050
27102
|
form.reset(defaultValues);
|
|
@@ -27052,135 +27104,142 @@ const FiltersPopper = (props) => {
|
|
|
27052
27104
|
};
|
|
27053
27105
|
const onSubmitHandler = (submitData) => {
|
|
27054
27106
|
props.filters.setFilterModel(immer.produce((draft) => {
|
|
27055
|
-
draft[
|
|
27107
|
+
draft["items"] = { ...draft["items"], ...submitData };
|
|
27056
27108
|
}));
|
|
27057
27109
|
handleClose();
|
|
27058
27110
|
};
|
|
27059
27111
|
const onError = (errors) => {
|
|
27060
27112
|
console.log(errors);
|
|
27061
27113
|
};
|
|
27062
|
-
return (jsxRuntime.jsx(material.Box, { id:
|
|
27114
|
+
return (jsxRuntime.jsx(material.Box, { id: "filtros", children: jsxRuntime.jsx(material.Popper, { id: "filters-menu", open: props.open, anchorEl: props.menuRef.current, placement: "bottom-end", transition: true, sx: { zIndex: 1202 }, children: ({ TransitionProps }) => (jsxRuntime.jsx(material.Grow, { ...TransitionProps, timeout: 350, children: jsxRuntime.jsx(material.Paper, { elevation: 5, sx: { zIndex: 5 }, children: jsxRuntime.jsx(material.ClickAwayListener, { onClickAway: handleClose, children: jsxRuntime.jsxs(material.Grid, { size: 12, container: true, padding: 2, width: 350, maxWidth: "100%", children: [jsxRuntime.jsx(material.Grid, { size: 12, container: true, rowSpacing: 2, maxHeight: 300, overflow: "auto", children: columns.map((column, index) => {
|
|
27063
27115
|
if (column.input)
|
|
27064
|
-
return (jsxRuntime.jsxs(material.Grid, { size: 12, container: true, direction:
|
|
27065
|
-
|
|
27066
|
-
|
|
27116
|
+
return (jsxRuntime.jsxs(material.Grid, { size: 12, container: true, direction: "column", spacing: 0, children: [jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(material.Typography, { fontWeight: "bold", gutterBottom: true, children: column.filterName ||
|
|
27117
|
+
column.headerName }) }), jsxRuntime.jsx(material.Grid, { size: 12, children: React.Children.map(column.input, (child) => {
|
|
27118
|
+
let addedProps = {
|
|
27119
|
+
control: form.control,
|
|
27120
|
+
};
|
|
27121
|
+
if (column.type == "number") {
|
|
27067
27122
|
addedProps = {
|
|
27068
27123
|
...addedProps,
|
|
27069
27124
|
extraProps: {
|
|
27070
|
-
...child.props
|
|
27125
|
+
...child.props
|
|
27126
|
+
.extraProps,
|
|
27071
27127
|
getValue: form.getValues,
|
|
27072
27128
|
setValue: form.setValue,
|
|
27073
|
-
}
|
|
27129
|
+
},
|
|
27074
27130
|
};
|
|
27075
27131
|
}
|
|
27076
27132
|
return React.cloneElement(child, {
|
|
27077
27133
|
...child.props,
|
|
27078
|
-
...addedProps
|
|
27134
|
+
...addedProps,
|
|
27079
27135
|
});
|
|
27080
27136
|
}) })] }, index));
|
|
27081
27137
|
return null;
|
|
27082
|
-
}) }), jsxRuntime.jsx(material.Grid, { size: 12, py: 2, children: jsxRuntime.jsx(Divider, {}) }), jsxRuntime.jsxs(material.Grid, { size: 12, display:
|
|
27138
|
+
}) }), jsxRuntime.jsx(material.Grid, { size: 12, py: 2, children: jsxRuntime.jsx(Divider, {}) }), jsxRuntime.jsxs(material.Grid, { size: 12, display: "flex", justifyContent: "space-evenly", children: [jsxRuntime.jsx(material.Button, { disabled: (!form.formState.isDirty ||
|
|
27139
|
+
props.disableQuickSearch) &&
|
|
27140
|
+
!dirty, startIcon: jsxRuntime.jsx(ClearIcon$1, {}), variant: "outlined", onClick: handleClear, children: "Limpiar" }), jsxRuntime.jsx(material.Button, { loading: props.disableQuickSearch, disabled: !form.formState.isDirty, startIcon: jsxRuntime.jsx(FilterAltIcon, {}), variant: "outlined", onClick: form.handleSubmit(onSubmitHandler, onError), children: "Aplicar" })] })] }) }) }) })) }) }));
|
|
27083
27141
|
};
|
|
27084
27142
|
|
|
27085
27143
|
const FiltersButton = (props) => {
|
|
27086
27144
|
const [open, setOpen] = React.useState(false);
|
|
27087
27145
|
const menuRef = React.useRef(null);
|
|
27088
27146
|
const handleClick = () => {
|
|
27089
|
-
setOpen(prevState => !prevState);
|
|
27147
|
+
setOpen((prevState) => !prevState);
|
|
27090
27148
|
};
|
|
27091
27149
|
const filterCount = React.useMemo(() => {
|
|
27092
27150
|
return lodash.countBy(Object.entries(props.filters.filterModel.items), function (filter) {
|
|
27093
27151
|
const key = filter[0];
|
|
27094
27152
|
const value = filter[1];
|
|
27095
|
-
if (key ==
|
|
27153
|
+
if (key == "ordering" || key == "search")
|
|
27096
27154
|
return;
|
|
27097
|
-
if (props.protectFilters &&
|
|
27155
|
+
if (props.protectFilters &&
|
|
27156
|
+
lodash.findIndex(props.protectFilters, function (x) {
|
|
27157
|
+
return x == key;
|
|
27158
|
+
}) > -1)
|
|
27098
27159
|
return;
|
|
27099
27160
|
return (lodash.isNumber(value) && value > 0) || !lodash.isEmpty(value) || lodash.isBoolean(value);
|
|
27100
27161
|
}).true;
|
|
27101
|
-
}, [
|
|
27102
|
-
props.filters.filterModel.items, props.protectFilters
|
|
27103
|
-
]);
|
|
27162
|
+
}, [props.filters.filterModel.items, props.protectFilters]);
|
|
27104
27163
|
// ===== || ABRIR CON CTRL + Shift + F || ===== //
|
|
27105
27164
|
const handleKeyPress = React.useCallback((event) => {
|
|
27106
|
-
if (event.ctrlKey && event.shiftKey && event.key ===
|
|
27165
|
+
if (event.ctrlKey && event.shiftKey && event.key === "F") {
|
|
27107
27166
|
event.preventDefault();
|
|
27108
27167
|
setOpen(true);
|
|
27109
27168
|
}
|
|
27110
|
-
else if (event.key ===
|
|
27169
|
+
else if (event.key === "Escape" && open) {
|
|
27111
27170
|
setOpen(false);
|
|
27112
27171
|
}
|
|
27113
27172
|
}, [open]);
|
|
27114
27173
|
React.useEffect(() => {
|
|
27115
|
-
document.addEventListener(
|
|
27174
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
27116
27175
|
return () => {
|
|
27117
|
-
document.removeEventListener(
|
|
27176
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
27118
27177
|
};
|
|
27119
27178
|
}, [handleKeyPress]);
|
|
27120
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: "Filtros", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { ref: menuRef, id: "filters-menu-trigger", "aria-controls": "filters-menu", "aria-haspopup": "true", "aria-expanded": open ?
|
|
27121
|
-
if (key.key ==
|
|
27179
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: "Filtros", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { ref: menuRef, id: "filters-menu-trigger", "aria-controls": "filters-menu", "aria-haspopup": "true", "aria-expanded": open ? "true" : undefined, color: "default", onClick: handleClick, onKeyDown: (key) => {
|
|
27180
|
+
if (key.key == "Escape")
|
|
27122
27181
|
setOpen(false);
|
|
27123
|
-
}, className:
|
|
27182
|
+
}, className: "my-icon-button", children: jsxRuntime.jsx(material.Badge, { badgeContent: filterCount, color: "primary", children: jsxRuntime.jsx(FilterListIcon, { fontSize: "small" }) }) }) }), jsxRuntime.jsx(FiltersPopper, { ...props, menuRef: menuRef, open: open, setOpen: setOpen })] }));
|
|
27124
27183
|
};
|
|
27125
27184
|
|
|
27126
27185
|
const ExportCSV = (props) => {
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27186
|
+
const { pathname } = reactRouterDom.useLocation();
|
|
27187
|
+
const endpoint = props.slots?.endpoint || pathname;
|
|
27188
|
+
const notifications = core.useNotifications();
|
|
27189
|
+
const api = useAPI();
|
|
27190
|
+
const [descargarCSV, { isLoading }] = api.useLazyDescargarCSVQuery();
|
|
27131
27191
|
const handleClick = () => {
|
|
27132
27192
|
const extraItems = { variant: props.slots?.variant };
|
|
27133
27193
|
if (props.rowSelectionModel.ids.size > 0)
|
|
27134
|
-
extraItems[`${props.slots?.column_key ||
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
|
|
27146
|
-
|
|
27147
|
-
|
|
27148
|
-
|
|
27149
|
-
|
|
27150
|
-
|
|
27151
|
-
|
|
27152
|
-
|
|
27153
|
-
|
|
27154
|
-
|
|
27155
|
-
|
|
27194
|
+
extraItems[`${props.slots?.column_key || "id"}__in`] = Array.from(props.rowSelectionModel.ids).join(",");
|
|
27195
|
+
const filters = lodash.merge({}, lodash.omit(props.filterModel, lodash.map(props.ignore?.filters, function (filter) {
|
|
27196
|
+
return `items.${filter}`;
|
|
27197
|
+
}) || []), { items: extraItems });
|
|
27198
|
+
descargarCSV({
|
|
27199
|
+
endpoint: endpoint,
|
|
27200
|
+
filterModel: filters,
|
|
27201
|
+
sortModel: props.sortModel,
|
|
27202
|
+
ignoreSort: props.ignore?.sort,
|
|
27203
|
+
})
|
|
27204
|
+
.unwrap()
|
|
27205
|
+
.then((response) => {
|
|
27206
|
+
const file = document.createElement("a");
|
|
27207
|
+
file.href = response.file;
|
|
27208
|
+
file.download = response.filename;
|
|
27209
|
+
file.click();
|
|
27210
|
+
notifications.show("CSV descargado!", { severity: "success" });
|
|
27211
|
+
props.handleClick();
|
|
27212
|
+
})
|
|
27213
|
+
.catch((error) => {
|
|
27214
|
+
console.log(error);
|
|
27215
|
+
notifications.show("Error al descargar CSV.", { severity: "error" });
|
|
27216
|
+
});
|
|
27156
27217
|
};
|
|
27157
|
-
return (jsxRuntime.jsx(MenuItemWithLoading, { handleClick: handleClick, isLoading:
|
|
27218
|
+
return (jsxRuntime.jsx(MenuItemWithLoading, { handleClick: handleClick, isLoading: isLoading, disabled: props.disabledWithoutSelection && !props.rowSelectionModel.ids.size, children: props.slots?.title || "Descargar como CSV" }, "export-dg-csv"));
|
|
27158
27219
|
};
|
|
27159
27220
|
|
|
27160
27221
|
const ExportButton = (props) => {
|
|
27161
27222
|
const [exportMenuOpen, setExportMenuOpen] = React.useState(false);
|
|
27162
27223
|
const exportMenuTriggerRef = React.useRef(null);
|
|
27163
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Tooltip, { title: "Exportar", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { ref: exportMenuTriggerRef, id: "export-menu-trigger", "aria-controls": "export-menu", "aria-haspopup": "true", "aria-expanded": exportMenuOpen ?
|
|
27224
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Tooltip, { title: "Exportar", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { ref: exportMenuTriggerRef, id: "export-menu-trigger", "aria-controls": "export-menu", "aria-haspopup": "true", "aria-expanded": exportMenuOpen ? "true" : undefined, onClick: () => setExportMenuOpen(true), className: "my-icon-button", children: jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" }) }) }), jsxRuntime.jsxs(Menu, { id: "export-menu", anchorEl: exportMenuTriggerRef.current, open: exportMenuOpen, onClose: () => setExportMenuOpen(false), anchorOrigin: { vertical: "bottom", horizontal: "left" }, transformOrigin: { vertical: "top", horizontal: "left" }, slotProps: {
|
|
27164
27225
|
list: {
|
|
27165
|
-
|
|
27226
|
+
"aria-labelledby": "export-menu-trigger",
|
|
27166
27227
|
},
|
|
27167
|
-
}, children: [!props.csvProps?.hide &&
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
} }), props.extraOptions?.map(item => {
|
|
27228
|
+
}, children: [!props.csvProps?.hide && (jsxRuntime.jsx(ExportCSV, { handleClick: () => setExportMenuOpen(false), filterModel: props.filterModel, sortModel: props.sortModel, rowSelectionModel: props.rowSelectionModel, slots: {
|
|
27229
|
+
endpoint: props.csvProps?.endpoint,
|
|
27230
|
+
} })), props.extraOptions?.map((item) => {
|
|
27171
27231
|
const csvExport = item.props.csvExport;
|
|
27172
|
-
const remainingProps = lodash.omit(item.props,
|
|
27173
|
-
return
|
|
27232
|
+
const remainingProps = lodash.omit(item.props, "csvExport");
|
|
27233
|
+
return item.element({
|
|
27174
27234
|
handleClick: () => setExportMenuOpen(false),
|
|
27175
27235
|
filterModel: props.filterModel,
|
|
27176
27236
|
sortModel: props.sortModel,
|
|
27237
|
+
rowSelectionModel: props.rowSelectionModel,
|
|
27177
27238
|
csvExport: {
|
|
27178
|
-
rowSelectionModel: props.rowSelectionModel,
|
|
27179
27239
|
...csvExport,
|
|
27180
27240
|
},
|
|
27181
|
-
endpoint: props.csvProps?.endpoint,
|
|
27182
27241
|
...remainingProps,
|
|
27183
|
-
})
|
|
27242
|
+
});
|
|
27184
27243
|
})] })] }));
|
|
27185
27244
|
};
|
|
27186
27245
|
|
|
@@ -27188,34 +27247,33 @@ const ColumnsButton = () => {
|
|
|
27188
27247
|
const apiRef = xDataGrid.useGridApiContext();
|
|
27189
27248
|
const allCols = apiRef.current.getAllColumns().length;
|
|
27190
27249
|
const visibleCols = apiRef.current.getVisibleColumns().length;
|
|
27191
|
-
return (jsxRuntime.jsx(material.Tooltip, { title: "Columnas", children: jsxRuntime.jsx(xDataGrid.ColumnsPanelTrigger, { render: jsxRuntime.jsx(xDataGrid.ToolbarButton, { className:
|
|
27250
|
+
return (jsxRuntime.jsx(material.Tooltip, { title: "Columnas", children: jsxRuntime.jsx(xDataGrid.ColumnsPanelTrigger, { render: jsxRuntime.jsx(xDataGrid.ToolbarButton, { className: "my-icon-button" }), children: jsxRuntime.jsx(material.Badge, { color: "primary", variant: "dot", invisible: visibleCols >= allCols, children: jsxRuntime.jsx(ViewColumnIcon, { fontSize: "small" }) }) }) }));
|
|
27192
27251
|
};
|
|
27193
27252
|
|
|
27194
27253
|
const RefreshButton = (props) => {
|
|
27195
27254
|
// ===== || EJECUTAR CON CTRL + Shift + R || ===== //
|
|
27196
27255
|
const handleKeyPress = React.useCallback((event) => {
|
|
27197
|
-
if (event.ctrlKey && event.shiftKey && event.key ===
|
|
27256
|
+
if (event.ctrlKey && event.shiftKey && event.key === "R") {
|
|
27198
27257
|
event.preventDefault();
|
|
27199
27258
|
if (props.refetch)
|
|
27200
27259
|
props.refetch();
|
|
27201
27260
|
}
|
|
27202
27261
|
}, [props]);
|
|
27203
27262
|
React.useEffect(() => {
|
|
27204
|
-
document.addEventListener(
|
|
27263
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
27205
27264
|
return () => {
|
|
27206
|
-
document.removeEventListener(
|
|
27265
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
27207
27266
|
};
|
|
27208
27267
|
}, [handleKeyPress]);
|
|
27209
|
-
return (jsxRuntime.jsx(Tooltip, { title:
|
|
27268
|
+
return (jsxRuntime.jsx(Tooltip, { title: "Refrescar", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.refetch, children: jsxRuntime.jsx(RefreshIcon, { fontSize: "small" }) }) }));
|
|
27210
27269
|
};
|
|
27211
27270
|
|
|
27212
27271
|
const CustomToolbar = (props) => {
|
|
27213
27272
|
const [expanded, setExpanded] = React.useState(true);
|
|
27214
27273
|
return (jsxRuntime.jsx(xDataGrid.Toolbar, { style: {
|
|
27215
|
-
minHeight: expanded ?
|
|
27216
|
-
}, children: expanded ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Stack, { direction:
|
|
27217
|
-
jsxRuntime.jsxs(
|
|
27218
|
-
props.extraButtons.map((button, index) => (jsxRuntime.jsxs(material.Box, { display: 'flex', children: [jsxRuntime.jsx(material.Divider, { orientation: "vertical", variant: "middle", flexItem: true, sx: { mx: 0.5 } }), jsxRuntime.jsx(Tooltip, { title: button.label, children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: () => button.onClick(), className: 'my-icon-button', ...button.buttonProps, children: jsxRuntime.jsx(button.icon, { fontSize: "small" }) }) })] }, `toolbar-button-${index}`))), jsxRuntime.jsx(SelectedRowsButton, { selection: props.selection, extraActions: props.extraActions })] })] })) : (jsxRuntime.jsx(material.Box, { width: 1, display: 'flex', justifyContent: 'center', alignItems: 'center', children: jsxRuntime.jsx(material.IconButton, { onClick: () => setExpanded(true), children: jsxRuntime.jsx(ExpandMoreIcon, {}) }) })) }));
|
|
27274
|
+
minHeight: expanded ? "inherit" : "10px",
|
|
27275
|
+
}, children: expanded ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Stack, { direction: "row", width: 0.5, justifyContent: "left", children: [!props.buttons?.refresh?.hide && (jsxRuntime.jsx(RefreshButton, { refetch: props.buttons?.refresh?.refetch })), !(props.buttons?.refresh?.hide || props.buttons?.export?.hide) && (jsxRuntime.jsx(material.Divider, { orientation: "vertical", variant: "middle", flexItem: true, sx: { mx: 0.5 } })), !props.buttons?.export?.hide && (jsxRuntime.jsx(ExportButton, { filterModel: props.filters.filterModel, sortModel: props.sortModel, rowSelectionModel: props.selection, ...props.buttons.export }))] }), jsxRuntime.jsx(material.Box, { width: 1, display: "flex", justifyContent: "center", alignItems: "top", children: jsxRuntime.jsx(material.IconButton, { size: "small", onClick: () => setExpanded(false), children: jsxRuntime.jsx(ExpandLessIcon, {}) }) }), jsxRuntime.jsxs(material.Stack, { direction: "row", width: 0.5, justifyContent: "right", children: [jsxRuntime.jsx(ColumnsButton, {}), !props.buttons.filters?.hide && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Divider, { orientation: "vertical", variant: "middle", flexItem: true, sx: { mx: 0.5 } }), jsxRuntime.jsx(FiltersButton, { ...props })] })), jsxRuntime.jsx(material.Divider, { orientation: "vertical", variant: "middle", flexItem: true, sx: { mx: 0.5 } }), jsxRuntime.jsx(QuickSearch, { disableQuickSearch: props.disableQuickSearch, filters: props.filters }), props.extraButtons &&
|
|
27276
|
+
props.extraButtons.map((button, index) => (jsxRuntime.jsxs(material.Box, { display: "flex", children: [jsxRuntime.jsx(material.Divider, { orientation: "vertical", variant: "middle", flexItem: true, sx: { mx: 0.5 } }), jsxRuntime.jsx(Tooltip, { title: button.label, children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: () => button.onClick(), className: "my-icon-button", ...button.buttonProps, children: jsxRuntime.jsx(button.icon, { fontSize: "small" }) }) })] }, `toolbar-button-${index}`))), jsxRuntime.jsx(SelectedRowsButton, { selection: props.selection, extraActions: props.extraActions })] })] })) : (jsxRuntime.jsx(material.Box, { width: 1, display: "flex", justifyContent: "center", alignItems: "center", children: jsxRuntime.jsx(material.IconButton, { onClick: () => setExpanded(true), children: jsxRuntime.jsx(ExpandMoreIcon, {}) }) })) }));
|
|
27219
27277
|
};
|
|
27220
27278
|
|
|
27221
27279
|
const StyledGridOverlay = material.styled('div')(({ theme }) => ({
|
|
@@ -27253,20 +27311,22 @@ function CustomPagination() {
|
|
|
27253
27311
|
}
|
|
27254
27312
|
|
|
27255
27313
|
const DraggableRow = (params) => {
|
|
27256
|
-
const { attributes, listeners, setNodeRef, transform, transition
|
|
27314
|
+
const { attributes, listeners, setNodeRef, transform, transition } = sortable.useSortable({
|
|
27315
|
+
id: params.rowId.toString(),
|
|
27316
|
+
});
|
|
27257
27317
|
const style = {
|
|
27258
27318
|
transform: utilities.CSS.Transform.toString(transform),
|
|
27259
|
-
transition
|
|
27319
|
+
transition,
|
|
27260
27320
|
};
|
|
27261
|
-
return (jsxRuntime.jsxs(material.Box, { display:
|
|
27262
|
-
width:
|
|
27321
|
+
return (jsxRuntime.jsxs(material.Box, { display: "flex", ref: setNodeRef, style: style, children: [jsxRuntime.jsx(material.Box, { ...attributes, ...listeners, sx: {
|
|
27322
|
+
width: "20px",
|
|
27263
27323
|
height: params.rowHeight,
|
|
27264
|
-
background:
|
|
27265
|
-
borderTop:
|
|
27266
|
-
cursor:
|
|
27267
|
-
|
|
27268
|
-
cursor:
|
|
27269
|
-
}
|
|
27324
|
+
background: "repeating-linear-gradient( 45deg, #e0e0e0, #e0e0e0 5px, transparent 5px, transparent 10px)",
|
|
27325
|
+
borderTop: "1px solid rgba(224, 224, 224, 1)",
|
|
27326
|
+
cursor: "grab",
|
|
27327
|
+
"&:active": {
|
|
27328
|
+
cursor: "grabbing",
|
|
27329
|
+
},
|
|
27270
27330
|
} }), jsxRuntime.jsx(xDataGrid.GridRow, { ...params })] }));
|
|
27271
27331
|
};
|
|
27272
27332
|
|
|
@@ -27283,38 +27343,41 @@ const EditGridWrapper = (props) => {
|
|
|
27283
27343
|
const handleClickEdit = () => {
|
|
27284
27344
|
if (edit)
|
|
27285
27345
|
handleCancelarEdit();
|
|
27286
|
-
setEdit(prevState => !prevState);
|
|
27346
|
+
setEdit((prevState) => !prevState);
|
|
27287
27347
|
};
|
|
27288
27348
|
const processRowUpdate = async (newRow, originalRow) => {
|
|
27289
27349
|
const original_data = jsonForm({ submitData: originalRow });
|
|
27290
|
-
const data = jsonForm({
|
|
27350
|
+
const data = jsonForm({
|
|
27351
|
+
submitData: newRow,
|
|
27352
|
+
...(props.parser ? { props: props.parser } : []),
|
|
27353
|
+
});
|
|
27291
27354
|
if (lodash.isEqual(data, original_data))
|
|
27292
27355
|
return originalRow;
|
|
27293
27356
|
try {
|
|
27294
27357
|
const result = await editMutation(data).unwrap();
|
|
27295
|
-
setErrors(prevState => immer.produce(prevState, draft => {
|
|
27358
|
+
setErrors((prevState) => immer.produce(prevState, (draft) => {
|
|
27296
27359
|
delete draft[newRow.id];
|
|
27297
27360
|
}));
|
|
27298
27361
|
if (props?.postAction)
|
|
27299
27362
|
props.postAction(result);
|
|
27300
|
-
notifications.show(`Información actualizada!`, { severity:
|
|
27363
|
+
notifications.show(`Información actualizada!`, { severity: "success" });
|
|
27301
27364
|
return result.list;
|
|
27302
27365
|
}
|
|
27303
27366
|
catch (e) {
|
|
27304
|
-
setErrors(prevState => immer.produce(prevState, draft => {
|
|
27305
|
-
draft[newRow.id] = lodash.get(e,
|
|
27367
|
+
setErrors((prevState) => immer.produce(prevState, (draft) => {
|
|
27368
|
+
draft[newRow.id] = lodash.get(e, "data");
|
|
27306
27369
|
}));
|
|
27307
|
-
notifications.show(
|
|
27370
|
+
notifications.show("Error actualizando información!", { severity: "error" });
|
|
27308
27371
|
}
|
|
27309
27372
|
};
|
|
27310
27373
|
// ===== || KEYDOWN || ===== //
|
|
27311
27374
|
const handleKeyPress = React.useCallback((event) => {
|
|
27312
27375
|
if (props.permission) {
|
|
27313
|
-
if (event.ctrlKey && event.shiftKey && event.key ===
|
|
27376
|
+
if (event.ctrlKey && event.shiftKey && event.key === "E") {
|
|
27314
27377
|
event.preventDefault();
|
|
27315
27378
|
setEdit(true);
|
|
27316
27379
|
}
|
|
27317
|
-
else if (event.key ===
|
|
27380
|
+
else if (event.key === "Escape" && event.shiftKey && edit) {
|
|
27318
27381
|
event.preventDefault();
|
|
27319
27382
|
handleCancelarEdit();
|
|
27320
27383
|
setEdit(false);
|
|
@@ -27322,9 +27385,9 @@ const EditGridWrapper = (props) => {
|
|
|
27322
27385
|
}
|
|
27323
27386
|
}, [edit, props.permission]);
|
|
27324
27387
|
React.useEffect(() => {
|
|
27325
|
-
document.addEventListener(
|
|
27388
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
27326
27389
|
return () => {
|
|
27327
|
-
document.removeEventListener(
|
|
27390
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
27328
27391
|
};
|
|
27329
27392
|
}, [handleKeyPress]);
|
|
27330
27393
|
// ========================= || DRAG N DROP || ========================= //
|
|
@@ -27341,7 +27404,10 @@ const EditGridWrapper = (props) => {
|
|
|
27341
27404
|
if (over) {
|
|
27342
27405
|
const activeRow = rows.find((row) => row.id == active.id);
|
|
27343
27406
|
const overRow = rows.find((row) => row.id == over.id);
|
|
27344
|
-
const mutationArgs = {
|
|
27407
|
+
const mutationArgs = {
|
|
27408
|
+
...props.dnd?.args,
|
|
27409
|
+
id: activeRow.id,
|
|
27410
|
+
};
|
|
27345
27411
|
mutationArgs[field] = lodash.get(overRow, field);
|
|
27346
27412
|
editMutation(mutationArgs);
|
|
27347
27413
|
}
|
|
@@ -27359,33 +27425,37 @@ const EditGridWrapper = (props) => {
|
|
|
27359
27425
|
slotProps: {
|
|
27360
27426
|
toolbar: {
|
|
27361
27427
|
extraButtons: [
|
|
27362
|
-
...(props.permission && !props.disabled
|
|
27363
|
-
|
|
27364
|
-
|
|
27365
|
-
|
|
27366
|
-
|
|
27367
|
-
|
|
27368
|
-
|
|
27428
|
+
...(props.permission && !props.disabled
|
|
27429
|
+
? [
|
|
27430
|
+
{
|
|
27431
|
+
label: edit ? "Cancelar" : "Editar",
|
|
27432
|
+
icon: edit ? CancelIcon : EditIcon,
|
|
27433
|
+
onClick: handleClickEdit,
|
|
27434
|
+
},
|
|
27435
|
+
]
|
|
27436
|
+
: []),
|
|
27437
|
+
],
|
|
27438
|
+
},
|
|
27369
27439
|
},
|
|
27370
27440
|
onRowEditStart: ({ reason, row }, event) => {
|
|
27371
|
-
if (!lodash.get(row, `obj_permissions.edit`) ||
|
|
27441
|
+
if (!lodash.get(row, `obj_permissions.edit`) ||
|
|
27442
|
+
(reason === xDataGrid.GridRowEditStartReasons.cellDoubleClick && !edit)) {
|
|
27372
27443
|
event.defaultMuiPrevented = true;
|
|
27373
27444
|
}
|
|
27374
27445
|
},
|
|
27375
27446
|
// edit
|
|
27376
27447
|
checkboxSelection: !edit,
|
|
27377
27448
|
...(edit ? { onRowClick: undefined } : []),
|
|
27378
|
-
editMode:
|
|
27449
|
+
editMode: "row",
|
|
27379
27450
|
rowModesModel: rowModesModel,
|
|
27380
27451
|
onRowModesModelChange: setRowModesModel,
|
|
27381
27452
|
processRowUpdate: processRowUpdate,
|
|
27382
27453
|
loadingParams: [loadingMutation],
|
|
27383
27454
|
}, props.dataGridProps);
|
|
27384
|
-
const renderEditGrid = () => (jsxRuntime.jsx(core$1.DndContext, { sensors: sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, modifiers: [
|
|
27385
|
-
|
|
27386
|
-
|
|
27387
|
-
|
|
27388
|
-
], autoScroll: false, children: jsxRuntime.jsx(sortable.SortableContext, { items: rows ? rows.map((row) => row.id.toString()) : [], strategy: sortable.verticalListSortingStrategy, children: props.renderFunction({ ...props.renderFunctionProps, dataGridProps: editGridProps }) }) }));
|
|
27455
|
+
const renderEditGrid = () => (jsxRuntime.jsx(core$1.DndContext, { sensors: sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, modifiers: [modifiers.restrictToVerticalAxis, modifiers.restrictToWindowEdges, modifiers.restrictToParentElement], autoScroll: false, children: jsxRuntime.jsx(sortable.SortableContext, { items: rows ? rows.map((row) => row.id.toString()) : [], strategy: sortable.verticalListSortingStrategy, children: props.renderFunction({
|
|
27456
|
+
...props.renderFunctionProps,
|
|
27457
|
+
dataGridProps: editGridProps,
|
|
27458
|
+
}) }) }));
|
|
27389
27459
|
return renderEditGrid();
|
|
27390
27460
|
};
|
|
27391
27461
|
|
|
@@ -27406,43 +27476,47 @@ const editColumn = (props) => {
|
|
|
27406
27476
|
[id]: { mode: xDataGrid.GridRowModes.View, ignoreModifications: true },
|
|
27407
27477
|
});
|
|
27408
27478
|
};
|
|
27409
|
-
return [
|
|
27410
|
-
|
|
27411
|
-
|
|
27412
|
-
|
|
27479
|
+
return [
|
|
27480
|
+
{
|
|
27481
|
+
field: "edit",
|
|
27482
|
+
headerName: "Editar",
|
|
27483
|
+
type: "actions",
|
|
27413
27484
|
width: 80,
|
|
27414
|
-
cellClassName:
|
|
27485
|
+
cellClassName: "actions",
|
|
27415
27486
|
getActions: ({ id, row }) => {
|
|
27416
|
-
const canEdit = get(row,
|
|
27487
|
+
const canEdit = get(row, "obj_permissions.edit");
|
|
27417
27488
|
const isInEditMode = props.rowModesModel[id]?.mode === xDataGrid.GridRowModes.Edit;
|
|
27418
27489
|
if (isInEditMode) {
|
|
27419
27490
|
return [
|
|
27420
|
-
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(SaveIcon, {}), label:
|
|
27421
|
-
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(CancelIcon, {}), label:
|
|
27491
|
+
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(SaveIcon, {}), label: "Guardar", color: "primary", onClick: handleSaveClick(id) }, "save"),
|
|
27492
|
+
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(CancelIcon, {}), label: "Cancelar", className: "textPrimary", onClick: handleCancelClick(id), color: "inherit" }, "cancel"),
|
|
27422
27493
|
];
|
|
27423
27494
|
}
|
|
27424
27495
|
return [
|
|
27425
|
-
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(EditIcon, { sx: { color: canEdit ?
|
|
27496
|
+
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(EditIcon, { sx: { color: canEdit ? "black" : "inherit" } }), label: "Editar", className: "textPrimary", onClick: handleEditClick(id), disabled: !canEdit }, "edit"),
|
|
27426
27497
|
];
|
|
27427
|
-
}
|
|
27428
|
-
}
|
|
27498
|
+
},
|
|
27499
|
+
},
|
|
27500
|
+
];
|
|
27429
27501
|
};
|
|
27430
27502
|
|
|
27431
27503
|
const deleteColumn = (props) => {
|
|
27432
27504
|
if (!props.displayDelete)
|
|
27433
27505
|
return [];
|
|
27434
|
-
return [
|
|
27435
|
-
|
|
27436
|
-
|
|
27506
|
+
return [
|
|
27507
|
+
{
|
|
27508
|
+
field: "delete",
|
|
27509
|
+
headerName: "Eliminar",
|
|
27437
27510
|
width: 80,
|
|
27438
|
-
cellClassName:
|
|
27511
|
+
cellClassName: "actions",
|
|
27439
27512
|
renderCell: ({ id, row }) => {
|
|
27440
27513
|
const canDelete = get(row, `obj_permissions.delete`, false);
|
|
27441
27514
|
return [
|
|
27442
|
-
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(DeleteIcon, {}), label:
|
|
27515
|
+
jsxRuntime.jsx(xDataGrid.GridActionsCellItem, { icon: jsxRuntime.jsx(DeleteIcon, {}), label: "Eliminar", className: "textPrimary", onClick: props.handleOpen(id), color: "primary", disabled: !canDelete }, "delete"),
|
|
27443
27516
|
];
|
|
27444
|
-
}
|
|
27445
|
-
}
|
|
27517
|
+
},
|
|
27518
|
+
},
|
|
27519
|
+
];
|
|
27446
27520
|
};
|
|
27447
27521
|
|
|
27448
27522
|
const DeleteGridWrapper = (props) => {
|
|
@@ -27456,25 +27530,25 @@ const DeleteGridWrapper = (props) => {
|
|
|
27456
27530
|
setDeleteRowId(undefined);
|
|
27457
27531
|
};
|
|
27458
27532
|
const handleClickDelete = () => {
|
|
27459
|
-
setDeleting(prevState => !prevState);
|
|
27533
|
+
setDeleting((prevState) => !prevState);
|
|
27460
27534
|
};
|
|
27461
27535
|
// ===== || KEYDOWN || ===== //
|
|
27462
27536
|
const handleKeyPress = React.useCallback((event) => {
|
|
27463
27537
|
if (props.permission) {
|
|
27464
|
-
if (event.ctrlKey && event.shiftKey && event.key ===
|
|
27538
|
+
if (event.ctrlKey && event.shiftKey && event.key === "D") {
|
|
27465
27539
|
event.preventDefault();
|
|
27466
27540
|
setDeleting(true);
|
|
27467
27541
|
}
|
|
27468
|
-
else if (event.key ===
|
|
27542
|
+
else if (event.key === "Escape" && event.shiftKey && deleting) {
|
|
27469
27543
|
event.preventDefault();
|
|
27470
27544
|
setDeleting(false);
|
|
27471
27545
|
}
|
|
27472
27546
|
}
|
|
27473
27547
|
}, [props.permission, deleting]);
|
|
27474
27548
|
React.useEffect(() => {
|
|
27475
|
-
document.addEventListener(
|
|
27549
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
27476
27550
|
return () => {
|
|
27477
|
-
document.removeEventListener(
|
|
27551
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
27478
27552
|
};
|
|
27479
27553
|
}, [handleKeyPress]);
|
|
27480
27554
|
// ===== || GRID PROPS || ===== //
|
|
@@ -27488,20 +27562,23 @@ const DeleteGridWrapper = (props) => {
|
|
|
27488
27562
|
slotProps: {
|
|
27489
27563
|
toolbar: {
|
|
27490
27564
|
extraButtons: [
|
|
27491
|
-
...(props.permission
|
|
27492
|
-
|
|
27493
|
-
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
|
|
27565
|
+
...(props.permission
|
|
27566
|
+
? [
|
|
27567
|
+
{
|
|
27568
|
+
label: deleting ? "Cancelar" : "Eliminar",
|
|
27569
|
+
icon: deleting ? CancelIcon : DeleteIcon,
|
|
27570
|
+
onClick: handleClickDelete,
|
|
27571
|
+
},
|
|
27572
|
+
]
|
|
27573
|
+
: []),
|
|
27574
|
+
],
|
|
27575
|
+
},
|
|
27498
27576
|
},
|
|
27499
27577
|
// edit
|
|
27500
27578
|
checkboxSelection: !deleting,
|
|
27501
27579
|
...(deleting ? { onRowClick: undefined } : []),
|
|
27502
27580
|
}, props.dataGridProps);
|
|
27503
|
-
const renderDeleteGrid = () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.mutation &&
|
|
27504
|
-
jsxRuntime.jsx(DeleteConfirmationDialog, { mutation: props.mutation, open: !!deleteRowId, handleClose: handleClose, id: deleteRowId, disableNavBack: true }), props.renderFunction({ ...props.renderFunctionProps, dataGridProps: deleteGridProps })] }));
|
|
27581
|
+
const renderDeleteGrid = () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.mutation && (jsxRuntime.jsx(DeleteConfirmationDialog, { mutation: props.mutation, open: !!deleteRowId, handleClose: handleClose, id: deleteRowId, disableNavBack: true })), props.renderFunction({ ...props.renderFunctionProps, dataGridProps: deleteGridProps })] }));
|
|
27505
27582
|
return renderDeleteGrid();
|
|
27506
27583
|
};
|
|
27507
27584
|
|
|
@@ -27510,7 +27587,7 @@ const CreateGridWrapper = (props) => {
|
|
|
27510
27587
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
27511
27588
|
const open = Boolean(anchorEl);
|
|
27512
27589
|
const handleClick = () => {
|
|
27513
|
-
setAnchorEl(document.getElementById(
|
|
27590
|
+
setAnchorEl(document.getElementById("create-button"));
|
|
27514
27591
|
};
|
|
27515
27592
|
const handleClose = () => {
|
|
27516
27593
|
setAnchorEl(null);
|
|
@@ -27525,51 +27602,56 @@ const CreateGridWrapper = (props) => {
|
|
|
27525
27602
|
// ===== || KEYDOWN || ===== //
|
|
27526
27603
|
const handleKeyPress = React.useCallback((event) => {
|
|
27527
27604
|
if (props.permission) {
|
|
27528
|
-
if (event.ctrlKey && event.key ===
|
|
27605
|
+
if (event.ctrlKey && event.key === "e") {
|
|
27529
27606
|
event.preventDefault();
|
|
27530
27607
|
handleClick();
|
|
27531
27608
|
}
|
|
27532
27609
|
}
|
|
27533
27610
|
}, [props.permission]);
|
|
27534
27611
|
React.useEffect(() => {
|
|
27535
|
-
document.addEventListener(
|
|
27612
|
+
document.addEventListener("keydown", handleKeyPress);
|
|
27536
27613
|
return () => {
|
|
27537
|
-
document.removeEventListener(
|
|
27614
|
+
document.removeEventListener("keydown", handleKeyPress);
|
|
27538
27615
|
};
|
|
27539
27616
|
}, [handleKeyPress]);
|
|
27540
27617
|
const createGridProps = mergeSettings({
|
|
27541
27618
|
slotProps: {
|
|
27542
27619
|
toolbar: {
|
|
27543
27620
|
extraButtons: [
|
|
27544
|
-
...(props.permission
|
|
27545
|
-
|
|
27546
|
-
|
|
27547
|
-
|
|
27548
|
-
|
|
27549
|
-
|
|
27550
|
-
|
|
27551
|
-
|
|
27552
|
-
|
|
27553
|
-
|
|
27621
|
+
...(props.permission
|
|
27622
|
+
? [
|
|
27623
|
+
{
|
|
27624
|
+
label: "Crear",
|
|
27625
|
+
icon: AddIcon,
|
|
27626
|
+
onClick: handleClick,
|
|
27627
|
+
buttonProps: {
|
|
27628
|
+
id: "create-button",
|
|
27629
|
+
},
|
|
27630
|
+
},
|
|
27631
|
+
]
|
|
27632
|
+
: []),
|
|
27633
|
+
],
|
|
27634
|
+
},
|
|
27554
27635
|
},
|
|
27555
27636
|
}, props.dataGridProps);
|
|
27556
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(StyledMenu, { id:
|
|
27557
|
-
|
|
27558
|
-
}, anchorEl: anchorEl, open: open, onClose: handleClose, children: [props.csv_upload?.enable &&
|
|
27559
|
-
|
|
27560
|
-
|
|
27561
|
-
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
|
|
27566
|
-
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
27637
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(StyledMenu, { id: "create-menu", MenuListProps: {
|
|
27638
|
+
"aria-labelledby": "create-menu-button",
|
|
27639
|
+
}, anchorEl: anchorEl, open: open, onClose: handleClose, children: [props.csv_upload?.enable &&
|
|
27640
|
+
[
|
|
27641
|
+
{
|
|
27642
|
+
title: "CSV",
|
|
27643
|
+
endpoint: props.pathname,
|
|
27644
|
+
},
|
|
27645
|
+
...(props.csv_upload.extraOptions || []),
|
|
27646
|
+
].map((option, index) => {
|
|
27647
|
+
return (jsxRuntime.jsxs(MenuItem, { onClick: () => {
|
|
27648
|
+
handleToggleOpen(option);
|
|
27649
|
+
handleClose();
|
|
27650
|
+
}, disableRipple: true, children: [jsxRuntime.jsx(material.ListItemIcon, { children: jsxRuntime.jsx(AttachFileIcon, { sx: { transform: "rotate(90deg)" } }) }), option.title] }, index));
|
|
27651
|
+
}), jsxRuntime.jsxs(MenuItem, { onClick: () => {
|
|
27570
27652
|
navigate(props.navigation ? `${props.navigation}crear` : `crear`);
|
|
27571
27653
|
handleClose();
|
|
27572
|
-
}, disableRipple: true, children: "Manual" })] }), props.csv_upload?.enable && (jsxRuntime.jsx(CSVUpload, { open: csv.open, drawerToggle: handleToggleClose, data: csv.data })), props.renderFunction({ dataGridProps: createGridProps })] }));
|
|
27654
|
+
}, disableRipple: true, children: [jsxRuntime.jsx(material.ListItemIcon, { children: jsxRuntime.jsx(DrawIcon, {}) }), "Manual"] })] }), props.csv_upload?.enable && (jsxRuntime.jsx(CSVUpload, { open: csv.open, drawerToggle: handleToggleClose, data: csv.data })), props.renderFunction({ dataGridProps: createGridProps })] }));
|
|
27573
27655
|
};
|
|
27574
27656
|
|
|
27575
27657
|
const Base = (props) => {
|
|
@@ -27580,14 +27662,20 @@ const Base = (props) => {
|
|
|
27580
27662
|
setFilterModel: setFilterModel,
|
|
27581
27663
|
}));
|
|
27582
27664
|
// ========================= || PAGINADO || ========================= //
|
|
27583
|
-
const [paginationModel, setPaginationModel] = React.useState({
|
|
27665
|
+
const [paginationModel, setPaginationModel] = React.useState({
|
|
27666
|
+
page: 0,
|
|
27667
|
+
pageSize: 50,
|
|
27668
|
+
});
|
|
27584
27669
|
// ========================= || ORDENADO || ========================= //
|
|
27585
27670
|
const [sortModel, setSortModel] = React.useState([]);
|
|
27586
27671
|
// ========================= || FILTRADO || ========================= //
|
|
27587
|
-
const [filterModel, setFilterModel] = React.useState({
|
|
27672
|
+
const [filterModel, setFilterModel] = React.useState({
|
|
27673
|
+
items: {},
|
|
27674
|
+
quickFilterValues: "",
|
|
27675
|
+
});
|
|
27588
27676
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27589
27677
|
const setQuickSearchValue = React.useCallback(lodash.debounce((quickSearch) => {
|
|
27590
|
-
setFilterModel(prevState => ({ ...prevState, quickFilterValues: quickSearch }));
|
|
27678
|
+
setFilterModel((prevState) => ({ ...prevState, quickFilterValues: quickSearch }));
|
|
27591
27679
|
}, 500), []);
|
|
27592
27680
|
// ========================= || COLUMNAS || ========================= //
|
|
27593
27681
|
const getTogglableColumns = (columns) => {
|
|
@@ -27595,7 +27683,7 @@ const Base = (props) => {
|
|
|
27595
27683
|
return [];
|
|
27596
27684
|
return columns
|
|
27597
27685
|
.filter((column) => {
|
|
27598
|
-
return ![
|
|
27686
|
+
return !["__check__", "actions"].includes(column.field);
|
|
27599
27687
|
})
|
|
27600
27688
|
.map((column) => column.field);
|
|
27601
27689
|
};
|
|
@@ -27607,7 +27695,7 @@ const Base = (props) => {
|
|
|
27607
27695
|
// ========================= || LAZY QUERY || ========================= //
|
|
27608
27696
|
const [query, { data, isLoading, isFetching, isError, isUninitialized }] = props.api.data.query(props.api.data.options || {});
|
|
27609
27697
|
// ========================= || INITIAL STATE || ========================= //
|
|
27610
|
-
const localStoreName = React.useMemo(() => `${props.pathname}${props.slotProps?.tab ? `_${props.slotProps?.tab}` :
|
|
27698
|
+
const localStoreName = React.useMemo(() => `${props.pathname}${props.slotProps?.tab ? `_${props.slotProps?.tab}` : ""}_DG`, [props.pathname, props.slotProps?.tab]);
|
|
27611
27699
|
const internalFilterRef = React.useRef(filterModel);
|
|
27612
27700
|
const filterRef = props.slotProps?.filtersRef || internalFilterRef;
|
|
27613
27701
|
React.useEffect(() => {
|
|
@@ -27617,28 +27705,30 @@ const Base = (props) => {
|
|
|
27617
27705
|
const saveSnapshot = React.useCallback(() => {
|
|
27618
27706
|
if (apiRef?.current?.exportState && localStorage && !props.slotProps?.dontSaveState) {
|
|
27619
27707
|
const currentState = apiRef.current.exportState();
|
|
27620
|
-
lodash.set(currentState,
|
|
27708
|
+
lodash.set(currentState, "filters.filterModel", filterRef.current);
|
|
27621
27709
|
setWithExpiry(localStoreName, currentState, 86400000);
|
|
27622
27710
|
}
|
|
27623
27711
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27624
27712
|
}, [apiRef, props.pathname]);
|
|
27625
27713
|
React.useLayoutEffect(() => {
|
|
27626
27714
|
const stateFromLocalStorage = getWithExpiry(localStoreName);
|
|
27627
|
-
const init = stateFromLocalStorage
|
|
27628
|
-
|
|
27629
|
-
|
|
27630
|
-
const
|
|
27715
|
+
const init = stateFromLocalStorage
|
|
27716
|
+
? stateFromLocalStorage
|
|
27717
|
+
: lodash.get(props, "dataGridProps.initialState", {});
|
|
27718
|
+
const pagination = lodash.get(init, "pagination.paginationModel", paginationModel);
|
|
27719
|
+
const sorting = lodash.get(init, "sorting.sortModel", sortModel);
|
|
27720
|
+
const filters = lodash.get(init, "filters.filterModel", filterModel);
|
|
27631
27721
|
setPaginationModel(pagination);
|
|
27632
27722
|
setSortModel(sorting);
|
|
27633
27723
|
setFilterModel(filters);
|
|
27634
|
-
setColumnVisibilityModel(lodash.get(init,
|
|
27724
|
+
setColumnVisibilityModel(lodash.get(init, "columns.columnVisibilityModel", columnVisibilityModel));
|
|
27635
27725
|
// handle refresh and navigating away/refreshing
|
|
27636
|
-
window.addEventListener(
|
|
27726
|
+
window.addEventListener("beforeunload", saveSnapshot);
|
|
27637
27727
|
// console.log(getQueryArgs(pagination, sorting, filters, props.api.data.args))
|
|
27638
27728
|
query(getQueryArgs(pagination, sorting, filters, props.api.data.args));
|
|
27639
27729
|
return () => {
|
|
27640
27730
|
// in case of an SPA remove the event-listener
|
|
27641
|
-
window.removeEventListener(
|
|
27731
|
+
window.removeEventListener("beforeunload", saveSnapshot);
|
|
27642
27732
|
saveSnapshot();
|
|
27643
27733
|
};
|
|
27644
27734
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -27657,8 +27747,8 @@ const Base = (props) => {
|
|
|
27657
27747
|
};
|
|
27658
27748
|
// ========================= || SELECCIÓN || ========================= //
|
|
27659
27749
|
const [rowSelectionModel, setRowSelectionModel] = React.useState({
|
|
27660
|
-
type:
|
|
27661
|
-
ids: new Set()
|
|
27750
|
+
type: "include",
|
|
27751
|
+
ids: new Set(),
|
|
27662
27752
|
});
|
|
27663
27753
|
const handleRowSelectionModelChange = (newSelection) => {
|
|
27664
27754
|
setRowSelectionModel(newSelection);
|
|
@@ -27676,13 +27766,13 @@ const Base = (props) => {
|
|
|
27676
27766
|
const handleRowClick = ({ id }, event) => {
|
|
27677
27767
|
const link_to = `${props.slotProps?.navigation != undefined ? props.slotProps?.navigation : props.pathname}/${id}`;
|
|
27678
27768
|
if (event.ctrlKey) {
|
|
27679
|
-
const newTab = document.createElement(
|
|
27769
|
+
const newTab = document.createElement("a");
|
|
27680
27770
|
newTab.href = link_to;
|
|
27681
|
-
newTab.target =
|
|
27771
|
+
newTab.target = "_blank";
|
|
27682
27772
|
newTab.click();
|
|
27683
27773
|
}
|
|
27684
27774
|
else {
|
|
27685
|
-
navigate(`${props.slotProps?.navigation ? props.slotProps?.navigation : props.pathname}/${id}`);
|
|
27775
|
+
navigate(`${props.slotProps?.navigation || props.slotProps?.navigation === "" ? props.slotProps?.navigation : props.pathname}/${id}`);
|
|
27686
27776
|
}
|
|
27687
27777
|
};
|
|
27688
27778
|
const handleRowEditStop = (params, event) => {
|
|
@@ -27701,13 +27791,13 @@ const Base = (props) => {
|
|
|
27701
27791
|
},
|
|
27702
27792
|
slotProps: {
|
|
27703
27793
|
baseCheckbox: {
|
|
27704
|
-
size:
|
|
27794
|
+
size: "small",
|
|
27705
27795
|
},
|
|
27706
27796
|
toolbar: {
|
|
27707
27797
|
filters: {
|
|
27708
27798
|
filterModel: filterModel,
|
|
27709
27799
|
setFilterModel: setFilterModel,
|
|
27710
|
-
setQuickSearchValue: setQuickSearchValue
|
|
27800
|
+
setQuickSearchValue: setQuickSearchValue,
|
|
27711
27801
|
},
|
|
27712
27802
|
protectFilters: props.api.data.protectFilters,
|
|
27713
27803
|
columnsFilter: props.slotProps?.columnsFilter,
|
|
@@ -27718,27 +27808,27 @@ const Base = (props) => {
|
|
|
27718
27808
|
buttons: {
|
|
27719
27809
|
refresh: {
|
|
27720
27810
|
refetch: handleRefetch,
|
|
27721
|
-
}
|
|
27722
|
-
}
|
|
27811
|
+
},
|
|
27812
|
+
},
|
|
27723
27813
|
},
|
|
27724
27814
|
columnsManagement: {
|
|
27725
27815
|
getTogglableColumns: getTogglableColumns,
|
|
27726
27816
|
},
|
|
27727
27817
|
},
|
|
27728
27818
|
}, props.dataGridProps);
|
|
27729
|
-
const renderDataGrid = ({ dataGridProps: renderDataGridProps }) => {
|
|
27819
|
+
const renderDataGrid = ({ dataGridProps: renderDataGridProps, }) => {
|
|
27730
27820
|
// console.log(dataGridProps)
|
|
27731
27821
|
return (jsxRuntime.jsx(material.Box, { width: 1, minHeight: 300, height: 1,
|
|
27732
27822
|
// maxHeight={'calc(100% - 30px)'}
|
|
27733
|
-
display:
|
|
27823
|
+
display: "flex", flexDirection: "column", pb: 0, children: jsxRuntime.jsx(material.NoSsr, { children: jsxRuntime.jsx(xDataGrid.DataGrid, { apiRef: apiRef, rows: data?.results || [], loading: lodash.some(lodash.get(renderDataGridProps, "loadingParams", []), function (x) {
|
|
27734
27824
|
return x;
|
|
27735
27825
|
}),
|
|
27736
27826
|
// paginado //
|
|
27737
|
-
pagination: true, paginationMode:
|
|
27827
|
+
pagination: true, paginationMode: "server", paginationModel: paginationModel, onPaginationModelChange: setPaginationModel, pageSizeOptions: [50, 100, { value: -1, label: "Todos" }],
|
|
27738
27828
|
// ordenado
|
|
27739
|
-
sortingMode:
|
|
27829
|
+
sortingMode: "server", sortModel: sortModel, onSortModelChange: setSortModel,
|
|
27740
27830
|
// filtrado
|
|
27741
|
-
filterMode:
|
|
27831
|
+
filterMode: "server",
|
|
27742
27832
|
// onFilterModelChange={handleFilterChange}
|
|
27743
27833
|
disableColumnFilter: true, showToolbar: true,
|
|
27744
27834
|
// selection
|
|
@@ -27756,13 +27846,13 @@ const Base = (props) => {
|
|
|
27756
27846
|
// row count
|
|
27757
27847
|
rowCount: rowCount,
|
|
27758
27848
|
// settings
|
|
27759
|
-
density:
|
|
27849
|
+
density: "compact",
|
|
27760
27850
|
// striping
|
|
27761
|
-
getRowClassName: (params) => params.indexRelativeToCurrentPage % 2 === 0 ?
|
|
27762
|
-
columnHeaderSortIconLabel:
|
|
27763
|
-
columnMenuSortAsc:
|
|
27764
|
-
columnMenuSortDesc:
|
|
27765
|
-
columnMenuLabel:
|
|
27851
|
+
getRowClassName: (params) => params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd", localeText: {
|
|
27852
|
+
columnHeaderSortIconLabel: "Ordenar",
|
|
27853
|
+
columnMenuSortAsc: "Ordenar de menor a mayor",
|
|
27854
|
+
columnMenuSortDesc: "Ordenar de mayor a menor",
|
|
27855
|
+
columnMenuLabel: "Menú",
|
|
27766
27856
|
}, ...renderDataGridProps }) }) }));
|
|
27767
27857
|
};
|
|
27768
27858
|
// ========================= || RETURN || ========================= //
|
|
@@ -27776,7 +27866,7 @@ const Base = (props) => {
|
|
|
27776
27866
|
pathname: props.pathname,
|
|
27777
27867
|
navigation: props.slotProps?.navigation,
|
|
27778
27868
|
...renderProps,
|
|
27779
|
-
...props.api.create
|
|
27869
|
+
...props.api.create,
|
|
27780
27870
|
};
|
|
27781
27871
|
renderFunction = CreateGridWrapper;
|
|
27782
27872
|
}
|
|
@@ -27787,7 +27877,7 @@ const Base = (props) => {
|
|
|
27787
27877
|
renderFunctionProps: renderProps,
|
|
27788
27878
|
dataGridProps: dataGridProps,
|
|
27789
27879
|
baseGridRef: apiRef,
|
|
27790
|
-
...props.api.edit
|
|
27880
|
+
...props.api.edit,
|
|
27791
27881
|
};
|
|
27792
27882
|
renderFunction = EditGridWrapper;
|
|
27793
27883
|
}
|
|
@@ -27797,7 +27887,7 @@ const Base = (props) => {
|
|
|
27797
27887
|
renderFunction: renderFunction,
|
|
27798
27888
|
renderFunctionProps: renderProps,
|
|
27799
27889
|
dataGridProps: dataGridProps,
|
|
27800
|
-
...props.api.delete
|
|
27890
|
+
...props.api.delete,
|
|
27801
27891
|
});
|
|
27802
27892
|
}
|
|
27803
27893
|
return renderFunction(renderProps);
|
|
@@ -27818,13 +27908,13 @@ const ActiveCell = ({ value }) => {
|
|
|
27818
27908
|
}, [value]);
|
|
27819
27909
|
const renderIcon = React.useCallback(() => {
|
|
27820
27910
|
const iconProps = {
|
|
27821
|
-
size:
|
|
27911
|
+
size: "small",
|
|
27822
27912
|
sx: {
|
|
27823
27913
|
color: color[700],
|
|
27824
|
-
fontSize:
|
|
27914
|
+
fontSize: "30px",
|
|
27825
27915
|
stroke: color[700],
|
|
27826
|
-
strokeWidth: 1.5
|
|
27827
|
-
}
|
|
27916
|
+
strokeWidth: 1.5,
|
|
27917
|
+
},
|
|
27828
27918
|
};
|
|
27829
27919
|
switch (value) {
|
|
27830
27920
|
case true:
|
|
@@ -27835,7 +27925,7 @@ const ActiveCell = ({ value }) => {
|
|
|
27835
27925
|
return jsxRuntime.jsx(ErrorOutlineIcon, { ...iconProps });
|
|
27836
27926
|
}
|
|
27837
27927
|
}, [color, value]);
|
|
27838
|
-
return (jsxRuntime.jsx(material.Box, { px: 2, py: 0.5, display:
|
|
27928
|
+
return (jsxRuntime.jsx(material.Box, { px: 2, py: 0.5, display: "flex", alignItems: "center", justifyContent: "center", borderRadius: 2, borderColor: color[900], children: renderIcon() }));
|
|
27839
27929
|
};
|
|
27840
27930
|
|
|
27841
27931
|
const MyGridEditSingleSelect = (props) => {
|
|
@@ -27997,34 +28087,38 @@ const Field = (props) => {
|
|
|
27997
28087
|
return true;
|
|
27998
28088
|
}, [props.data, props.dependantOn]);
|
|
27999
28089
|
const renderField = React.useCallback(() => {
|
|
28000
|
-
if (!props.pageType || props.pageType ==
|
|
28090
|
+
if (!props.pageType || props.pageType == "list")
|
|
28001
28091
|
return;
|
|
28002
|
-
if (props.pageType ==
|
|
28092
|
+
if (props.pageType == "detail")
|
|
28003
28093
|
return jsxRuntime.jsx(DetailField, { ...props });
|
|
28004
28094
|
else
|
|
28005
28095
|
return jsxRuntime.jsx(EditField, { ...props });
|
|
28006
28096
|
}, [props]);
|
|
28007
28097
|
if (!show)
|
|
28008
28098
|
return;
|
|
28009
|
-
return (jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction:
|
|
28099
|
+
return (jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction: "column", ...props.gridProps, children: [jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(material.Typography, { variant: "body1", fontWeight: "bold", children: props.label }) }), jsxRuntime.jsx(material.Grid, { size: 12, children: renderField() })] }));
|
|
28010
28100
|
};
|
|
28011
28101
|
|
|
28012
28102
|
const EditToolbar = (props) => {
|
|
28013
|
-
return (jsxRuntime.jsxs(xDataGrid.Toolbar, { children: [props.pageType !=
|
|
28014
|
-
jsxRuntime.jsx(Tooltip, { title: 'Crear', children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.handleCreate, children: jsxRuntime.jsx(AddIcon, { fontSize: "small" }) }) }), !!props.selected &&
|
|
28015
|
-
jsxRuntime.jsx(Tooltip, { title: 'Borrar', children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.handleDelete, children: jsxRuntime.jsx(DeleteIcon, { fontSize: "small" }) }) })] }));
|
|
28103
|
+
return (jsxRuntime.jsxs(xDataGrid.Toolbar, { children: [props.pageType != "detail" && (jsxRuntime.jsx(Tooltip, { title: "Crear", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.handleCreate, children: jsxRuntime.jsx(AddIcon, { fontSize: "small" }) }) })), !!props.selected && (jsxRuntime.jsx(Tooltip, { title: "Borrar", children: jsxRuntime.jsx(xDataGrid.ToolbarButton, { onClick: props.handleDelete, children: jsxRuntime.jsx(DeleteIcon, { fontSize: "small" }) }) }))] }));
|
|
28016
28104
|
};
|
|
28017
28105
|
const FieldArrayField = (props) => {
|
|
28018
28106
|
const { fields, remove } = reactHookForm.useFieldArray({
|
|
28019
28107
|
control: props.form.control,
|
|
28020
28108
|
name: props.name,
|
|
28021
|
-
keyName:
|
|
28109
|
+
keyName: "_id",
|
|
28022
28110
|
});
|
|
28023
|
-
const [drawer, setDrawer] = React.useState({
|
|
28024
|
-
|
|
28025
|
-
|
|
28111
|
+
const [drawer, setDrawer] = React.useState({
|
|
28112
|
+
open: false,
|
|
28113
|
+
data: undefined,
|
|
28114
|
+
});
|
|
28115
|
+
const [rowSelectionModel, setRowSelectionModel] = React.useState({
|
|
28116
|
+
type: "include",
|
|
28117
|
+
ids: new Set(),
|
|
28118
|
+
});
|
|
28119
|
+
const getIndex = React.useCallback((id) => lodash.findIndex(fields, function (field) {
|
|
28026
28120
|
return field._id == id;
|
|
28027
|
-
})
|
|
28121
|
+
}), [fields]);
|
|
28028
28122
|
const handleCreate = () => {
|
|
28029
28123
|
setDrawer({ open: true, data: undefined });
|
|
28030
28124
|
};
|
|
@@ -28047,7 +28141,7 @@ const FieldArrayField = (props) => {
|
|
|
28047
28141
|
const handleRowClick = (e) => {
|
|
28048
28142
|
setDrawer({ open: true, data: e.row });
|
|
28049
28143
|
};
|
|
28050
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction:
|
|
28144
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Grid, { rowSpacing: 1, container: true, size: "grow", direction: "column", ...props.gridProps, children: [jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(material.Typography, { variant: "body1", fontWeight: "bold", children: props.label }) }), jsxRuntime.jsx(material.Grid, { size: 12, children: jsxRuntime.jsx(xDataGrid.DataGrid, { ...props.dataGridProps, rows: fields, checkboxSelection: props.pageType != "detail", onRowSelectionModelChange: (newRowSelectionModel) => {
|
|
28051
28145
|
setRowSelectionModel(newRowSelectionModel);
|
|
28052
28146
|
}, showToolbar: true, slots: { toolbar: EditToolbar }, slotProps: {
|
|
28053
28147
|
toolbar: {
|
|
@@ -28056,7 +28150,7 @@ const FieldArrayField = (props) => {
|
|
|
28056
28150
|
handleDelete: handleDelete,
|
|
28057
28151
|
pageType: props.pageType,
|
|
28058
28152
|
},
|
|
28059
|
-
}, disableRowSelectionOnClick: true, onRowClick: handleRowClick, getRowId: (row) => row._id }) })] }), jsxRuntime.jsx(MainDrawer, { open: drawer.open, drawerToggle: closeDrawer, title:
|
|
28153
|
+
}, disableRowSelectionOnClick: true, onRowClick: handleRowClick, getRowId: (row) => row._id }) })] }), jsxRuntime.jsx(MainDrawer, { open: drawer.open, drawerToggle: closeDrawer, title: "Cargo Adicional", children: jsxRuntime.jsx(material.Grid, { size: 12, container: true, children: props.fields.map((field) => {
|
|
28060
28154
|
const fieldName = `${props.name}.${getIndex(drawer.data?._id)}.${field.name}`;
|
|
28061
28155
|
return (jsxRuntime.jsx(Field, { ...field, form: props.form, name: fieldName, fieldData: lodash.get(drawer.data, field.name) }, fieldName));
|
|
28062
28156
|
}) }) })] }));
|
|
@@ -28154,10 +28248,10 @@ const Logo = () => {
|
|
|
28154
28248
|
// ==============================|| PESTAÑAS ||============================== //
|
|
28155
28249
|
/**
|
|
28156
28250
|
* Pestañas customizables
|
|
28157
|
-
**/
|
|
28251
|
+
**/
|
|
28158
28252
|
const Tabs = (props) => {
|
|
28159
28253
|
// valor inicial
|
|
28160
|
-
const [value, setValue] = React.useState(props.initialValue ||
|
|
28254
|
+
const [value, setValue] = React.useState(props.initialValue || "1");
|
|
28161
28255
|
// manejar cambio de pestaña
|
|
28162
28256
|
const handleChange = (_event, newValue) => {
|
|
28163
28257
|
setValue(newValue);
|
|
@@ -28165,29 +28259,33 @@ const Tabs = (props) => {
|
|
|
28165
28259
|
};
|
|
28166
28260
|
// hacer el render del contenido de la pestaña seleccionada
|
|
28167
28261
|
const renderTabs = () => {
|
|
28168
|
-
return
|
|
28262
|
+
return props.tabs.map((option) => {
|
|
28169
28263
|
const renderContent = () => {
|
|
28170
28264
|
return React.Children.map(option.children, (child) => {
|
|
28171
28265
|
const cloneProps = { ...child.props };
|
|
28172
|
-
lodash.set(cloneProps,
|
|
28173
|
-
lodash.set(cloneProps,
|
|
28266
|
+
lodash.set(cloneProps, "type", props.type);
|
|
28267
|
+
lodash.set(cloneProps, "slotProps.tab", option.value);
|
|
28174
28268
|
return React.cloneElement(child, cloneProps);
|
|
28175
28269
|
});
|
|
28176
28270
|
};
|
|
28177
28271
|
return (jsxRuntime.jsx(TabPanel, { value: option.value, sx: {
|
|
28178
|
-
pt: 2,
|
|
28272
|
+
pt: 2,
|
|
28273
|
+
pb: 0,
|
|
28274
|
+
px: 0,
|
|
28275
|
+
width: 1,
|
|
28276
|
+
height: 1,
|
|
28179
28277
|
}, children: renderContent() }, option.value));
|
|
28180
|
-
})
|
|
28278
|
+
});
|
|
28181
28279
|
};
|
|
28182
28280
|
return (
|
|
28183
28281
|
// contexto
|
|
28184
|
-
jsxRuntime.jsx(material.Box, { width: 1, height:
|
|
28185
|
-
minHeight: 40
|
|
28282
|
+
jsxRuntime.jsx(material.Box, { width: 1, height: "calc(100vh - 175px)", children: jsxRuntime.jsxs(TabContext, { value: value, children: [jsxRuntime.jsx(TabList, { onChange: handleChange, "aria-label": "create-work-order-tabs", variant: "scrollable", scrollButtons: "auto", sx: {
|
|
28283
|
+
minHeight: 40,
|
|
28186
28284
|
}, children: props.tabs.map((option) => {
|
|
28187
|
-
return (jsxRuntime.jsx(Tab, { label: option.label, icon: option.icon, iconPosition:
|
|
28188
|
-
color:
|
|
28285
|
+
return (jsxRuntime.jsx(Tab, { label: option.label, icon: option.icon, iconPosition: "start", value: option.value, sx: {
|
|
28286
|
+
color: "secondary.light",
|
|
28189
28287
|
py: 0,
|
|
28190
|
-
minHeight: 40
|
|
28288
|
+
minHeight: 40,
|
|
28191
28289
|
} }, option.value));
|
|
28192
28290
|
}) }), jsxRuntime.jsx(material.Box, { width: 1, height: 0.935, children: renderTabs() })] }) }));
|
|
28193
28291
|
};
|
|
@@ -28271,7 +28369,7 @@ function DetailPage(props) {
|
|
|
28271
28369
|
resolver: zod$1.zodResolver(props.edit.schema),
|
|
28272
28370
|
defaultValues: props.edit?.defaultValues,
|
|
28273
28371
|
});
|
|
28274
|
-
const { data, isLoading, isFetching, error: fetchError } = props.api.data.query(!props.api.data.skipToken ? props.api.data.args : query$1.skipToken);
|
|
28372
|
+
const { data, isLoading, isFetching, error: fetchError, } = props.api.data.query(!props.api.data.skipToken ? props.api.data.args : query$1.skipToken);
|
|
28275
28373
|
React.useEffect(() => {
|
|
28276
28374
|
if (data) {
|
|
28277
28375
|
// set form data based on query data
|
|
@@ -28279,7 +28377,7 @@ function DetailPage(props) {
|
|
|
28279
28377
|
if (props.slots?.title) {
|
|
28280
28378
|
const title = lodash.map(props.slots?.title, function (field) {
|
|
28281
28379
|
return lodash.get(data, field);
|
|
28282
|
-
}).join(
|
|
28380
|
+
}).join(" ");
|
|
28283
28381
|
if (title)
|
|
28284
28382
|
dispatch(changeTitle(title));
|
|
28285
28383
|
}
|
|
@@ -28290,60 +28388,64 @@ function DetailPage(props) {
|
|
|
28290
28388
|
form.reset();
|
|
28291
28389
|
navigate(-1);
|
|
28292
28390
|
};
|
|
28293
|
-
const canEdit = React.useMemo(() => lodash.get(data, `${props.slotProps?.permissionsPath ? `${props.slotProps?.permissionsPath}.` :
|
|
28294
|
-
const canDelete = React.useMemo(() => lodash.get(data, `${props.slotProps?.permissionsPath ? `${props.slotProps?.permissionsPath}.` :
|
|
28391
|
+
const canEdit = React.useMemo(() => lodash.get(data, `${props.slotProps?.permissionsPath ? `${props.slotProps?.permissionsPath}.` : ""}obj_permissions.edit`), [data, props.slotProps?.permissionsPath]);
|
|
28392
|
+
const canDelete = React.useMemo(() => lodash.get(data, `${props.slotProps?.permissionsPath ? `${props.slotProps?.permissionsPath}.` : ""}obj_permissions.delete`), [data, props.slotProps?.permissionsPath]);
|
|
28295
28393
|
// ==============================|| VALIDATION ||============================== //
|
|
28296
28394
|
useValidateFieldData(props, form);
|
|
28297
28395
|
// ==============================|| QUICK RETURN ||============================== //
|
|
28298
|
-
if ((!canEdit && props.pageType ==
|
|
28396
|
+
if ((!canEdit && props.pageType == "edit") || (fetchError && fetchError.originalStatus == 403))
|
|
28299
28397
|
return jsxRuntime.jsx(NotAllowed, {});
|
|
28300
28398
|
if (fetchError && fetchError.originalStatus == 404)
|
|
28301
28399
|
return jsxRuntime.jsx(NotFound, {});
|
|
28302
28400
|
// ==============================|| SUBMIT ||============================== //
|
|
28303
28401
|
const onSubmitHandler = (submitedData) => {
|
|
28304
|
-
const formData =
|
|
28402
|
+
const formData = "nativeEvent" in submitedData ? form.getValues() : submitedData;
|
|
28305
28403
|
const params = { submitData: formData, data: data, props: props.slotProps?.parser };
|
|
28306
28404
|
const dataToSend = props.edit.useFormData ? formDataForm(params) : jsonForm(params);
|
|
28307
|
-
mutation(props.edit.useFormData ? dataToSend : { ...dataToSend, ...props.api.mutate.args })
|
|
28405
|
+
mutation(props.edit.useFormData ? dataToSend : { ...dataToSend, ...props.api.mutate.args })
|
|
28406
|
+
.unwrap()
|
|
28308
28407
|
.then(() => {
|
|
28309
28408
|
if (!props.slotProps?.button?.save?.disableNavBack)
|
|
28310
28409
|
navigate(-1);
|
|
28311
28410
|
if (props.slotProps?.button?.save?.onClick)
|
|
28312
28411
|
props.slotProps?.button?.save?.onClick();
|
|
28313
28412
|
form.reset();
|
|
28314
|
-
notifications.show(`${capitalizedObject} ${props.pageType ==
|
|
28413
|
+
notifications.show(`${capitalizedObject} ${props.pageType == "edit" ? "actualizad@" : "cread@"}!`, { severity: "success" });
|
|
28315
28414
|
})
|
|
28316
28415
|
.catch((error) => {
|
|
28317
28416
|
if (error.status === 401) ;
|
|
28318
28417
|
if (error.status === 403) {
|
|
28319
|
-
notifications.show(error.data.detail, { severity:
|
|
28418
|
+
notifications.show(error.data.detail, { severity: "error" });
|
|
28320
28419
|
}
|
|
28321
28420
|
else {
|
|
28322
28421
|
console.log(error);
|
|
28323
28422
|
setErrors(form, error);
|
|
28324
|
-
notifications.show(
|
|
28325
|
-
error.data.detail.join(
|
|
28326
|
-
`Error ${props.pageType ==
|
|
28423
|
+
notifications.show(error.data.detail
|
|
28424
|
+
? error.data.detail.join(", ")
|
|
28425
|
+
: `Error ${props.pageType == "edit" ? "actualizando" : "creando"} ${props.object.name}!`, { severity: "error" });
|
|
28327
28426
|
}
|
|
28328
28427
|
});
|
|
28329
28428
|
};
|
|
28330
28429
|
// ==============================|| RENDER SECTIONS ||============================== //
|
|
28331
28430
|
const renderContent = () => {
|
|
28332
28431
|
let displayed_sections = -1;
|
|
28333
|
-
return (jsxRuntime.jsxs(material.Grid, { size: 12, container: true, direction:
|
|
28432
|
+
return (jsxRuntime.jsxs(material.Grid, { size: 12, container: true, direction: "column", position: "relative", pb: 2, children: [props.pageType == "detail" && data?.has_history && (jsxRuntime.jsx(HistorialDrawer, { ...props.slotProps?.historial })), props.sections.map((section, index) => {
|
|
28334
28433
|
if (!section.display)
|
|
28335
28434
|
return null;
|
|
28336
|
-
if (typeof section.display ==
|
|
28435
|
+
if (typeof section.display == "object") {
|
|
28337
28436
|
const validateAgainst = form.watch(section.display.field)?.toString();
|
|
28338
28437
|
if (!section.display.method(validateAgainst, section.display.value))
|
|
28339
28438
|
return null;
|
|
28340
28439
|
}
|
|
28341
28440
|
displayed_sections += 1;
|
|
28342
|
-
return (jsxRuntime.jsx(Section, { data: data, form: form, bgColor: displayed_sections % 2 == 1 ?
|
|
28441
|
+
return (jsxRuntime.jsx(Section, { data: data, form: form, bgColor: displayed_sections % 2 == 1 ? "white" : "#F7F7F7", pageType: props.pageType, ...section, first: displayed_sections == 0 }, index));
|
|
28343
28442
|
})] }));
|
|
28344
28443
|
};
|
|
28345
28444
|
const renderPostAction = () => {
|
|
28346
|
-
if (props.api.mutate.postAction &&
|
|
28445
|
+
if (props.api.mutate.postAction &&
|
|
28446
|
+
isSuccess &&
|
|
28447
|
+
"post_action" in mutationResponse &&
|
|
28448
|
+
mutationResponse["post_action"]["type"] === props.api.mutate.postAction.type) {
|
|
28347
28449
|
switch (props.api.mutate.postAction.after) {
|
|
28348
28450
|
// case 'create':
|
|
28349
28451
|
// if (props.pageType === 'create') return addPropsToNode(props.api.mutate.postAction.node, mutationResponse);
|
|
@@ -28352,37 +28454,44 @@ function DetailPage(props) {
|
|
|
28352
28454
|
// if (props.pageType === 'edit') return props.api.mutate.postAction.node;
|
|
28353
28455
|
// break;
|
|
28354
28456
|
default:
|
|
28355
|
-
return addPropsToNode(props.api.mutate.postAction.node, {
|
|
28457
|
+
return addPropsToNode(props.api.mutate.postAction.node, {
|
|
28458
|
+
parent: props.api.data.args["id"],
|
|
28459
|
+
...mutationResponse["post_action"],
|
|
28460
|
+
});
|
|
28356
28461
|
}
|
|
28357
28462
|
}
|
|
28358
28463
|
};
|
|
28359
|
-
const badgeInfo = lodash.get(data, props.slots?.badge ||
|
|
28464
|
+
const badgeInfo = lodash.get(data, props.slots?.badge || "");
|
|
28360
28465
|
const renderButton = () => {
|
|
28361
28466
|
if (props.slots?.button)
|
|
28362
28467
|
return props.slots?.button;
|
|
28363
|
-
if (props.pageType ==
|
|
28468
|
+
if (props.pageType == "detail") {
|
|
28364
28469
|
if (!canEdit && !canDelete)
|
|
28365
28470
|
return null;
|
|
28366
|
-
return (jsxRuntime.jsxs(material.Stack, { direction:
|
|
28471
|
+
return (jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 1, children: [canDelete && props.api.delete && (jsxRuntime.jsx(DeleteButton, { mutation: props.api.delete.mutation, disableNavBack: props.slotProps?.deleteButton?.disableNavBack })), canEdit && jsxRuntime.jsx(EditButton, {})] }));
|
|
28367
28472
|
}
|
|
28368
28473
|
else {
|
|
28369
28474
|
return (jsxRuntime.jsx(SaveCancelButton, { slotProps: {
|
|
28370
28475
|
saveBtn: {
|
|
28371
28476
|
loading: mutationIsLoading,
|
|
28372
28477
|
disabled: !form.formState.isDirty,
|
|
28373
|
-
...(props.slotProps?.button?.save?.type ==
|
|
28374
|
-
|
|
28375
|
-
|
|
28376
|
-
|
|
28478
|
+
...(props.slotProps?.button?.save?.type == "onClick"
|
|
28479
|
+
? {
|
|
28480
|
+
type: "button",
|
|
28481
|
+
onClick: onSubmitHandler,
|
|
28482
|
+
}
|
|
28483
|
+
: {}),
|
|
28377
28484
|
},
|
|
28378
|
-
...(props.slotProps?.button?.cancel
|
|
28379
|
-
|
|
28380
|
-
|
|
28485
|
+
...(props.slotProps?.button?.cancel
|
|
28486
|
+
? { cancelBtn: props.slotProps?.button?.cancel }
|
|
28487
|
+
: {
|
|
28488
|
+
cancelBtn: { onClick: handleCancel },
|
|
28489
|
+
}),
|
|
28381
28490
|
} }));
|
|
28382
28491
|
}
|
|
28383
28492
|
};
|
|
28384
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ContentLayout, { button: renderButton(), badge: props.pageType ==
|
|
28385
|
-
jsxRuntime.jsx(StatusBadge, { title: badgeInfo[
|
|
28493
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ContentLayout, { button: renderButton(), badge: props.pageType == "detail" &&
|
|
28494
|
+
badgeInfo && (jsxRuntime.jsx(StatusBadge, { title: badgeInfo["label"], severity: badgeInfo["value"] })), children: jsxRuntime.jsx(LoadingComponent, { height: 0.7, isLoading: isLoading || isFetching, children: jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx(material.Box, { id: "formulario", component: "form", autoComplete: "off", noValidate: true, onSubmit: form.handleSubmit(onSubmitHandler), width: "100%", position: "relative", children: renderContent() }) }) }) }), renderPostAction()] }));
|
|
28386
28495
|
}
|
|
28387
28496
|
|
|
28388
28497
|
const ListPage = (props) => {
|
|
@@ -28390,19 +28499,20 @@ const ListPage = (props) => {
|
|
|
28390
28499
|
};
|
|
28391
28500
|
|
|
28392
28501
|
function SlideTransition(props) {
|
|
28393
|
-
return jsxRuntime.jsx(material.Slide, { ...props, direction:
|
|
28502
|
+
return jsxRuntime.jsx(material.Slide, { ...props, direction: "left" });
|
|
28394
28503
|
}
|
|
28395
28504
|
const BaseProgressSnack = (props) => {
|
|
28396
|
-
|
|
28505
|
+
console.log(props);
|
|
28506
|
+
const dispatch = reactRedux.useDispatch();
|
|
28397
28507
|
const handleClose = (e) => {
|
|
28398
28508
|
if (e?.defaultMuiPrevented)
|
|
28399
28509
|
return;
|
|
28400
|
-
|
|
28510
|
+
dispatch(closeProgressSnack(props.id));
|
|
28401
28511
|
};
|
|
28402
|
-
const finished = React.useMemo(() => lodash.get(props.data,
|
|
28403
|
-
const error = React.useMemo(() => lodash.get(props.data,
|
|
28512
|
+
const finished = React.useMemo(() => lodash.get(props.data, "finished"), [props.data]);
|
|
28513
|
+
const error = React.useMemo(() => lodash.get(props.data, "error"), [props.data]);
|
|
28404
28514
|
const renderItem = React.useCallback(() => {
|
|
28405
|
-
return (jsxRuntime.jsx(material.Snackbar, { anchorOrigin: { vertical:
|
|
28515
|
+
return (jsxRuntime.jsx(material.Snackbar, { anchorOrigin: { vertical: "bottom", horizontal: "right" }, open: props.open, onClose: handleClose, slots: {
|
|
28406
28516
|
transition: SlideTransition,
|
|
28407
28517
|
}, slotProps: {
|
|
28408
28518
|
clickAwayListener: {
|
|
@@ -28410,27 +28520,27 @@ const BaseProgressSnack = (props) => {
|
|
|
28410
28520
|
event.defaultMuiPrevented = true;
|
|
28411
28521
|
},
|
|
28412
28522
|
},
|
|
28413
|
-
}, children: jsxRuntime.jsx(material.Badge, { invisible: props.index < 1, badgeContent: props.index + 1, color:
|
|
28414
|
-
bgcolor: props.data[
|
|
28523
|
+
}, children: jsxRuntime.jsx(material.Badge, { invisible: props.index < 1, badgeContent: props.index + 1, color: "primary", children: jsxRuntime.jsx(material.Paper, { elevation: 2, sx: {
|
|
28524
|
+
bgcolor: props.data["error"] ? "primary.main" : "secondary.dark",
|
|
28415
28525
|
minWidth: 300,
|
|
28416
|
-
maxWidth:
|
|
28526
|
+
maxWidth: "100vw",
|
|
28417
28527
|
p: 2,
|
|
28418
|
-
borderRadius:
|
|
28419
|
-
color:
|
|
28420
|
-
}, children: jsxRuntime.jsxs(material.Stack, { direction:
|
|
28421
|
-
color:
|
|
28422
|
-
|
|
28423
|
-
backgroundColor:
|
|
28528
|
+
borderRadius: "12px",
|
|
28529
|
+
color: "white",
|
|
28530
|
+
}, children: jsxRuntime.jsxs(material.Stack, { direction: "column", spacing: 1, children: [jsxRuntime.jsxs(material.Stack, { direction: "row", alignItems: "center", spacing: 1, justifyContent: "space-between", children: [jsxRuntime.jsx(material.Typography, { pr: 2, color: "inherit", children: props.data.title || "N/A" }), finished && !error && (jsxRuntime.jsx(material.Tooltip, { title: "Cerrar", placement: "bottom", children: jsxRuntime.jsx(material.IconButton, { color: "secondary", size: "small", onClick: handleClose, sx: {
|
|
28531
|
+
color: "inherit",
|
|
28532
|
+
"&:hover": {
|
|
28533
|
+
backgroundColor: "rgba(255, 255, 255, 0.2)",
|
|
28424
28534
|
},
|
|
28425
|
-
}, children: jsxRuntime.jsx(CloseIcon, { fontSize:
|
|
28535
|
+
}, children: jsxRuntime.jsx(CloseIcon, { fontSize: "small" }) }) }))] }), !finished && !error && props.content(props.data)] }) }) }) }));
|
|
28426
28536
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28427
28537
|
}, [finished, props]);
|
|
28428
28538
|
return renderItem();
|
|
28429
28539
|
};
|
|
28430
28540
|
|
|
28431
28541
|
const ObjectProgressStack = (props) => {
|
|
28432
|
-
const snacks = reactRedux.useSelector(state => lodash.get(state,
|
|
28433
|
-
return (jsxRuntime.jsx(material.Stack, { direction:
|
|
28542
|
+
const snacks = reactRedux.useSelector((state) => lodash.get(state, "snackProgress", {}));
|
|
28543
|
+
return (jsxRuntime.jsx(material.Stack, { direction: "column", spacing: 2, children: Object.keys(snacks).map((key, index) => {
|
|
28434
28544
|
return (jsxRuntime.jsx(BaseProgressSnack, { id: key, index: index, ...snacks[key], content: props.content }, key));
|
|
28435
28545
|
}) }));
|
|
28436
28546
|
};
|
|
@@ -28701,7 +28811,7 @@ exports.DeleteButton = DeleteButton;
|
|
|
28701
28811
|
exports.DeleteConfirmationDialog = DeleteConfirmationDialog;
|
|
28702
28812
|
exports.DetailPage = DetailPage;
|
|
28703
28813
|
exports.EditButton = EditButton;
|
|
28704
|
-
exports.
|
|
28814
|
+
exports.ExportCSV = ExportCSV;
|
|
28705
28815
|
exports.HistorialDrawer = HistorialDrawer;
|
|
28706
28816
|
exports.ListPage = ListPage;
|
|
28707
28817
|
exports.Loadable = Loadable;
|