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

75% Statements 6/8
50% Branches 1/2
33.33% Functions 1/3
75% Lines 6/8

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  1x                                                   1x 1x   1x                         1x 1x      
<template>
  <Action
    :text="t('labels.length')"
    icon="straighten"
    :color="enabled ? 'blue-lighten-1' : 'white'"
    :variant="variant"
    @click="toggle"
    data-testid="button"
  />
</template>
 
<script setup lang="ts">
import { useToolStore } from '@/stores/tool.store';
import { useToolGroup } from '@/composables/useToolGroup';
import { ScanView } from '@3cr/types-ts';
import { useI18n } from 'vue-i18n';
import { computed } from 'vue';
 
interface Props {
  view: ScanView;
  variant?: 'button' | 'menu-item';
}
 
withDefaults(defineProps<Props>(), {
  variant: 'button',
});
 
const { t } = useI18n();
const { measurementAngleTool, measurementLengthTool, measurementPolygonTool } =
  useToolStore();
const { activeTool, toggleTool } = useToolGroup(
  measurementLengthTool,
  measurementPolygonTool,
  measurementAngleTool,
);
 
function toggle(): void {
  setTimeout(() => {
    // TODO: fix input issue with unity
    toggleTool(measurementLengthTool);
  }, 100);
}
 
const enabled = computed(() => {
  return activeTool.value === measurementLengthTool;
});
</script>