From 6b0b8dcabc243cbd59edb39e5031f09a13c4e189 Mon Sep 17 00:00:00 2001 From: ManUtopiK Date: Fri, 31 Jan 2020 02:52:57 +0100 Subject: [PATCH] Filter outdated topics and display dates in popup --- src/App.vue | 96 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 13 deletions(-) diff --git a/src/App.vue b/src/App.vue index 2ddb3fa..aa0b02f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -28,16 +28,20 @@ -

- {{ topic.fancy_title }} -

+

+
@@ -54,7 +58,7 @@ topic.creator.avatar_template.replace(/{size}/, '20') " :alt="topic.creator.name" - class="pr-1 rounded-full" + class="mr-1 rounded-full" /> {{ topic.creator.name }} ({{ topic.creator.username }}) @@ -70,14 +74,20 @@ :key="t" class="tag bg-gray-300 ml-1 mb-1 hover:bg-blue-300" > - - {{ tag }} - + -
+
-
+ @@ -157,11 +167,21 @@ export default { .then(resp => resp.json()) .then(data => { this.users = data.users; - // parse topics and feed each one with creator object + this.topics = data.topic_list.topics + // parse topics with geolocation and remove old topic .filter(topic => { - return topic.location && topic.location.geo_location; + let outdated = false; // allow all topics + if (topic.event) { + const eventEnd = new Date( + topic.event.start || topic.event.end + ).getTime(); + outdated = Date.now() > eventEnd; + } + + return topic.location && topic.location.geo_location && !outdated; }) + // and feed each one with creator object .map(topic => { return { ...topic, @@ -188,6 +208,53 @@ export default { }); } }); + }, + methods: { + cleanDateEvent(event) { + const sameDay = + event.end && + new Date(event.start).toLocaleDateString("fr-FR") === + new Date(event.end).toLocaleDateString("fr-FR"); + + let dateString = !event.end || sameDay ? "Le " : "Du "; + // eslint-disable-next-line no-console + console.log(event); + dateString += new Date(event.start).toLocaleDateString("fr-FR", { + weekday: "short", + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit" + }); + + if (event.end) { + if (sameDay) { + dateString = + dateString.replace(/à/, "de") + + " à" + + new Date(event.end) + .toLocaleDateString("fr-FR", { + hour: "2-digit", + minute: "2-digit" + }) + .replace(/.*à/, ""); + } else if (event.end) { + dateString += + "
Au " + + new Date(event.end).toLocaleDateString("fr-FR", { + weekday: "short", + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit" + }); + } + } + + return dateString; + } } }; // @@ -211,6 +278,9 @@ export default { .tag a { color: #333 !important; } +.title:hover h2 { + text-decoration: underline; +} .leaflet-popup-content-wrapper { padding: 0 !important;