frontend-plus-react 0.1.3 → 0.1.5
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/index.cjs +539 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -12
- package/dist/index.d.ts +16 -12
- package/dist/index.js +718 -627
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -622,7 +622,7 @@ var SnackbarAlert = _react2.default.forwardRef(function SnackbarAlert2(props, re
|
|
|
622
622
|
});
|
|
623
623
|
var SnackbarContext = _react.createContext.call(void 0, void 0);
|
|
624
624
|
var DEFAULT_SUCCESS_DURATION = 3e3;
|
|
625
|
-
var DEFAULT_ERROR_DURATION =
|
|
625
|
+
var DEFAULT_ERROR_DURATION = 1e4;
|
|
626
626
|
var SnackbarProvider = ({ children }) => {
|
|
627
627
|
const [snackbar, setSnackbar] = _react.useState.call(void 0, {
|
|
628
628
|
open: false,
|
|
@@ -757,9 +757,12 @@ var useApiCall = () => {
|
|
|
757
757
|
const { showSnackbar } = useSnackbar();
|
|
758
758
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
759
759
|
const [error, setError] = _react.useState.call(void 0, null);
|
|
760
|
-
const callApi = _react.useCallback.call(void 0, async (procedureName, params) => {
|
|
760
|
+
const callApi = _react.useCallback.call(void 0, async (procedureName, params, opts) => {
|
|
761
761
|
setLoading(true);
|
|
762
762
|
setError(null);
|
|
763
|
+
const defaultOpts = { ...{
|
|
764
|
+
reportOnSnackbar: true
|
|
765
|
+
}, ...opts };
|
|
763
766
|
try {
|
|
764
767
|
const result = await executeBackendProcedure(procedureName, params);
|
|
765
768
|
return result === null ? void 0 : result;
|
|
@@ -771,7 +774,9 @@ var useApiCall = () => {
|
|
|
771
774
|
} else if (err instanceof Error) {
|
|
772
775
|
snackbarMessage = err.message;
|
|
773
776
|
}
|
|
774
|
-
|
|
777
|
+
if (defaultOpts.reportOnSnackbar) {
|
|
778
|
+
showSnackbar(snackbarMessage, "error");
|
|
779
|
+
}
|
|
775
780
|
throw err;
|
|
776
781
|
} finally {
|
|
777
782
|
setLoading(false);
|
|
@@ -781,14 +786,6 @@ var useApiCall = () => {
|
|
|
781
786
|
};
|
|
782
787
|
|
|
783
788
|
// src/components/grid/GenericDataGrid.tsx
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
789
|
var _material = require('@mui/material');
|
|
793
790
|
|
|
794
791
|
// src/utils/functions.tsx
|
|
@@ -991,17 +988,44 @@ var useRedirectPath = () => {
|
|
|
991
988
|
var cambiarGuionesBajosPorEspacios = (texto) => texto.replace(/_/g, " ");
|
|
992
989
|
|
|
993
990
|
// src/components/grid/GenericDataGrid.tsx
|
|
994
|
-
var _Search = require('@mui/icons-material/Search'); var _Search2 = _interopRequireDefault(_Search);
|
|
995
|
-
var _SearchOff = require('@mui/icons-material/SearchOff'); var _SearchOff2 = _interopRequireDefault(_SearchOff);
|
|
996
991
|
var _Add = require('@mui/icons-material/Add'); var _Add2 = _interopRequireDefault(_Add);
|
|
997
|
-
var _Delete = require('@mui/icons-material/Delete'); var _Delete2 = _interopRequireDefault(_Delete);
|
|
998
992
|
|
|
999
|
-
// src/components/
|
|
993
|
+
// src/components/ConfirmDialog.tsx
|
|
994
|
+
var _Dialog = require('@mui/material/Dialog'); var _Dialog2 = _interopRequireDefault(_Dialog);
|
|
995
|
+
var _DialogTitle = require('@mui/material/DialogTitle'); var _DialogTitle2 = _interopRequireDefault(_DialogTitle);
|
|
996
|
+
var _DialogContent = require('@mui/material/DialogContent'); var _DialogContent2 = _interopRequireDefault(_DialogContent);
|
|
997
|
+
var _DialogContentText = require('@mui/material/DialogContentText'); var _DialogContentText2 = _interopRequireDefault(_DialogContentText);
|
|
998
|
+
var _DialogActions = require('@mui/material/DialogActions'); var _DialogActions2 = _interopRequireDefault(_DialogActions);
|
|
999
|
+
var _Button = require('@mui/material/Button'); var _Button2 = _interopRequireDefault(_Button);
|
|
1000
|
+
|
|
1001
|
+
var ConfirmDialog = ({ open, onClose, title, message }) => {
|
|
1002
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1003
|
+
_Dialog2.default,
|
|
1004
|
+
{
|
|
1005
|
+
open,
|
|
1006
|
+
onClose: () => onClose(false),
|
|
1007
|
+
"aria-labelledby": "confirm-dialog-title",
|
|
1008
|
+
"aria-describedby": "confirm-dialog-description",
|
|
1009
|
+
children: [
|
|
1010
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DialogTitle2.default, { id: "confirm-dialog-title", children: title }),
|
|
1011
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DialogContent2.default, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DialogContentText2.default, { id: "confirm-dialog-description", children: message }) }),
|
|
1012
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _DialogActions2.default, { children: [
|
|
1013
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Button2.default, { onClick: () => onClose(false), color: "primary", children: "Cancelar" }),
|
|
1014
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Button2.default, { onClick: () => onClose(true), color: "error", autoFocus: true, children: "Confirmar" })
|
|
1015
|
+
] })
|
|
1016
|
+
]
|
|
1017
|
+
}
|
|
1018
|
+
);
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
// src/components/grid/renderers/headerCellRenderers.tsx
|
|
1000
1022
|
|
|
1023
|
+
var _Search = require('@mui/icons-material/Search'); var _Search2 = _interopRequireDefault(_Search);
|
|
1024
|
+
var _SearchOff = require('@mui/icons-material/SearchOff'); var _SearchOff2 = _interopRequireDefault(_SearchOff);
|
|
1001
1025
|
|
|
1002
|
-
|
|
1026
|
+
var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
1003
1027
|
const { column } = props;
|
|
1004
|
-
const isPrimaryKey =
|
|
1028
|
+
const isPrimaryKey = fieldDef.isPk;
|
|
1005
1029
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1006
1030
|
_material.Box,
|
|
1007
1031
|
{
|
|
@@ -1029,63 +1053,19 @@ function PkHeaderRenderer(props) {
|
|
|
1029
1053
|
)
|
|
1030
1054
|
}
|
|
1031
1055
|
);
|
|
1032
|
-
}
|
|
1033
|
-
var PkHeaderRenderer_default = PkHeaderRenderer;
|
|
1034
|
-
|
|
1035
|
-
// src/components/grid/PkCellRenderer.tsx
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
function PkCellRenderer(props) {
|
|
1039
|
-
const { column, row } = props;
|
|
1040
|
-
const isPrimaryKey = column.isPK;
|
|
1041
|
-
const rowAsRecord = row;
|
|
1042
|
-
const value = rowAsRecord[column.key];
|
|
1043
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1044
|
-
_material.Typography,
|
|
1045
|
-
{
|
|
1046
|
-
variant: "body2",
|
|
1047
|
-
sx: {
|
|
1048
|
-
//fontWeight: isPrimaryKey ? 'bold' : 'normal',
|
|
1049
|
-
fontSize: "0.875rem",
|
|
1050
|
-
// Ajusta el tamaño si es necesario
|
|
1051
|
-
whiteSpace: "nowrap",
|
|
1052
|
-
overflow: "hidden",
|
|
1053
|
-
textOverflow: "ellipsis",
|
|
1054
|
-
width: "100%"
|
|
1055
|
-
},
|
|
1056
|
-
children: value === null || value === void 0 ? "" : String(value)
|
|
1057
|
-
}
|
|
1058
|
-
);
|
|
1059
|
-
}
|
|
1060
|
-
var PkCellRenderer_default = PkCellRenderer;
|
|
1061
|
-
|
|
1062
|
-
// src/components/ConfirmDialog.tsx
|
|
1063
|
-
var _Dialog = require('@mui/material/Dialog'); var _Dialog2 = _interopRequireDefault(_Dialog);
|
|
1064
|
-
var _DialogTitle = require('@mui/material/DialogTitle'); var _DialogTitle2 = _interopRequireDefault(_DialogTitle);
|
|
1065
|
-
var _DialogContent = require('@mui/material/DialogContent'); var _DialogContent2 = _interopRequireDefault(_DialogContent);
|
|
1066
|
-
var _DialogContentText = require('@mui/material/DialogContentText'); var _DialogContentText2 = _interopRequireDefault(_DialogContentText);
|
|
1067
|
-
var _DialogActions = require('@mui/material/DialogActions'); var _DialogActions2 = _interopRequireDefault(_DialogActions);
|
|
1068
|
-
var _Button = require('@mui/material/Button'); var _Button2 = _interopRequireDefault(_Button);
|
|
1069
|
-
|
|
1070
|
-
var ConfirmDialog = ({ open, onClose, title, message }) => {
|
|
1071
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1072
|
-
_Dialog2.default,
|
|
1073
|
-
{
|
|
1074
|
-
open,
|
|
1075
|
-
onClose: () => onClose(false),
|
|
1076
|
-
"aria-labelledby": "confirm-dialog-title",
|
|
1077
|
-
"aria-describedby": "confirm-dialog-description",
|
|
1078
|
-
children: [
|
|
1079
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DialogTitle2.default, { id: "confirm-dialog-title", children: title }),
|
|
1080
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DialogContent2.default, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _DialogContentText2.default, { id: "confirm-dialog-description", children: message }) }),
|
|
1081
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _DialogActions2.default, { children: [
|
|
1082
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Button2.default, { onClick: () => onClose(false), color: "primary", children: "Cancelar" }),
|
|
1083
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Button2.default, { onClick: () => onClose(true), color: "error", autoFocus: true, children: "Confirmar" })
|
|
1084
|
-
] })
|
|
1085
|
-
]
|
|
1086
|
-
}
|
|
1087
|
-
);
|
|
1088
1056
|
};
|
|
1057
|
+
var actionsColumnHeaderCellRenderer = (props, isFilterRowVisible, toggleFilterVisibility) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1058
|
+
_material.IconButton,
|
|
1059
|
+
{
|
|
1060
|
+
color: "inherit",
|
|
1061
|
+
onClick: toggleFilterVisibility,
|
|
1062
|
+
size: "small",
|
|
1063
|
+
title: isFilterRowVisible ? "Ocultar filtros" : "Mostrar filtros",
|
|
1064
|
+
sx: { p: 0.5 },
|
|
1065
|
+
children: isFilterRowVisible ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _SearchOff2.default, { sx: { fontSize: 20 } }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 20 } })
|
|
1066
|
+
}
|
|
1067
|
+
);
|
|
1068
|
+
var detailColumnCellHeaderRenderer = (props, detailTable) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: detailTable.label, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "caption", sx: { fontSize: "0.75rem", fontWeight: "bold" }, children: detailTable.abr.toUpperCase() }) });
|
|
1089
1069
|
|
|
1090
1070
|
// src/components/grid/FilterInputRender.tsx
|
|
1091
1071
|
|
|
@@ -1118,10 +1098,231 @@ function FilterInputRenderer({
|
|
|
1118
1098
|
}
|
|
1119
1099
|
var FilterInputRender_default = FilterInputRenderer;
|
|
1120
1100
|
|
|
1121
|
-
// src/components/grid/
|
|
1101
|
+
// src/components/grid/renderers/summaryCellRenderers.tsx
|
|
1102
|
+
|
|
1103
|
+
var defaultColumnSummaryCellRenderer = (props, fixedFields, isFilterRowVisible, filters, setFilters) => {
|
|
1104
|
+
const { column } = props;
|
|
1105
|
+
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _3 => _3.find, 'call', _4 => _4((f) => f.fieldName === column.key)]);
|
|
1106
|
+
if (fixedFieldEntry && fixedFieldEntry.until === void 0 || !isFilterRowVisible) return null;
|
|
1107
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1108
|
+
FilterInputRender_default,
|
|
1109
|
+
{
|
|
1110
|
+
column,
|
|
1111
|
+
filters,
|
|
1112
|
+
setFilters
|
|
1113
|
+
}
|
|
1114
|
+
);
|
|
1115
|
+
};
|
|
1116
|
+
var actionsColumnSummaryCellRenderer = (props) => null;
|
|
1117
|
+
var detailColumnCellSummaryRenderer = (props) => null;
|
|
1118
|
+
|
|
1119
|
+
// src/components/grid/renderers/cellRenderers.tsx
|
|
1120
|
+
|
|
1121
|
+
var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
|
|
1122
|
+
var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _KeyboardArrowUp2 = _interopRequireDefault(_KeyboardArrowUp);
|
|
1123
|
+
var _Delete = require('@mui/icons-material/Delete'); var _Delete2 = _interopRequireDefault(_Delete);
|
|
1124
|
+
|
|
1125
|
+
// src/components/grid/ExampleClientSideComponent.tsx
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
var ExampleClientSideComponent = ({ row, column, fieldDefinition }) => {
|
|
1129
|
+
const value = row[column.key];
|
|
1130
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: {
|
|
1131
|
+
padding: 0.5,
|
|
1132
|
+
width: "100%",
|
|
1133
|
+
height: "100%",
|
|
1134
|
+
display: "flex",
|
|
1135
|
+
alignItems: "center",
|
|
1136
|
+
backgroundColor: value === "Special" ? "lightblue" : "transparent"
|
|
1137
|
+
}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", sx: { fontWeight: "bold" }, children: value ? `CS: ${value}` : "N/A" }) });
|
|
1138
|
+
};
|
|
1139
|
+
var ExampleClientSideComponent_default = ExampleClientSideComponent;
|
|
1140
|
+
|
|
1141
|
+
// src/components/grid/FallbackClientSideRenderer.tsx
|
|
1142
|
+
|
|
1143
|
+
var _WarningAmber = require('@mui/icons-material/WarningAmber'); var _WarningAmber2 = _interopRequireDefault(_WarningAmber);
|
|
1144
|
+
|
|
1145
|
+
var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
1146
|
+
const clientSideName = _optionalChain([fieldDefinition, 'optionalAccess', _5 => _5.clientSide]) || "Desconocido";
|
|
1147
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: `Componente clientSide '${clientSideName}' no implementado. Mostrando valor por defecto.`, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1148
|
+
_material.Box,
|
|
1149
|
+
{
|
|
1150
|
+
sx: {
|
|
1151
|
+
display: "flex",
|
|
1152
|
+
alignItems: "center",
|
|
1153
|
+
justifyContent: "space-between",
|
|
1154
|
+
// Para espaciar el valor y el icono
|
|
1155
|
+
gap: 1,
|
|
1156
|
+
// Espacio entre elementos
|
|
1157
|
+
width: "100%",
|
|
1158
|
+
height: "100%",
|
|
1159
|
+
paddingLeft: "8px",
|
|
1160
|
+
backgroundColor: "rgba(255, 193, 7, 0.1)",
|
|
1161
|
+
// Amarillo claro para advertencia
|
|
1162
|
+
border: "1px dashed rgba(255, 193, 7, 0.5)",
|
|
1163
|
+
boxSizing: "border-box",
|
|
1164
|
+
overflow: "hidden"
|
|
1165
|
+
// Evita que el contenido se desborde
|
|
1166
|
+
},
|
|
1167
|
+
children: [
|
|
1168
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children: clientSideName + " not found" }),
|
|
1169
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1170
|
+
_WarningAmber2.default,
|
|
1171
|
+
{
|
|
1172
|
+
sx: {
|
|
1173
|
+
fontSize: 18,
|
|
1174
|
+
color: "warning.main",
|
|
1175
|
+
marginRight: "4px"
|
|
1176
|
+
// Pequeño margen a la derecha del icono
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
)
|
|
1180
|
+
]
|
|
1181
|
+
}
|
|
1182
|
+
) });
|
|
1183
|
+
};
|
|
1184
|
+
var FallbackClientSideRenderer_default = FallbackClientSideRenderer;
|
|
1185
|
+
|
|
1186
|
+
// src/components/grid/clientSides.ts
|
|
1187
|
+
var clientSides = {
|
|
1188
|
+
"ExampleClientSideComponent": ExampleClientSideComponent_default,
|
|
1189
|
+
// Aseguramos el tipo aquí también
|
|
1190
|
+
"FallbackClientSideRenderer": FallbackClientSideRenderer_default
|
|
1191
|
+
// Y aquí
|
|
1192
|
+
};
|
|
1193
|
+
var extendClientSides = (newRenderers) => {
|
|
1194
|
+
clientSides = exports.clientSides = { ...clientSides, ...newRenderers };
|
|
1195
|
+
console.log("clientSides extendidos:", clientSides);
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
// src/components/grid/renderers/cellRenderers.tsx
|
|
1199
|
+
|
|
1200
|
+
var allColumnsCellRenderer = (props) => {
|
|
1201
|
+
const theme = _material.useTheme.call(void 0, );
|
|
1202
|
+
const column = props.column;
|
|
1203
|
+
const { row, rowIdx } = props;
|
|
1204
|
+
if (row[DETAIL_ROW_INDICATOR]) {
|
|
1205
|
+
const detailTableAbr = row[DETAIL_ROW_INDICATOR];
|
|
1206
|
+
const detailColumn = column;
|
|
1207
|
+
if (column.customType === "detail" && detailColumn.detailTable.abr === detailTableAbr) {
|
|
1208
|
+
const detailTable = detailColumn.tableDefinition.detailTables.find((dt) => dt.abr === detailTableAbr);
|
|
1209
|
+
let fixedFields = [];
|
|
1210
|
+
detailTable.fields.forEach((field) => {
|
|
1211
|
+
if (typeof field === "string") {
|
|
1212
|
+
fixedFields.push({ fieldName: field, value: row[field] });
|
|
1213
|
+
} else {
|
|
1214
|
+
fixedFields.push({ fieldName: field.target, value: row[field.source] });
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1218
|
+
_material.Box,
|
|
1219
|
+
{
|
|
1220
|
+
sx: {
|
|
1221
|
+
// Se eliminó el padding para que la sub-grilla se extienda por completo
|
|
1222
|
+
minHeight: "200px",
|
|
1223
|
+
width: "100%",
|
|
1224
|
+
height: "100%",
|
|
1225
|
+
//display: 'flex',
|
|
1226
|
+
//flexDirection: 'column',
|
|
1227
|
+
boxSizing: "border-box"
|
|
1228
|
+
},
|
|
1229
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1230
|
+
onClick: (e) => e.stopPropagation(),
|
|
1231
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1232
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
1233
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GenericDataGrid_default, { tableName: detailTable.table, fixedFields })
|
|
1234
|
+
}
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
return void 0;
|
|
1238
|
+
}
|
|
1239
|
+
switch (column.customType) {
|
|
1240
|
+
case "default": {
|
|
1241
|
+
const defaultColumn = column;
|
|
1242
|
+
const { fieldDef, tableDefinition, primaryKey, cellFeedback, fixedFields, localCellChanges } = defaultColumn;
|
|
1243
|
+
const rowId = getPrimaryKeyValues(row, primaryKey);
|
|
1244
|
+
if (_optionalChain([fieldDef, 'optionalAccess', _6 => _6.clientSide])) {
|
|
1245
|
+
const ClientSideComponent = clientSides[fieldDef.clientSide];
|
|
1246
|
+
if (ClientSideComponent) {
|
|
1247
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientSideComponent, { ...props, fieldDefinition: fieldDef, tableDefinition, primaryKey });
|
|
1248
|
+
}
|
|
1249
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FallbackClientSideRenderer_default, { ...props, fieldDefinition: fieldDef, tableDefinition, primaryKey });
|
|
1250
|
+
}
|
|
1251
|
+
let cellBackgroundColor = "transparent";
|
|
1252
|
+
if (cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === props.column.key) {
|
|
1253
|
+
cellBackgroundColor = cellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1254
|
+
} else {
|
|
1255
|
+
const isNewRowLocalCheck = row[NEW_ROW_INDICATOR];
|
|
1256
|
+
const isMandatory = tableDefinition.primaryKey.includes(props.column.key) || _optionalChain([tableDefinition, 'access', _7 => _7.fields, 'access', _8 => _8.find, 'call', _9 => _9((f) => f.name === props.column.key), 'optionalAccess', _10 => _10.nullable]) === false;
|
|
1257
|
+
const hasValue = row[props.column.key] !== null && row[props.column.key] !== void 0 && String(row[props.column.key]).trim() !== "";
|
|
1258
|
+
const isFixedFieldCurrent = _optionalChain([fixedFields, 'optionalAccess', _11 => _11.some, 'call', _12 => _12((f) => f.fieldName === props.column.key)]);
|
|
1259
|
+
if (isFixedFieldCurrent) {
|
|
1260
|
+
cellBackgroundColor = theme.palette.action.selected;
|
|
1261
|
+
} else if (isNewRowLocalCheck && isMandatory && !hasValue || localCellChanges.has(rowId) && _optionalChain([localCellChanges, 'access', _13 => _13.get, 'call', _14 => _14(rowId), 'optionalAccess', _15 => _15.has, 'call', _16 => _16(props.column.key)])) {
|
|
1262
|
+
cellBackgroundColor = theme.palette.info.light;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
const value = row[props.column.key];
|
|
1266
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === props.column.key ? _optionalChain([cellFeedback, 'optionalAccess', _17 => _17.message]) : "", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", backgroundColor: cellBackgroundColor, transition: "background-color 0.3s ease-in-out", display: "flex", alignItems: "center", paddingLeft: "8px", boxSizing: "border-box" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", sx: { fontSize: "0.875rem", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", width: "100%" }, children: value === null || value === void 0 ? "" : String(value) }) }) });
|
|
1267
|
+
}
|
|
1268
|
+
case "detail": {
|
|
1269
|
+
const detailColumn = column;
|
|
1270
|
+
const { detailTable, primaryKey, tableData, setTableData, detailKey } = detailColumn;
|
|
1271
|
+
const isExpanded = tableData.some(
|
|
1272
|
+
(r) => r[DETAIL_ROW_INDICATOR] === detailTable.abr && getPrimaryKeyValues(r, primaryKey) === getPrimaryKeyValues({ ...row, [DETAIL_ROW_INDICATOR]: detailTable.abr }, primaryKey)
|
|
1273
|
+
);
|
|
1274
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: detailTable.label, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1275
|
+
_material.IconButton,
|
|
1276
|
+
{
|
|
1277
|
+
size: "small",
|
|
1278
|
+
onClick: (event) => {
|
|
1279
|
+
let rows = [...tableData];
|
|
1280
|
+
const rowId = getPrimaryKeyValues({ ...row, [DETAIL_ROW_INDICATOR]: detailTable.abr }, primaryKey);
|
|
1281
|
+
if (isExpanded) {
|
|
1282
|
+
setTableData(rows.filter(
|
|
1283
|
+
(r) => !(r[DETAIL_ROW_INDICATOR] === detailTable.abr && getPrimaryKeyValues(r, primaryKey) === rowId)
|
|
1284
|
+
));
|
|
1285
|
+
} else {
|
|
1286
|
+
const parentRowIndex = rowIdx;
|
|
1287
|
+
rows.splice(parentRowIndex + 1, 0, {
|
|
1288
|
+
...row,
|
|
1289
|
+
[DETAIL_ROW_INDICATOR]: detailTable.abr
|
|
1290
|
+
});
|
|
1291
|
+
setTableData(rows);
|
|
1292
|
+
}
|
|
1293
|
+
event.stopPropagation();
|
|
1294
|
+
},
|
|
1295
|
+
title: isExpanded ? "Contraer detalle" : "Expandir detalle",
|
|
1296
|
+
sx: { p: 0.5 },
|
|
1297
|
+
children: isExpanded ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowUp2.default, { sx: { fontSize: 20 } }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { sx: { fontSize: 20 } })
|
|
1298
|
+
}
|
|
1299
|
+
) }) });
|
|
1300
|
+
}
|
|
1301
|
+
case "action": {
|
|
1302
|
+
const actionColumn = column;
|
|
1303
|
+
const { tableDefinition, handleDeleteRow } = actionColumn;
|
|
1304
|
+
if (!_optionalChain([tableDefinition, 'access', _18 => _18.allow, 'optionalAccess', _19 => _19.delete])) return void 0;
|
|
1305
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Button, { variant: "outlined", color: "error", size: "small", onClick: () => handleDeleteRow(row), title: "Eliminar fila", sx: { minWidth: 35, height: 30, p: 0.5, "& .MuiButton-startIcon": { m: 0 } }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Delete2.default, { sx: { fontSize: 18 } }) }) });
|
|
1306
|
+
}
|
|
1307
|
+
default:
|
|
1308
|
+
return void 0;
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// src/components/grid/InputRenderer.tsx
|
|
1122
1313
|
|
|
1123
1314
|
var _InputBase = require('@mui/material/InputBase'); var _InputBase2 = _interopRequireDefault(_InputBase);
|
|
1124
1315
|
|
|
1316
|
+
|
|
1317
|
+
function findChangedValues(oldRowData, newRowData) {
|
|
1318
|
+
let changes = [];
|
|
1319
|
+
for (const key in newRowData) {
|
|
1320
|
+
if (Object.prototype.hasOwnProperty.call(oldRowData, key) && oldRowData[key] !== newRowData[key]) {
|
|
1321
|
+
changes.push(key);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
return changes;
|
|
1325
|
+
}
|
|
1125
1326
|
function InputRenderer({
|
|
1126
1327
|
column,
|
|
1127
1328
|
row,
|
|
@@ -1129,6 +1330,7 @@ function InputRenderer({
|
|
|
1129
1330
|
tableDefinition,
|
|
1130
1331
|
onRowChange,
|
|
1131
1332
|
onClose,
|
|
1333
|
+
cellFeedback,
|
|
1132
1334
|
setCellFeedback,
|
|
1133
1335
|
onEnterPress,
|
|
1134
1336
|
setTableData,
|
|
@@ -1138,9 +1340,15 @@ function InputRenderer({
|
|
|
1138
1340
|
}) {
|
|
1139
1341
|
const tableName = tableDefinition.tableName;
|
|
1140
1342
|
const [editingValue, setEditingValue] = _react.useState.call(void 0, row[column.key]);
|
|
1343
|
+
const theme = _material.useTheme.call(void 0, );
|
|
1141
1344
|
const { showSuccess, showError } = useSnackbar();
|
|
1345
|
+
const rowId = getPrimaryKeyValues(row, primaryKey);
|
|
1346
|
+
let cellBackgroundColor;
|
|
1347
|
+
if (cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === column.key) {
|
|
1348
|
+
cellBackgroundColor = cellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1349
|
+
}
|
|
1142
1350
|
const initialRowId = _react.useMemo.call(void 0, () => getPrimaryKeyValues(row, primaryKey), [row, primaryKey]);
|
|
1143
|
-
const { callApi
|
|
1351
|
+
const { callApi } = useApiCall();
|
|
1144
1352
|
const handleCommit = _react.useCallback.call(void 0, async (currentValue, closeEditor, focusNextCell) => {
|
|
1145
1353
|
const processedNewValue = typeof currentValue === "string" ? currentValue.trim() === "" ? null : currentValue.trim() : currentValue;
|
|
1146
1354
|
const potentialUpdatedRow = { ...row, [column.key]: processedNewValue };
|
|
@@ -1148,31 +1356,16 @@ function InputRenderer({
|
|
|
1148
1356
|
(key) => potentialUpdatedRow[key] !== void 0 && potentialUpdatedRow[key] !== null && String(potentialUpdatedRow[key]).trim() !== ""
|
|
1149
1357
|
);
|
|
1150
1358
|
const isNewRow = !arePKValuesFilled || potentialUpdatedRow[NEW_ROW_INDICATOR];
|
|
1151
|
-
const isMandatoryField = tableDefinition.primaryKey.includes(column.key) || _optionalChain([tableDefinition, 'access',
|
|
1359
|
+
const isMandatoryField = tableDefinition.primaryKey.includes(column.key) || _optionalChain([tableDefinition, 'access', _20 => _20.fields, 'access', _21 => _21.find, 'call', _22 => _22((f) => f.name === column.key), 'optionalAccess', _23 => _23.nullable]) === false;
|
|
1152
1360
|
const isMandatoryFieldEmpty = isNewRow && isMandatoryField && (processedNewValue === null || processedNewValue === void 0 || String(processedNewValue).trim() === "");
|
|
1153
1361
|
if (processedNewValue === row[column.key] && !isNewRow && !isMandatoryFieldEmpty) {
|
|
1154
1362
|
console.log("No se guard\xF3: el valor no cambi\xF3 (y no es una nueva fila o campo obligatorio vac\xEDo que se est\xE1 iniciando).");
|
|
1155
|
-
onClose(false, focusNextCell);
|
|
1156
|
-
setLocalCellChanges((prev) => {
|
|
1157
|
-
const newMap = new Map(prev);
|
|
1158
|
-
const columnKeys = newMap.get(initialRowId);
|
|
1159
|
-
if (columnKeys) {
|
|
1160
|
-
columnKeys.delete(column.key);
|
|
1161
|
-
if (columnKeys.size === 0) {
|
|
1162
|
-
newMap.delete(initialRowId);
|
|
1163
|
-
} else {
|
|
1164
|
-
newMap.set(initialRowId, columnKeys);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
return newMap;
|
|
1168
|
-
});
|
|
1169
1363
|
return;
|
|
1170
1364
|
}
|
|
1171
1365
|
const oldRowData = { ...row };
|
|
1172
1366
|
const primaryKeyValuesForBackend = tableDefinition.primaryKey.map((key) => potentialUpdatedRow[key]);
|
|
1173
1367
|
const currentRowIdBeforeUpdate = getPrimaryKeyValues(oldRowData, tableDefinition.primaryKey);
|
|
1174
1368
|
onRowChange({ ...row, [column.key]: processedNewValue }, true);
|
|
1175
|
-
onClose(true, focusNextCell);
|
|
1176
1369
|
if (isNewRow) {
|
|
1177
1370
|
const areAllMandatoryFieldsFilled = tableDefinition.fields.every((fieldDef) => {
|
|
1178
1371
|
const isMandatory = fieldDef.nullable === false || fieldDef.isPk;
|
|
@@ -1219,7 +1412,7 @@ function InputRenderer({
|
|
|
1219
1412
|
}
|
|
1220
1413
|
});
|
|
1221
1414
|
if (localCellChanges.has(initialRowId)) {
|
|
1222
|
-
_optionalChain([localCellChanges, 'access',
|
|
1415
|
+
_optionalChain([localCellChanges, 'access', _24 => _24.get, 'call', _25 => _25(initialRowId), 'optionalAccess', _26 => _26.forEach, 'call', _27 => _27((colKey) => {
|
|
1223
1416
|
if (!rowToSend.hasOwnProperty(colKey)) {
|
|
1224
1417
|
rowToSend[colKey] = potentialUpdatedRow[colKey];
|
|
1225
1418
|
}
|
|
@@ -1239,21 +1432,7 @@ function InputRenderer({
|
|
|
1239
1432
|
newRow: rowToSend,
|
|
1240
1433
|
oldRow: oldRowData,
|
|
1241
1434
|
status
|
|
1242
|
-
});
|
|
1243
|
-
setLocalCellChanges((prev) => {
|
|
1244
|
-
const newMap = new Map(prev);
|
|
1245
|
-
const columnKeys = newMap.get(initialRowId);
|
|
1246
|
-
if (columnKeys) {
|
|
1247
|
-
columnKeys.delete(column.key);
|
|
1248
|
-
if (columnKeys.size === 0) {
|
|
1249
|
-
newMap.delete(initialRowId);
|
|
1250
|
-
} else {
|
|
1251
|
-
newMap.set(initialRowId, columnKeys);
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
return newMap;
|
|
1255
|
-
});
|
|
1256
|
-
showSuccess("Registro guardado exitosamente!");
|
|
1435
|
+
}, { reportOnSnackbar: false });
|
|
1257
1436
|
let finalRowIdForFeedback;
|
|
1258
1437
|
let persistedRowData;
|
|
1259
1438
|
if (response.row && isNewRow) {
|
|
@@ -1276,15 +1455,18 @@ function InputRenderer({
|
|
|
1276
1455
|
});
|
|
1277
1456
|
finalRowIdForFeedback = getPrimaryKeyValues(persistedRowData, tableDefinition.primaryKey);
|
|
1278
1457
|
} else {
|
|
1279
|
-
persistedRowData =
|
|
1458
|
+
persistedRowData = response.row;
|
|
1280
1459
|
const isPrimaryKeyColumn = tableDefinition.primaryKey.includes(column.key);
|
|
1281
1460
|
finalRowIdForFeedback = isPrimaryKeyColumn ? getPrimaryKeyValues(potentialUpdatedRow, tableDefinition.primaryKey) : currentRowIdBeforeUpdate;
|
|
1461
|
+
onRowChange({ ...response.row }, true);
|
|
1462
|
+
onClose(true, focusNextCell);
|
|
1282
1463
|
}
|
|
1283
|
-
|
|
1464
|
+
findChangedValues(oldRowData, response.row).forEach(
|
|
1465
|
+
(key) => setCellFeedback({ rowId: finalRowIdForFeedback, columnKey: key, type: "success" })
|
|
1466
|
+
);
|
|
1284
1467
|
} catch (err) {
|
|
1285
1468
|
console.error("Error al guardar el registro:", err);
|
|
1286
|
-
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error" });
|
|
1287
|
-
onRowChange(oldRowData, true);
|
|
1469
|
+
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error", message: err.message });
|
|
1288
1470
|
}
|
|
1289
1471
|
}, [
|
|
1290
1472
|
column,
|
|
@@ -1303,6 +1485,7 @@ function InputRenderer({
|
|
|
1303
1485
|
initialRowId
|
|
1304
1486
|
]);
|
|
1305
1487
|
const handleKeyDown = _react.useCallback.call(void 0, (event) => {
|
|
1488
|
+
console.log("entra");
|
|
1306
1489
|
if (event.key === "Enter") {
|
|
1307
1490
|
handleCommit(editingValue, true, true);
|
|
1308
1491
|
event.preventDefault();
|
|
@@ -1317,7 +1500,7 @@ function InputRenderer({
|
|
|
1317
1500
|
handleCommit(editingValue, true, false);
|
|
1318
1501
|
}, [handleCommit, editingValue]);
|
|
1319
1502
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1320
|
-
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
1503
|
+
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess', _28 => _28.editable]) !== false;
|
|
1321
1504
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1322
1505
|
_InputBase2.default,
|
|
1323
1506
|
{
|
|
@@ -1333,7 +1516,8 @@ function InputRenderer({
|
|
|
1333
1516
|
borderRadius: "4px",
|
|
1334
1517
|
padding: "2px 4px",
|
|
1335
1518
|
fontSize: "0.8rem",
|
|
1336
|
-
boxSizing: "border-box"
|
|
1519
|
+
boxSizing: "border-box",
|
|
1520
|
+
backgroundColor: cellBackgroundColor
|
|
1337
1521
|
},
|
|
1338
1522
|
onClick: (e) => e.stopPropagation(),
|
|
1339
1523
|
autoFocus: true,
|
|
@@ -1341,90 +1525,94 @@ function InputRenderer({
|
|
|
1341
1525
|
}
|
|
1342
1526
|
);
|
|
1343
1527
|
}
|
|
1344
|
-
var
|
|
1345
|
-
|
|
1346
|
-
// src/components/grid/
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
display: "flex",
|
|
1374
|
-
alignItems: "center",
|
|
1375
|
-
justifyContent: "space-between",
|
|
1376
|
-
// Para espaciar el valor y el icono
|
|
1377
|
-
gap: 1,
|
|
1378
|
-
// Espacio entre elementos
|
|
1379
|
-
width: "100%",
|
|
1380
|
-
height: "100%",
|
|
1381
|
-
paddingLeft: "8px",
|
|
1382
|
-
backgroundColor: "rgba(255, 193, 7, 0.1)",
|
|
1383
|
-
// Amarillo claro para advertencia
|
|
1384
|
-
border: "1px dashed rgba(255, 193, 7, 0.5)",
|
|
1385
|
-
boxSizing: "border-box",
|
|
1386
|
-
overflow: "hidden"
|
|
1387
|
-
// Evita que el contenido se desborde
|
|
1388
|
-
},
|
|
1389
|
-
children: [
|
|
1390
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children: value !== null && value !== void 0 ? String(value) : "*Vac\xEDo*" }),
|
|
1391
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1392
|
-
_WarningAmber2.default,
|
|
1528
|
+
var InputRenderer_default = InputRenderer;
|
|
1529
|
+
|
|
1530
|
+
// src/components/grid/renderers/editCellRenderers.tsx
|
|
1531
|
+
|
|
1532
|
+
var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
1533
|
+
const column = props.column;
|
|
1534
|
+
switch (column.customType) {
|
|
1535
|
+
case "default": {
|
|
1536
|
+
const defaultColumn = column;
|
|
1537
|
+
const {
|
|
1538
|
+
tableDefinition,
|
|
1539
|
+
fixedFields,
|
|
1540
|
+
primaryKey,
|
|
1541
|
+
setTableData,
|
|
1542
|
+
cellFeedback,
|
|
1543
|
+
setCellFeedback,
|
|
1544
|
+
handleEnterKeyPressInEditor,
|
|
1545
|
+
localCellChanges,
|
|
1546
|
+
setLocalCellChanges
|
|
1547
|
+
} = defaultColumn;
|
|
1548
|
+
if (column.editable) {
|
|
1549
|
+
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1550
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _29 => _29.some, 'call', _30 => _30((f) => f.fieldName === column.key)]);
|
|
1551
|
+
const isFieldEditableByUI = _optionalChain([fieldDefinition, 'optionalAccess', _31 => _31.editable]) !== false && !isFixedField;
|
|
1552
|
+
if (!isFieldEditableByUI) {
|
|
1553
|
+
return void 0;
|
|
1554
|
+
}
|
|
1555
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1556
|
+
InputRenderer_default,
|
|
1393
1557
|
{
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1558
|
+
...props,
|
|
1559
|
+
tableDefinition,
|
|
1560
|
+
setCellFeedback,
|
|
1561
|
+
cellFeedback,
|
|
1562
|
+
onEnterPress: (rowIndex, columnKey) => handleEnterKeyPressInEditor(rowIndex, columnKey, allColumns),
|
|
1563
|
+
setTableData,
|
|
1564
|
+
setLocalCellChanges,
|
|
1565
|
+
localCellChanges,
|
|
1566
|
+
primaryKey
|
|
1400
1567
|
}
|
|
1401
|
-
)
|
|
1402
|
-
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1570
|
+
return void 0;
|
|
1403
1571
|
}
|
|
1404
|
-
|
|
1572
|
+
case "detail": {
|
|
1573
|
+
return void 0;
|
|
1574
|
+
}
|
|
1575
|
+
case "action": {
|
|
1576
|
+
return void 0;
|
|
1577
|
+
}
|
|
1578
|
+
default:
|
|
1579
|
+
return void 0;
|
|
1580
|
+
}
|
|
1405
1581
|
};
|
|
1406
|
-
var FallbackClientSideRenderer_default = FallbackClientSideRenderer;
|
|
1407
1582
|
|
|
1408
|
-
// src/components/grid/
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1583
|
+
// src/components/grid/renderers/emptyRowRenderer.tsx
|
|
1584
|
+
|
|
1585
|
+
function EmptyRowsRenderer() {
|
|
1586
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: {
|
|
1587
|
+
// Posicionamiento absoluto respecto a la pantalla
|
|
1588
|
+
position: "fixed",
|
|
1589
|
+
top: "50%",
|
|
1590
|
+
// Centrado verticalmente
|
|
1591
|
+
left: "50%",
|
|
1592
|
+
// Centrado horizontalmente
|
|
1593
|
+
transform: "translate(-50%, -50%)",
|
|
1594
|
+
// Ajuste para el 50% del tamaño del div
|
|
1595
|
+
// Estilos de visualización
|
|
1596
|
+
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
1597
|
+
border: "1px solid #ccc",
|
|
1598
|
+
borderRadius: "4px",
|
|
1599
|
+
padding: "16px 24px",
|
|
1600
|
+
boxShadow: "0 2px 10px rgba(0,0,0,0.1)"
|
|
1601
|
+
}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { textAlign: "center" }, children: "No hay filas para mostrar" }) });
|
|
1602
|
+
}
|
|
1419
1603
|
|
|
1420
1604
|
// src/components/grid/GenericDataGrid.tsx
|
|
1421
1605
|
|
|
1422
1606
|
var getPrimaryKeyValues = (row, primaryKey) => {
|
|
1607
|
+
if (row[DETAIL_ROW_INDICATOR]) {
|
|
1608
|
+
primaryKey = primaryKey.concat(DETAIL_ROW_INDICATOR);
|
|
1609
|
+
}
|
|
1423
1610
|
return primaryKey.map((key) => {
|
|
1424
1611
|
return row[key] !== void 0 && row[key] !== null ? String(row[key]) : "NULL_OR_UNDEFINED";
|
|
1425
1612
|
}).join("|");
|
|
1426
1613
|
};
|
|
1427
|
-
var NEW_ROW_INDICATOR = "
|
|
1614
|
+
var NEW_ROW_INDICATOR = "$new";
|
|
1615
|
+
var DETAIL_ROW_INDICATOR = "$detail";
|
|
1428
1616
|
var GenericDataGrid = ({
|
|
1429
1617
|
tableName,
|
|
1430
1618
|
fixedFields
|
|
@@ -1434,6 +1622,7 @@ var GenericDataGrid = ({
|
|
|
1434
1622
|
const [isFilterRowVisible, setIsFilterRowVisible] = _react.useState.call(void 0, false);
|
|
1435
1623
|
const [filters, setFilters] = _react.useState.call(void 0, {});
|
|
1436
1624
|
const [selectedRows, setSelectedRows] = _react.useState.call(void 0, () => /* @__PURE__ */ new Set());
|
|
1625
|
+
const [selectedCell, setSelectedCell] = _react.useState.call(void 0, void 0);
|
|
1437
1626
|
const [cellFeedback, setCellFeedback] = _react.useState.call(void 0, null);
|
|
1438
1627
|
const [localCellChanges, setLocalCellChanges] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
1439
1628
|
const theme = _material.useTheme.call(void 0, );
|
|
@@ -1444,6 +1633,8 @@ var GenericDataGrid = ({
|
|
|
1444
1633
|
const feedbackTimerRef = _react.useRef.call(void 0, null);
|
|
1445
1634
|
const dataGridRef = _react.useRef.call(void 0, null);
|
|
1446
1635
|
const { callApi, loading, error } = useApiCall();
|
|
1636
|
+
const getRowCount = () => tableData.filter((row) => !row[DETAIL_ROW_INDICATOR]).length;
|
|
1637
|
+
const getFilteredRowCount = () => filteredRows.filter((row) => !row[DETAIL_ROW_INDICATOR]).length;
|
|
1447
1638
|
_react.useEffect.call(void 0, () => {
|
|
1448
1639
|
setFilters({});
|
|
1449
1640
|
setIsFilterRowVisible(false);
|
|
@@ -1467,7 +1658,6 @@ var GenericDataGrid = ({
|
|
|
1467
1658
|
const data = await callApi("table_data", {
|
|
1468
1659
|
table: tableName,
|
|
1469
1660
|
fixedFields
|
|
1470
|
-
// Envía el array fixedFields directamente a la API
|
|
1471
1661
|
});
|
|
1472
1662
|
setTableData(data);
|
|
1473
1663
|
} catch (err) {
|
|
@@ -1478,15 +1668,20 @@ var GenericDataGrid = ({
|
|
|
1478
1668
|
}
|
|
1479
1669
|
};
|
|
1480
1670
|
fetchDataAndDefinition();
|
|
1481
|
-
}, [
|
|
1671
|
+
}, [
|
|
1672
|
+
tableName,
|
|
1673
|
+
/*fixedFields,*/
|
|
1674
|
+
showError
|
|
1675
|
+
]);
|
|
1482
1676
|
_react.useEffect.call(void 0, () => {
|
|
1483
1677
|
if (cellFeedback) {
|
|
1484
1678
|
if (feedbackTimerRef.current) {
|
|
1485
1679
|
clearTimeout(feedbackTimerRef.current);
|
|
1486
1680
|
}
|
|
1487
|
-
const timerDuration =
|
|
1681
|
+
const timerDuration = 3e3;
|
|
1488
1682
|
feedbackTimerRef.current = setTimeout(() => {
|
|
1489
|
-
|
|
1683
|
+
if (cellFeedback.type == "success")
|
|
1684
|
+
setCellFeedback(null);
|
|
1490
1685
|
}, timerDuration);
|
|
1491
1686
|
}
|
|
1492
1687
|
return () => {
|
|
@@ -1638,225 +1833,120 @@ var GenericDataGrid = ({
|
|
|
1638
1833
|
const handleEnterKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, currentColumns) => {
|
|
1639
1834
|
if (dataGridRef.current && tableDefinition) {
|
|
1640
1835
|
const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1836
|
+
const editableColumns = currentColumns.filter((col) => {
|
|
1837
|
+
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1838
|
+
return col.key !== "filterToggle" && col.key !== "deleteAction" && (_optionalChain([fieldDefinition, 'optionalAccess', _32 => _32.editable]) !== false && !_optionalChain([fieldDefinition, 'optionalAccess', _33 => _33.clientSide]));
|
|
1839
|
+
});
|
|
1840
|
+
if (currentColumnIndex !== -1 && editableColumns.length > 0) {
|
|
1841
|
+
const editableColumnKeys = editableColumns.map((col) => col.key);
|
|
1842
|
+
let currentEditableColumnIndex = editableColumnKeys.indexOf(columnKey);
|
|
1843
|
+
if (currentEditableColumnIndex !== -1) {
|
|
1844
|
+
let nextEditableColumnIndex = currentEditableColumnIndex + 1;
|
|
1845
|
+
let nextRowIndex = rowIndex;
|
|
1846
|
+
if (nextEditableColumnIndex >= editableColumns.length) {
|
|
1847
|
+
nextEditableColumnIndex = 0;
|
|
1648
1848
|
nextRowIndex++;
|
|
1649
1849
|
if (nextRowIndex >= filteredRows.length) {
|
|
1650
1850
|
nextRowIndex = 0;
|
|
1651
|
-
nextColumnIndex = 0;
|
|
1652
|
-
if (filteredRows.length === 0 || rowIndex === filteredRows.length - 1 && currentColumnIndex === currentColumns.length - 1) {
|
|
1653
|
-
foundNextTarget = true;
|
|
1654
|
-
break;
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
const nextColumn = currentColumns[nextColumnIndex];
|
|
1659
|
-
if (nextColumn) {
|
|
1660
|
-
const fieldDefinition = tableDefinition.fields.find((f) => f.name === nextColumn.key);
|
|
1661
|
-
const isEditableField = _optionalChain([fieldDefinition, 'optionalAccess', _13 => _13.editable]) !== false;
|
|
1662
|
-
if (nextColumn.key !== "filterToggle" && nextColumn.key !== "deleteAction" && isEditableField) {
|
|
1663
|
-
foundNextTarget = true;
|
|
1664
|
-
} else {
|
|
1665
|
-
nextColumnIndex++;
|
|
1666
1851
|
}
|
|
1667
|
-
} else {
|
|
1668
|
-
nextColumnIndex++;
|
|
1669
1852
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor:
|
|
1853
|
+
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1854
|
+
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1855
|
+
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1673
1856
|
}
|
|
1674
1857
|
}
|
|
1675
1858
|
}
|
|
1676
1859
|
}, [filteredRows, tableDefinition]);
|
|
1860
|
+
const handleSelectedCellChange = _react.useCallback.call(void 0, (args) => {
|
|
1861
|
+
setSelectedCell(args);
|
|
1862
|
+
}, []);
|
|
1677
1863
|
const columns = _react.useMemo.call(void 0, () => {
|
|
1678
1864
|
if (!tableDefinition) return [];
|
|
1679
1865
|
const fieldsToShow = tableDefinition.fields.filter((field) => {
|
|
1680
|
-
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess',
|
|
1866
|
+
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _34 => _34.find, 'call', _35 => _35((f) => f.fieldName === field.name)]);
|
|
1681
1867
|
return !(fixedFieldEntry && fixedFieldEntry.until === void 0);
|
|
1682
1868
|
});
|
|
1683
|
-
const defaultColumns = fieldsToShow.map((
|
|
1684
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
1685
|
-
const isFieldEditable =
|
|
1869
|
+
const defaultColumns = fieldsToShow.map((fieldDef) => {
|
|
1870
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _36 => _36.some, 'call', _37 => _37((f) => f.fieldName === fieldDef.name)]);
|
|
1871
|
+
const isFieldEditable = fieldDef.editable !== false && !isFixedField;
|
|
1686
1872
|
return {
|
|
1687
|
-
key:
|
|
1688
|
-
|
|
1873
|
+
key: fieldDef.name,
|
|
1874
|
+
customType: "default",
|
|
1875
|
+
tableDefinition,
|
|
1876
|
+
fieldDef,
|
|
1877
|
+
cellFeedback,
|
|
1878
|
+
primaryKey,
|
|
1879
|
+
fixedFields,
|
|
1880
|
+
localCellChanges,
|
|
1881
|
+
setLocalCellChanges,
|
|
1882
|
+
setTableData,
|
|
1883
|
+
setCellFeedback,
|
|
1884
|
+
name: fieldDef.label || cambiarGuionesBajosPorEspacios(fieldDef.name),
|
|
1689
1885
|
resizable: true,
|
|
1690
1886
|
sortable: true,
|
|
1691
1887
|
editable: isFieldEditable,
|
|
1692
|
-
|
|
1888
|
+
handleEnterKeyPressInEditor,
|
|
1693
1889
|
flexGrow: 1,
|
|
1694
1890
|
minWidth: 60,
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
renderSummaryCell: ({ column }) => {
|
|
1698
|
-
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((f) => f.fieldName === column.key)]);
|
|
1699
|
-
if (fixedFieldEntry && fixedFieldEntry.until === void 0) return null;
|
|
1700
|
-
return isFilterRowVisible ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1701
|
-
FilterInputRender_default,
|
|
1702
|
-
{
|
|
1703
|
-
column,
|
|
1704
|
-
filters,
|
|
1705
|
-
setFilters
|
|
1706
|
-
}
|
|
1707
|
-
) : null;
|
|
1708
|
-
},
|
|
1709
|
-
renderCell: (props) => {
|
|
1710
|
-
const rowId = getPrimaryKeyValues(props.row, primaryKey);
|
|
1711
|
-
const fieldDefinition = tableDefinition.fields.find((f) => f.name === props.column.key);
|
|
1712
|
-
if (_optionalChain([fieldDefinition, 'optionalAccess', _20 => _20.clientSide])) {
|
|
1713
|
-
const ClientSideComponent = clientSides[fieldDefinition.clientSide];
|
|
1714
|
-
if (ClientSideComponent) {
|
|
1715
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1716
|
-
ClientSideComponent,
|
|
1717
|
-
{
|
|
1718
|
-
...props,
|
|
1719
|
-
fieldDefinition,
|
|
1720
|
-
tableDefinition,
|
|
1721
|
-
primaryKey
|
|
1722
|
-
}
|
|
1723
|
-
);
|
|
1724
|
-
} else {
|
|
1725
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1726
|
-
FallbackClientSideRenderer_default,
|
|
1727
|
-
{
|
|
1728
|
-
...props,
|
|
1729
|
-
fieldDefinition,
|
|
1730
|
-
tableDefinition,
|
|
1731
|
-
primaryKey
|
|
1732
|
-
}
|
|
1733
|
-
);
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
let cellBackgroundColor = "transparent";
|
|
1737
|
-
if (cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === props.column.key) {
|
|
1738
|
-
cellBackgroundColor = cellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1739
|
-
} else {
|
|
1740
|
-
const isNewRowLocalCheck = props.row[NEW_ROW_INDICATOR];
|
|
1741
|
-
const isMandatory = tableDefinition.primaryKey.includes(props.column.key) || _optionalChain([tableDefinition, 'access', _21 => _21.fields, 'access', _22 => _22.find, 'call', _23 => _23((f) => f.name === props.column.key), 'optionalAccess', _24 => _24.nullable]) === false;
|
|
1742
|
-
const hasValue = props.row[props.column.key] !== null && props.row[props.column.key] !== void 0 && String(props.row[props.column.key]).trim() !== "";
|
|
1743
|
-
const isFixedFieldCurrent = _optionalChain([fixedFields, 'optionalAccess', _25 => _25.some, 'call', _26 => _26((f) => f.fieldName === props.column.key)]);
|
|
1744
|
-
if (isFixedFieldCurrent) {
|
|
1745
|
-
cellBackgroundColor = theme.palette.action.selected;
|
|
1746
|
-
} else if (isNewRowLocalCheck && isMandatory && !hasValue || localCellChanges.has(rowId) && _optionalChain([localCellChanges, 'access', _27 => _27.get, 'call', _28 => _28(rowId), 'optionalAccess', _29 => _29.has, 'call', _30 => _30(props.column.key)])) {
|
|
1747
|
-
cellBackgroundColor = theme.palette.info.light;
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1751
|
-
_material.Box,
|
|
1752
|
-
{
|
|
1753
|
-
sx: {
|
|
1754
|
-
position: "absolute",
|
|
1755
|
-
top: 0,
|
|
1756
|
-
left: 0,
|
|
1757
|
-
width: "100%",
|
|
1758
|
-
height: "100%",
|
|
1759
|
-
backgroundColor: cellBackgroundColor,
|
|
1760
|
-
transition: "background-color 0.3s ease-in-out",
|
|
1761
|
-
display: "flex",
|
|
1762
|
-
alignItems: "center",
|
|
1763
|
-
paddingLeft: "8px",
|
|
1764
|
-
boxSizing: "border-box"
|
|
1765
|
-
},
|
|
1766
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1767
|
-
PkCellRenderer_default,
|
|
1768
|
-
{
|
|
1769
|
-
...props,
|
|
1770
|
-
column: { ...props.column, isPK: !!field.isPk }
|
|
1771
|
-
}
|
|
1772
|
-
)
|
|
1773
|
-
}
|
|
1774
|
-
);
|
|
1775
|
-
}
|
|
1891
|
+
renderHeaderCell: (props) => defaultColumnHeaderCellRenderer(props, fieldDef),
|
|
1892
|
+
renderSummaryCell: (props) => defaultColumnSummaryCellRenderer(props, fixedFields, isFilterRowVisible, filters, setFilters)
|
|
1776
1893
|
};
|
|
1777
1894
|
});
|
|
1778
|
-
const
|
|
1895
|
+
const actionsColumn = {
|
|
1779
1896
|
key: "filterToggle",
|
|
1780
|
-
|
|
1897
|
+
customType: "action",
|
|
1898
|
+
tableDefinition,
|
|
1899
|
+
handleDeleteRow,
|
|
1900
|
+
name: "filterCol",
|
|
1781
1901
|
width: 50,
|
|
1902
|
+
editable: false,
|
|
1782
1903
|
resizable: false,
|
|
1783
1904
|
sortable: false,
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
_material.IconButton,
|
|
1787
|
-
{
|
|
1788
|
-
color: "inherit",
|
|
1789
|
-
onClick: toggleFilterVisibility,
|
|
1790
|
-
size: "small",
|
|
1791
|
-
title: isFilterRowVisible ? "Ocultar filtros" : "Mostrar filtros",
|
|
1792
|
-
sx: { p: 0.5 },
|
|
1793
|
-
children: isFilterRowVisible ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _SearchOff2.default, { sx: { fontSize: 20 } }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 20 } })
|
|
1794
|
-
}
|
|
1795
|
-
),
|
|
1796
|
-
renderSummaryCell: () => null
|
|
1905
|
+
renderHeaderCell: (props) => actionsColumnHeaderCellRenderer(props, isFilterRowVisible, toggleFilterVisibility),
|
|
1906
|
+
renderSummaryCell: (props) => actionsColumnSummaryCellRenderer(props)
|
|
1797
1907
|
};
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1908
|
+
const detailColumns = [];
|
|
1909
|
+
if (tableDefinition.detailTables && tableDefinition.detailTables.length > 0) {
|
|
1910
|
+
tableDefinition.detailTables.forEach((detailTable) => {
|
|
1911
|
+
const detailKey = `detail_${detailTable.abr}`;
|
|
1912
|
+
detailColumns.push({
|
|
1913
|
+
key: detailKey,
|
|
1914
|
+
customType: "detail",
|
|
1915
|
+
tableDefinition,
|
|
1916
|
+
detailTable,
|
|
1917
|
+
primaryKey,
|
|
1918
|
+
tableData,
|
|
1919
|
+
setTableData,
|
|
1920
|
+
detailKey,
|
|
1921
|
+
name: detailTable.label || `Detalle ${detailTable.abr}`,
|
|
1922
|
+
resizable: false,
|
|
1923
|
+
sortable: false,
|
|
1924
|
+
editable: false,
|
|
1925
|
+
width: 50,
|
|
1926
|
+
renderHeaderCell: (props) => detailColumnCellHeaderRenderer(props, detailTable),
|
|
1927
|
+
renderSummaryCell: (props) => detailColumnCellSummaryRenderer(props)
|
|
1928
|
+
});
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
const allColumns = [
|
|
1932
|
+
actionsColumn,
|
|
1933
|
+
...detailColumns,
|
|
1934
|
+
...defaultColumns
|
|
1935
|
+
];
|
|
1936
|
+
return allColumns.map((col) => ({
|
|
1937
|
+
...col,
|
|
1938
|
+
colSpan: (args) => {
|
|
1939
|
+
if (args.type === "ROW") {
|
|
1940
|
+
const detailTableAbr = args.row[DETAIL_ROW_INDICATOR];
|
|
1941
|
+
if (col.key === `detail_${detailTableAbr}`) {
|
|
1942
|
+
return allColumns.length;
|
|
1826
1943
|
}
|
|
1827
|
-
) });
|
|
1828
|
-
}
|
|
1829
|
-
};
|
|
1830
|
-
const allColumns = [filterToggleColumn, deleteActionColumn, ...defaultColumns];
|
|
1831
|
-
return allColumns.map((col) => {
|
|
1832
|
-
if (col.editable) {
|
|
1833
|
-
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1834
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _33 => _33.some, 'call', _34 => _34((f) => f.fieldName === col.key)]);
|
|
1835
|
-
const isFieldEditableByUI = _optionalChain([fieldDefinition, 'optionalAccess', _35 => _35.editable]) !== false && !isFixedField;
|
|
1836
|
-
if (!isFieldEditableByUI) {
|
|
1837
|
-
return { ...col, renderEditCell: void 0 };
|
|
1838
1944
|
}
|
|
1839
|
-
return
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
{
|
|
1845
|
-
...props,
|
|
1846
|
-
tableDefinition,
|
|
1847
|
-
setCellFeedback,
|
|
1848
|
-
onEnterPress: (rowIndex, columnKey) => handleEnterKeyPressInEditor(rowIndex, columnKey, allColumns),
|
|
1849
|
-
setTableData,
|
|
1850
|
-
setLocalCellChanges,
|
|
1851
|
-
localCellChanges,
|
|
1852
|
-
primaryKey
|
|
1853
|
-
}
|
|
1854
|
-
);
|
|
1855
|
-
}
|
|
1856
|
-
};
|
|
1857
|
-
}
|
|
1858
|
-
return col;
|
|
1859
|
-
});
|
|
1945
|
+
return void 0;
|
|
1946
|
+
},
|
|
1947
|
+
renderEditCell: (props) => allColumnsEditCellRenderer(props, allColumns),
|
|
1948
|
+
renderCell: (props) => allColumnsCellRenderer(props)
|
|
1949
|
+
}));
|
|
1860
1950
|
}, [
|
|
1861
1951
|
tableDefinition,
|
|
1862
1952
|
isFilterRowVisible,
|
|
@@ -1868,22 +1958,31 @@ var GenericDataGrid = ({
|
|
|
1868
1958
|
theme.palette.error.light,
|
|
1869
1959
|
theme.palette.info.light,
|
|
1870
1960
|
theme.palette.action.selected,
|
|
1871
|
-
// Añade el color de campos fijos
|
|
1872
1961
|
handleEnterKeyPressInEditor,
|
|
1873
1962
|
setTableData,
|
|
1874
1963
|
localCellChanges,
|
|
1875
1964
|
handleDeleteRow,
|
|
1876
|
-
fixedFields
|
|
1877
|
-
|
|
1965
|
+
fixedFields,
|
|
1966
|
+
tableData
|
|
1878
1967
|
]);
|
|
1879
|
-
const showNoRowsMessage = filteredRows.length === 0 && !loading && !error;
|
|
1880
1968
|
const handleRowsChange = _react.useCallback.call(void 0, (updatedRows) => {
|
|
1881
1969
|
setTableData(updatedRows);
|
|
1882
1970
|
}, []);
|
|
1971
|
+
const deselectAllOtherGrids = (currentGridElement) => {
|
|
1972
|
+
const allSelectedCells = document.querySelectorAll("div[aria-selected='true']");
|
|
1973
|
+
allSelectedCells.forEach((cell) => {
|
|
1974
|
+
const parentGrid = cell.closest(".rdg");
|
|
1975
|
+
if (parentGrid && parentGrid !== currentGridElement) {
|
|
1976
|
+
cell.setAttribute("aria-selected", "false");
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
};
|
|
1883
1980
|
const handleCellClick = _react.useCallback.call(void 0, (args) => {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
const
|
|
1981
|
+
deselectAllOtherGrids(_optionalChain([dataGridRef, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.element]));
|
|
1982
|
+
args.selectCell(true);
|
|
1983
|
+
const fieldDefinition = _optionalChain([tableDefinition, 'optionalAccess', _40 => _40.fields, 'access', _41 => _41.find, 'call', _42 => _42((f) => f.name === args.column.key)]);
|
|
1984
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _43 => _43.some, 'call', _44 => _44((f) => f.fieldName === args.column.key)]);
|
|
1985
|
+
const isEditable = _optionalChain([fieldDefinition, 'optionalAccess', _45 => _45.editable]) !== false && !isFixedField;
|
|
1887
1986
|
console.log("Clicked column index:", args.column.idx);
|
|
1888
1987
|
console.log("Clicked row index:", args.rowIdx);
|
|
1889
1988
|
console.log("Is editable:", isEditable);
|
|
@@ -1900,9 +1999,8 @@ var GenericDataGrid = ({
|
|
|
1900
1999
|
if (!tableDefinition) {
|
|
1901
2000
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "200px", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Alert, { severity: "warning", children: "No se pudo cargar la definici\xF3n de la tabla." }) });
|
|
1902
2001
|
}
|
|
1903
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: {
|
|
1904
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex",
|
|
1905
|
-
_optionalChain([tableDefinition, 'access', _42 => _42.allow, 'optionalAccess', _43 => _43.insert]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex", px: 2 }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2002
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { pt: 2, display: "flex", flexDirection: "column", height: "100%", boxSizing: "border-box" }, children: [
|
|
2003
|
+
_optionalChain([tableDefinition, 'access', _46 => _46.allow, 'optionalAccess', _47 => _47.insert]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex", px: 2, pb: 1 }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1906
2004
|
_material.Button,
|
|
1907
2005
|
{
|
|
1908
2006
|
variant: "contained",
|
|
@@ -1911,19 +2009,33 @@ var GenericDataGrid = ({
|
|
|
1911
2009
|
children: "Nuevo Registro"
|
|
1912
2010
|
}
|
|
1913
2011
|
) }),
|
|
1914
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1915
|
-
"mostrando ",
|
|
1916
|
-
`${tableData.length} registros`
|
|
1917
|
-
] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { children: [
|
|
1918
|
-
"mostrando ",
|
|
1919
|
-
`${filteredRows.length} registros filtrados`
|
|
1920
|
-
] }) }) }),
|
|
1921
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2012
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1922
2013
|
_material.Box,
|
|
1923
2014
|
{
|
|
1924
2015
|
sx: {
|
|
1925
|
-
|
|
1926
|
-
|
|
2016
|
+
backgroundColor: theme.palette.primary.main,
|
|
2017
|
+
color: theme.palette.primary.contrastText,
|
|
2018
|
+
padding: theme.spacing(1),
|
|
2019
|
+
textAlign: "left",
|
|
2020
|
+
fontWeight: "bold",
|
|
2021
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
2022
|
+
borderTopLeftRadius: theme.shape.borderRadius,
|
|
2023
|
+
borderTopRightRadius: theme.shape.borderRadius,
|
|
2024
|
+
ml: 2,
|
|
2025
|
+
mr: 2
|
|
2026
|
+
},
|
|
2027
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "subtitle1", component: "div", children: [
|
|
2028
|
+
cambiarGuionesBajosPorEspacios(tableDefinition.title || tableDefinition.name),
|
|
2029
|
+
" - mostrando ",
|
|
2030
|
+
getFilteredRowCount() === getRowCount() ? `${getRowCount()} registros` : `${getFilteredRowCount()} registros filtrados`
|
|
2031
|
+
] })
|
|
2032
|
+
}
|
|
2033
|
+
),
|
|
2034
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2035
|
+
_material.Box,
|
|
2036
|
+
{
|
|
2037
|
+
sx: {
|
|
2038
|
+
flexGrow: 1,
|
|
1927
2039
|
boxSizing: "border-box",
|
|
1928
2040
|
position: "relative",
|
|
1929
2041
|
overflowX: "auto",
|
|
@@ -1931,51 +2043,30 @@ var GenericDataGrid = ({
|
|
|
1931
2043
|
px: 2,
|
|
1932
2044
|
pb: 2
|
|
1933
2045
|
},
|
|
1934
|
-
children:
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
_material.Box,
|
|
1959
|
-
{
|
|
1960
|
-
sx: {
|
|
1961
|
-
position: "absolute",
|
|
1962
|
-
top: isFilterRowVisible ? "70px" : "36px",
|
|
1963
|
-
left: (theme2) => theme2.spacing(2),
|
|
1964
|
-
right: (theme2) => theme2.spacing(2),
|
|
1965
|
-
bottom: (theme2) => theme2.spacing(2),
|
|
1966
|
-
display: "flex",
|
|
1967
|
-
justifyContent: "center",
|
|
1968
|
-
alignItems: "center",
|
|
1969
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
1970
|
-
color: (theme2) => theme2.palette.text.secondary,
|
|
1971
|
-
border: (theme2) => `1px solid ${theme2.palette.divider}`,
|
|
1972
|
-
borderRadius: "4px",
|
|
1973
|
-
zIndex: 1
|
|
1974
|
-
},
|
|
1975
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", children: "No hay filas para mostrar." })
|
|
1976
|
-
}
|
|
1977
|
-
)
|
|
1978
|
-
]
|
|
2046
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2047
|
+
_reactdatagrid.DataGrid,
|
|
2048
|
+
{
|
|
2049
|
+
ref: dataGridRef,
|
|
2050
|
+
columns,
|
|
2051
|
+
rows: filteredRows.map((row) => ({
|
|
2052
|
+
...row,
|
|
2053
|
+
style: exitingRowIds.has(getPrimaryKeyValues(row, primaryKey)) ? { maxHeight: 0, opacity: 0, overflow: "hidden" } : { maxHeight: "35px", opacity: 1 }
|
|
2054
|
+
})),
|
|
2055
|
+
enableVirtualization: true,
|
|
2056
|
+
rowKeyGetter: (row) => getPrimaryKeyValues(row, primaryKey),
|
|
2057
|
+
onSelectedRowsChange: setSelectedRows,
|
|
2058
|
+
onSelectedCellChange: handleSelectedCellChange,
|
|
2059
|
+
onRowsChange: handleRowsChange,
|
|
2060
|
+
selectedRows,
|
|
2061
|
+
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 : 35,
|
|
2062
|
+
style: { height: "100%", width: "100%", boxSizing: "border-box" },
|
|
2063
|
+
headerRowHeight: 35,
|
|
2064
|
+
topSummaryRows: isFilterRowVisible ? [{ id: "filterRow" }] : void 0,
|
|
2065
|
+
summaryRowHeight: isFilterRowVisible ? 35 : 0,
|
|
2066
|
+
renderers: { noRowsFallback: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EmptyRowsRenderer, {}) },
|
|
2067
|
+
onCellClick: handleCellClick
|
|
2068
|
+
}
|
|
2069
|
+
)
|
|
1979
2070
|
}
|
|
1980
2071
|
),
|
|
1981
2072
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2512,7 +2603,7 @@ var SessionExpiredMessage_default = SessionExpiredMessage;
|
|
|
2512
2603
|
var HomePage = () => {
|
|
2513
2604
|
const { clientContext } = useApp();
|
|
2514
2605
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 3 }, children: [
|
|
2515
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess',
|
|
2606
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess', _48 => _48.username])}` }),
|
|
2516
2607
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", children: "Usa el men\xFA lateral para navegar por las diferentes secciones." })
|
|
2517
2608
|
] });
|
|
2518
2609
|
};
|
|
@@ -2641,7 +2732,7 @@ var LoginPage = () => {
|
|
|
2641
2732
|
fullWidth: true,
|
|
2642
2733
|
margin: "normal",
|
|
2643
2734
|
error: !!errors.username,
|
|
2644
|
-
helperText: _optionalChain([errors, 'access',
|
|
2735
|
+
helperText: _optionalChain([errors, 'access', _49 => _49.username, 'optionalAccess', _50 => _50.message]),
|
|
2645
2736
|
disabled: isSubmitting
|
|
2646
2737
|
}
|
|
2647
2738
|
)
|
|
@@ -2664,7 +2755,7 @@ var LoginPage = () => {
|
|
|
2664
2755
|
fullWidth: true,
|
|
2665
2756
|
margin: "normal",
|
|
2666
2757
|
error: !!errors.password,
|
|
2667
|
-
helperText: _optionalChain([errors, 'access',
|
|
2758
|
+
helperText: _optionalChain([errors, 'access', _51 => _51.password, 'optionalAccess', _52 => _52.message]),
|
|
2668
2759
|
disabled: isSubmitting
|
|
2669
2760
|
}
|
|
2670
2761
|
)
|
|
@@ -2742,7 +2833,7 @@ var ProcedureForm = () => {
|
|
|
2742
2833
|
const [executionLog, setExecutionLog] = _react.useState.call(void 0, []);
|
|
2743
2834
|
const [procedureResultData, setProcedureResultData] = _react.useState.call(void 0, null);
|
|
2744
2835
|
const procedure = _react.useMemo.call(void 0, () => {
|
|
2745
|
-
if (procedureName && _optionalChain([clientContext, 'optionalAccess',
|
|
2836
|
+
if (procedureName && _optionalChain([clientContext, 'optionalAccess', _53 => _53.procedure])) {
|
|
2746
2837
|
return clientContext.procedure[procedureName];
|
|
2747
2838
|
}
|
|
2748
2839
|
return void 0;
|
|
@@ -3033,7 +3124,7 @@ var ProcedureForm = () => {
|
|
|
3033
3124
|
}
|
|
3034
3125
|
}, [formValues, handleChange, apiLoading, validationErrors]);
|
|
3035
3126
|
const ResultDisplayContent = _react.useMemo.call(void 0, () => {
|
|
3036
|
-
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess',
|
|
3127
|
+
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess', _54 => _54.resultOk])) return null;
|
|
3037
3128
|
const ComponentToRender = resultsOk[procedure.resultOk];
|
|
3038
3129
|
if (ComponentToRender) {
|
|
3039
3130
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentToRender, { data: procedureResultData });
|