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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | 2x 1x 1x 1x 1x 1x 16x 16x 47x 47x 47x 47x 47x 47x 47x 47x 10x 5x 20x 5x 5x 5x 12x 3x 3x 3x 3x 3x 3x 47x | <template>
<v-dialog
v-model="modal"
persistent
width="535"
data-testid="mcad-update-modal"
>
<v-card class="new-style position-relative">
<v-card-title class="pl-6 pr-6 pb-0 pt-4">
<span>{{ t('labels.mcadEdit') }}</span>
<v-btn
variant="text"
size="default"
icon="close"
color="shark_400"
@click="modal = false"
data-testid="close-top"
class="annotation-close-button position-absolute"
style="top: 0; right: 0"
/>
</v-card-title>
<v-card-text class="pt-3">
<v-form density="compact">
<sh-text-field
v-model="title"
:label="t('fields.title.label')"
variant="outlined"
class="new-style pb-0"
/>
<sh-textarea
no-resize
v-model="description"
variant="outlined"
:label="t('fields.description.label')"
:placeholder="t('fields.description.placeholder')"
counter="400"
class="Title-text-field pt-0"
/>
<v-divider class="pt-4 mt-4" />
<McadInvert
:mcad="mcad"
style="border-radius: 8px; background-color: white"
class="pb-3"
/>
<span
class="text-caption"
style="font-size: 12px !important; font-weight: 600"
>
{{ t('labels.colour') }}
</span>
<v-row class="pt-1 pl-3">
<v-col class="pl-0 pr-0">
<ColourPalette
v-model="colour"
class="pl-0 pr-0"
/>
</v-col>
</v-row>
</v-form>
</v-card-text>
<v-card-actions class="pb-4 pr-4">
<v-spacer />
<v-btn
color="minsk_900"
data-testid="close"
variant="text"
@click="modal = false"
>
<span>{{ t('labels.cancel') }}</span>
</v-btn>
<v-btn
class="ml-auto"
data-testid="save"
color="minsk_900"
variant="flat"
@click="updateMcadObject"
>
<span>{{ t('labels.save') }}</span>
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { hexToRgba, rgbaToHex } from '@/functions/colours';
import { useViewer3cr } from '@/composables/useViewer3cr';
import { useI18n } from 'vue-i18n';
import { DataOverlayMcad } from '@3cr/viewer-types-ts';
interface Props {
mcad: DataOverlayMcad;
}
const props = defineProps<Props>();
const { t } = useI18n();
const viewer3cr = useViewer3cr();
const title = ref<string>('');
const description = ref<string>('');
const colour = ref<string>('');
const modal = defineModel<boolean>({ default: false });
watch(modal, (modalOpen: boolean) => {
if (modalOpen) {
hydrate();
}
});
function hydrate(): void {
const toByte = (n: number) => n * 255;
const { R, G, B, A } = props.mcad.Colour;
title.value = props.mcad.Title;
colour.value = rgbaToHex(toByte(R), toByte(G), toByte(B), toByte(A));
}
async function updateMcadObject(): Promise<void> {
const toDec = (n: number) => n / 255;
const [r, g, b, a] = hexToRgba(colour.value);
const titleMessage = {
Version: '0.0.0',
Id: props.mcad.Id,
Value: title.value,
};
await viewer3cr.setMcadObjectTitle({ message: titleMessage });
const colourMessage = {
Version: '0.0.0',
Id: props.mcad.Id,
Colour: {
Version: '0.0.0',
R: toDec(r),
G: toDec(g),
B: toDec(b),
A: toDec(a) || 1,
},
};
await viewer3cr.setMcadObjectColour({ message: colourMessage });
modal.value = false;
}
defineExpose({
modal,
});
</script>
|