From b4f500532fecd75b90eb42ae7c3cafaac91e6e48 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 5 Aug 2020 11:42:23 +0200 Subject: [PATCH] Allow to filter by begins_on and ends_on. Redirect explore to search Signed-off-by: Thomas Citharel --- js/package.json | 1 + js/src/common.scss | 2 +- .../components/Event/AddressAutoComplete.vue | 3 +- js/src/graphql/search.ts | 18 +- js/src/i18n/en_US.json | 15 +- js/src/i18n/fr_FR.json | 15 +- js/src/main.ts | 2 + js/src/plugins/dateFns.ts | 14 + js/src/router/event.ts | 3 +- js/src/router/index.ts | 2 +- js/src/views/Event/Explore.vue | 116 ------ js/src/views/Search.vue | 336 +++++++++++------- js/yarn.lock | 5 + lib/graphql/schema/search.ex | 2 + lib/mobilizon/events/events.ex | 29 +- test/graphql/resolvers/search_test.exs | 39 +- 16 files changed, 354 insertions(+), 248 deletions(-) create mode 100644 js/src/plugins/dateFns.ts delete mode 100644 js/src/views/Event/Explore.vue diff --git a/js/package.json b/js/package.json index 97609c267..6aa5d3a05 100644 --- a/js/package.json +++ b/js/package.json @@ -25,6 +25,7 @@ "buefy": "^0.8.2", "bulma-divider": "^0.2.0", "core-js": "^3.6.4", + "date-fns": "^2.15.0", "eslint-plugin-cypress": "^2.10.3", "graphql": "^15.0.0", "graphql-tag": "^2.10.3", diff --git a/js/src/common.scss b/js/src/common.scss index 373e1d810..db448b2f5 100644 --- a/js/src/common.scss +++ b/js/src/common.scss @@ -26,7 +26,7 @@ input.input { } .section { - padding: 1rem 2rem 4rem; + padding: 1rem 1% 4rem; } figure img.is-rounded { diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue index 16e6c96df..83292ce5c 100644 --- a/js/src/components/Event/AddressAutoComplete.vue +++ b/js/src/components/Event/AddressAutoComplete.vue @@ -2,7 +2,7 @@ { Vue.use(Buefy); Vue.use(NotifierPlugin); +Vue.use(DateFnsPlugin, { locale }); Vue.use(filters); Vue.use(VueMeta); Vue.use(VueScrollTo); diff --git a/js/src/plugins/dateFns.ts b/js/src/plugins/dateFns.ts new file mode 100644 index 000000000..c989092f6 --- /dev/null +++ b/js/src/plugins/dateFns.ts @@ -0,0 +1,14 @@ +import Vue from "vue"; +import Locale from "date-fns"; + +declare module "vue/types/vue" { + interface Vue { + $dateFnsLocale: Locale; + } +} + +export function DateFnsPlugin(vue: typeof Vue, { locale }: { locale: string }): void { + import(`date-fns/locale/${locale}/index.js`).then((localeEntity) => { + Vue.prototype.$dateFnsLocale = localeEntity; + }); +} diff --git a/js/src/router/event.ts b/js/src/router/event.ts index 0431c9e30..e287e893a 100644 --- a/js/src/router/event.ts +++ b/js/src/router/event.ts @@ -8,7 +8,6 @@ const participations = () => const editEvent = () => import(/* webpackChunkName: "edit-event" */ "@/views/Event/Edit.vue"); const event = () => import(/* webpackChunkName: "event" */ "@/views/Event/Event.vue"); const myEvents = () => import(/* webpackChunkName: "my-events" */ "@/views/Event/MyEvents.vue"); -const explore = () => import(/* webpackChunkName: "explore" */ "@/views/Event/Explore.vue"); export enum EventRouteName { EVENT_LIST = "EventList", @@ -43,7 +42,7 @@ export const eventRoutes: RouteConfig[] = [ { path: "/events/explore", name: EventRouteName.EXPLORE, - component: explore, + redirect: { name: "Search" }, meta: { requiredAuth: false }, }, { diff --git a/js/src/router/index.ts b/js/src/router/index.ts index 19091f961..1084ede7b 100644 --- a/js/src/router/index.ts +++ b/js/src/router/index.ts @@ -49,7 +49,7 @@ const router = new Router({ ...discussionRoutes, ...errorRoutes, { - path: "/search/:searchTerm/:searchType?", + path: "/search/:searchTerm?/:searchType?", name: RouteName.SEARCH, component: Search, props: true, diff --git a/js/src/views/Event/Explore.vue b/js/src/views/Event/Explore.vue deleted file mode 100644 index 2c8981e17..000000000 --- a/js/src/views/Event/Explore.vue +++ /dev/null @@ -1,116 +0,0 @@ - - - - - diff --git a/js/src/views/Search.vue b/js/src/views/Search.vue index 8b5af747d..3a10508c4 100644 --- a/js/src/views/Search.vue +++ b/js/src/views/Search.vue @@ -1,16 +1,62 @@