Modal template for deletion confirmation (#2190)

## Description

<!-- What changed? Why? (the code + comments should speak for itself on
the "how") -->

<!-- Fun screenshots or a cool video or something are super helpful as
well. If this touches platform-specific behavior, this is where test
evidence should be collected. -->

<!-- Any issues this pull request closes or pull requests this
supersedes should be linked with `Closes #issuenumber`. -->

This adds a template modal that can be used for confirming that the user
wants to delete something. The main goal is to reduce complication and
duplicated code, and standardize the way we handle deletion.

closes #2175

## Meta

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [x] This PR has been
[linted](https://docs.photonvision.org/en/latest/docs/contributing/linting.html).
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [ ] If this PR addresses a bug, a regression test for it is added

---------

Co-authored-by: Devolian <devondoyle@outlook.com>
This commit is contained in:
Sam Freund
2025-11-18 02:41:20 -06:00
committed by GitHub
parent 77e5545eef
commit d27b3d0775
7 changed files with 188 additions and 337 deletions

View File

@@ -5,6 +5,7 @@ import { useStateStore } from "@/stores/StateStore";
import { computed, inject, ref } from "vue";
import { axiosPost, getResolutionString, parseJsonFile } from "@/lib/PhotonUtils";
import { useTheme } from "vuetify";
import PvDeleteModal from "@/components/common/pv-delete-modal.vue";
const theme = useTheme();
@@ -12,7 +13,7 @@ const props = defineProps<{
videoFormat: VideoFormat;
}>();
const confirmRemoveDialog = ref({ show: false, vf: {} as VideoFormat });
const confirmRemoveDialog = ref({ show: false, vf: props.videoFormat as VideoFormat });
const removeCalibration = (vf: VideoFormat) => {
axiosPost("/calibration/remove", "delete a camera calibration", {
@@ -20,8 +21,6 @@ const removeCalibration = (vf: VideoFormat) => {
width: vf.resolution.width,
height: vf.resolution.height
});
confirmRemoveDialog.value.show = false;
};
const exportCalibration = ref();
@@ -110,17 +109,6 @@ const calibrationImageURL = (index: number) =>
<v-card-title class="pa-0"> Calibration Details </v-card-title>
</v-col>
<v-col cols="12" md="6" class="d-flex align-center pt-0 pt-md-3">
<v-btn
color="error"
:disabled="!currentCalibrationCoeffs"
class="mr-2"
style="flex: 1"
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
@click="() => (confirmRemoveDialog = { show: true, vf: props.videoFormat })"
>
<v-icon start size="large">mdi-delete</v-icon>
<span>Delete</span>
</v-btn>
<v-btn
color="buttonPassive"
class="mr-2"
@@ -140,6 +128,7 @@ const calibrationImageURL = (index: number) =>
/>
<v-btn
color="buttonPassive"
class="mr-2"
:disabled="!currentCalibrationCoeffs"
style="flex: 1"
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
@@ -154,6 +143,16 @@ const calibrationImageURL = (index: number) =>
:href="exportCalibrationURL"
target="_blank"
/>
<v-btn
color="error"
:disabled="!currentCalibrationCoeffs"
style="flex: 1"
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
@click="() => (confirmRemoveDialog = { show: true, vf: props.videoFormat })"
>
<v-icon start size="large">mdi-delete</v-icon>
<span>Delete</span>
</v-btn>
</v-col>
</div>
<v-card-title class="pt-0 pb-0"
@@ -312,32 +311,13 @@ const calibrationImageURL = (index: number) =>
</v-card-text>
</v-card>
<v-dialog v-model="confirmRemoveDialog.show" width="600">
<v-card color="surface" dark>
<v-card-title>Delete Calibration</v-card-title>
<v-card-text class="pt-0">
Are you sure you want to delete the calibration for {{ confirmRemoveDialog.vf.resolution.width }}x{{
confirmRemoveDialog.vf.resolution.height
}}? This cannot be undone.
<v-card-actions class="pt-5 pb-0 pr-0" style="justify-content: flex-end">
<v-btn
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
color="primary"
@click="() => (confirmRemoveDialog.show = false)"
>
Cancel
</v-btn>
<v-btn
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
color="error"
@click="removeCalibration(confirmRemoveDialog.vf)"
>
Delete
</v-btn>
</v-card-actions>
</v-card-text>
</v-card>
</v-dialog>
<pv-delete-modal
v-model="confirmRemoveDialog.show"
:width="500"
:title="'Delete Calibration'"
:description="`Are you sure you want to delete the calibration for '${confirmRemoveDialog.vf.resolution.width}x${confirmRemoveDialog.vf.resolution.height}'? This action cannot be undone.`"
:on-confirm="() => removeCalibration(confirmRemoveDialog.vf)"
/>
</template>
<style scoped>