frontend-plus-react 0.1.4 → 0.1.6
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 +267 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +347 -233
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.cts +0 -200
- package/dist/index.d.ts +0 -200
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,13 +786,6 @@ var useApiCall = () => {
|
|
|
781
786
|
};
|
|
782
787
|
|
|
783
788
|
// src/components/grid/GenericDataGrid.tsx
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
789
|
var _material = require('@mui/material');
|
|
792
790
|
|
|
793
791
|
// src/utils/functions.tsx
|
|
@@ -988,9 +986,18 @@ var useRedirectPath = () => {
|
|
|
988
986
|
|
|
989
987
|
// src/utils/functions.tsx
|
|
990
988
|
var cambiarGuionesBajosPorEspacios = (texto) => texto.replace(/_/g, " ");
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
989
|
+
var getDetailTableAndFixedFieldsForDetailTableAbr = (tableDefinition, detailTableAbr, row) => {
|
|
990
|
+
const detailTable = tableDefinition.detailTables.find((dt) => dt.abr === detailTableAbr);
|
|
991
|
+
let fixedFields = [];
|
|
992
|
+
detailTable.fields.forEach((field) => {
|
|
993
|
+
if (typeof field === "string") {
|
|
994
|
+
fixedFields.push({ fieldName: field, value: row[field] });
|
|
995
|
+
} else {
|
|
996
|
+
fixedFields.push({ fieldName: field.target, value: row[field.source] });
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
return { detailTable, fixedFields };
|
|
1000
|
+
};
|
|
994
1001
|
|
|
995
1002
|
// src/components/ConfirmDialog.tsx
|
|
996
1003
|
var _Dialog = require('@mui/material/Dialog'); var _Dialog2 = _interopRequireDefault(_Dialog);
|
|
@@ -1024,6 +1031,7 @@ var ConfirmDialog = ({ open, onClose, title, message }) => {
|
|
|
1024
1031
|
|
|
1025
1032
|
var _Search = require('@mui/icons-material/Search'); var _Search2 = _interopRequireDefault(_Search);
|
|
1026
1033
|
var _SearchOff = require('@mui/icons-material/SearchOff'); var _SearchOff2 = _interopRequireDefault(_SearchOff);
|
|
1034
|
+
var _MoreVert = require('@mui/icons-material/MoreVert'); var _MoreVert2 = _interopRequireDefault(_MoreVert);
|
|
1027
1035
|
|
|
1028
1036
|
var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
1029
1037
|
const { column } = props;
|
|
@@ -1047,7 +1055,7 @@ var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
|
1047
1055
|
sx: {
|
|
1048
1056
|
fontWeight: "bold",
|
|
1049
1057
|
textDecoration: isPrimaryKey ? "underline" : "none",
|
|
1050
|
-
fontSize: "
|
|
1058
|
+
fontSize: "o.930rem"
|
|
1051
1059
|
// Puedes ajustar el tamaño si es necesario
|
|
1052
1060
|
},
|
|
1053
1061
|
children: column.name
|
|
@@ -1056,17 +1064,30 @@ var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
|
1056
1064
|
}
|
|
1057
1065
|
);
|
|
1058
1066
|
};
|
|
1059
|
-
var actionsColumnHeaderCellRenderer = (props, isFilterRowVisible, toggleFilterVisibility) => /* @__PURE__ */ _jsxruntime.
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1067
|
+
var actionsColumnHeaderCellRenderer = (props, isFilterRowVisible, toggleFilterVisibility) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 0.2 }, children: [
|
|
1068
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1069
|
+
_material.IconButton,
|
|
1070
|
+
{
|
|
1071
|
+
color: "inherit",
|
|
1072
|
+
onClick: toggleFilterVisibility,
|
|
1073
|
+
size: "small",
|
|
1074
|
+
title: isFilterRowVisible ? "Ocultar filtros" : "Mostrar filtros",
|
|
1075
|
+
sx: { p: 0.25 },
|
|
1076
|
+
children: isFilterRowVisible ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _SearchOff2.default, { sx: { fontSize: 18 } }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 18 } })
|
|
1077
|
+
}
|
|
1078
|
+
),
|
|
1079
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1080
|
+
_material.IconButton,
|
|
1081
|
+
{
|
|
1082
|
+
onClick: () => {
|
|
1083
|
+
},
|
|
1084
|
+
size: "small",
|
|
1085
|
+
title: "Opciones de esta tabla",
|
|
1086
|
+
sx: { p: 0.25 },
|
|
1087
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _MoreVert2.default, { sx: { fontSize: 20, variant: "filled", size: "small" } })
|
|
1088
|
+
}
|
|
1089
|
+
)
|
|
1090
|
+
] });
|
|
1070
1091
|
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() }) });
|
|
1071
1092
|
|
|
1072
1093
|
// src/components/grid/FilterInputRender.tsx
|
|
@@ -1087,6 +1108,7 @@ function FilterInputRenderer({
|
|
|
1087
1108
|
}),
|
|
1088
1109
|
sx: {
|
|
1089
1110
|
width: "100%",
|
|
1111
|
+
height: 25,
|
|
1090
1112
|
margin: "0",
|
|
1091
1113
|
border: "1px solid #ccc",
|
|
1092
1114
|
borderRadius: "4px",
|
|
@@ -1102,18 +1124,19 @@ var FilterInputRender_default = FilterInputRenderer;
|
|
|
1102
1124
|
|
|
1103
1125
|
// src/components/grid/renderers/summaryCellRenderers.tsx
|
|
1104
1126
|
|
|
1127
|
+
|
|
1105
1128
|
var defaultColumnSummaryCellRenderer = (props, fixedFields, isFilterRowVisible, filters, setFilters) => {
|
|
1106
1129
|
const { column } = props;
|
|
1107
1130
|
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _3 => _3.find, 'call', _4 => _4((f) => f.fieldName === column.key)]);
|
|
1108
1131
|
if (fixedFieldEntry && fixedFieldEntry.until === void 0 || !isFilterRowVisible) return null;
|
|
1109
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1132
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1110
1133
|
FilterInputRender_default,
|
|
1111
1134
|
{
|
|
1112
1135
|
column,
|
|
1113
1136
|
filters,
|
|
1114
1137
|
setFilters
|
|
1115
1138
|
}
|
|
1116
|
-
);
|
|
1139
|
+
) });
|
|
1117
1140
|
};
|
|
1118
1141
|
var actionsColumnSummaryCellRenderer = (props) => null;
|
|
1119
1142
|
var detailColumnCellSummaryRenderer = (props) => null;
|
|
@@ -1122,7 +1145,9 @@ var detailColumnCellSummaryRenderer = (props) => null;
|
|
|
1122
1145
|
|
|
1123
1146
|
var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
|
|
1124
1147
|
var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _KeyboardArrowUp2 = _interopRequireDefault(_KeyboardArrowUp);
|
|
1148
|
+
var _ViewHeadline = require('@mui/icons-material/ViewHeadline'); var _ViewHeadline2 = _interopRequireDefault(_ViewHeadline);
|
|
1125
1149
|
var _Delete = require('@mui/icons-material/Delete'); var _Delete2 = _interopRequireDefault(_Delete);
|
|
1150
|
+
var _Add = require('@mui/icons-material/Add'); var _Add2 = _interopRequireDefault(_Add);
|
|
1126
1151
|
|
|
1127
1152
|
// src/components/grid/ExampleClientSideComponent.tsx
|
|
1128
1153
|
|
|
@@ -1145,7 +1170,6 @@ var ExampleClientSideComponent_default = ExampleClientSideComponent;
|
|
|
1145
1170
|
var _WarningAmber = require('@mui/icons-material/WarningAmber'); var _WarningAmber2 = _interopRequireDefault(_WarningAmber);
|
|
1146
1171
|
|
|
1147
1172
|
var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
1148
|
-
const value = row[column.key];
|
|
1149
1173
|
const clientSideName = _optionalChain([fieldDefinition, 'optionalAccess', _5 => _5.clientSide]) || "Desconocido";
|
|
1150
1174
|
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,
|
|
1151
1175
|
_material.Box,
|
|
@@ -1168,7 +1192,7 @@ var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
|
1168
1192
|
// Evita que el contenido se desborde
|
|
1169
1193
|
},
|
|
1170
1194
|
children: [
|
|
1171
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children:
|
|
1195
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children: clientSideName + " not found" }),
|
|
1172
1196
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1173
1197
|
_WarningAmber2.default,
|
|
1174
1198
|
{
|
|
@@ -1208,24 +1232,26 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1208
1232
|
const detailTableAbr = row[DETAIL_ROW_INDICATOR];
|
|
1209
1233
|
const detailColumn = column;
|
|
1210
1234
|
if (column.customType === "detail" && detailColumn.detailTable.abr === detailTableAbr) {
|
|
1211
|
-
const detailTable = detailColumn.tableDefinition
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1235
|
+
const { detailTable, fixedFields } = getDetailTableAndFixedFieldsForDetailTableAbr(detailColumn.tableDefinition, detailTableAbr, row);
|
|
1236
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1237
|
+
_material.Box,
|
|
1238
|
+
{
|
|
1239
|
+
sx: {
|
|
1240
|
+
// Se eliminó el padding para que la sub-grilla se extienda por completo
|
|
1241
|
+
minHeight: "200px",
|
|
1242
|
+
width: "100%",
|
|
1243
|
+
height: "100%",
|
|
1244
|
+
//display: 'flex',
|
|
1245
|
+
//flexDirection: 'column',
|
|
1246
|
+
boxSizing: "border-box"
|
|
1247
|
+
},
|
|
1248
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1249
|
+
onClick: (e) => e.stopPropagation(),
|
|
1250
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1251
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
1252
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GenericDataGrid_default, { tableName: detailTable.table, fixedFields, gridStyles: { height: 322 } })
|
|
1218
1253
|
}
|
|
1219
|
-
|
|
1220
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { 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
|
-
}, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GenericDataGrid_default, { tableName: detailTable.table, fixedFields }) });
|
|
1254
|
+
);
|
|
1229
1255
|
}
|
|
1230
1256
|
return void 0;
|
|
1231
1257
|
}
|
|
@@ -1256,7 +1282,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1256
1282
|
}
|
|
1257
1283
|
}
|
|
1258
1284
|
const value = row[props.column.key];
|
|
1259
|
-
return /* @__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) }) });
|
|
1285
|
+
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) }) }) });
|
|
1260
1286
|
}
|
|
1261
1287
|
case "detail": {
|
|
1262
1288
|
const detailColumn = column;
|
|
@@ -1267,7 +1293,6 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1267
1293
|
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,
|
|
1268
1294
|
_material.IconButton,
|
|
1269
1295
|
{
|
|
1270
|
-
size: "small",
|
|
1271
1296
|
onClick: (event) => {
|
|
1272
1297
|
let rows = [...tableData];
|
|
1273
1298
|
const rowId = getPrimaryKeyValues({ ...row, [DETAIL_ROW_INDICATOR]: detailTable.abr }, primaryKey);
|
|
@@ -1285,17 +1310,51 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1285
1310
|
}
|
|
1286
1311
|
event.stopPropagation();
|
|
1287
1312
|
},
|
|
1288
|
-
title: isExpanded ? "Contraer detalle" : "Expandir detalle",
|
|
1289
|
-
sx: { p: 0.5 },
|
|
1290
1313
|
children: isExpanded ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowUp2.default, { sx: { fontSize: 20 } }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { sx: { fontSize: 20 } })
|
|
1291
1314
|
}
|
|
1292
1315
|
) }) });
|
|
1293
1316
|
}
|
|
1294
1317
|
case "action": {
|
|
1295
1318
|
const actionColumn = column;
|
|
1296
|
-
const { tableDefinition, handleDeleteRow } = actionColumn;
|
|
1297
|
-
|
|
1298
|
-
|
|
1319
|
+
const { tableDefinition, handleDeleteRow, handleAddRow } = actionColumn;
|
|
1320
|
+
const gridActionButtons = [
|
|
1321
|
+
{
|
|
1322
|
+
action: "insert",
|
|
1323
|
+
handler: handleAddRow,
|
|
1324
|
+
icon: _Add2.default,
|
|
1325
|
+
title: "Agregar registro",
|
|
1326
|
+
color: "success"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
action: "delete",
|
|
1330
|
+
handler: handleDeleteRow,
|
|
1331
|
+
icon: _Delete2.default,
|
|
1332
|
+
title: "Eliminar registro",
|
|
1333
|
+
color: "error"
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
action: "vertical-edit",
|
|
1337
|
+
handler: () => {
|
|
1338
|
+
},
|
|
1339
|
+
// implementar funcion
|
|
1340
|
+
icon: _ViewHeadline2.default,
|
|
1341
|
+
title: "Editar registro en forma de ficha",
|
|
1342
|
+
color: "primary"
|
|
1343
|
+
}
|
|
1344
|
+
];
|
|
1345
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", gap: 0.5 }, children: gridActionButtons.map((actionDef) => tableDefinition.allow[actionDef.action] ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1346
|
+
_material.Button,
|
|
1347
|
+
{
|
|
1348
|
+
variant: "outlined",
|
|
1349
|
+
color: actionDef.color,
|
|
1350
|
+
size: "small",
|
|
1351
|
+
onClick: () => actionDef.handler(row),
|
|
1352
|
+
title: actionDef.title,
|
|
1353
|
+
sx: { width: 22, minWidth: 22, height: 22, "& .MuiButton-startIcon": { m: 0 } },
|
|
1354
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionDef.icon, { sx: { fontSize: 18 } })
|
|
1355
|
+
},
|
|
1356
|
+
actionDef.action
|
|
1357
|
+
) : null) });
|
|
1299
1358
|
}
|
|
1300
1359
|
default:
|
|
1301
1360
|
return void 0;
|
|
@@ -1306,6 +1365,16 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1306
1365
|
|
|
1307
1366
|
var _InputBase = require('@mui/material/InputBase'); var _InputBase2 = _interopRequireDefault(_InputBase);
|
|
1308
1367
|
|
|
1368
|
+
|
|
1369
|
+
function findChangedValues(oldRowData, newRowData) {
|
|
1370
|
+
let changes = [];
|
|
1371
|
+
for (const key in newRowData) {
|
|
1372
|
+
if (Object.prototype.hasOwnProperty.call(oldRowData, key) && oldRowData[key] !== newRowData[key]) {
|
|
1373
|
+
changes.push(key);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return changes;
|
|
1377
|
+
}
|
|
1309
1378
|
function InputRenderer({
|
|
1310
1379
|
column,
|
|
1311
1380
|
row,
|
|
@@ -1313,6 +1382,7 @@ function InputRenderer({
|
|
|
1313
1382
|
tableDefinition,
|
|
1314
1383
|
onRowChange,
|
|
1315
1384
|
onClose,
|
|
1385
|
+
cellFeedback,
|
|
1316
1386
|
setCellFeedback,
|
|
1317
1387
|
onEnterPress,
|
|
1318
1388
|
setTableData,
|
|
@@ -1322,7 +1392,13 @@ function InputRenderer({
|
|
|
1322
1392
|
}) {
|
|
1323
1393
|
const tableName = tableDefinition.tableName;
|
|
1324
1394
|
const [editingValue, setEditingValue] = _react.useState.call(void 0, row[column.key]);
|
|
1395
|
+
const theme = _material.useTheme.call(void 0, );
|
|
1325
1396
|
const { showSuccess, showError } = useSnackbar();
|
|
1397
|
+
const rowId = getPrimaryKeyValues(row, primaryKey);
|
|
1398
|
+
let cellBackgroundColor;
|
|
1399
|
+
if (cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === column.key) {
|
|
1400
|
+
cellBackgroundColor = cellFeedback.type === "error" ? theme.palette.error.light : theme.palette.success.light;
|
|
1401
|
+
}
|
|
1326
1402
|
const initialRowId = _react.useMemo.call(void 0, () => getPrimaryKeyValues(row, primaryKey), [row, primaryKey]);
|
|
1327
1403
|
const { callApi } = useApiCall();
|
|
1328
1404
|
const handleCommit = _react.useCallback.call(void 0, async (currentValue, closeEditor, focusNextCell) => {
|
|
@@ -1332,31 +1408,16 @@ function InputRenderer({
|
|
|
1332
1408
|
(key) => potentialUpdatedRow[key] !== void 0 && potentialUpdatedRow[key] !== null && String(potentialUpdatedRow[key]).trim() !== ""
|
|
1333
1409
|
);
|
|
1334
1410
|
const isNewRow = !arePKValuesFilled || potentialUpdatedRow[NEW_ROW_INDICATOR];
|
|
1335
|
-
const isMandatoryField = tableDefinition.primaryKey.includes(column.key) || _optionalChain([tableDefinition, 'access',
|
|
1411
|
+
const isMandatoryField = tableDefinition.primaryKey.includes(column.key) || _optionalChain([tableDefinition, 'access', _18 => _18.fields, 'access', _19 => _19.find, 'call', _20 => _20((f) => f.name === column.key), 'optionalAccess', _21 => _21.nullable]) === false;
|
|
1336
1412
|
const isMandatoryFieldEmpty = isNewRow && isMandatoryField && (processedNewValue === null || processedNewValue === void 0 || String(processedNewValue).trim() === "");
|
|
1337
1413
|
if (processedNewValue === row[column.key] && !isNewRow && !isMandatoryFieldEmpty) {
|
|
1338
1414
|
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).");
|
|
1339
|
-
onClose(false, focusNextCell);
|
|
1340
|
-
setLocalCellChanges((prev) => {
|
|
1341
|
-
const newMap = new Map(prev);
|
|
1342
|
-
const columnKeys = newMap.get(initialRowId);
|
|
1343
|
-
if (columnKeys) {
|
|
1344
|
-
columnKeys.delete(column.key);
|
|
1345
|
-
if (columnKeys.size === 0) {
|
|
1346
|
-
newMap.delete(initialRowId);
|
|
1347
|
-
} else {
|
|
1348
|
-
newMap.set(initialRowId, columnKeys);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
return newMap;
|
|
1352
|
-
});
|
|
1353
1415
|
return;
|
|
1354
1416
|
}
|
|
1355
1417
|
const oldRowData = { ...row };
|
|
1356
1418
|
const primaryKeyValuesForBackend = tableDefinition.primaryKey.map((key) => potentialUpdatedRow[key]);
|
|
1357
1419
|
const currentRowIdBeforeUpdate = getPrimaryKeyValues(oldRowData, tableDefinition.primaryKey);
|
|
1358
1420
|
onRowChange({ ...row, [column.key]: processedNewValue }, true);
|
|
1359
|
-
onClose(true, focusNextCell);
|
|
1360
1421
|
if (isNewRow) {
|
|
1361
1422
|
const areAllMandatoryFieldsFilled = tableDefinition.fields.every((fieldDef) => {
|
|
1362
1423
|
const isMandatory = fieldDef.nullable === false || fieldDef.isPk;
|
|
@@ -1403,7 +1464,7 @@ function InputRenderer({
|
|
|
1403
1464
|
}
|
|
1404
1465
|
});
|
|
1405
1466
|
if (localCellChanges.has(initialRowId)) {
|
|
1406
|
-
_optionalChain([localCellChanges, 'access',
|
|
1467
|
+
_optionalChain([localCellChanges, 'access', _22 => _22.get, 'call', _23 => _23(initialRowId), 'optionalAccess', _24 => _24.forEach, 'call', _25 => _25((colKey) => {
|
|
1407
1468
|
if (!rowToSend.hasOwnProperty(colKey)) {
|
|
1408
1469
|
rowToSend[colKey] = potentialUpdatedRow[colKey];
|
|
1409
1470
|
}
|
|
@@ -1424,20 +1485,6 @@ function InputRenderer({
|
|
|
1424
1485
|
oldRow: oldRowData,
|
|
1425
1486
|
status
|
|
1426
1487
|
});
|
|
1427
|
-
setLocalCellChanges((prev) => {
|
|
1428
|
-
const newMap = new Map(prev);
|
|
1429
|
-
const columnKeys = newMap.get(initialRowId);
|
|
1430
|
-
if (columnKeys) {
|
|
1431
|
-
columnKeys.delete(column.key);
|
|
1432
|
-
if (columnKeys.size === 0) {
|
|
1433
|
-
newMap.delete(initialRowId);
|
|
1434
|
-
} else {
|
|
1435
|
-
newMap.set(initialRowId, columnKeys);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
return newMap;
|
|
1439
|
-
});
|
|
1440
|
-
showSuccess("Registro guardado exitosamente!");
|
|
1441
1488
|
let finalRowIdForFeedback;
|
|
1442
1489
|
let persistedRowData;
|
|
1443
1490
|
if (response.row && isNewRow) {
|
|
@@ -1460,15 +1507,17 @@ function InputRenderer({
|
|
|
1460
1507
|
});
|
|
1461
1508
|
finalRowIdForFeedback = getPrimaryKeyValues(persistedRowData, tableDefinition.primaryKey);
|
|
1462
1509
|
} else {
|
|
1463
|
-
persistedRowData =
|
|
1510
|
+
persistedRowData = response.row;
|
|
1464
1511
|
const isPrimaryKeyColumn = tableDefinition.primaryKey.includes(column.key);
|
|
1465
1512
|
finalRowIdForFeedback = isPrimaryKeyColumn ? getPrimaryKeyValues(potentialUpdatedRow, tableDefinition.primaryKey) : currentRowIdBeforeUpdate;
|
|
1513
|
+
onRowChange({ ...response.row }, true);
|
|
1466
1514
|
}
|
|
1467
|
-
|
|
1515
|
+
findChangedValues(oldRowData, response.row).forEach(
|
|
1516
|
+
(key) => setCellFeedback({ rowId: finalRowIdForFeedback, columnKey: key, type: "success" })
|
|
1517
|
+
);
|
|
1468
1518
|
} catch (err) {
|
|
1469
1519
|
console.error("Error al guardar el registro:", err);
|
|
1470
|
-
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error" });
|
|
1471
|
-
onRowChange(oldRowData, true);
|
|
1520
|
+
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error", message: err.message });
|
|
1472
1521
|
}
|
|
1473
1522
|
}, [
|
|
1474
1523
|
column,
|
|
@@ -1487,21 +1536,19 @@ function InputRenderer({
|
|
|
1487
1536
|
initialRowId
|
|
1488
1537
|
]);
|
|
1489
1538
|
const handleKeyDown = _react.useCallback.call(void 0, (event) => {
|
|
1490
|
-
if (
|
|
1539
|
+
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight"].includes(event.key)) {
|
|
1491
1540
|
handleCommit(editingValue, true, true);
|
|
1492
1541
|
event.preventDefault();
|
|
1493
1542
|
if (onEnterPress) {
|
|
1494
|
-
onEnterPress(rowIdx, column.key);
|
|
1543
|
+
onEnterPress(rowIdx, column.key, event.key);
|
|
1495
1544
|
}
|
|
1496
|
-
} else if (event.key === "Tab") {
|
|
1497
|
-
handleCommit(editingValue, true, true);
|
|
1498
1545
|
}
|
|
1499
1546
|
}, [handleCommit, editingValue, column.key, rowIdx, onEnterPress]);
|
|
1500
1547
|
const handleBlur = _react.useCallback.call(void 0, () => {
|
|
1501
1548
|
handleCommit(editingValue, true, false);
|
|
1502
1549
|
}, [handleCommit, editingValue]);
|
|
1503
1550
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1504
|
-
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
1551
|
+
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess', _26 => _26.editable]) !== false;
|
|
1505
1552
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1506
1553
|
_InputBase2.default,
|
|
1507
1554
|
{
|
|
@@ -1517,7 +1564,8 @@ function InputRenderer({
|
|
|
1517
1564
|
borderRadius: "4px",
|
|
1518
1565
|
padding: "2px 4px",
|
|
1519
1566
|
fontSize: "0.8rem",
|
|
1520
|
-
boxSizing: "border-box"
|
|
1567
|
+
boxSizing: "border-box",
|
|
1568
|
+
backgroundColor: cellBackgroundColor
|
|
1521
1569
|
},
|
|
1522
1570
|
onClick: (e) => e.stopPropagation(),
|
|
1523
1571
|
autoFocus: true,
|
|
@@ -1529,28 +1577,56 @@ var InputRenderer_default = InputRenderer;
|
|
|
1529
1577
|
|
|
1530
1578
|
// src/components/grid/renderers/editCellRenderers.tsx
|
|
1531
1579
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
return void 0;
|
|
1540
|
-
}
|
|
1541
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1542
|
-
InputRenderer_default,
|
|
1543
|
-
{
|
|
1544
|
-
...props,
|
|
1580
|
+
|
|
1581
|
+
var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
1582
|
+
const column = props.column;
|
|
1583
|
+
switch (column.customType) {
|
|
1584
|
+
case "default": {
|
|
1585
|
+
const defaultColumn = column;
|
|
1586
|
+
const {
|
|
1545
1587
|
tableDefinition,
|
|
1546
|
-
|
|
1547
|
-
|
|
1588
|
+
fixedFields,
|
|
1589
|
+
primaryKey,
|
|
1548
1590
|
setTableData,
|
|
1549
|
-
|
|
1591
|
+
cellFeedback,
|
|
1592
|
+
setCellFeedback,
|
|
1593
|
+
handleEnterKeyPressInEditor,
|
|
1550
1594
|
localCellChanges,
|
|
1551
|
-
|
|
1595
|
+
setLocalCellChanges
|
|
1596
|
+
} = defaultColumn;
|
|
1597
|
+
if (column.editable) {
|
|
1598
|
+
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1599
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _27 => _27.some, 'call', _28 => _28((f) => f.fieldName === column.key)]);
|
|
1600
|
+
const isFieldEditableByUI = _optionalChain([fieldDefinition, 'optionalAccess', _29 => _29.editable]) !== false && !isFixedField;
|
|
1601
|
+
if (!isFieldEditableByUI) {
|
|
1602
|
+
return void 0;
|
|
1603
|
+
}
|
|
1604
|
+
const rowId = getPrimaryKeyValues(props.row, primaryKey);
|
|
1605
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: cellFeedback && cellFeedback.rowId === rowId && cellFeedback.columnKey === props.column.key ? _optionalChain([cellFeedback, 'optionalAccess', _30 => _30.message]) : "", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1606
|
+
InputRenderer_default,
|
|
1607
|
+
{
|
|
1608
|
+
...props,
|
|
1609
|
+
tableDefinition,
|
|
1610
|
+
setCellFeedback,
|
|
1611
|
+
cellFeedback,
|
|
1612
|
+
onEnterPress: (rowIndex, columnKey, key) => handleEnterKeyPressInEditor(rowIndex, columnKey, key, allColumns),
|
|
1613
|
+
setTableData,
|
|
1614
|
+
setLocalCellChanges,
|
|
1615
|
+
localCellChanges,
|
|
1616
|
+
primaryKey
|
|
1617
|
+
}
|
|
1618
|
+
) }) });
|
|
1552
1619
|
}
|
|
1553
|
-
|
|
1620
|
+
return void 0;
|
|
1621
|
+
}
|
|
1622
|
+
case "detail": {
|
|
1623
|
+
return void 0;
|
|
1624
|
+
}
|
|
1625
|
+
case "action": {
|
|
1626
|
+
return void 0;
|
|
1627
|
+
}
|
|
1628
|
+
default:
|
|
1629
|
+
return void 0;
|
|
1554
1630
|
}
|
|
1555
1631
|
};
|
|
1556
1632
|
|
|
@@ -1578,7 +1654,10 @@ function EmptyRowsRenderer() {
|
|
|
1578
1654
|
// src/components/grid/GenericDataGrid.tsx
|
|
1579
1655
|
|
|
1580
1656
|
var getPrimaryKeyValues = (row, primaryKey) => {
|
|
1581
|
-
|
|
1657
|
+
if (row[DETAIL_ROW_INDICATOR]) {
|
|
1658
|
+
primaryKey = primaryKey.concat(DETAIL_ROW_INDICATOR);
|
|
1659
|
+
}
|
|
1660
|
+
return primaryKey.map((key) => {
|
|
1582
1661
|
return row[key] !== void 0 && row[key] !== null ? String(row[key]) : "NULL_OR_UNDEFINED";
|
|
1583
1662
|
}).join("|");
|
|
1584
1663
|
};
|
|
@@ -1586,13 +1665,16 @@ var NEW_ROW_INDICATOR = "$new";
|
|
|
1586
1665
|
var DETAIL_ROW_INDICATOR = "$detail";
|
|
1587
1666
|
var GenericDataGrid = ({
|
|
1588
1667
|
tableName,
|
|
1589
|
-
fixedFields
|
|
1668
|
+
fixedFields,
|
|
1669
|
+
gridStyles
|
|
1590
1670
|
}) => {
|
|
1671
|
+
const isOpenMenu = useIsDrawerOpen();
|
|
1591
1672
|
const [tableDefinition, setTableDefinition] = _react.useState.call(void 0, null);
|
|
1592
1673
|
const [tableData, setTableData] = _react.useState.call(void 0, []);
|
|
1593
1674
|
const [isFilterRowVisible, setIsFilterRowVisible] = _react.useState.call(void 0, false);
|
|
1594
1675
|
const [filters, setFilters] = _react.useState.call(void 0, {});
|
|
1595
1676
|
const [selectedRows, setSelectedRows] = _react.useState.call(void 0, () => /* @__PURE__ */ new Set());
|
|
1677
|
+
const [selectedCell, setSelectedCell] = _react.useState.call(void 0, void 0);
|
|
1596
1678
|
const [cellFeedback, setCellFeedback] = _react.useState.call(void 0, null);
|
|
1597
1679
|
const [localCellChanges, setLocalCellChanges] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
1598
1680
|
const theme = _material.useTheme.call(void 0, );
|
|
@@ -1638,7 +1720,11 @@ var GenericDataGrid = ({
|
|
|
1638
1720
|
}
|
|
1639
1721
|
};
|
|
1640
1722
|
fetchDataAndDefinition();
|
|
1641
|
-
}, [
|
|
1723
|
+
}, [
|
|
1724
|
+
tableName,
|
|
1725
|
+
/*fixedFields,*/
|
|
1726
|
+
showError
|
|
1727
|
+
]);
|
|
1642
1728
|
_react.useEffect.call(void 0, () => {
|
|
1643
1729
|
if (cellFeedback) {
|
|
1644
1730
|
if (feedbackTimerRef.current) {
|
|
@@ -1646,7 +1732,8 @@ var GenericDataGrid = ({
|
|
|
1646
1732
|
}
|
|
1647
1733
|
const timerDuration = 3e3;
|
|
1648
1734
|
feedbackTimerRef.current = setTimeout(() => {
|
|
1649
|
-
|
|
1735
|
+
if (cellFeedback.type == "success")
|
|
1736
|
+
setCellFeedback(null);
|
|
1650
1737
|
}, timerDuration);
|
|
1651
1738
|
}
|
|
1652
1739
|
return () => {
|
|
@@ -1795,12 +1882,12 @@ var GenericDataGrid = ({
|
|
|
1795
1882
|
}
|
|
1796
1883
|
return rows;
|
|
1797
1884
|
}, [tableData, filters, isFilterRowVisible]);
|
|
1798
|
-
const handleEnterKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, currentColumns) => {
|
|
1885
|
+
const handleEnterKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, key, currentColumns) => {
|
|
1799
1886
|
if (dataGridRef.current && tableDefinition) {
|
|
1800
1887
|
const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
|
|
1801
1888
|
const editableColumns = currentColumns.filter((col) => {
|
|
1802
1889
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1803
|
-
return col.key !== "
|
|
1890
|
+
return col.key !== "actionsColumn" && col.customType != "detail" && (_optionalChain([fieldDefinition, 'optionalAccess', _31 => _31.editable]) !== false && !_optionalChain([fieldDefinition, 'optionalAccess', _32 => _32.clientSide]));
|
|
1804
1891
|
});
|
|
1805
1892
|
if (currentColumnIndex !== -1 && editableColumns.length > 0) {
|
|
1806
1893
|
const editableColumnKeys = editableColumns.map((col) => col.key);
|
|
@@ -1817,19 +1904,22 @@ var GenericDataGrid = ({
|
|
|
1817
1904
|
}
|
|
1818
1905
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1819
1906
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1820
|
-
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor:
|
|
1907
|
+
_optionalChain([dataGridRef, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.selectCell, 'call', _35 => _35({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true })]);
|
|
1821
1908
|
}
|
|
1822
1909
|
}
|
|
1823
1910
|
}
|
|
1824
1911
|
}, [filteredRows, tableDefinition]);
|
|
1912
|
+
const handleSelectedCellChange = _react.useCallback.call(void 0, (args) => {
|
|
1913
|
+
setSelectedCell(args);
|
|
1914
|
+
}, []);
|
|
1825
1915
|
const columns = _react.useMemo.call(void 0, () => {
|
|
1826
1916
|
if (!tableDefinition) return [];
|
|
1827
1917
|
const fieldsToShow = tableDefinition.fields.filter((field) => {
|
|
1828
|
-
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess',
|
|
1918
|
+
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _36 => _36.find, 'call', _37 => _37((f) => f.fieldName === field.name)]);
|
|
1829
1919
|
return !(fixedFieldEntry && fixedFieldEntry.until === void 0);
|
|
1830
1920
|
});
|
|
1831
1921
|
const defaultColumns = fieldsToShow.map((fieldDef) => {
|
|
1832
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
1922
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((f) => f.fieldName === fieldDef.name)]);
|
|
1833
1923
|
const isFieldEditable = fieldDef.editable !== false && !isFixedField;
|
|
1834
1924
|
return {
|
|
1835
1925
|
key: fieldDef.name,
|
|
@@ -1840,27 +1930,37 @@ var GenericDataGrid = ({
|
|
|
1840
1930
|
primaryKey,
|
|
1841
1931
|
fixedFields,
|
|
1842
1932
|
localCellChanges,
|
|
1933
|
+
setLocalCellChanges,
|
|
1934
|
+
setTableData,
|
|
1935
|
+
setCellFeedback,
|
|
1843
1936
|
name: fieldDef.label || cambiarGuionesBajosPorEspacios(fieldDef.name),
|
|
1844
1937
|
resizable: true,
|
|
1845
1938
|
sortable: true,
|
|
1846
|
-
//frozen: true,
|
|
1847
1939
|
editable: isFieldEditable,
|
|
1940
|
+
handleEnterKeyPressInEditor,
|
|
1848
1941
|
flexGrow: 1,
|
|
1849
1942
|
minWidth: 60,
|
|
1850
1943
|
renderHeaderCell: (props) => defaultColumnHeaderCellRenderer(props, fieldDef),
|
|
1851
1944
|
renderSummaryCell: (props) => defaultColumnSummaryCellRenderer(props, fixedFields, isFilterRowVisible, filters, setFilters)
|
|
1852
1945
|
};
|
|
1853
1946
|
});
|
|
1947
|
+
const availableActions = [
|
|
1948
|
+
_optionalChain([tableDefinition, 'access', _40 => _40.allow, 'optionalAccess', _41 => _41.insert]),
|
|
1949
|
+
_optionalChain([tableDefinition, 'access', _42 => _42.allow, 'optionalAccess', _43 => _43.delete]),
|
|
1950
|
+
_optionalChain([tableDefinition, 'access', _44 => _44.allow, 'optionalAccess', _45 => _45["vertical-edit"]])
|
|
1951
|
+
].filter(Boolean).length;
|
|
1952
|
+
const actionColumnWidth = availableActions === 0 ? 30 : 12 + availableActions * 25;
|
|
1854
1953
|
const actionsColumn = {
|
|
1855
|
-
key: "
|
|
1954
|
+
key: "actionsColumn",
|
|
1856
1955
|
customType: "action",
|
|
1857
1956
|
tableDefinition,
|
|
1858
1957
|
handleDeleteRow,
|
|
1958
|
+
handleAddRow,
|
|
1859
1959
|
name: "filterCol",
|
|
1860
|
-
width:
|
|
1960
|
+
width: actionColumnWidth,
|
|
1961
|
+
editable: false,
|
|
1861
1962
|
resizable: false,
|
|
1862
1963
|
sortable: false,
|
|
1863
|
-
//frozen: true,
|
|
1864
1964
|
renderHeaderCell: (props) => actionsColumnHeaderCellRenderer(props, isFilterRowVisible, toggleFilterVisibility),
|
|
1865
1965
|
renderSummaryCell: (props) => actionsColumnSummaryCellRenderer(props)
|
|
1866
1966
|
};
|
|
@@ -1880,8 +1980,9 @@ var GenericDataGrid = ({
|
|
|
1880
1980
|
name: detailTable.label || `Detalle ${detailTable.abr}`,
|
|
1881
1981
|
resizable: false,
|
|
1882
1982
|
sortable: false,
|
|
1883
|
-
|
|
1884
|
-
|
|
1983
|
+
editable: false,
|
|
1984
|
+
width: 30,
|
|
1985
|
+
minWidth: 30,
|
|
1885
1986
|
renderHeaderCell: (props) => detailColumnCellHeaderRenderer(props, detailTable),
|
|
1886
1987
|
renderSummaryCell: (props) => detailColumnCellSummaryRenderer(props)
|
|
1887
1988
|
});
|
|
@@ -1903,7 +2004,9 @@ var GenericDataGrid = ({
|
|
|
1903
2004
|
}
|
|
1904
2005
|
return void 0;
|
|
1905
2006
|
},
|
|
1906
|
-
|
|
2007
|
+
editorOptions: { closeOnExternalRowChange: false },
|
|
2008
|
+
//con esto no se pierde el foco
|
|
2009
|
+
renderEditCell: (props) => allColumnsEditCellRenderer(props, allColumns),
|
|
1907
2010
|
renderCell: (props) => allColumnsCellRenderer(props)
|
|
1908
2011
|
}));
|
|
1909
2012
|
}, [
|
|
@@ -1921,16 +2024,33 @@ var GenericDataGrid = ({
|
|
|
1921
2024
|
setTableData,
|
|
1922
2025
|
localCellChanges,
|
|
1923
2026
|
handleDeleteRow,
|
|
2027
|
+
handleAddRow,
|
|
1924
2028
|
fixedFields,
|
|
1925
2029
|
tableData
|
|
1926
2030
|
]);
|
|
1927
2031
|
const handleRowsChange = _react.useCallback.call(void 0, (updatedRows) => {
|
|
1928
2032
|
setTableData(updatedRows);
|
|
1929
2033
|
}, []);
|
|
2034
|
+
const deselectAllOtherGrids = (currentGridElement) => {
|
|
2035
|
+
const allSelectedCells = document.querySelectorAll("div[aria-selected='true']");
|
|
2036
|
+
allSelectedCells.forEach((cell) => {
|
|
2037
|
+
const parentGrid = cell.closest(".rdg");
|
|
2038
|
+
if (parentGrid && parentGrid !== currentGridElement) {
|
|
2039
|
+
cell.setAttribute("aria-selected", "false");
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
};
|
|
2043
|
+
const handleCellKeyDown = (args, event) => {
|
|
2044
|
+
if (["Tab", "Enter"].includes(event.key)) {
|
|
2045
|
+
event.preventGridDefault();
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
1930
2048
|
const handleCellClick = _react.useCallback.call(void 0, (args) => {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
const
|
|
2049
|
+
deselectAllOtherGrids(_optionalChain([dataGridRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.element]));
|
|
2050
|
+
args.selectCell(true);
|
|
2051
|
+
const fieldDefinition = _optionalChain([tableDefinition, 'optionalAccess', _48 => _48.fields, 'access', _49 => _49.find, 'call', _50 => _50((f) => f.name === args.column.key)]);
|
|
2052
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _51 => _51.some, 'call', _52 => _52((f) => f.fieldName === args.column.key)]);
|
|
2053
|
+
const isEditable = _optionalChain([fieldDefinition, 'optionalAccess', _53 => _53.editable]) !== false && !isFixedField;
|
|
1934
2054
|
console.log("Clicked column index:", args.column.idx);
|
|
1935
2055
|
console.log("Clicked row index:", args.rowIdx);
|
|
1936
2056
|
console.log("Is editable:", isEditable);
|
|
@@ -1948,15 +2068,6 @@ var GenericDataGrid = ({
|
|
|
1948
2068
|
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." }) });
|
|
1949
2069
|
}
|
|
1950
2070
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { pt: 2, display: "flex", flexDirection: "column", height: "100%", boxSizing: "border-box" }, children: [
|
|
1951
|
-
_optionalChain([tableDefinition, 'access', _43 => _43.allow, 'optionalAccess', _44 => _44.insert]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { display: "flex", px: 2, pb: 1 }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1952
|
-
_material.Button,
|
|
1953
|
-
{
|
|
1954
|
-
variant: "contained",
|
|
1955
|
-
onClick: handleAddRow,
|
|
1956
|
-
startIcon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Add2.default, {}),
|
|
1957
|
-
children: "Nuevo Registro"
|
|
1958
|
-
}
|
|
1959
|
-
) }),
|
|
1960
2071
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1961
2072
|
_material.Box,
|
|
1962
2073
|
{
|
|
@@ -1972,10 +2083,10 @@ var GenericDataGrid = ({
|
|
|
1972
2083
|
ml: 2,
|
|
1973
2084
|
mr: 2
|
|
1974
2085
|
},
|
|
1975
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "
|
|
2086
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "subtitle2", component: "div", children: [
|
|
1976
2087
|
cambiarGuionesBajosPorEspacios(tableDefinition.title || tableDefinition.name),
|
|
1977
|
-
" -
|
|
1978
|
-
getFilteredRowCount() === getRowCount() ? `${getRowCount()} registros` : `${getFilteredRowCount()}
|
|
2088
|
+
" - ",
|
|
2089
|
+
getFilteredRowCount() === getRowCount() ? `${getRowCount()} registros` : `${getFilteredRowCount()} (F)`
|
|
1979
2090
|
] })
|
|
1980
2091
|
}
|
|
1981
2092
|
),
|
|
@@ -1994,6 +2105,7 @@ var GenericDataGrid = ({
|
|
|
1994
2105
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1995
2106
|
_reactdatagrid.DataGrid,
|
|
1996
2107
|
{
|
|
2108
|
+
className: "rdg-light",
|
|
1997
2109
|
ref: dataGridRef,
|
|
1998
2110
|
columns,
|
|
1999
2111
|
rows: filteredRows.map((row) => ({
|
|
@@ -2003,15 +2115,17 @@ var GenericDataGrid = ({
|
|
|
2003
2115
|
enableVirtualization: true,
|
|
2004
2116
|
rowKeyGetter: (row) => getPrimaryKeyValues(row, primaryKey),
|
|
2005
2117
|
onSelectedRowsChange: setSelectedRows,
|
|
2118
|
+
onSelectedCellChange: handleSelectedCellChange,
|
|
2006
2119
|
onRowsChange: handleRowsChange,
|
|
2007
2120
|
selectedRows,
|
|
2008
|
-
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 :
|
|
2009
|
-
style: { height: "100%", width: "100%", boxSizing: "border-box" },
|
|
2010
|
-
headerRowHeight:
|
|
2121
|
+
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 : 30,
|
|
2122
|
+
style: { ...{ height: "100%", width: "100%", boxSizing: "border-box" }, ...gridStyles },
|
|
2123
|
+
headerRowHeight: 30,
|
|
2011
2124
|
topSummaryRows: isFilterRowVisible ? [{ id: "filterRow" }] : void 0,
|
|
2012
|
-
summaryRowHeight: isFilterRowVisible ?
|
|
2125
|
+
summaryRowHeight: isFilterRowVisible ? 30 : 0,
|
|
2126
|
+
renderers: { noRowsFallback: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EmptyRowsRenderer, {}) },
|
|
2013
2127
|
onCellClick: handleCellClick,
|
|
2014
|
-
|
|
2128
|
+
onCellKeyDown: handleCellKeyDown
|
|
2015
2129
|
}
|
|
2016
2130
|
)
|
|
2017
2131
|
}
|
|
@@ -2550,7 +2664,7 @@ var SessionExpiredMessage_default = SessionExpiredMessage;
|
|
|
2550
2664
|
var HomePage = () => {
|
|
2551
2665
|
const { clientContext } = useApp();
|
|
2552
2666
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 3 }, children: [
|
|
2553
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess',
|
|
2667
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess', _54 => _54.username])}` }),
|
|
2554
2668
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", children: "Usa el men\xFA lateral para navegar por las diferentes secciones." })
|
|
2555
2669
|
] });
|
|
2556
2670
|
};
|
|
@@ -2679,7 +2793,7 @@ var LoginPage = () => {
|
|
|
2679
2793
|
fullWidth: true,
|
|
2680
2794
|
margin: "normal",
|
|
2681
2795
|
error: !!errors.username,
|
|
2682
|
-
helperText: _optionalChain([errors, 'access',
|
|
2796
|
+
helperText: _optionalChain([errors, 'access', _55 => _55.username, 'optionalAccess', _56 => _56.message]),
|
|
2683
2797
|
disabled: isSubmitting
|
|
2684
2798
|
}
|
|
2685
2799
|
)
|
|
@@ -2702,7 +2816,7 @@ var LoginPage = () => {
|
|
|
2702
2816
|
fullWidth: true,
|
|
2703
2817
|
margin: "normal",
|
|
2704
2818
|
error: !!errors.password,
|
|
2705
|
-
helperText: _optionalChain([errors, 'access',
|
|
2819
|
+
helperText: _optionalChain([errors, 'access', _57 => _57.password, 'optionalAccess', _58 => _58.message]),
|
|
2706
2820
|
disabled: isSubmitting
|
|
2707
2821
|
}
|
|
2708
2822
|
)
|
|
@@ -2780,7 +2894,7 @@ var ProcedureForm = () => {
|
|
|
2780
2894
|
const [executionLog, setExecutionLog] = _react.useState.call(void 0, []);
|
|
2781
2895
|
const [procedureResultData, setProcedureResultData] = _react.useState.call(void 0, null);
|
|
2782
2896
|
const procedure = _react.useMemo.call(void 0, () => {
|
|
2783
|
-
if (procedureName && _optionalChain([clientContext, 'optionalAccess',
|
|
2897
|
+
if (procedureName && _optionalChain([clientContext, 'optionalAccess', _59 => _59.procedure])) {
|
|
2784
2898
|
return clientContext.procedure[procedureName];
|
|
2785
2899
|
}
|
|
2786
2900
|
return void 0;
|
|
@@ -3071,7 +3185,7 @@ var ProcedureForm = () => {
|
|
|
3071
3185
|
}
|
|
3072
3186
|
}, [formValues, handleChange, apiLoading, validationErrors]);
|
|
3073
3187
|
const ResultDisplayContent = _react.useMemo.call(void 0, () => {
|
|
3074
|
-
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess',
|
|
3188
|
+
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess', _60 => _60.resultOk])) return null;
|
|
3075
3189
|
const ComponentToRender = resultsOk[procedure.resultOk];
|
|
3076
3190
|
if (ComponentToRender) {
|
|
3077
3191
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentToRender, { data: procedureResultData });
|