11<template >
2- <h6 class =" text-h6 my-4 " >Add Additional Metadata</h6 >
2+ <h6 class =" text-h6 my-5 " >Add Additional Metadata</h6 >
33
4- <v-row class =" mt-8" >
4+ <v-row class =" mt-8" align = " center " >
55 <v-col cols =" 5" >
66 <v-combobox
77 density =" comfortable"
88 v-model =" formKey"
99 :items =" keyList"
1010 label =" Key"
11+ :hide-details =" !isKeyUsed"
12+ :error-messages ="
13+ isKeyUsed ? 'A key may only be used once per site.' : ''
14+ "
1115 />
1216 </v-col >
13- <v-col cols =" 7 " >
17+ <v-col cols =" 5 " >
1418 <v-combobox
1519 density =" comfortable"
1620 v-model =" formValue"
1721 :items =" valueList"
22+ :disabled =" !formKey || isKeyUsed"
1823 label =" Value"
24+ hide-details
1925 >
20- <template v-slot :append >
21- <v-btn @click =" addTag" >Add</v-btn >
22- </template >
2326 </v-combobox >
2427 </v-col >
28+ <v-col >
29+ <v-btn :disabled =" !formKey || !formValue || isKeyUsed" @click =" addTag"
30+ >Add</v-btn
31+ >
32+ </v-col >
2533 </v-row >
2634
27- <v-chip
28- v-for =" (tag, index) in previewTags"
29- rounded =" true"
30- :color =" materialColors[index % materialColors.length]"
31- :key =" tag.id"
32- closable
33- class =" mr-1 mb-1"
34- @click:close =" removeTag(index)"
35- >
36- {{ tag.key }}: {{ tag.value }}
37- </v-chip >
35+ <v-row >
36+ <v-col >
37+ <v-chip
38+ v-for =" (tag, index) in previewTags"
39+ rounded =" true"
40+ :color =" materialColors[index % materialColors.length]"
41+ :key =" tag.id"
42+ closable
43+ class =" mr-1 mb-1"
44+ @click:close =" removeTag(index)"
45+ >
46+ {{ tag.key }}: {{ tag.value }}
47+ </v-chip >
48+ </v-col >
49+ </v-row >
3850</template >
3951
4052<script setup lang="ts">
41- import { onMounted } from ' vue'
53+ import { computed , onMounted } from ' vue'
4254import { materialColors } from ' @/utils/materialColors'
4355import { storeToRefs } from ' pinia'
4456import { useTagStore } from ' @/store/tags'
@@ -48,6 +60,10 @@ const props = defineProps({ thingId: String })
4860const { tags, previewTags } = storeToRefs (useTagStore ())
4961const { formKey, formValue, keyList, valueList } = useUserTags ()
5062
63+ const isKeyUsed = computed (() =>
64+ previewTags .value .some ((tag ) => tag .key === formKey .value )
65+ )
66+
5167const addTag = () => {
5268 if (formKey .value === ' ' || formValue .value === ' ' ) {
5369 return
0 commit comments