From 9c30d14975cf34c40db787aff2fb3f536dd0dbbe Mon Sep 17 00:00:00 2001 From: matt Date: Mon, 25 Jul 2022 13:12:01 +0000 Subject: [PATCH] Split start/end location fields to Events --- public/single.html | 8 ++++++-- public/single.js | 15 +++++++++++---- src/collections/Events.ts | 22 +++++++++++++++++++--- src/payload-types.ts | 3 ++- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/public/single.html b/public/single.html index 8104d5a..940e2a4 100644 --- a/public/single.html +++ b/public/single.html @@ -43,8 +43,12 @@

Location

-

-

+
+ Start location: +
+
+ End location: +
diff --git a/public/single.js b/public/single.js index 0c8308b..fd1a360 100644 --- a/public/single.js +++ b/public/single.js @@ -56,10 +56,17 @@ async function main() { $event.querySelector('.event-start .event-datetime').innerText = event.start; $event.querySelector('.event-end .event-datetime').innerText = event.end ? event.end : 'N/A'; - if (event.location) - $event.querySelector('.event-location').appendChild(getDirectionLink(event.location)); - else - $event.querySelector('.event-location').innerText = 'There is no location specified for this event'; + if (event.startLocation) { + $event.querySelector('.event-location-start').appendChild(getDirectionLink(event.startLocation)); + + if (event.endLocation) + $event.querySelector('.event-location-end').appendChild(getDirectionLink(event.endLocation)); + else + $event.querySelector('.event-location-end').innerText = ''; + } else { + $event.querySelector('.event-location-start').innerText = 'There are no locations specified for this event'; + $event.querySelector('.event-location-end').innerText = ''; + } $event.querySelector('.event-notes').innerText = event.notes ?? 'There are no notes for this event'; diff --git a/src/collections/Events.ts b/src/collections/Events.ts index 1d059b5..9afc567 100644 --- a/src/collections/Events.ts +++ b/src/collections/Events.ts @@ -110,9 +110,25 @@ const Events: CollectionConfig = { ] }, { - name: 'location', - label: 'Location', - type: 'text' + type: 'row', + fields: [ + { + name: 'startLocation', + label: 'Start Location', + type: 'text', + admin: { + width: '50%', + } + }, + { + name: 'endLocation', + label: 'End Location', + type: 'text', + admin: { + width: '50%', + } + }, + ] }, { name: 'notes', diff --git a/src/payload-types.ts b/src/payload-types.ts index 1ab5aca..e4d412f 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -41,7 +41,8 @@ export interface Event { }; start: string; end?: string; - location?: string; + startLocation?: string; + endLocation?: string; notes?: string; uploads: { upload: string | Upload;