add permanent purge functionality for wagons and routes

- Implemented a  method in  to permanently delete wagons without history.
- Added corresponding permissions for hard delete actions in .
- Updated the UI components to include purge actions, ensuring they are only available to users with the appropriate permissions.
- Created modals for confirming permanent deletions in  and .
- Enhanced API services to handle purge requests for locomotives, wagons, and routes.
- Added tests for the purge functionality in both  and  services to ensure proper behavior and error handling.
This commit is contained in:
Marshal
2026-08-04 14:07:16 +00:00
parent 8cf49aa1cc
commit 5d68a3f7b7
22 changed files with 806 additions and 20 deletions

View File

@@ -22,6 +22,8 @@ export interface FleetCardGridProps {
/** Omit to hide the action (caller lacks the update/delete permission). */
onEdit?: (record: FleetRecord) => void;
onRemove?: (record: FleetRecord) => void;
/** Irreversible purge — omitted unless the caller holds the hard-delete grant. */
onPurge?: (record: FleetRecord) => void;
}
const FleetCardGrid = ({
@@ -35,6 +37,7 @@ const FleetCardGrid = ({
onPaginationChange,
onEdit,
onRemove,
onPurge,
}: FleetCardGridProps) => {
const presentation = resolveFleetCardPresentation(config);
@@ -183,6 +186,7 @@ const FleetCardGrid = ({
layout="compact"
onEdit={onEdit}
onRemove={onRemove}
onPurge={onPurge}
/>
</Stack>
</Card>

View File

@@ -1,4 +1,12 @@
import { Edit2, Trash2, Eye, Users, MoreVertical, History } from "lucide-react";
import {
Edit2,
Trash2,
Eye,
Users,
MoreVertical,
History,
ShieldAlert,
} from "lucide-react";
import { ActionIcon, Menu, MenuItem, Tooltip } from "@mantine/core";
import { useNavigate } from "react-router-dom";
@@ -11,6 +19,8 @@ export interface FleetRecordActionsProps {
/** Omit to hide the action (caller lacks the update/delete permission). */
onEdit?: (record: FleetRecord) => void;
onRemove?: (record: FleetRecord) => void;
/** Irreversible purge — omitted unless the caller holds the hard-delete grant. */
onPurge?: (record: FleetRecord) => void;
onAssignDriver?: (record: FleetRecord) => void;
onHistory?: (record: FleetRecord) => void;
onViewDetail?: (record: FleetRecord) => void;
@@ -22,6 +32,7 @@ const FleetRecordActions = ({
config,
onEdit,
onRemove,
onPurge,
onAssignDriver,
onHistory,
onViewDetail,
@@ -46,6 +57,7 @@ const FleetRecordActions = ({
if (
!onEdit &&
!onRemove &&
!onPurge &&
!showDetail &&
!showViewDetail &&
!showHistory &&
@@ -170,6 +182,15 @@ const FleetRecordActions = ({
{removeLabel}
</MenuItem>
) : null}
{onPurge ? (
<MenuItem
color="red"
onClick={() => onPurge(record)}
leftSection={<ShieldAlert size={14} strokeWidth={2} />}
>
Delete permanently
</MenuItem>
) : null}
</Menu.Dropdown>
</Menu>
);