frontend-plus-react 0.1.4 → 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 +154 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +142 -89
- 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,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
|
|
@@ -1145,7 +1143,6 @@ var ExampleClientSideComponent_default = ExampleClientSideComponent;
|
|
|
1145
1143
|
var _WarningAmber = require('@mui/icons-material/WarningAmber'); var _WarningAmber2 = _interopRequireDefault(_WarningAmber);
|
|
1146
1144
|
|
|
1147
1145
|
var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
1148
|
-
const value = row[column.key];
|
|
1149
1146
|
const clientSideName = _optionalChain([fieldDefinition, 'optionalAccess', _5 => _5.clientSide]) || "Desconocido";
|
|
1150
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,
|
|
1151
1148
|
_material.Box,
|
|
@@ -1168,7 +1165,7 @@ var FallbackClientSideRenderer = ({ column, row, fieldDefinition }) => {
|
|
|
1168
1165
|
// Evita que el contenido se desborde
|
|
1169
1166
|
},
|
|
1170
1167
|
children: [
|
|
1171
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children:
|
|
1168
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", noWrap: true, sx: { flexGrow: 1 }, children: clientSideName + " not found" }),
|
|
1172
1169
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1173
1170
|
_WarningAmber2.default,
|
|
1174
1171
|
{
|
|
@@ -1217,15 +1214,25 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1217
1214
|
fixedFields.push({ fieldName: field.target, value: row[field.source] });
|
|
1218
1215
|
}
|
|
1219
1216
|
});
|
|
1220
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
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
|
+
);
|
|
1229
1236
|
}
|
|
1230
1237
|
return void 0;
|
|
1231
1238
|
}
|
|
@@ -1256,7 +1263,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1256
1263
|
}
|
|
1257
1264
|
}
|
|
1258
1265
|
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) }) });
|
|
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) }) }) });
|
|
1260
1267
|
}
|
|
1261
1268
|
case "detail": {
|
|
1262
1269
|
const detailColumn = column;
|
|
@@ -1294,7 +1301,7 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1294
1301
|
case "action": {
|
|
1295
1302
|
const actionColumn = column;
|
|
1296
1303
|
const { tableDefinition, handleDeleteRow } = actionColumn;
|
|
1297
|
-
if (!_optionalChain([tableDefinition, 'access',
|
|
1304
|
+
if (!_optionalChain([tableDefinition, 'access', _18 => _18.allow, 'optionalAccess', _19 => _19.delete])) return void 0;
|
|
1298
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 } }) }) });
|
|
1299
1306
|
}
|
|
1300
1307
|
default:
|
|
@@ -1306,6 +1313,16 @@ var allColumnsCellRenderer = (props) => {
|
|
|
1306
1313
|
|
|
1307
1314
|
var _InputBase = require('@mui/material/InputBase'); var _InputBase2 = _interopRequireDefault(_InputBase);
|
|
1308
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
|
+
}
|
|
1309
1326
|
function InputRenderer({
|
|
1310
1327
|
column,
|
|
1311
1328
|
row,
|
|
@@ -1313,6 +1330,7 @@ function InputRenderer({
|
|
|
1313
1330
|
tableDefinition,
|
|
1314
1331
|
onRowChange,
|
|
1315
1332
|
onClose,
|
|
1333
|
+
cellFeedback,
|
|
1316
1334
|
setCellFeedback,
|
|
1317
1335
|
onEnterPress,
|
|
1318
1336
|
setTableData,
|
|
@@ -1322,7 +1340,13 @@ function InputRenderer({
|
|
|
1322
1340
|
}) {
|
|
1323
1341
|
const tableName = tableDefinition.tableName;
|
|
1324
1342
|
const [editingValue, setEditingValue] = _react.useState.call(void 0, row[column.key]);
|
|
1343
|
+
const theme = _material.useTheme.call(void 0, );
|
|
1325
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
|
+
}
|
|
1326
1350
|
const initialRowId = _react.useMemo.call(void 0, () => getPrimaryKeyValues(row, primaryKey), [row, primaryKey]);
|
|
1327
1351
|
const { callApi } = useApiCall();
|
|
1328
1352
|
const handleCommit = _react.useCallback.call(void 0, async (currentValue, closeEditor, focusNextCell) => {
|
|
@@ -1332,31 +1356,16 @@ function InputRenderer({
|
|
|
1332
1356
|
(key) => potentialUpdatedRow[key] !== void 0 && potentialUpdatedRow[key] !== null && String(potentialUpdatedRow[key]).trim() !== ""
|
|
1333
1357
|
);
|
|
1334
1358
|
const isNewRow = !arePKValuesFilled || potentialUpdatedRow[NEW_ROW_INDICATOR];
|
|
1335
|
-
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;
|
|
1336
1360
|
const isMandatoryFieldEmpty = isNewRow && isMandatoryField && (processedNewValue === null || processedNewValue === void 0 || String(processedNewValue).trim() === "");
|
|
1337
1361
|
if (processedNewValue === row[column.key] && !isNewRow && !isMandatoryFieldEmpty) {
|
|
1338
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).");
|
|
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
1363
|
return;
|
|
1354
1364
|
}
|
|
1355
1365
|
const oldRowData = { ...row };
|
|
1356
1366
|
const primaryKeyValuesForBackend = tableDefinition.primaryKey.map((key) => potentialUpdatedRow[key]);
|
|
1357
1367
|
const currentRowIdBeforeUpdate = getPrimaryKeyValues(oldRowData, tableDefinition.primaryKey);
|
|
1358
1368
|
onRowChange({ ...row, [column.key]: processedNewValue }, true);
|
|
1359
|
-
onClose(true, focusNextCell);
|
|
1360
1369
|
if (isNewRow) {
|
|
1361
1370
|
const areAllMandatoryFieldsFilled = tableDefinition.fields.every((fieldDef) => {
|
|
1362
1371
|
const isMandatory = fieldDef.nullable === false || fieldDef.isPk;
|
|
@@ -1403,7 +1412,7 @@ function InputRenderer({
|
|
|
1403
1412
|
}
|
|
1404
1413
|
});
|
|
1405
1414
|
if (localCellChanges.has(initialRowId)) {
|
|
1406
|
-
_optionalChain([localCellChanges, 'access',
|
|
1415
|
+
_optionalChain([localCellChanges, 'access', _24 => _24.get, 'call', _25 => _25(initialRowId), 'optionalAccess', _26 => _26.forEach, 'call', _27 => _27((colKey) => {
|
|
1407
1416
|
if (!rowToSend.hasOwnProperty(colKey)) {
|
|
1408
1417
|
rowToSend[colKey] = potentialUpdatedRow[colKey];
|
|
1409
1418
|
}
|
|
@@ -1423,21 +1432,7 @@ function InputRenderer({
|
|
|
1423
1432
|
newRow: rowToSend,
|
|
1424
1433
|
oldRow: oldRowData,
|
|
1425
1434
|
status
|
|
1426
|
-
});
|
|
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!");
|
|
1435
|
+
}, { reportOnSnackbar: false });
|
|
1441
1436
|
let finalRowIdForFeedback;
|
|
1442
1437
|
let persistedRowData;
|
|
1443
1438
|
if (response.row && isNewRow) {
|
|
@@ -1460,15 +1455,18 @@ function InputRenderer({
|
|
|
1460
1455
|
});
|
|
1461
1456
|
finalRowIdForFeedback = getPrimaryKeyValues(persistedRowData, tableDefinition.primaryKey);
|
|
1462
1457
|
} else {
|
|
1463
|
-
persistedRowData =
|
|
1458
|
+
persistedRowData = response.row;
|
|
1464
1459
|
const isPrimaryKeyColumn = tableDefinition.primaryKey.includes(column.key);
|
|
1465
1460
|
finalRowIdForFeedback = isPrimaryKeyColumn ? getPrimaryKeyValues(potentialUpdatedRow, tableDefinition.primaryKey) : currentRowIdBeforeUpdate;
|
|
1461
|
+
onRowChange({ ...response.row }, true);
|
|
1462
|
+
onClose(true, focusNextCell);
|
|
1466
1463
|
}
|
|
1467
|
-
|
|
1464
|
+
findChangedValues(oldRowData, response.row).forEach(
|
|
1465
|
+
(key) => setCellFeedback({ rowId: finalRowIdForFeedback, columnKey: key, type: "success" })
|
|
1466
|
+
);
|
|
1468
1467
|
} catch (err) {
|
|
1469
1468
|
console.error("Error al guardar el registro:", err);
|
|
1470
|
-
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error" });
|
|
1471
|
-
onRowChange(oldRowData, true);
|
|
1469
|
+
setCellFeedback({ rowId: currentRowIdBeforeUpdate, columnKey: column.key, type: "error", message: err.message });
|
|
1472
1470
|
}
|
|
1473
1471
|
}, [
|
|
1474
1472
|
column,
|
|
@@ -1487,6 +1485,7 @@ function InputRenderer({
|
|
|
1487
1485
|
initialRowId
|
|
1488
1486
|
]);
|
|
1489
1487
|
const handleKeyDown = _react.useCallback.call(void 0, (event) => {
|
|
1488
|
+
console.log("entra");
|
|
1490
1489
|
if (event.key === "Enter") {
|
|
1491
1490
|
handleCommit(editingValue, true, true);
|
|
1492
1491
|
event.preventDefault();
|
|
@@ -1501,7 +1500,7 @@ function InputRenderer({
|
|
|
1501
1500
|
handleCommit(editingValue, true, false);
|
|
1502
1501
|
}, [handleCommit, editingValue]);
|
|
1503
1502
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === column.key);
|
|
1504
|
-
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess',
|
|
1503
|
+
const isFieldEditable = _optionalChain([fieldDefinition, 'optionalAccess', _28 => _28.editable]) !== false;
|
|
1505
1504
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1506
1505
|
_InputBase2.default,
|
|
1507
1506
|
{
|
|
@@ -1517,7 +1516,8 @@ function InputRenderer({
|
|
|
1517
1516
|
borderRadius: "4px",
|
|
1518
1517
|
padding: "2px 4px",
|
|
1519
1518
|
fontSize: "0.8rem",
|
|
1520
|
-
boxSizing: "border-box"
|
|
1519
|
+
boxSizing: "border-box",
|
|
1520
|
+
backgroundColor: cellBackgroundColor
|
|
1521
1521
|
},
|
|
1522
1522
|
onClick: (e) => e.stopPropagation(),
|
|
1523
1523
|
autoFocus: true,
|
|
@@ -1529,28 +1529,54 @@ var InputRenderer_default = InputRenderer;
|
|
|
1529
1529
|
|
|
1530
1530
|
// src/components/grid/renderers/editCellRenderers.tsx
|
|
1531
1531
|
|
|
1532
|
-
var
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
if (!isFieldEditableByUI) {
|
|
1539
|
-
return void 0;
|
|
1540
|
-
}
|
|
1541
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1542
|
-
InputRenderer_default,
|
|
1543
|
-
{
|
|
1544
|
-
...props,
|
|
1532
|
+
var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
1533
|
+
const column = props.column;
|
|
1534
|
+
switch (column.customType) {
|
|
1535
|
+
case "default": {
|
|
1536
|
+
const defaultColumn = column;
|
|
1537
|
+
const {
|
|
1545
1538
|
tableDefinition,
|
|
1546
|
-
|
|
1547
|
-
|
|
1539
|
+
fixedFields,
|
|
1540
|
+
primaryKey,
|
|
1548
1541
|
setTableData,
|
|
1549
|
-
|
|
1542
|
+
cellFeedback,
|
|
1543
|
+
setCellFeedback,
|
|
1544
|
+
handleEnterKeyPressInEditor,
|
|
1550
1545
|
localCellChanges,
|
|
1551
|
-
|
|
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,
|
|
1557
|
+
{
|
|
1558
|
+
...props,
|
|
1559
|
+
tableDefinition,
|
|
1560
|
+
setCellFeedback,
|
|
1561
|
+
cellFeedback,
|
|
1562
|
+
onEnterPress: (rowIndex, columnKey) => handleEnterKeyPressInEditor(rowIndex, columnKey, allColumns),
|
|
1563
|
+
setTableData,
|
|
1564
|
+
setLocalCellChanges,
|
|
1565
|
+
localCellChanges,
|
|
1566
|
+
primaryKey
|
|
1567
|
+
}
|
|
1568
|
+
);
|
|
1552
1569
|
}
|
|
1553
|
-
|
|
1570
|
+
return void 0;
|
|
1571
|
+
}
|
|
1572
|
+
case "detail": {
|
|
1573
|
+
return void 0;
|
|
1574
|
+
}
|
|
1575
|
+
case "action": {
|
|
1576
|
+
return void 0;
|
|
1577
|
+
}
|
|
1578
|
+
default:
|
|
1579
|
+
return void 0;
|
|
1554
1580
|
}
|
|
1555
1581
|
};
|
|
1556
1582
|
|
|
@@ -1578,7 +1604,10 @@ function EmptyRowsRenderer() {
|
|
|
1578
1604
|
// src/components/grid/GenericDataGrid.tsx
|
|
1579
1605
|
|
|
1580
1606
|
var getPrimaryKeyValues = (row, primaryKey) => {
|
|
1581
|
-
|
|
1607
|
+
if (row[DETAIL_ROW_INDICATOR]) {
|
|
1608
|
+
primaryKey = primaryKey.concat(DETAIL_ROW_INDICATOR);
|
|
1609
|
+
}
|
|
1610
|
+
return primaryKey.map((key) => {
|
|
1582
1611
|
return row[key] !== void 0 && row[key] !== null ? String(row[key]) : "NULL_OR_UNDEFINED";
|
|
1583
1612
|
}).join("|");
|
|
1584
1613
|
};
|
|
@@ -1593,6 +1622,7 @@ var GenericDataGrid = ({
|
|
|
1593
1622
|
const [isFilterRowVisible, setIsFilterRowVisible] = _react.useState.call(void 0, false);
|
|
1594
1623
|
const [filters, setFilters] = _react.useState.call(void 0, {});
|
|
1595
1624
|
const [selectedRows, setSelectedRows] = _react.useState.call(void 0, () => /* @__PURE__ */ new Set());
|
|
1625
|
+
const [selectedCell, setSelectedCell] = _react.useState.call(void 0, void 0);
|
|
1596
1626
|
const [cellFeedback, setCellFeedback] = _react.useState.call(void 0, null);
|
|
1597
1627
|
const [localCellChanges, setLocalCellChanges] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
1598
1628
|
const theme = _material.useTheme.call(void 0, );
|
|
@@ -1638,7 +1668,11 @@ var GenericDataGrid = ({
|
|
|
1638
1668
|
}
|
|
1639
1669
|
};
|
|
1640
1670
|
fetchDataAndDefinition();
|
|
1641
|
-
}, [
|
|
1671
|
+
}, [
|
|
1672
|
+
tableName,
|
|
1673
|
+
/*fixedFields,*/
|
|
1674
|
+
showError
|
|
1675
|
+
]);
|
|
1642
1676
|
_react.useEffect.call(void 0, () => {
|
|
1643
1677
|
if (cellFeedback) {
|
|
1644
1678
|
if (feedbackTimerRef.current) {
|
|
@@ -1646,7 +1680,8 @@ var GenericDataGrid = ({
|
|
|
1646
1680
|
}
|
|
1647
1681
|
const timerDuration = 3e3;
|
|
1648
1682
|
feedbackTimerRef.current = setTimeout(() => {
|
|
1649
|
-
|
|
1683
|
+
if (cellFeedback.type == "success")
|
|
1684
|
+
setCellFeedback(null);
|
|
1650
1685
|
}, timerDuration);
|
|
1651
1686
|
}
|
|
1652
1687
|
return () => {
|
|
@@ -1800,7 +1835,7 @@ var GenericDataGrid = ({
|
|
|
1800
1835
|
const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
|
|
1801
1836
|
const editableColumns = currentColumns.filter((col) => {
|
|
1802
1837
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1803
|
-
return col.key !== "filterToggle" && col.key !== "deleteAction" && (_optionalChain([fieldDefinition, 'optionalAccess',
|
|
1838
|
+
return col.key !== "filterToggle" && col.key !== "deleteAction" && (_optionalChain([fieldDefinition, 'optionalAccess', _32 => _32.editable]) !== false && !_optionalChain([fieldDefinition, 'optionalAccess', _33 => _33.clientSide]));
|
|
1804
1839
|
});
|
|
1805
1840
|
if (currentColumnIndex !== -1 && editableColumns.length > 0) {
|
|
1806
1841
|
const editableColumnKeys = editableColumns.map((col) => col.key);
|
|
@@ -1817,19 +1852,22 @@ var GenericDataGrid = ({
|
|
|
1817
1852
|
}
|
|
1818
1853
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1819
1854
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1820
|
-
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor:
|
|
1855
|
+
dataGridRef.current.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1821
1856
|
}
|
|
1822
1857
|
}
|
|
1823
1858
|
}
|
|
1824
1859
|
}, [filteredRows, tableDefinition]);
|
|
1860
|
+
const handleSelectedCellChange = _react.useCallback.call(void 0, (args) => {
|
|
1861
|
+
setSelectedCell(args);
|
|
1862
|
+
}, []);
|
|
1825
1863
|
const columns = _react.useMemo.call(void 0, () => {
|
|
1826
1864
|
if (!tableDefinition) return [];
|
|
1827
1865
|
const fieldsToShow = tableDefinition.fields.filter((field) => {
|
|
1828
|
-
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess',
|
|
1866
|
+
const fixedFieldEntry = _optionalChain([fixedFields, 'optionalAccess', _34 => _34.find, 'call', _35 => _35((f) => f.fieldName === field.name)]);
|
|
1829
1867
|
return !(fixedFieldEntry && fixedFieldEntry.until === void 0);
|
|
1830
1868
|
});
|
|
1831
1869
|
const defaultColumns = fieldsToShow.map((fieldDef) => {
|
|
1832
|
-
const isFixedField = _optionalChain([fixedFields, 'optionalAccess',
|
|
1870
|
+
const isFixedField = _optionalChain([fixedFields, 'optionalAccess', _36 => _36.some, 'call', _37 => _37((f) => f.fieldName === fieldDef.name)]);
|
|
1833
1871
|
const isFieldEditable = fieldDef.editable !== false && !isFixedField;
|
|
1834
1872
|
return {
|
|
1835
1873
|
key: fieldDef.name,
|
|
@@ -1840,11 +1878,14 @@ var GenericDataGrid = ({
|
|
|
1840
1878
|
primaryKey,
|
|
1841
1879
|
fixedFields,
|
|
1842
1880
|
localCellChanges,
|
|
1881
|
+
setLocalCellChanges,
|
|
1882
|
+
setTableData,
|
|
1883
|
+
setCellFeedback,
|
|
1843
1884
|
name: fieldDef.label || cambiarGuionesBajosPorEspacios(fieldDef.name),
|
|
1844
1885
|
resizable: true,
|
|
1845
1886
|
sortable: true,
|
|
1846
|
-
//frozen: true,
|
|
1847
1887
|
editable: isFieldEditable,
|
|
1888
|
+
handleEnterKeyPressInEditor,
|
|
1848
1889
|
flexGrow: 1,
|
|
1849
1890
|
minWidth: 60,
|
|
1850
1891
|
renderHeaderCell: (props) => defaultColumnHeaderCellRenderer(props, fieldDef),
|
|
@@ -1858,9 +1899,9 @@ var GenericDataGrid = ({
|
|
|
1858
1899
|
handleDeleteRow,
|
|
1859
1900
|
name: "filterCol",
|
|
1860
1901
|
width: 50,
|
|
1902
|
+
editable: false,
|
|
1861
1903
|
resizable: false,
|
|
1862
1904
|
sortable: false,
|
|
1863
|
-
//frozen: true,
|
|
1864
1905
|
renderHeaderCell: (props) => actionsColumnHeaderCellRenderer(props, isFilterRowVisible, toggleFilterVisibility),
|
|
1865
1906
|
renderSummaryCell: (props) => actionsColumnSummaryCellRenderer(props)
|
|
1866
1907
|
};
|
|
@@ -1880,8 +1921,8 @@ var GenericDataGrid = ({
|
|
|
1880
1921
|
name: detailTable.label || `Detalle ${detailTable.abr}`,
|
|
1881
1922
|
resizable: false,
|
|
1882
1923
|
sortable: false,
|
|
1924
|
+
editable: false,
|
|
1883
1925
|
width: 50,
|
|
1884
|
-
//frozen: true,
|
|
1885
1926
|
renderHeaderCell: (props) => detailColumnCellHeaderRenderer(props, detailTable),
|
|
1886
1927
|
renderSummaryCell: (props) => detailColumnCellSummaryRenderer(props)
|
|
1887
1928
|
});
|
|
@@ -1903,7 +1944,7 @@ var GenericDataGrid = ({
|
|
|
1903
1944
|
}
|
|
1904
1945
|
return void 0;
|
|
1905
1946
|
},
|
|
1906
|
-
renderEditCell: (props) =>
|
|
1947
|
+
renderEditCell: (props) => allColumnsEditCellRenderer(props, allColumns),
|
|
1907
1948
|
renderCell: (props) => allColumnsCellRenderer(props)
|
|
1908
1949
|
}));
|
|
1909
1950
|
}, [
|
|
@@ -1927,10 +1968,21 @@ var GenericDataGrid = ({
|
|
|
1927
1968
|
const handleRowsChange = _react.useCallback.call(void 0, (updatedRows) => {
|
|
1928
1969
|
setTableData(updatedRows);
|
|
1929
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
|
+
};
|
|
1930
1980
|
const handleCellClick = _react.useCallback.call(void 0, (args) => {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
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;
|
|
1934
1986
|
console.log("Clicked column index:", args.column.idx);
|
|
1935
1987
|
console.log("Clicked row index:", args.rowIdx);
|
|
1936
1988
|
console.log("Is editable:", isEditable);
|
|
@@ -1948,7 +2000,7 @@ var GenericDataGrid = ({
|
|
|
1948
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." }) });
|
|
1949
2001
|
}
|
|
1950
2002
|
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',
|
|
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,
|
|
1952
2004
|
_material.Button,
|
|
1953
2005
|
{
|
|
1954
2006
|
variant: "contained",
|
|
@@ -2003,6 +2055,7 @@ var GenericDataGrid = ({
|
|
|
2003
2055
|
enableVirtualization: true,
|
|
2004
2056
|
rowKeyGetter: (row) => getPrimaryKeyValues(row, primaryKey),
|
|
2005
2057
|
onSelectedRowsChange: setSelectedRows,
|
|
2058
|
+
onSelectedCellChange: handleSelectedCellChange,
|
|
2006
2059
|
onRowsChange: handleRowsChange,
|
|
2007
2060
|
selectedRows,
|
|
2008
2061
|
rowHeight: (row) => row[DETAIL_ROW_INDICATOR] ? 400 : 35,
|
|
@@ -2010,8 +2063,8 @@ var GenericDataGrid = ({
|
|
|
2010
2063
|
headerRowHeight: 35,
|
|
2011
2064
|
topSummaryRows: isFilterRowVisible ? [{ id: "filterRow" }] : void 0,
|
|
2012
2065
|
summaryRowHeight: isFilterRowVisible ? 35 : 0,
|
|
2013
|
-
|
|
2014
|
-
|
|
2066
|
+
renderers: { noRowsFallback: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EmptyRowsRenderer, {}) },
|
|
2067
|
+
onCellClick: handleCellClick
|
|
2015
2068
|
}
|
|
2016
2069
|
)
|
|
2017
2070
|
}
|
|
@@ -2550,7 +2603,7 @@ var SessionExpiredMessage_default = SessionExpiredMessage;
|
|
|
2550
2603
|
var HomePage = () => {
|
|
2551
2604
|
const { clientContext } = useApp();
|
|
2552
2605
|
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',
|
|
2606
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: `Bienvenido/a ${_optionalChain([clientContext, 'optionalAccess', _48 => _48.username])}` }),
|
|
2554
2607
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", children: "Usa el men\xFA lateral para navegar por las diferentes secciones." })
|
|
2555
2608
|
] });
|
|
2556
2609
|
};
|
|
@@ -2679,7 +2732,7 @@ var LoginPage = () => {
|
|
|
2679
2732
|
fullWidth: true,
|
|
2680
2733
|
margin: "normal",
|
|
2681
2734
|
error: !!errors.username,
|
|
2682
|
-
helperText: _optionalChain([errors, 'access',
|
|
2735
|
+
helperText: _optionalChain([errors, 'access', _49 => _49.username, 'optionalAccess', _50 => _50.message]),
|
|
2683
2736
|
disabled: isSubmitting
|
|
2684
2737
|
}
|
|
2685
2738
|
)
|
|
@@ -2702,7 +2755,7 @@ var LoginPage = () => {
|
|
|
2702
2755
|
fullWidth: true,
|
|
2703
2756
|
margin: "normal",
|
|
2704
2757
|
error: !!errors.password,
|
|
2705
|
-
helperText: _optionalChain([errors, 'access',
|
|
2758
|
+
helperText: _optionalChain([errors, 'access', _51 => _51.password, 'optionalAccess', _52 => _52.message]),
|
|
2706
2759
|
disabled: isSubmitting
|
|
2707
2760
|
}
|
|
2708
2761
|
)
|
|
@@ -2780,7 +2833,7 @@ var ProcedureForm = () => {
|
|
|
2780
2833
|
const [executionLog, setExecutionLog] = _react.useState.call(void 0, []);
|
|
2781
2834
|
const [procedureResultData, setProcedureResultData] = _react.useState.call(void 0, null);
|
|
2782
2835
|
const procedure = _react.useMemo.call(void 0, () => {
|
|
2783
|
-
if (procedureName && _optionalChain([clientContext, 'optionalAccess',
|
|
2836
|
+
if (procedureName && _optionalChain([clientContext, 'optionalAccess', _53 => _53.procedure])) {
|
|
2784
2837
|
return clientContext.procedure[procedureName];
|
|
2785
2838
|
}
|
|
2786
2839
|
return void 0;
|
|
@@ -3071,7 +3124,7 @@ var ProcedureForm = () => {
|
|
|
3071
3124
|
}
|
|
3072
3125
|
}, [formValues, handleChange, apiLoading, validationErrors]);
|
|
3073
3126
|
const ResultDisplayContent = _react.useMemo.call(void 0, () => {
|
|
3074
|
-
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess',
|
|
3127
|
+
if (!procedureResultData || !_optionalChain([procedure, 'optionalAccess', _54 => _54.resultOk])) return null;
|
|
3075
3128
|
const ComponentToRender = resultsOk[procedure.resultOk];
|
|
3076
3129
|
if (ComponentToRender) {
|
|
3077
3130
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentToRender, { data: procedureResultData });
|