Sorting scene edit page tags alphanumerically, preventing double tags.

This commit is contained in:
DebaucheryLibrarian 2024-10-12 22:35:58 +02:00
parent 211f600242
commit fdce7b0232
2 changed files with 12 additions and 1 deletions

View File

@ -43,6 +43,8 @@
<script setup>
import { ref, watch } from 'vue';
import events from '#/src/events.js';
import TagSearch from '#/components/tags/search.vue';
const newTags = ref([]);
@ -69,6 +71,15 @@ const props = defineProps({
const emit = defineEmits(['tags']);
function addTag(tag) {
if (props.edits.tags.some((tagId) => tagId === tag.id)) {
events.emit('feedback', {
type: 'error',
message: 'Tag already added',
});
return;
}
newTags.value = newTags.value.concat(tag);
emit('tags', props.edits.tags.concat(tag.id));

View File

@ -237,7 +237,7 @@ const fields = computed(() => [
{
key: 'tags',
type: 'tags',
value: scene.value.tags,
value: scene.value.tags.toSorted((tagA, tagB) => tagA.name.localeCompare(tagB.name)),
},
{
key: 'movies',