All files / src/components/modal/actions ResetViewAction.vue

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
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  2x                                                 2x 2x 2x   2x 2x       1x 1x 1x 1x      
<template>
  <Action
    :text="text"
    icon="home"
    :variant="variant"
    @click="reset"
  />
</template>
 
<script setup lang="ts">
import { ScanView, ViewSelectionActions } from '@3cr/types-ts';
import { useViewer3cr } from '@/composables/useViewer3cr';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import { useViewerStore } from '@/stores/viewer.store';
 
interface Props {
  view: ScanView;
  variant?: 'button' | 'menu-item';
}
 
withDefaults(defineProps<Props>(), {
  variant: 'button',
});
 
const { t } = useI18n();
const viewer3cr = useViewer3cr();
const { defaultLayout2x2 } = storeToRefs(useViewerStore());
 
const text = computed(() => {
  return t('labels.resetView');
});
 
async function reset(): Promise<void> {
  await viewer3cr.viewSelection(ViewSelectionActions.vs06);
  await viewer3cr.viewSelection(ViewSelectionActions.vs05);
  const message = { Version: '0.0.0', PositionData: defaultLayout2x2.value };
  await viewer3cr.customLayout({ message });
}
</script>