From 0ee7e649a7233247343a3d564c5304ff44fb2374 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 28 Mar 2022 20:02:43 +0200 Subject: [PATCH] Allow to register custom categories Signed-off-by: Thomas Citharel --- js/src/graphql/config.ts | 8 + js/src/i18n/en_US.json | 15 - js/src/i18n/fr_FR.json | 15 - js/src/types/config.model.ts | 1 + js/src/utils/categories.ts | 68 --- js/src/views/Event/Edit.vue | 6 +- js/src/views/Event/Event.vue | 3 +- js/src/views/Search.vue | 5 +- lib/graphql/resolvers/config.ex | 12 + lib/graphql/schema/config.ex | 15 + lib/graphql/schema/custom/enum_types.ex | 86 +-- lib/mobilizon/events/categories.ex | 144 +++++ priv/gettext/ar/LC_MESSAGES/default.po | 150 +++++ priv/gettext/be/LC_MESSAGES/default.po | 150 +++++ priv/gettext/ca/LC_MESSAGES/default.po | 150 +++++ priv/gettext/cs/LC_MESSAGES/default.po | 150 +++++ priv/gettext/de/LC_MESSAGES/default.po | 150 +++++ priv/gettext/default.pot | 150 +++++ priv/gettext/en/LC_MESSAGES/default.po | 150 +++++ priv/gettext/es/LC_MESSAGES/default.po | 150 +++++ priv/gettext/fi/LC_MESSAGES/default.po | 150 +++++ priv/gettext/fr/LC_MESSAGES/default.po | 707 +++++++--------------- priv/gettext/fr/LC_MESSAGES/errors.po | 327 ++++++++-- priv/gettext/gd/LC_MESSAGES/default.po | 150 +++++ priv/gettext/gl/LC_MESSAGES/default.po | 150 +++++ priv/gettext/he/LC_MESSAGES/default.po | 150 +++++ priv/gettext/hr/LC_MESSAGES/default.po | 150 +++++ priv/gettext/hu/LC_MESSAGES/default.po | 150 +++++ priv/gettext/id/LC_MESSAGES/default.po | 150 +++++ priv/gettext/it/LC_MESSAGES/default.po | 150 +++++ priv/gettext/ja/LC_MESSAGES/default.po | 150 +++++ priv/gettext/nb_NO/LC_MESSAGES/default.po | 150 +++++ priv/gettext/nl/LC_MESSAGES/default.po | 150 +++++ priv/gettext/nn/LC_MESSAGES/default.po | 150 +++++ priv/gettext/oc/LC_MESSAGES/default.po | 150 +++++ priv/gettext/pl/LC_MESSAGES/default.po | 150 +++++ priv/gettext/pt/LC_MESSAGES/default.po | 150 +++++ priv/gettext/pt_BR/LC_MESSAGES/default.po | 150 +++++ priv/gettext/ru/LC_MESSAGES/default.po | 150 +++++ priv/gettext/sv/LC_MESSAGES/default.po | 150 +++++ 40 files changed, 4587 insertions(+), 725 deletions(-) delete mode 100644 js/src/utils/categories.ts create mode 100644 lib/mobilizon/events/categories.ex diff --git a/js/src/graphql/config.ts b/js/src/graphql/config.ts index 0fb5fa2ce..230da2134 100644 --- a/js/src/graphql/config.ts +++ b/js/src/graphql/config.ts @@ -11,6 +11,10 @@ export const CONFIG = gql` demoMode countryCode languages + eventCategories { + id + label + } anonymous { participation { allowed @@ -103,6 +107,10 @@ export const CONFIG_EDIT_EVENT = gql` features { groups } + eventCategories { + id + label + } anonymous { participation { allowed diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index 236522afd..49f4b8b11 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -1307,21 +1307,6 @@ "Last seen on": "Last seen on", "No user matches the filters": "No user matches the filters", "Reset filters": "Reset filters", - "Arts": "Arts", - "Book Clubs": "Book Clubs", - "Business": "Business", - "Causes": "Causes", - "Comedy": "Comedy", - "Crafts": "Crafts", - "Food & Drink": "Food & Drink", - "Health": "Health", - "Music": "Music", - "Auto, Boat & Air": "Auto, Boat & Air", - "Community": "Community", - "Family & Education": "Family & Education", - "Fashion & Beauty": "Fashion & Beauty", - "Film & Media": "Film & Media", - "Games": "Games", "Category": "Category", "Select a category": "Select a category", "Any category": "Any category" diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index b3fc7b805..6d4ae2839 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -1306,21 +1306,6 @@ "{title} ({count} todos)": "{title} ({count} todos)", "{username} was invited to {group}": "{username} a été invité à {group}", "© The OpenStreetMap Contributors": "© Les Contributeur⋅ices OpenStreetMap", - "Arts": "Arts", - "Book Clubs": "Clubs de lecture", - "Business": "Entreprises", - "Causes": "Causes", - "Comedy": "Comédie", - "Crafts": "Artisanat", - "Food & Drink": "Alimentation et boissons", - "Health": "Santé", - "Music": "Musique", - "Auto, Boat & Air": "Automobile, bateaux et aéronautique", - "Community": "Communauté", - "Family & Education": "Famille et éducation", - "Fashion & Beauty": "Mode et beauté", - "Film & Media": "Films et médias", - "Games": "Jeux", "Category": "Catégorie", "Select a category": "Choisissez une categorie", "Any category": "N'importe quelle catégorie" diff --git a/js/src/types/config.model.ts b/js/src/types/config.model.ts index 2c771db4f..b8474d4fa 100644 --- a/js/src/types/config.model.ts +++ b/js/src/types/config.model.ts @@ -17,6 +17,7 @@ export interface IConfig { registrationsAllowlist: boolean; demoMode: boolean; countryCode: string; + eventCategories: { id: string; label: string }[]; languages: string[]; location: { latitude: number; diff --git a/js/src/utils/categories.ts b/js/src/utils/categories.ts deleted file mode 100644 index 981659c4c..000000000 --- a/js/src/utils/categories.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { i18n } from "@/utils/i18n"; - -export const eventCategories = [ - { - id: "ARTS", - label: i18n.t("Arts"), - icon: "palette", - }, - { - id: "BOOK_CLUBS", - label: i18n.t("Book Clubs"), - icon: "favourite-book", - }, - { - id: "BUSINESS", - label: i18n.t("Business"), - }, - { - id: "CAUSES", - label: i18n.t("Causes"), - }, - { - id: "COMEDY", - label: i18n.t("Comedy"), - }, - { - id: "CRAFTS", - label: i18n.t("Crafts"), - }, - { - id: "FOOD_DRINK", - label: i18n.t("Food & Drink"), - }, - { - id: "HEALTH", - label: i18n.t("Health"), - }, - { - id: "MUSIC", - label: i18n.t("Music"), - }, - { - id: "AUTO_BOAT_AIR", - label: i18n.t("Auto, Boat & Air"), - }, - { - id: "COMMUNITY", - label: i18n.t("Community"), - }, - { - id: "FAMILY_EDUCATION", - label: i18n.t("Family & Education"), - }, - { - id: "FASHION_BEAUTY", - label: i18n.t("Fashion & Beauty"), - }, - { - id: "FILM_MEDIA", - label: i18n.t("Film & Media"), - }, - { - id: "GAMES", - label: i18n.t("Games"), - }, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore -].sort(({ label: label1 }, { label: label2 }) => label1.localeCompare(label2)); diff --git a/js/src/views/Event/Edit.vue b/js/src/views/Event/Edit.vue index f251aadb3..95e3cf83e 100644 --- a/js/src/views/Event/Edit.vue +++ b/js/src/views/Event/Edit.vue @@ -34,6 +34,7 @@