refactor: improve properties input
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
mode: 'edit' | 'view'
|
||||
organizer: any | null
|
||||
participants: Record<string, any>
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:organizer': [organizer: any | null]
|
||||
'add-participant': []
|
||||
'remove-participant': [key: string]
|
||||
}>()
|
||||
@@ -39,61 +37,26 @@ const typeOptions = [
|
||||
]
|
||||
|
||||
const hasParticipants = () => {
|
||||
return props.organizer || Object.keys(props.participants || {}).length > 0
|
||||
return Object.keys(props.participants || {}).length > 0
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="hasParticipants() || mode === 'edit'" class="event-editor-section">
|
||||
<div class="text-subtitle-1 mb-2">Participants</div>
|
||||
|
||||
<!-- Organizer -->
|
||||
<div v-if="organizer || mode === 'edit'" class="mb-4">
|
||||
<div class="text-subtitle-2 mb-2">Organizer</div>
|
||||
|
||||
<!-- Read-only view -->
|
||||
<div v-if="mode === 'view' && organizer" class="pa-2 border rounded">
|
||||
<div class="mb-1"><strong>{{ organizer.name || organizer.address }}</strong></div>
|
||||
<div class="text-caption text-grey">{{ organizer.address }}</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit view -->
|
||||
<div v-else-if="mode === 'edit'" class="pa-3 border rounded">
|
||||
<v-row dense>
|
||||
<v-col cols="12" md="6">
|
||||
<v-text-field
|
||||
v-model="organizer.name"
|
||||
label="Name"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" md="6">
|
||||
<v-text-field
|
||||
v-model="organizer.address"
|
||||
label="Email/Address"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
:rules="[v => !!v || 'Address is required']"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
<div class="d-flex align-center justify-space-between mb-2">
|
||||
<div class="text-subtitle-1">Participants</div>
|
||||
<v-btn v-if="mode === 'edit'"
|
||||
icon="mdi-account"
|
||||
size="x-small"
|
||||
variant="text"
|
||||
rounded="0"
|
||||
title="Add Attendee"
|
||||
@click="$emit('add-participant')">
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
<!-- Participants List -->
|
||||
<div v-if="Object.keys(participants || {}).length > 0 || mode === 'edit'">
|
||||
<div class="d-flex align-center justify-space-between mb-2">
|
||||
<div class="text-subtitle-2">Attendees</div>
|
||||
<v-btn v-if="mode === 'edit'"
|
||||
size="small"
|
||||
variant="outlined"
|
||||
@click="$emit('add-participant')">
|
||||
<v-icon left>mdi-plus</v-icon>
|
||||
Add
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
<!-- Read-only view -->
|
||||
<div v-if="mode === 'view'">
|
||||
<div v-for="(participant, key) in participants" :key="key" class="mb-2 pa-2 border rounded">
|
||||
|
||||
Reference in New Issue
Block a user