feat: edit event type label in dialog, drop non-functional status field
Made-with: Cursor
This commit is contained in:
@@ -201,6 +201,28 @@ class EventTest extends TestCase
|
|||||||
->assertJson(['data' => ['name' => 'Updated Festival']]);
|
->assertJson(['data' => ['name' => 'Updated Festival']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_org_admin_can_update_event_type_label(): void
|
||||||
|
{
|
||||||
|
$event = Event::factory()->series()->create([
|
||||||
|
'organisation_id' => $this->organisation->id,
|
||||||
|
'event_type_label' => 'Oud label',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Sanctum::actingAs($this->orgAdmin);
|
||||||
|
|
||||||
|
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$event->id}", [
|
||||||
|
'event_type_label' => 'Schaatsseizoen',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJsonPath('data.event_type_label', 'Schaatsseizoen');
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('events', [
|
||||||
|
'id' => $event->id,
|
||||||
|
'event_type_label' => 'Schaatsseizoen',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_event_manager_can_update_event(): void
|
public function test_event_manager_can_update_event(): void
|
||||||
{
|
{
|
||||||
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
$event = Event::factory()->create(['organisation_id' => $this->organisation->id]);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { VForm } from 'vuetify/components/VForm'
|
import { VForm } from 'vuetify/components/VForm'
|
||||||
import { useUpdateEvent } from '@/composables/api/useEvents'
|
import { useUpdateEvent } from '@/composables/api/useEvents'
|
||||||
import { requiredValidator } from '@core/utils/validators'
|
import { requiredValidator } from '@core/utils/validators'
|
||||||
import type { EventStatus, EventItem } from '@/types/event'
|
import type { EventItem } from '@/types/event'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
event: EventItem
|
event: EventItem
|
||||||
@@ -20,8 +20,8 @@ const form = ref({
|
|||||||
start_date: '',
|
start_date: '',
|
||||||
end_date: '',
|
end_date: '',
|
||||||
timezone: '',
|
timezone: '',
|
||||||
status: '' as EventStatus,
|
|
||||||
sub_event_label: '' as string | null,
|
sub_event_label: '' as string | null,
|
||||||
|
event_type_label: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const errors = ref<Record<string, string>>({})
|
const errors = ref<Record<string, string>>({})
|
||||||
@@ -50,16 +50,6 @@ const timezoneOptions = [
|
|||||||
{ title: 'UTC', value: 'UTC' },
|
{ title: 'UTC', value: 'UTC' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const statusOptions: { title: string; value: EventStatus }[] = [
|
|
||||||
{ title: 'Draft', value: 'draft' },
|
|
||||||
{ title: 'Published', value: 'published' },
|
|
||||||
{ title: 'Registration Open', value: 'registration_open' },
|
|
||||||
{ title: 'Build-up', value: 'buildup' },
|
|
||||||
{ title: 'Show Day', value: 'showday' },
|
|
||||||
{ title: 'Tear-down', value: 'teardown' },
|
|
||||||
{ title: 'Closed', value: 'closed' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const endDateRule = (v: string) => {
|
const endDateRule = (v: string) => {
|
||||||
if (!v) return 'Einddatum is verplicht'
|
if (!v) return 'Einddatum is verplicht'
|
||||||
if (form.value.start_date && v < form.value.start_date) {
|
if (form.value.start_date && v < form.value.start_date) {
|
||||||
@@ -75,8 +65,8 @@ watch(() => props.event, (ev) => {
|
|||||||
start_date: ev.start_date,
|
start_date: ev.start_date,
|
||||||
end_date: ev.end_date,
|
end_date: ev.end_date,
|
||||||
timezone: ev.timezone,
|
timezone: ev.timezone,
|
||||||
status: ev.status,
|
|
||||||
sub_event_label: ev.sub_event_label ?? '',
|
sub_event_label: ev.sub_event_label ?? '',
|
||||||
|
event_type_label: ev.event_type_label ?? '',
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
@@ -86,11 +76,20 @@ function onSubmit() {
|
|||||||
|
|
||||||
errors.value = {}
|
errors.value = {}
|
||||||
|
|
||||||
|
const trimmedTypeLabel = form.value.event_type_label.trim()
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
...form.value,
|
name: form.value.name,
|
||||||
|
slug: form.value.slug,
|
||||||
|
start_date: form.value.start_date,
|
||||||
|
end_date: form.value.end_date,
|
||||||
|
timezone: form.value.timezone,
|
||||||
sub_event_label: isFestivalOrSeries.value && form.value.sub_event_label
|
sub_event_label: isFestivalOrSeries.value && form.value.sub_event_label
|
||||||
? form.value.sub_event_label
|
? form.value.sub_event_label
|
||||||
: null,
|
: null,
|
||||||
|
...(isFestivalOrSeries.value
|
||||||
|
? { event_type_label: trimmedTypeLabel === '' ? null : trimmedTypeLabel }
|
||||||
|
: {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEvent(payload, {
|
updateEvent(payload, {
|
||||||
@@ -159,6 +158,20 @@ function onSubmit() {
|
|||||||
autocomplete="one-time-code"
|
autocomplete="one-time-code"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
|
<VCol
|
||||||
|
v-if="isFestivalOrSeries"
|
||||||
|
cols="12"
|
||||||
|
>
|
||||||
|
<AppTextField
|
||||||
|
v-model="form.event_type_label"
|
||||||
|
label="Naam van het type (optioneel)"
|
||||||
|
placeholder="Festival, Evenement, Schaatsbaan..."
|
||||||
|
:error-messages="errors.event_type_label"
|
||||||
|
maxlength="50"
|
||||||
|
counter
|
||||||
|
autocomplete="one-time-code"
|
||||||
|
/>
|
||||||
|
</VCol>
|
||||||
<VCol
|
<VCol
|
||||||
cols="12"
|
cols="12"
|
||||||
md="6"
|
md="6"
|
||||||
@@ -183,10 +196,7 @@ function onSubmit() {
|
|||||||
:error-messages="errors.end_date"
|
:error-messages="errors.end_date"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol
|
<VCol cols="12">
|
||||||
cols="12"
|
|
||||||
md="6"
|
|
||||||
>
|
|
||||||
<AppSelect
|
<AppSelect
|
||||||
v-model="form.timezone"
|
v-model="form.timezone"
|
||||||
label="Tijdzone"
|
label="Tijdzone"
|
||||||
@@ -194,17 +204,6 @@ function onSubmit() {
|
|||||||
:error-messages="errors.timezone"
|
:error-messages="errors.timezone"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol
|
|
||||||
cols="12"
|
|
||||||
md="6"
|
|
||||||
>
|
|
||||||
<AppSelect
|
|
||||||
v-model="form.status"
|
|
||||||
label="Status"
|
|
||||||
:items="statusOptions"
|
|
||||||
:error-messages="errors.status"
|
|
||||||
/>
|
|
||||||
</VCol>
|
|
||||||
</VRow>
|
</VRow>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
<VCardActions>
|
<VCardActions>
|
||||||
|
|||||||
Reference in New Issue
Block a user