refactor: standardize provider
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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) => {
|
||||
<v-combobox v-show="mode === 'create' && services.length > 1"
|
||||
v-model="editingCollectionService"
|
||||
label="Service"
|
||||
:items="services.filter(s => s.capabilities?.CollectionCreate)"
|
||||
:items="services.filter(s => s.capable('CollectionCreate'))"
|
||||
item-title="label"
|
||||
item-value="id"
|
||||
item-value="identifier"
|
||||
required
|
||||
:rules="[(v: ServiceObject) => !!v || 'Service is required']"
|
||||
/>
|
||||
@@ -142,7 +142,7 @@ watch(() => props.modelValue, async (newValue) => {
|
||||
<div class="mb-4"><strong>Service </strong> {{ editingCollection.service }}</div>
|
||||
|
||||
<v-text-field
|
||||
v-model="editingCollection.label"
|
||||
v-model="editingCollection.properties.label"
|
||||
label="Label"
|
||||
required
|
||||
:rules="[(v: string) => !!v || 'Label is required']"
|
||||
@@ -160,7 +160,7 @@ watch(() => 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)">
|
||||
<v-icon
|
||||
v-if="editingCollection.color === color"
|
||||
v-if="editingCollection.properties.color === color"
|
||||
icon="mdi-check"
|
||||
size="x-small"
|
||||
color="white"
|
||||
@@ -207,7 +207,7 @@ watch(() => props.modelValue, async (newValue) => {
|
||||
|
||||
<div class="color-menu-body__picker">
|
||||
<v-color-picker
|
||||
v-model="editingCollection.color"
|
||||
v-model="editingCollection.properties.color"
|
||||
mode="hex"
|
||||
hide-canvas
|
||||
width="100%"
|
||||
@@ -221,20 +221,10 @@ watch(() => props.modelValue, async (newValue) => {
|
||||
</v-text-field>
|
||||
|
||||
<v-textarea
|
||||
v-model="editingCollection.description"
|
||||
v-model="editingCollection.properties.description"
|
||||
label="Description"
|
||||
rows="2"
|
||||
/>
|
||||
|
||||
<v-row>
|
||||
<v-col v-if="mode === 'edit'" cols="6">
|
||||
<v-switch
|
||||
v-model="editingCollection.enabled"
|
||||
label="Enabled"
|
||||
color="primary"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
|
||||
@@ -243,7 +233,7 @@ watch(() => props.modelValue, async (newValue) => {
|
||||
<v-card-actions class="justify-space-between align-center">
|
||||
<div>
|
||||
<v-btn
|
||||
v-if="mode === 'edit' && editingCollectionService?.capabilities?.CollectionDestroy"
|
||||
v-if="mode === 'edit' && editingCollectionService?.capable('CollectionDestroy')"
|
||||
color="error"
|
||||
variant="text"
|
||||
@click="onDelete"
|
||||
|
||||
Reference in New Issue
Block a user