frontend-plus-react 0.1.5 → 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 +144 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +220 -159
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.cts +0 -204
- package/dist/index.d.ts +0 -204
package/dist/index.cjs
CHANGED
|
@@ -986,9 +986,18 @@ var useRedirectPath = () => {
|
|
|
986
986
|
|
|
987
987
|
// src/utils/functions.tsx
|
|
988
988
|
var cambiarGuionesBajosPorEspacios = (texto) => texto.replace(/_/g, " ");
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
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
|
+
};
|
|
992
1001
|
|
|
993
1002
|
// src/components/ConfirmDialog.tsx
|
|
994
1003
|
var _Dialog = require('@mui/material/Dialog'); var _Dialog2 = _interopRequireDefault(_Dialog);
|
|
@@ -1022,6 +1031,7 @@ var ConfirmDialog = ({ open, onClose, title, message }) => {
|
|
|
1022
1031
|
|
|
1023
1032
|
var _Search = require('@mui/icons-material/Search'); var _Search2 = _interopRequireDefault(_Search);
|
|
1024
1033
|
var _SearchOff = require('@mui/icons-material/SearchOff'); var _SearchOff2 = _interopRequireDefault(_SearchOff);
|
|
1034
|
+
var _MoreVert = require('@mui/icons-material/MoreVert'); var _MoreVert2 = _interopRequireDefault(_MoreVert);
|
|
1025
1035
|
|
|
1026
1036
|
var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
1027
1037
|
const { column } = props;
|
|
@@ -1045,7 +1055,7 @@ var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
|
1045
1055
|
sx: {
|
|
1046
1056
|
fontWeight: "bold",
|
|
1047
1057
|
textDecoration: isPrimaryKey ? "underline" : "none",
|
|
1048
|
-
fontSize: "
|
|
1058
|
+
fontSize: "o.930rem"
|
|
1049
1059
|
// Puedes ajustar el tamaño si es necesario
|
|
1050
1060
|
},
|
|
1051
1061
|
children: column.name
|
|
@@ -1054,17 +1064,30 @@ var defaultColumnHeaderCellRenderer = (props, fieldDef) => {
|
|
|
1054
1064
|
}
|
|
1055
1065
|
);
|
|
1056
1066
|
};
|
|
1057
|
-
var actionsColumnHeaderCellRenderer = (props, isFilterRowVisible, toggleFilterVisibility) => /* @__PURE__ */ _jsxruntime.
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
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
|
+
] });
|
|
1068
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() }) });
|
|
1069
1092
|
|
|
1070
1093
|
// src/components/grid/FilterInputRender.tsx
|
|
@@ -1085,6 +1108,7 @@ function FilterInputRenderer({
|
|
|
1085
1108
|
}),
|
|
1086
1109
|
sx: {
|
|
1087
1110
|
width: "100%",
|
|
1111
|
+
height: 25,
|
|
1088
1112
|
margin: "0",
|
|
1089
1113
|
border: "1px solid #ccc",
|
|
1090
1114
|
borderRadius: "4px",
|
|
@@ -1100,18 +1124,19 @@ var FilterInputRender_default = FilterInputRenderer;
|
|
|
1100
1124
|
|
|
1101
1125
|
// src/components/grid/renderers/summaryCellRenderers.tsx
|
|
1102
1126
|
|
|
1127
|
+
|
|
1103
1128
|
var defaultColumnSummaryCellRenderer = (props, fixedFields, isFilterRowVisible, filters, setFilters) => {
|
|
1104
1129
|
const { column } = props;
|
|
1105
1130
|
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _3 => _3.find, 'call', _4 => _4((f) => f.fieldName === column.key)]);
|
|
1106
1131
|
if (fixedFieldEntry && fixedFieldEntry.until === void 0 || !isFilterRowVisible) return null;
|
|
1107
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1132
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1108
1133
|
FilterInputRender_default,
|
|
1109
1134
|
{
|
|
1110
1135
|
column,
|
|
1111
1136
|
filters,
|
|
1112
1137
|
setFilters
|
|
1113
1138
|
}
|
|
1114
|
-
);
|
|
1139
|
+
) });
|
|
1115
1140
|
};
|
|
1116
1141
|
var actionsColumnSummaryCellRenderer = (props) => null;
|
|
1117
1142
|
var detailColumnCellSummaryRenderer = (props) => null;
|
|
@@ -1120,7 +1145,9 @@ var detailColumnCellSummaryRenderer = (props) => null;
|
|
|
1120
1145
|
|
|
1121
1146
|
var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
|
|
1122
1147
|
var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _KeyboardArrowUp2 = _interopRequireDefault(_KeyboardArrowUp);
|
|
1148
|
+
var _ViewHeadline = require('@mui/icons-material/ViewHeadline'); var _ViewHeadline2 = _interopRequireDefault(_ViewHeadline);
|
|
1123
1149
|
var _Delete = require('@mui/icons-material/Delete'); var _Delete2 = _interopRequireDefault(_Delete);
|
|
1150
|
+
var _Add = require('@mui/icons-material/Add'); var _Add2 = _interopRequireDefault(_Add);
|
|
1124
1151
|
|
|
1125
1152
|
// src/components/grid/ExampleClientSideComponent.tsx
|
|
1126
1153
|
|
|
@@ -1205,15 +1232,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1205
1232
|
const detailTableAbr = row[DETAIL_ROW_INDICATOR];
|
|
1206
1233
|
const detailColumn = column;
|
|
1207
1234
|
if (column.customType === "detail" && detailColumn.detailTable.abr === detailTableAbr) {
|
|
1208
|
-
const detailTable = detailColumn.tableDefinition
|
|
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
|
-
});
|
|
1235
|
+
const { detailTable, fixedFields } = getDetailTableAndFixedFieldsForDetailTableAbr(detailColumn.tableDefinition, detailTableAbr, row);
|
|
1217
1236
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1218
1237
|
_material.Box,
|
|
1219
1238
|
{
|
|
@@ -1230,7 +1249,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1230
1249
|
onClick: (e) => e.stopPropagation(),
|
|
1231
1250
|
onKeyDown: (e) => e.stopPropagation(),
|
|
1232
1251
|
onDoubleClick: (e) => e.stopPropagation(),
|
|
1233
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GenericDataGrid_default, { tableName: detailTable.table, fixedFields })
|
|
1252
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GenericDataGrid_default, { tableName: detailTable.table, fixedFields, gridStyles: { height: 322 } })
|
|
1234
1253
|
}
|
|
1235
1254
|
);
|
|
1236
1255
|
}
|
|
@@ -1274,7 +1293,6 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1274
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,
|
|
1275
1294
|
_material.IconButton,
|
|
1276
1295
|
{
|
|
1277
|
-
size: "small",
|
|
1278
1296
|
onClick: (event) => {
|
|
1279
1297
|
let rows = [...tableData];
|
|
1280
1298
|
const rowId = getPrimaryKeyValues({ ...row, [DETAIL_ROW_INDICATOR]: detailTable.abr }, primaryKey);
|
|
@@ -1292,17 +1310,51 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1292
1310
|
}
|
|
1293
1311
|
event.stopPropagation();
|
|
1294
1312
|
},
|
|
1295
|
-
title: isExpanded ? "Contraer detalle" : "Expandir detalle",
|
|
1296
|
-
sx: { p: 0.5 },
|
|
1297
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 } })
|
|
1298
1314
|
}
|
|
1299
1315
|
) }) });
|
|
1300
1316
|
}
|
|
1301
1317
|
case "action": {
|
|
1302
1318
|
const actionColumn = column;
|
|
1303
|
-
const { tableDefinition, handleDeleteRow } = actionColumn;
|
|
1304
|
-
|
|
1305
|
-
|
|
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) });
|
|
1306
1358
|
}
|
|
1307
1359
|
default:
|
|
1308
1360
|
return void 0;
|
|
@@ -1356,7 +1408,7 @@ function InputRenderer({
|
|
|
1356
1408
|
(key) => potentialUpdatedRow[key] !== void 0 && potentialUpdatedRow[key] !== null && String(potentialUpdatedRow[key]).trim() !== ""
|
|
1357
1409
|
);
|
|
1358
1410
|
const isNewRow = !arePKValuesFilled || potentialUpdatedRow[NEW_ROW_INDICATOR];
|
|
1359
|
-
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;
|
|
1360
1412
|
const isMandatoryFieldEmpty = isNewRow && isMandatoryField && (processedNewValue === null || processedNewValue === void 0 || String(processedNewValue).trim() === "");
|
|
1361
1413
|
if (processedNewValue === row[column.key] && !isNewRow && !isMandatoryFieldEmpty) {
|
|
1362
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).");
|
|
@@ -1412,7 +1464,7 @@ function InputRenderer({
|
|
|
1412
1464
|
}
|
|
1413
1465
|
});
|
|
1414
1466
|
if (localCellChanges.has(initialRowId)) {
|
|
1415
|
-
_optionalChain([localCellChanges, 'access',
|
|
1467
|
+
_optionalChain([localCellChanges, 'access', _22 => _22.get, 'call', _23 => _23(initialRowId), 'optionalAccess', _24 => _24.forEach, 'call', _25 => _25((colKey) => {
|
|
1416
1468
|
if (!rowToSend.hasOwnProperty(colKey)) {
|
|
1417
1469
|
rowToSend[colKey] = potentialUpdatedRow[colKey];
|
|
1418
1470
|
}
|
|
@@ -1432,7 +1484,7 @@ function InputRenderer({
|
|
|
1432
1484
|
newRow: rowToSend,
|
|
1433
1485
|
oldRow: oldRowData,
|
|
1434
1486
|
status
|
|
1435
|
-
}
|
|
1487
|
+
});
|
|
1436
1488
|
let finalRowIdForFeedback;
|
|
1437
1489
|
let persistedRowData;
|
|
1438
1490
|
if (response.row && isNewRow) {
|
|
@@ -1459,7 +1511,6 @@ function InputRenderer({
|
|
|
1459
1511
|
const isPrimaryKeyColumn = tableDefinition.primaryKey.includes(column.key);
|
|
1460
1512
|
finalRowIdForFeedback = isPrimaryKeyColumn ? getPrimaryKeyValues(potentialUpdatedRow, tableDefinition.primaryKey) : currentRowIdBeforeUpdate;
|
|
1461
1513
|
onRowChange({ ...response.row }, true);
|
|
1462
|
-
onClose(true, focusNextCell);
|
|
1463
1514
|
}
|
|
1464
1515
|
findChangedValues(oldRowData, response.row).forEach(
|
|
1465
1516
|
(key) => setCellFeedback({ rowId: finalRowIdForFeedback, columnKey: key, type: "success" })
|
|
@@ -1485,22 +1536,19 @@ function InputRenderer({
|
|
|
1485
1536
|
initialRowId
|
|
1486
1537
|
]);
|
|
1487
1538
|
const handleKeyDown = _react.useCallback.call(void 0, (event) => {
|
|
1488
|
-
|
|
1489
|
-
if (event.key === "Enter") {
|
|
1539
|
+
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight"].includes(event.key)) {
|
|
1490
1540
|
handleCommit(editingValue, true, true);
|
|
1491
1541
|
event.preventDefault();
|
|
1492
1542
|
if (onEnterPress) {
|
|
1493
|
-
onEnterPress(rowIdx, column.key);
|
|
1543
|
+
onEnterPress(rowIdx, column.key, event.key);
|
|
1494
1544
|
}
|
|
1495
|
-
} else if (event.key === "Tab") {
|
|
1496
|
-
handleCommit(editingValue, true, true);
|
|
1497
1545
|
}
|
|
1498
1546
|
}, [handleCommit, editingValue, column.key, rowIdx, onEnterPress]);
|
|
1499
1547
|
const handleBlur = _react.useCallback.call(void 0, () => {
|
|
1500
1548
|
handleCommit(editingValue, true, false);
|
|
1501
1549
|
}, [handleCommit, editingValue]);
|
|
1502
1550
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1503
|
-
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
1551
|
+
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess', _26 => _26.editable]) !== false;
|
|
1504
1552
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1505
1553
|
_InputBase2.default,
|
|
1506
1554
|
{
|
|
@@ -1529,6 +1577,7 @@ var InputRenderer_default = InputRenderer;
|
|
|
1529
1577
|
|
|
1530
1578
|
// src/components/grid/renderers/editCellRenderers.tsx
|
|
1531
1579
|
|
|
1580
|
+
|
|
1532
1581
|
var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
1533
1582
|
const column = props.column;
|
|
1534
1583
|
switch (column.customType) {
|
|
@@ -1547,25 +1596,26 @@ var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
|
1547
1596
|
} = defaultColumn;
|
|
1548
1597
|
if (column.editable) {
|
|
1549
1598
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1550
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
1551
|
-
const isFieldEditableByUI = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
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;
|
|
1552
1601
|
if (!isFieldEditableByUI) {
|
|
1553
1602
|
return void 0;
|
|
1554
1603
|
}
|
|
1555
|
-
|
|
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,
|
|
1556
1606
|
InputRenderer_default,
|
|
1557
1607
|
{
|
|
1558
1608
|
...props,
|
|
1559
1609
|
tableDefinition,
|
|
1560
1610
|
setCellFeedback,
|
|
1561
1611
|
cellFeedback,
|
|
1562
|
-
onEnterPress: (rowIndex, columnKey) => handleEnterKeyPressInEditor(rowIndex, columnKey, allColumns),
|
|
1612
|
+
onEnterPress: (rowIndex, columnKey, key) => handleEnterKeyPressInEditor(rowIndex, columnKey, key, allColumns),
|
|
1563
1613
|
setTableData,
|
|
1564
1614
|
setLocalCellChanges,
|
|
1565
1615
|
localCellChanges,
|
|
1566
1616
|
primaryKey
|
|
1567
1617
|
}
|
|
1568
|
-
);
|
|
1618
|
+
) }) });
|
|
1569
1619
|
}
|
|
1570
1620
|
return void 0;
|
|
1571
1621
|
}
|
|
@@ -1615,8 +1665,10 @@ var NEW_ROW_INDICATOR = "$new";
|
|
|
1615
1665
|
var DETAIL_ROW_INDICATOR = "$detail";
|
|
1616
1666
|
var GenericDataGrid = ({
|
|
1617
1667
|
tableName,
|
|
1618
|
-
fixedFields
|
|
1668
|
+
fixedFields,
|
|
1669
|
+
gridStyles
|
|
1619
1670
|
}) => {
|
|
1671
|
+
const isOpenMenu = useIsDrawerOpen();
|
|
1620
1672
|
const [tableDefinition, setTableDefinition] = _react.useState.call(void 0, null);
|
|
1621
1673
|
const [tableData, setTableData] = _react.useState.call(void 0, []);
|
|
1622
1674
|
const [isFilterRowVisible, setIsFilterRowVisible] = _react.useState.call(void 0, false);
|
|
@@ -1830,12 +1882,12 @@ var GenericDataGrid = ({
|
|
|
1830
1882
|
}
|
|
1831
1883
|
return rows;
|
|
1832
1884
|
}, [tableData, filters, isFilterRowVisible]);
|
|
1833
|
-
const handleEnterKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, currentColumns) => {
|
|
1885
|
+
const handleEnterKeyPressInEditor = _react.useCallback.call(void 0, (rowIndex, columnKey, key, currentColumns) => {
|
|
1834
1886
|
if (dataGridRef.current && tableDefinition) {
|
|
1835
1887
|
const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
|
|
1836
1888
|
const editableColumns = currentColumns.filter((col) => {
|
|
1837
1889
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1838
|
-
return col.key !== "
|
|
1890
|
+
return col.key !== "actionsColumn" && col.customType != "detail" && (_optionalChain([fieldDefinition, 'optionalAccess', _31 => _31.editable]) !== false && !_optionalChain([fieldDefinition, 'optionalAccess', _32 => _32.clientSide]));
|
|
1839
1891
|
});
|
|
1840
1892
|
if (currentColumnIndex !== -1 && editableColumns.length > 0) {
|
|
1841
1893
|
const editableColumnKeys = editableColumns.map((col) => col.key);
|
|
@@ -1852,7 +1904,7 @@ var GenericDataGrid = ({
|
|
|
1852
1904
|
}
|
|
1853
1905
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1854
1906
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1855
|
-
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1907
|
+
_optionalChain([dataGridRef, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.selectCell, 'call', _35 => _35({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true })]);
|
|
1856
1908
|
}
|
|
1857
1909
|
}
|
|
1858
1910
|
}
|
|
@@ -1863,11 +1915,11 @@ var GenericDataGrid = ({
|
|
|
1863
1915
|
const columns = _react.useMemo.call(void 0, () => {
|
|
1864
1916
|
if (!tableDefinition) return [];
|
|
1865
1917
|
const fieldsToShow = tableDefinition.fields.filter((field) => {
|
|
1866
|
-
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess',
|
|
1918
|
+
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _36 => _36.find, 'call', _37 => _37((f) => f.fieldName === field.name)]);
|
|
1867
1919
|
return !(fixedFieldEntry && fixedFieldEntry.until === void 0);
|
|
1868
1920
|
});
|
|
1869
1921
|
const defaultColumns = fieldsToShow.map((fieldDef) => {
|
|
1870
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
1922
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((f) => f.fieldName === fieldDef.name)]);
|
|
1871
1923
|
const isFieldEditable = fieldDef.editable !== false && !isFixedField;
|
|
1872
1924
|
return {
|
|
1873
1925
|
key: fieldDef.name,
|
|
@@ -1892,13 +1944,20 @@ var GenericDataGrid = ({
|
|
|
1892
1944
|
renderSummaryCell: (props) => defaultColumnSummaryCellRenderer(props, fixedFields, isFilterRowVisible, filters, setFilters)
|
|
1893
1945
|
};
|
|
1894
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;
|
|
1895
1953
|
const actionsColumn = {
|
|
1896
|
-
key: "
|
|
1954
|
+
key: "actionsColumn",
|
|
1897
1955
|
customType: "action",
|
|
1898
1956
|
tableDefinition,
|
|
1899
1957
|
handleDeleteRow,
|
|
1958
|
+
handleAddRow,
|
|
1900
1959
|
name: "filterCol",
|
|
1901
|
-
width:
|
|
1960
|
+
width: actionColumnWidth,
|
|
1902
1961
|
editable: false,
|
|
1903
1962
|
resizable: false,
|
|
1904
1963
|
sortable: false,
|
|
@@ -1922,7 +1981,8 @@ var GenericDataGrid = ({
|
|
|
1922
1981
|
resizable: false,
|
|
1923
1982
|
sortable: false,
|
|
1924
1983
|
editable: false,
|
|
1925
|
-
width:
|
|
1984
|
+
width: 30,
|
|
1985
|
+
minWidth: 30,
|
|
1926
1986
|
renderHeaderCell: (props) => detailColumnCellHeaderRenderer(props, detailTable),
|
|
1927
1987
|
renderSummaryCell: (props) => detailColumnCellSummaryRenderer(props)
|
|
1928
1988
|
});
|
|
@@ -1944,6 +2004,8 @@ var GenericDataGrid = ({
|
|
|
1944
2004
|
}
|
|
1945
2005
|
return void 0;
|
|
1946
2006
|
},
|
|
2007
|
+
editorOptions: { closeOnExternalRowChange: false },
|
|
2008
|
+
//con esto no se pierde el foco
|
|
1947
2009
|
renderEditCell: (props) => allColumnsEditCellRenderer(props, allColumns),
|
|
1948
2010
|
renderCell: (props) => allColumnsCellRenderer(props)
|
|
1949
2011
|
}));
|
|
@@ -1962,6 +2024,7 @@ var GenericDataGrid = ({
|
|
|
1962
2024
|
setTableData,
|
|
1963
2025
|
localCellChanges,
|
|
1964
2026
|
handleDeleteRow,
|
|
2027
|
+
handleAddRow,
|
|
1965
2028
|
fixedFields,
|
|
1966
2029
|
tableData
|
|
1967
2030
|
]);
|
|
@@ -1977,12 +2040,17 @@ var GenericDataGrid = ({
|
|
|
1977
2040
|
}
|
|
1978
2041
|
});
|
|
1979
2042
|
};
|
|
2043
|
+
const handleCellKeyDown = (args, event) => {
|
|
2044
|
+
if (["Tab", "Enter"].includes(event.key)) {
|
|
2045
|
+
event.preventGridDefault();
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
1980
2048
|
const handleCellClick = _react.useCallback.call(void 0, (args) => {
|
|
1981
|
-
deselectAllOtherGrids(_optionalChain([dataGridRef, 'access',
|
|
2049
|
+
deselectAllOtherGrids(_optionalChain([dataGridRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.element]));
|
|
1982
2050
|
args.selectCell(true);
|
|
1983
|
-
const fieldDefinition = _optionalChain([tableDefinition, 'optionalAccess',
|
|
1984
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
1985
|
-
const isEditable = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
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;
|
|
1986
2054
|
console.log("Clicked column index:", args.column.idx);
|
|
1987
2055
|
console.log("Clicked row index:", args.rowIdx);
|
|
1988
2056
|
console.log("Is editable:", isEditable);
|
|
@@ -2000,15 +2068,6 @@ var GenericDataGrid = ({
|
|
|
2000
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." }) });
|
|
2001
2069
|
}
|
|
2002
2070
|
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,
|
|
2004
|
-
_material.Button,
|
|
2005
|
-
{
|
|
2006
|
-
variant: "contained",
|
|
2007
|
-
onClick: handleAddRow,
|
|
2008
|
-
startIcon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Add2.default, {}),
|
|
2009
|
-
children: "Nuevo Registro"
|
|
2010
|
-
}
|
|
2011
|
-
) }),
|
|
2012
2071
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2013
2072
|
_material.Box,
|
|
2014
2073
|
{
|
|
@@ -2024,10 +2083,10 @@ var GenericDataGrid = ({
|
|
|
2024
2083
|
ml: 2,
|
|
2025
2084
|
mr: 2
|
|
2026
2085
|
},
|
|
2027
|
-
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: [
|
|
2028
2087
|
cambiarGuionesBajosPorEspacios(tableDefinition.title || tableDefinition.name),
|
|
2029
|
-
" -
|
|
2030
|
-
getFilteredRowCount() === getRowCount() ? `${getRowCount()} registros` : `${getFilteredRowCount()}
|
|
2088
|
+
" - ",
|
|
2089
|
+
getFilteredRowCount() === getRowCount() ? `${getRowCount()} registros` : `${getFilteredRowCount()} (F)`
|
|
2031
2090
|
] })
|
|
2032
2091
|
}
|
|
2033
2092
|
),
|
|
@@ -2046,6 +2105,7 @@ var GenericDataGrid = ({
|
|
|
2046
2105
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2047
2106
|
_reactdatagrid.DataGrid,
|
|
2048
2107
|
{
|
|
2108
|
+
className: "rdg-light",
|
|
2049
2109
|
ref: dataGridRef,
|
|
2050
2110
|
columns,
|
|
2051
2111
|
rows: filteredRows.map((row) => ({
|
|
@@ -2058,13 +2118,14 @@ var GenericDataGrid = ({
|
|
|
2058
2118
|
onSelectedCellChange: handleSelectedCellChange,
|
|
2059
2119
|
onRowsChange: handleRowsChange,
|
|
2060
2120
|
selectedRows,
|
|
2061
|
-
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 :
|
|
2062
|
-
style: { height: "100%", width: "100%", boxSizing: "border-box" },
|
|
2063
|
-
headerRowHeight:
|
|
2121
|
+
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 : 30,
|
|
2122
|
+
style: { ...{ height: "100%", width: "100%", boxSizing: "border-box" }, ...gridStyles },
|
|
2123
|
+
headerRowHeight: 30,
|
|
2064
2124
|
topSummaryRows: isFilterRowVisible ? [{ id: "filterRow" }] : void 0,
|
|
2065
|
-
summaryRowHeight: isFilterRowVisible ?
|
|
2125
|
+
summaryRowHeight: isFilterRowVisible ? 30 : 0,
|
|
2066
2126
|
renderers: { noRowsFallback: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EmptyRowsRenderer, {}) },
|
|
2067
|
-
onCellClick: handleCellClick
|
|
2127
|
+
onCellClick: handleCellClick,
|
|
2128
|
+
onCellKeyDown: handleCellKeyDown
|
|
2068
2129
|
}
|
|
2069
2130
|
)
|
|
2070
2131
|
}
|
|
@@ -2603,7 +2664,7 @@ var SessionExpiredMessage_default = SessionExpiredMessage;
|
|
|
2603
2664
|
var HomePage = () => {
|
|
2604
2665
|
const { clientContext } = useApp();
|
|
2605
2666
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 3 }, children: [
|
|
2606
|
-
/* @__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])}` }),
|
|
2607
2668
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", children: "Usa el men\xFA lateral para navegar por las diferentes secciones." })
|
|
2608
2669
|
] });
|
|
2609
2670
|
};
|
|
@@ -2732,7 +2793,7 @@ var LoginPage = () => {
|
|
|
2732
2793
|
fullWidth: true,
|
|
2733
2794
|
margin: "normal",
|
|
2734
2795
|
error: !!errors.username,
|
|
2735
|
-
helperText: _optionalChain([errors, 'access',
|
|
2796
|
+
helperText: _optionalChain([errors, 'access', _55 => _55.username, 'optionalAccess', _56 => _56.message]),
|
|
2736
2797
|
disabled: isSubmitting
|
|
2737
2798
|
}
|
|
2738
2799
|
)
|
|
@@ -2755,7 +2816,7 @@ var LoginPage = () => {
|
|
|
2755
2816
|
fullWidth: true,
|
|
2756
2817
|
margin: "normal",
|
|
2757
2818
|
error: !!errors.password,
|
|
2758
|
-
helperText: _optionalChain([errors, 'access',
|
|
2819
|
+
helperText: _optionalChain([errors, 'access', _57 => _57.password, 'optionalAccess', _58 => _58.message]),
|
|
2759
2820
|
disabled: isSubmitting
|
|
2760
2821
|
}
|
|
2761
2822
|
)
|
|
@@ -2833,7 +2894,7 @@ var ProcedureForm = () => {
|
|
|
2833
2894
|
const [executionLog, setExecutionLog] = _react.useState.call(void 0, []);
|
|
2834
2895
|
const [procedureResultData, setProcedureResultData] = _react.useState.call(void 0, null);
|
|
2835
2896
|
const procedure = _react.useMemo.call(void 0, () => {
|
|
2836
|
-
if (procedureName && _optionalChain([clientContext, 'optionalAccess',
|
|
2897
|
+
if (procedureName && _optionalChain([clientContext, 'optionalAccess', _59 => _59.procedure])) {
|
|
2837
2898
|
return clientContext.procedure[procedureName];
|
|
2838
2899
|
}
|
|
2839
2900
|
return void 0;
|
|
@@ -3124,7 +3185,7 @@ var ProcedureForm = () => {
|
|
|
3124
3185
|
}
|
|
3125
3186
|
}, [formValues, handleChange, apiLoading, validationErrors]);
|
|
3126
3187
|
const ResultDisplayContent = _react.useMemo.call(void 0, () => {
|
|
3127
|
-
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess',
|
|
3188
|
+
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess', _60 => _60.resultOk])) return null;
|
|
3128
3189
|
const ComponentToRender = resultsOk[procedure.resultOk];
|
|
3129
3190
|
if (ComponentToRender) {
|
|
3130
3191
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentToRender, { data: procedureResultData });
|