refactor: use unified manager design

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-06-20 19:25:00 -04:00
parent ae4c68e9c2
commit 583e6a3359
3 changed files with 26 additions and 38 deletions
+6 -16
View File
@@ -8,8 +8,10 @@ import { GroupObject } from '@PeopleManager/models/group'
import type { ServiceObject } from '@PeopleManager/models/service'
import { useCollectionsStore } from '@PeopleManager/stores/collectionsStore'
import { useEntitiesStore } from '@PeopleManager/stores/entitiesStore'
import { useServicesStore } from '@PeopleManager/stores/servicesStore'
export const usePeopleStore = defineStore('peopleStore', () => {
const servicesStore = useServicesStore()
const collectionsStore = useCollectionsStore()
const entitiesStore = useEntitiesStore()
@@ -56,15 +58,12 @@ export const usePeopleStore = defineStore('peopleStore', () => {
if (collectionEditorMode.value === 'create') {
const created = await collectionsStore.create(
service.provider,
service.identifier || '',
null,
service.identifier ?? '',
collection.properties,
)
selectedCollection.value = created
} else {
await collectionsStore.update(
collection.provider,
collection.service,
collection.identifier,
collection.properties,
)
@@ -74,7 +73,7 @@ export const usePeopleStore = defineStore('peopleStore', () => {
}
async function deleteCollection(collection: CollectionObject) {
await collectionsStore.delete(collection.provider, collection.service, collection.identifier)
await collectionsStore.delete(collection.identifier)
if (selectedCollection.value?.identifier === collection.identifier) {
selectedCollection.value = null
@@ -132,8 +131,6 @@ export const usePeopleStore = defineStore('peopleStore', () => {
// Create
entity.properties.created = new Date()
selectedEntity.value = await entitiesStore.create(
targetCollection.provider,
targetCollection.service,
targetCollection.identifier,
entity.properties,
)
@@ -141,9 +138,6 @@ export const usePeopleStore = defineStore('peopleStore', () => {
// Update
entity.properties.modified = new Date()
selectedEntity.value = await entitiesStore.update(
targetCollection.provider,
targetCollection.service,
targetCollection.identifier,
entity.identifier,
entity.properties,
)
@@ -162,12 +156,7 @@ export const usePeopleStore = defineStore('peopleStore', () => {
throw new Error('[People] - No collection selected, cannot delete entity')
}
await entitiesStore.delete(
targetCollection.provider,
targetCollection.service,
targetCollection.identifier,
entity.identifier,
)
await entitiesStore.delete([entity.identifier])
closeEntityEditor()
}
@@ -177,6 +166,7 @@ export const usePeopleStore = defineStore('peopleStore', () => {
async function initialize() {
loading.value = true
try {
await servicesStore.list()
await collectionsStore.list()
if (