From 676254b23de6d09bfadf2899cce97f6ca73e9ef8 Mon Sep 17 00:00:00 2001 From: Sebastian Krupinski Date: Wed, 25 Feb 2026 00:17:21 -0500 Subject: [PATCH] refactor: standardize provider Signed-off-by: Sebastian Krupinski --- src/components/CollectionEditor.vue | 40 ++--- src/components/CollectionList.vue | 46 +----- src/components/PersonEditor.vue | 38 ++--- src/components/PersonList.vue | 80 ++++++---- src/pages/PeoplePage.vue | 208 +++++++------------------ src/stores/peopleStore.ts | 227 ++++++++++++++++++++++++++++ 6 files changed, 369 insertions(+), 270 deletions(-) create mode 100644 src/stores/peopleStore.ts diff --git a/src/components/CollectionEditor.vue b/src/components/CollectionEditor.vue index 4b0ae13..9e454a7 100644 --- a/src/components/CollectionEditor.vue +++ b/src/components/CollectionEditor.vue @@ -2,7 +2,7 @@ import { ref, computed, watch } from 'vue' import { useServicesStore } from '@PeopleManager/stores/servicesStore' import { CollectionObject } from '@PeopleManager/models/collection' -import { ServiceObject } from '@PeopleManager/models/service' +import type { ServiceObject } from '@PeopleManager/models/service' // Store const servicesStore = useServicesStore() @@ -51,7 +51,7 @@ const dialogOpen = computed({ // Functions const onOpen = async () => { if (services.value.length === 0) { - services.value = await servicesStore.list() + services.value = Object.values(await servicesStore.list()) } if (!props.collection) { @@ -61,14 +61,14 @@ const onOpen = async () => { // Clone the collection to avoid mutating the original editingCollection.value = props.collection.clone() - if (props.collection.id !== null) { + if (props.collection.identifier) { // Edit mode - find the service editingCollectionService.value = services.value.find(s => - s.provider === props.collection!.provider && s.id === props.collection!.service + s.provider === props.collection!.provider && s.identifier === props.collection!.service ) || null } else { // Create mode - use first service that can create - editingCollectionService.value = services.value.filter(s => s.capabilities?.CollectionCreate)[0] || null + editingCollectionService.value = services.value.filter(s => s.capable('CollectionCreate'))[0] || null } } @@ -92,7 +92,7 @@ const onColorSelect = (color: string | null, closeMenu = true) => { if (!editingCollection.value) { return } - editingCollection.value.color = color + editingCollection.value.properties.color = color if (closeMenu) { colorMenuOpen.value = false } @@ -132,9 +132,9 @@ watch(() => props.modelValue, async (newValue) => { @@ -142,7 +142,7 @@ watch(() => props.modelValue, async (newValue) => {
Service {{ editingCollection.service }}
props.modelValue, async (newValue) => { icon variant="text" size="small" - :style="{ color: editingCollection.color || 'var(--v-theme-on-surface)' }" + :style="{ color: editingCollection.properties.color || 'var(--v-theme-on-surface)' }" aria-label="Select book color" title="Select color" > @@ -192,11 +192,11 @@ watch(() => props.modelValue, async (newValue) => { variant="flat" size="small" class="color-menu-body__presets--swatch" - :class="{ 'color-menu-body__presets--swatch--active': editingCollection.color === color }" + :class="{ 'color-menu-body__presets--swatch--active': editingCollection.properties.color === color }" :style="{ backgroundColor: color }" @click="onColorSelect(color)"> props.modelValue, async (newValue) => {
props.modelValue, async (newValue) => { - - - - - - @@ -243,7 +233,7 @@ watch(() => props.modelValue, async (newValue) => {
-import { ref, onMounted } from 'vue' -import { useCollectionsStore } from '@PeopleManager/stores/collectionsStore' import { CollectionObject } from '@PeopleManager/models/collection'; -// Store -const collectionsStore = useCollectionsStore() - // Props const props = defineProps<{ + collections: CollectionObject[] + loading?: boolean selectedCollection?: CollectionObject | null }>() @@ -17,43 +14,14 @@ const emit = defineEmits<{ 'edit': [collection: CollectionObject] }>() -// State -const loading = ref(false) -const collections = ref([]) - -// Lifecycle -onMounted(async () => { - loading.value = true - try { - collections.value = await collectionsStore.list() - } catch (error) { - console.error('[People] - Failed to load collections:', error) - } - loading.value = false -}) - // Functions const onCollectionSelect = (collection: CollectionObject) => { - console.log('[People] - Collection selected', collection) emit('select', collection) } const onCollectionEdit = (collection: CollectionObject) => { emit('edit', collection) } - -// Expose refresh method -defineExpose({ - async refresh() { - loading.value = true - try { - collections.value = await collectionsStore.list() - } catch (error) { - console.error('[People] - Failed to load collections:', error) - } - loading.value = false - } -})