From d58ca5743d4d1b464bf2f34a244a0b5f9569fbf3 Mon Sep 17 00:00:00 2001
From: Thomas Citharel
Date: Sun, 10 Oct 2021 16:25:50 +0200
Subject: [PATCH] Add timezone handling
Signed-off-by: Thomas Citharel
---
js/package.json | 1 +
js/src/components/Address/AddressInfo.vue | 124 +++++++++++
js/src/components/Event/EventFullDate.vue | 186 ++++++++++++----
js/src/components/Event/EventMap.vue | 175 +++++++++++++++
.../components/Event/EventMetadataSidebar.vue | 201 ++----------------
.../Event/FullAddressAutoComplete.vue | 152 +++++++------
js/src/components/NavBar.vue | 9 +-
js/src/filters/datetime.ts | 5 +-
js/src/graphql/address.ts | 1 +
js/src/graphql/config.ts | 25 +++
js/src/graphql/event.ts | 1 +
js/src/graphql/user.ts | 11 +
js/src/i18n/en_US.json | 46 +++-
js/src/i18n/fr_FR.json | 46 +++-
js/src/types/address.model.ts | 16 +-
js/src/types/event-options.model.ts | 3 +
js/src/types/event.model.ts | 21 +-
js/src/views/Event/Edit.vue | 199 ++++++++++++++---
js/src/views/Event/Event.vue | 35 ++-
.../components/Post/PostElementItem.spec.ts | 2 +-
js/tsconfig.json | 2 +-
js/yarn.lock | 5 +
lib/federation/activity_pub/actor.ex | 4 +-
lib/federation/activity_pub/permission.ex | 2 +-
lib/federation/activity_pub/types/events.ex | 2 +-
lib/graphql/api/events.ex | 6 +-
.../middleware/current_actor_provider.ex | 4 +-
lib/graphql/resolvers/address.ex | 2 +-
lib/graphql/resolvers/event.ex | 99 +++++++--
lib/graphql/schema/address.ex | 2 +
lib/graphql/schema/event.ex | 6 +-
lib/mobilizon.ex | 1 +
lib/mobilizon/addresses/address.ex | 51 ++++-
lib/mobilizon/events/event_options.ex | 3 +
lib/mobilizon/events/events.ex | 19 +-
lib/service/geospatial/addok.ex | 5 +-
lib/service/geospatial/google_maps.ex | 5 +-
lib/service/geospatial/map_quest.ex | 5 +-
lib/service/geospatial/mimirsbrunn.ex | 3 +-
lib/service/geospatial/nominatim.ex | 3 +-
lib/service/geospatial/pelias.ex | 3 +-
lib/service/geospatial/photon.ex | 5 +-
lib/service/geospatial/provider.ex | 13 ++
lib/service/metadata/event.ex | 54 ++++-
lib/service/timezone_detector.ex | 40 ++++
lib/web/auth/context.ex | 33 +--
mix.exs | 1 +
mix.lock | 1 +
...211008084901_add_timezone_to_addresses.exs | 9 +
49 files changed, 1218 insertions(+), 429 deletions(-)
create mode 100644 js/src/components/Address/AddressInfo.vue
create mode 100644 js/src/components/Event/EventMap.vue
create mode 100644 lib/service/timezone_detector.ex
create mode 100644 priv/repo/migrations/20211008084901_add_timezone_to_addresses.exs
diff --git a/js/package.json b/js/package.json
index 9e38573e..a3d4ca10 100644
--- a/js/package.json
+++ b/js/package.json
@@ -38,6 +38,7 @@
"bulma-divider": "^0.2.0",
"core-js": "^3.6.4",
"date-fns": "^2.16.0",
+ "date-fns-tz": "^1.1.6",
"graphql": "^15.0.0",
"graphql-tag": "^2.10.3",
"intersection-observer": "^0.12.0",
diff --git a/js/src/components/Address/AddressInfo.vue b/js/src/components/Address/AddressInfo.vue
new file mode 100644
index 00000000..a0ef9ead
--- /dev/null
+++ b/js/src/components/Address/AddressInfo.vue
@@ -0,0 +1,124 @@
+
+
+
+
+
+ {{ address.poiInfos.name }}
+
+
+
+ {{ address.poiInfos.alternativeName }}
+
+
+
+ 🌐
+ {{
+ $t("{timezoneLongName} ({timezoneShortName})", {
+ timezoneLongName,
+ timezoneShortName,
+ })
+ }}
+
+
+ 🌐 {{ timezoneShortName }}
+
+
+
+
+
+
diff --git a/js/src/components/Event/EventFullDate.vue b/js/src/components/Event/EventFullDate.vue
index 454a3949..33c1d617 100644
--- a/js/src/components/Event/EventFullDate.vue
+++ b/js/src/components/Event/EventFullDate.vue
@@ -18,64 +18,97 @@
- {{
- beginsOn | formatDateTimeString(showStartTime)
- }}
-
- {{
+
+ {{
+ formatDateTimeString(beginsOn, timezoneToShow, showStartTime)
+ }}
+
+
+ {{ singleTimeZone }}
+
+
+
+ {{
$t("On {date} from {startTime} to {endTime}", {
date: formatDate(beginsOn),
- startTime: formatTime(beginsOn),
- endTime: formatTime(endsOn),
+ startTime: formatTime(beginsOn, timezoneToShow),
+ endTime: formatTime(endsOn, timezoneToShow),
})
- }}
-
-
- {{
- $t("On {date} ending at {endTime}", {
- date: formatDate(beginsOn),
- endTime: formatTime(endsOn),
- })
- }}
-
-
+ }}
+
+
+ {{ singleTimeZone }}
+
+
+
{{
$t("On {date} starting at {startTime}", {
date: formatDate(beginsOn),
startTime: formatTime(beginsOn),
})
}}
-
- {{
- $t("On {date}", { date: formatDate(beginsOn) })
- }}
-
- {{
- $t("From the {startDate} at {startTime} to the {endDate} at {endTime}", {
- startDate: formatDate(beginsOn),
- startTime: formatTime(beginsOn),
- endDate: formatDate(endsOn),
- endTime: formatTime(endsOn),
- })
- }}
-
-
- {{
- $t("From the {startDate} at {startTime} to the {endDate}", {
- startDate: formatDate(beginsOn),
- startTime: formatTime(beginsOn),
- endDate: formatDate(endsOn),
- })
- }}
-
-
+
+
+ {{ $t("On {date}", { date: formatDate(beginsOn) }) }}
+
+
+
+ {{
+ $t(
+ "From the {startDate} at {startTime} to the {endDate} at {endTime}",
+ {
+ startDate: formatDate(beginsOn),
+ startTime: formatTime(beginsOn, timezoneToShow),
+ endDate: formatDate(endsOn),
+ endTime: formatTime(endsOn, timezoneToShow),
+ }
+ )
+ }}
+
+
+
+ {{ multipleTimeZones }}
+
+
+
+
+ {{
+ $t("From the {startDate} at {startTime} to the {endDate}", {
+ startDate: formatDate(beginsOn),
+ startTime: formatTime(beginsOn, timezoneToShow),
+ endDate: formatDate(endsOn),
+ })
+ }}
+
+
+
+ {{ singleTimeZone }}
+
+
+
{{
$t("From the {startDate} to the {endDate}", {
startDate: formatDate(beginsOn),
endDate: formatDate(endsOn),
})
}}
-
+
diff --git a/js/src/components/Event/EventMap.vue b/js/src/components/Event/EventMap.vue
new file mode 100644
index 00000000..7ed79b3f
--- /dev/null
+++ b/js/src/components/Event/EventMap.vue
@@ -0,0 +1,175 @@
+
+
+
+
+
diff --git a/js/src/components/Event/EventMetadataSidebar.vue b/js/src/components/Event/EventMetadataSidebar.vue
index 912038d6..1f94d5d0 100644
--- a/js/src/components/Event/EventMetadataSidebar.vue
+++ b/js/src/components/Event/EventMetadataSidebar.vue
@@ -11,7 +11,7 @@
{{ $t("Show map") }}
@@ -24,6 +24,8 @@
:beginsOn="event.beginsOn"
:show-start-time="event.options.showStartTime"
:show-end-time="event.options.showEndTime"
+ :timezone="event.options.timezone"
+ :userTimezone="userTimezone"
:endsOn="event.endsOn"
/>
@@ -130,91 +132,12 @@
>
{{ extra.value }}
-
-
-
diff --git a/js/src/components/Event/FullAddressAutoComplete.vue b/js/src/components/Event/FullAddressAutoComplete.vue
index b1af7d7a..48f16ead 100644
--- a/js/src/components/Event/FullAddressAutoComplete.vue
+++ b/js/src/components/Event/FullAddressAutoComplete.vue
@@ -1,72 +1,89 @@
-
-
-
- {{ actualLabel }}
-
- {{ $t("Getting location") }}
-
-
+
+
-
-
- {{ option.poiInfos.name }}
- {{ option.poiInfos.alternativeName }}
+
+ {{ actualLabel }}
+
+ {{ $t("Getting location") }}
-
- {{ $t("Searching…") }}
-
- {{ $t('No results for "{queryText}"', { queryText }) }}
- {{
- $t(
- "You can try another search term or drag and drop the marker on the map",
- {
- queryText,
- }
- )
- }}
-
-
-
-
-
-
-
-
-
+
+
+
+ {{ option.poiInfos.name }}
+ {{ option.poiInfos.alternativeName }}
+
+
+ {{ $t("Searching…") }}
+
+ {{
+ $t('No results for "{queryText}"', { queryText })
+ }}
+ {{
+ $t(
+ "You can try another search term or drag and drop the marker on the map",
+ {
+ queryText,
+ }
+ )
+ }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue
index bcf387f9..b30adfeb 100755
--- a/js/src/views/Event/Event.vue
+++ b/js/src/views/Event/Event.vue
@@ -303,6 +303,8 @@
v-if="event && config"
:event="event"
:config="config"
+ :user="loggedUser"
+ @showMapModal="showMap = true"
/>
@@ -458,6 +460,22 @@
+
+
+
+
+
@@ -508,11 +526,14 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
import Tag from "../../components/Tag.vue";
import EventMetadataSidebar from "../../components/Event/EventMetadataSidebar.vue";
import EventBanner from "../../components/Event/EventBanner.vue";
+import EventMap from "../../components/Event/EventMap.vue";
import PopoverActorCard from "../../components/Account/PopoverActorCard.vue";
import { IParticipant } from "../../types/participant.model";
import { ApolloCache, FetchResult } from "@apollo/client/core";
import { IEventMetadataDescription } from "@/types/event-metadata";
import { eventMetaDataList } from "../../services/EventMetadata";
+import { USER_SETTINGS } from "@/graphql/user";
+import { IUser } from "@/types/current-user.model";
// noinspection TypeScriptValidateTypes
@Component({
@@ -529,6 +550,7 @@ import { eventMetaDataList } from "../../services/EventMetadata";
PopoverActorCard,
EventBanner,
EventMetadataSidebar,
+ EventMap,
ShareEventModal: () =>
import(
/* webpackChunkName: "shareEventModal" */ "../../components/Event/ShareEventModal.vue"
@@ -567,9 +589,8 @@ import { eventMetaDataList } from "../../services/EventMetadata";
this.handleErrors(graphQLErrors);
},
},
- currentActor: {
- query: CURRENT_ACTOR_CLIENT,
- },
+ currentActor: CURRENT_ACTOR_CLIENT,
+ loggedUser: USER_SETTINGS,
participations: {
query: EVENT_PERSON_PARTICIPATION,
fetchPolicy: "cache-and-network",
@@ -646,6 +667,8 @@ export default class Event extends EventMixin {
person!: IPerson;
+ loggedUser!: IUser;
+
participations: IParticipant[] = [];
oldParticipationRole!: string;
@@ -1130,6 +1153,12 @@ export default class Event extends EventMixin {
return acc;
}, {});
}
+
+ showMap = false;
+
+ get routingType(): string | undefined {
+ return this.config?.maps?.routing?.type;
+ }
}