Files
homebox/frontend/components/WipeInventoryDialog.vue
copilot-swe-agent[bot] 7aaaa346ab 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>
2025-12-28 15:41:13 +00:00

86 lines
2.6 KiB
Vue

<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>