You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

105 lines
2.3 KiB

<template>
<v-data-table
:value="selected"
:headers="headers"
:items="labels"
item-key="id"
:search="search"
show-select
@input="update"
>
<template v-slot:top>
<v-text-field
v-model="search"
prepend-inner-icon="search"
label="Search"
single-line
hide-details
filled
/>
</template>
<template v-slot:item.text="{ item }">
<v-edit-dialog>
{{ item.text }}
<template v-slot:input>
<v-text-field
:value="item.text"
label="Edit"
single-line
@change="updateLabel({ id: item.id, text: $event })"
/>
</template>
</v-edit-dialog>
</template>
<template v-slot:item.suffix_key="{ item }">
<v-edit-dialog>
<div>{{ item.suffix_key }}</div>
<template v-slot:input>
<v-select
:value="item.suffix_key"
:items="keys"
label="Key"
@change="updateLabel({ id: item.id, suffix_key: $event })"
/>
</template>
</v-edit-dialog>
</template>
<template v-slot:item.background_color="{ item }">
<v-edit-dialog>
<v-chip :color="item.background_color" dark>
{{ item.background_color }}
</v-chip>
<template v-slot:input>
<v-color-picker
:value="item.backgroundColor"
show-swatches
hide-mode-switch
width="800"
mode="hexa"
class="ma-2"
@update:color="updateLabel({ id:item.id, background_color: $event.hex })"
/>
</template>
</v-edit-dialog>
</template>
</v-data-table>
</template>
<script>
export default {
props: {
headers: {
type: Array,
default: () => [],
required: true
},
labels: {
type: Array,
default: () => [],
required: true
},
selected: {
type: Array,
default: () => [],
required: true
},
keys: {
type: Array,
default: () => 'abcdefghijklmnopqrstuvwxyz'.split('')
}
},
data() {
return {
search: ''
}
},
methods: {
update(selected) {
this.$emit('update-selected', selected)
},
updateLabel(payload) {
this.$emit('update-label', payload)
}
}
}
</script>