mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
feat: add bulk delete functionality for features
- Introduced a new endpoint `/bulk-delete` to allow deletion of multiple features at once. - Implemented `createBulkDeleteHandler` to process bulk delete requests and handle success/failure responses. - Updated the UI to include a bulk delete option in the BoardView component, with confirmation dialog for user actions. - Enhanced the HTTP API client to support bulk delete requests. - Improved the selection action bar to trigger bulk delete functionality and provide user feedback.
This commit is contained in:
@@ -505,6 +505,34 @@ export function BoardView() {
|
||||
[currentProject, selectedFeatureIds, updateFeature, exitSelectionMode]
|
||||
);
|
||||
|
||||
// Handler for bulk deleting multiple features
|
||||
const handleBulkDelete = useCallback(async () => {
|
||||
if (!currentProject || selectedFeatureIds.size === 0) return;
|
||||
|
||||
try {
|
||||
const api = getHttpApiClient();
|
||||
const featureIds = Array.from(selectedFeatureIds);
|
||||
const result = await api.features.bulkDelete(currentProject.path, featureIds);
|
||||
|
||||
if (result.success) {
|
||||
// Delete from local state
|
||||
featureIds.forEach((featureId) => {
|
||||
persistFeatureDelete(featureId);
|
||||
});
|
||||
toast.success(`Deleted ${result.deletedCount} features`);
|
||||
exitSelectionMode();
|
||||
loadFeatures();
|
||||
} else {
|
||||
toast.error('Failed to delete some features', {
|
||||
description: `${result.failedCount} features failed to delete`,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Bulk delete failed:', error);
|
||||
toast.error('Failed to delete features');
|
||||
}
|
||||
}, [currentProject, selectedFeatureIds, persistFeatureDelete, exitSelectionMode, loadFeatures]);
|
||||
|
||||
// Get selected features for mass edit dialog
|
||||
const selectedFeatures = useMemo(() => {
|
||||
return hookFeatures.filter((f) => selectedFeatureIds.has(f.id));
|
||||
@@ -1257,6 +1285,7 @@ export function BoardView() {
|
||||
selectedCount={selectedCount}
|
||||
totalCount={allSelectableFeatureIds.length}
|
||||
onEdit={() => setShowMassEditDialog(true)}
|
||||
onDelete={handleBulkDelete}
|
||||
onClear={clearSelection}
|
||||
onSelectAll={() => selectAll(allSelectableFeatureIds)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user