All files / src/components/navigation/measurement MeasurementDeleteSnackbar.vue

100% Statements 10/10
100% Branches 2/2
100% Functions 4/4
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52    2x           10x 6x               10x                               11x   11x 11x   11x     1x             1x      
<template>
  <v-snackbar
    v-model="modelValue"
    variant="flat"
  >
    <v-icon
      class="pr-3 shark-400"
      icon="error"
    />
    <span class="shark-950">{{ t('texts.measurementDeleted') }}</span>
    <template #actions>
      <v-btn
        class="ml-auto px-4 my-1"
        color="minsk_900"
        variant="flat"
        @click="undo"
      >
        <span>{{ t('labels.undo') }}</span>
      </v-btn>
    </template>
  </v-snackbar>
</template>
 
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { DataOverlayType } from '@3cr/types-ts';
import { useViewer3cr } from '@/composables/useViewer3cr';
import { DataOverlay } from '@3cr/viewer-types-ts';
 
interface Props {
  measurement: DataOverlay;
}
 
const props = defineProps<Props>();
 
const { t } = useI18n();
const viewer3cr = useViewer3cr();
 
const modelValue = defineModel<boolean>({ default: false });
 
async function undo(): Promise<void> {
  const message = {
    Version: '0.0.0',
    Id: 'test',
    Data: JSON.stringify(props.measurement),
    DataType: DataOverlayType.Length, // TODO: determine based on measurement
  };
 
  await viewer3cr.createAnnotation({ message: [message] });
}
</script>