mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2026-01-04 12:04:58 +01:00
Add wipe inventory options for labels/locations and owner-only restriction
- Added WipeInventoryDialog component with checkboxes for wiping labels and locations - Modified backend WipeInventory method to accept wipeLabels and wipeLocations parameters - Added owner check in HandleWipeInventory to restrict action to group owners only - Updated frontend API client to send wipe options - Added new translation keys for checkbox labels and owner note - Integrated dialog into app layout and updated tools.vue to use new dialog Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
This commit is contained in:
85
frontend/components/WipeInventoryDialog.vue
Normal file
85
frontend/components/WipeInventoryDialog.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<BaseModal v-model="dialog" max-width="600px">
|
||||
<template #title>
|
||||
<span>{{ $t("tools.actions_set.wipe_inventory") }}</span>
|
||||
</template>
|
||||
<div class="space-y-4">
|
||||
<p class="text-base">
|
||||
{{ $t("tools.actions_set.wipe_inventory_confirm") }}
|
||||
</p>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<input
|
||||
id="wipe-labels-checkbox"
|
||||
v-model="wipeLabels"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
<label for="wipe-labels-checkbox" class="text-sm font-medium cursor-pointer">
|
||||
{{ $t("tools.actions_set.wipe_inventory_labels") }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-2">
|
||||
<input
|
||||
id="wipe-locations-checkbox"
|
||||
v-model="wipeLocations"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
<label for="wipe-locations-checkbox" class="text-sm font-medium cursor-pointer">
|
||||
{{ $t("tools.actions_set.wipe_inventory_locations") }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-sm text-gray-600">
|
||||
{{ $t("tools.actions_set.wipe_inventory_note") }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<BaseButton @click="close"> {{ $t("global.cancel") }} </BaseButton>
|
||||
<BaseButton type="primary" @click="confirm">
|
||||
{{ $t("global.confirm") }}
|
||||
</BaseButton>
|
||||
</template>
|
||||
</BaseModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogID } from "~/components/ui/dialog-provider/utils";
|
||||
import { useDialog } from "~/components/ui/dialog-provider";
|
||||
|
||||
const { registerOpenDialogCallback, closeDialog } = useDialog();
|
||||
|
||||
const dialog = ref(false);
|
||||
const wipeLabels = ref(false);
|
||||
const wipeLocations = ref(false);
|
||||
|
||||
let onCloseCallback: ((result?: { wipeLabels: boolean; wipeLocations: boolean } | undefined) => void) | undefined;
|
||||
|
||||
registerOpenDialogCallback(DialogID.WipeInventory, (params?: { onClose?: (result?: { wipeLabels: boolean; wipeLocations: boolean } | undefined) => void }) => {
|
||||
dialog.value = true;
|
||||
wipeLabels.value = false;
|
||||
wipeLocations.value = false;
|
||||
onCloseCallback = params?.onClose;
|
||||
});
|
||||
|
||||
function close() {
|
||||
dialog.value = false;
|
||||
closeDialog(DialogID.WipeInventory, undefined);
|
||||
onCloseCallback?.(undefined);
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
dialog.value = false;
|
||||
const result = {
|
||||
wipeLabels: wipeLabels.value,
|
||||
wipeLocations: wipeLocations.value,
|
||||
};
|
||||
closeDialog(DialogID.WipeInventory, result);
|
||||
onCloseCallback?.(result);
|
||||
}
|
||||
</script>
|
||||
@@ -26,6 +26,7 @@ export enum DialogID {
|
||||
UpdateLocation = "update-location",
|
||||
UpdateTemplate = "update-template",
|
||||
ItemChangeDetails = "item-table-updater",
|
||||
WipeInventory = "wipe-inventory",
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,7 @@ export type DialogResultMap = {
|
||||
[DialogID.ItemImage]?: { action: "delete"; id: string };
|
||||
[DialogID.EditMaintenance]?: boolean;
|
||||
[DialogID.ItemChangeDetails]?: boolean;
|
||||
[DialogID.WipeInventory]?: { wipeLabels: boolean; wipeLocations: boolean };
|
||||
};
|
||||
|
||||
/** Helpers to split IDs by requirement */
|
||||
|
||||
Reference in New Issue
Block a user