From 94b96b56cf626cacca32b82c5f2a8d8b18c296c2 Mon Sep 17 00:00:00 2001 From: Massedil Date: Wed, 14 Feb 2024 21:50:03 +0100 Subject: [PATCH 1/3] Add hide_number_of_participants feature --- lib/graphql/schema/event.ex | 14 +++++++++++++ lib/mobilizon/events/event.ex | 3 +++ ..._hide_number_of_participants_to_events.exs | 9 +++++++++ src/components/Event/EventActionSection.vue | 5 ++++- src/graphql/event.ts | 6 ++++++ src/types/event.model.ts | 6 ++++++ src/views/Event/EditView.vue | 20 +++++++++++++++++-- 7 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs diff --git a/lib/graphql/schema/event.ex b/lib/graphql/schema/event.ex index 9c6e04d5a..bb5e087c9 100644 --- a/lib/graphql/schema/event.ex +++ b/lib/graphql/schema/event.ex @@ -75,6 +75,10 @@ defmodule Mobilizon.GraphQL.Schema.EventType do field(:draft, :boolean, description: "Whether or not the event is a draft") + field(:hide_number_of_participants, :boolean, + description: "Whether or not the number of participants is hidden" + ) + field(:participant_stats, :participant_stats, description: "Statistics on the event", resolve: &Event.stats_participants/3 @@ -450,6 +454,11 @@ defmodule Mobilizon.GraphQL.Schema.EventType do description: "Whether or not the event is a draft" ) + arg(:hide_number_of_participants, :boolean, + default_value: false, + description: "Whether or not the number of participants is hidden" + ) + arg(:contacts, list_of(:contact), default_value: [], description: "The events contacts") arg(:language, :string, description: "The event language", default_value: "und") @@ -507,6 +516,11 @@ defmodule Mobilizon.GraphQL.Schema.EventType do arg(:options, :event_options_input, description: "The event options") arg(:metadata, list_of(:event_metadata_input), description: "The event metadata") arg(:draft, :boolean, description: "Whether or not the event is a draft") + + arg(:hide_number_of_participants, :boolean, + description: "Whether or not the number of participants is hidden" + ) + arg(:contacts, list_of(:contact), default_value: [], description: "The events contacts") arg(:language, :string, description: "The event language", default_value: "und") diff --git a/lib/mobilizon/events/event.ex b/lib/mobilizon/events/event.ex index ff76568ae..c2a1b69c6 100644 --- a/lib/mobilizon/events/event.ex +++ b/lib/mobilizon/events/event.ex @@ -45,6 +45,7 @@ defmodule Mobilizon.Events.Event do title: String.t(), status: atom(), draft: boolean, + hide_number_of_participants: boolean, visibility: atom(), join_options: atom(), external_participation_url: String.t(), @@ -79,6 +80,7 @@ defmodule Mobilizon.Events.Event do :category, :status, :draft, + :hide_number_of_participants, :local, :visibility, :join_options, @@ -105,6 +107,7 @@ defmodule Mobilizon.Events.Event do field(:title, :string) field(:status, EventStatus, default: :confirmed) field(:draft, :boolean, default: false) + field(:hide_number_of_participants, :boolean, default: false) field(:visibility, EventVisibility, default: :public) field(:join_options, JoinOptions, default: :free) field(:external_participation_url, :string) diff --git a/priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs b/priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs new file mode 100644 index 000000000..0d12b8692 --- /dev/null +++ b/priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs @@ -0,0 +1,9 @@ +defmodule Mobilizon.Storage.Repo.Migrations.AddHideNumberOfParticipantsToEvents do + use Ecto.Migration + + def change do + alter table(:events) do + add(:hide_number_of_participants, :boolean, default: false, null: false) + end + end +end diff --git a/src/components/Event/EventActionSection.vue b/src/components/Event/EventActionSection.vue index 5d4cf9cfa..051905426 100644 --- a/src/components/Event/EventActionSection.vue +++ b/src/components/Event/EventActionSection.vue @@ -23,7 +23,10 @@

t.title), onlineAddress: event.onlineAddress, phoneAddress: event.phoneAddress, diff --git a/src/views/Event/EditView.vue b/src/views/Event/EditView.vue index 0f1d15eb2..39283f01e 100644 --- a/src/views/Event/EditView.vue +++ b/src/views/Event/EditView.vue @@ -295,8 +295,15 @@ - {{ - t("Limited number of places") + {{ t("Limited number of places") }} + + + + {{ + t("Hide the number of participants") }} @@ -1091,6 +1098,15 @@ const needsApproval = computed({ }, }); +const hideParticipants = computed({ + get(): boolean { + return event.value?.hideNumberOfParticipants; + }, + set(value: boolean) { + event.value.hideNumberOfParticipants = value; + }, +}); + const checkTitleLength = computed((): Array => { return event.value.title.length > 80 ? ["info", t("The event title will be ellipsed.")] From c61815e2f48970be61bb49ee5366c0786a0cf005 Mon Sep 17 00:00:00 2001 From: Massedil Date: Thu, 15 Feb 2024 18:22:39 +0100 Subject: [PATCH 2/3] Add a register category with radio buttons --- src/views/Event/EditView.vue | 77 ++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 21 deletions(-) diff --git a/src/views/Event/EditView.vue b/src/views/Event/EditView.vue index 39283f01e..d04f43b08 100644 --- a/src/views/Event/EditView.vue +++ b/src/views/Event/EditView.vue @@ -241,19 +241,36 @@ {{ t('Page limited to my group (asks for auth)') }}

--> + +
+

+ {{ t("How to register") }} +

+ +
+ {{ t("I want to manage the registration on Mobilizon") }} +
+ +
+ {{ + t("I want to manage the registration with an external provider") + }} +
- - {{ - t("I want to manage the registration with an external provider") - }} - - - - @@ -287,27 +307,35 @@ {{ t("I want to approve every participation request") }} - - {{ t("Limited number of places") }} - - {{ t("Hide the number of participants") }} -
+ + {{ + t("Limited number of places") + }} + + +
{ return sortBy(eventCategories.value, ["label"]); }); -const externalParticipation = computed({ +const RegisterOption = { + MOBILIZON: "mobilizon", + EXTERNAL: "external", +}; + +const registerOption = computed({ get() { - return event.value?.joinOptions === EventJoinOptions.EXTERNAL; + return event.value?.joinOptions === EventJoinOptions.EXTERNAL + ? RegisterOption.EXTERNAL + : RegisterOption.MOBILIZON; }, set(newValue) { - if (newValue === true) { + if (newValue === RegisterOption.EXTERNAL) { event.value.joinOptions = EventJoinOptions.EXTERNAL; } else { event.value.joinOptions = EventJoinOptions.FREE; From c4805e7d173a3d84ba0d0196c9c38706dc228c7d Mon Sep 17 00:00:00 2001 From: Massedil Date: Thu, 29 Feb 2024 19:07:12 +0100 Subject: [PATCH 3/3] hide_number_of_participants is an EventOptions instead of a new field in Event --- lib/graphql/schema/event.ex | 22 +++++++------------ lib/mobilizon/events/event.ex | 3 --- lib/mobilizon/events/event_options.ex | 3 +++ ..._hide_number_of_participants_to_events.exs | 9 -------- src/components/Event/EventActionSection.vue | 2 +- src/graphql/event.ts | 6 ----- src/graphql/event_options.ts | 1 + src/types/event-options.model.ts | 3 +++ src/types/event.model.ts | 6 ----- src/views/Event/EditView.vue | 4 ++-- 10 files changed, 18 insertions(+), 41 deletions(-) delete mode 100644 priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs diff --git a/lib/graphql/schema/event.ex b/lib/graphql/schema/event.ex index bb5e087c9..e2961794d 100644 --- a/lib/graphql/schema/event.ex +++ b/lib/graphql/schema/event.ex @@ -75,10 +75,6 @@ defmodule Mobilizon.GraphQL.Schema.EventType do field(:draft, :boolean, description: "Whether or not the event is a draft") - field(:hide_number_of_participants, :boolean, - description: "Whether or not the number of participants is hidden" - ) - field(:participant_stats, :participant_stats, description: "Statistics on the event", resolve: &Event.stats_participants/3 @@ -267,6 +263,10 @@ defmodule Mobilizon.GraphQL.Schema.EventType do description: "Whether or not to show the participation price" ) + field(:hide_number_of_participants, :boolean, + description: "Whether or not the number of participants is hidden" + ) + field(:show_start_time, :boolean, description: "Show event start time") field(:show_end_time, :boolean, description: "Show event end time") @@ -320,6 +320,10 @@ defmodule Mobilizon.GraphQL.Schema.EventType do description: "Whether or not to show the participation price" ) + field(:hide_number_of_participants, :boolean, + description: "Whether or not the number of participants is hidden" + ) + field(:show_start_time, :boolean, description: "Show event start time") field(:show_end_time, :boolean, description: "Show event end time") @@ -454,11 +458,6 @@ defmodule Mobilizon.GraphQL.Schema.EventType do description: "Whether or not the event is a draft" ) - arg(:hide_number_of_participants, :boolean, - default_value: false, - description: "Whether or not the number of participants is hidden" - ) - arg(:contacts, list_of(:contact), default_value: [], description: "The events contacts") arg(:language, :string, description: "The event language", default_value: "und") @@ -516,11 +515,6 @@ defmodule Mobilizon.GraphQL.Schema.EventType do arg(:options, :event_options_input, description: "The event options") arg(:metadata, list_of(:event_metadata_input), description: "The event metadata") arg(:draft, :boolean, description: "Whether or not the event is a draft") - - arg(:hide_number_of_participants, :boolean, - description: "Whether or not the number of participants is hidden" - ) - arg(:contacts, list_of(:contact), default_value: [], description: "The events contacts") arg(:language, :string, description: "The event language", default_value: "und") diff --git a/lib/mobilizon/events/event.ex b/lib/mobilizon/events/event.ex index c2a1b69c6..ff76568ae 100644 --- a/lib/mobilizon/events/event.ex +++ b/lib/mobilizon/events/event.ex @@ -45,7 +45,6 @@ defmodule Mobilizon.Events.Event do title: String.t(), status: atom(), draft: boolean, - hide_number_of_participants: boolean, visibility: atom(), join_options: atom(), external_participation_url: String.t(), @@ -80,7 +79,6 @@ defmodule Mobilizon.Events.Event do :category, :status, :draft, - :hide_number_of_participants, :local, :visibility, :join_options, @@ -107,7 +105,6 @@ defmodule Mobilizon.Events.Event do field(:title, :string) field(:status, EventStatus, default: :confirmed) field(:draft, :boolean, default: false) - field(:hide_number_of_participants, :boolean, default: false) field(:visibility, EventVisibility, default: :public) field(:join_options, JoinOptions, default: :free) field(:external_participation_url, :string) diff --git a/lib/mobilizon/events/event_options.ex b/lib/mobilizon/events/event_options.ex index 3a2780b9b..894d33106 100644 --- a/lib/mobilizon/events/event_options.ex +++ b/lib/mobilizon/events/event_options.ex @@ -25,6 +25,7 @@ defmodule Mobilizon.Events.EventOptions do show_participation_price: boolean, offers: [EventOffer.t()], participation_condition: [EventParticipationCondition.t()], + hide_number_of_participants: boolean, show_start_time: boolean, show_end_time: boolean, timezone: String.t() | nil, @@ -41,6 +42,7 @@ defmodule Mobilizon.Events.EventOptions do :program, :comment_moderation, :show_participation_price, + :hide_number_of_participants, :show_start_time, :show_end_time, :timezone, @@ -59,6 +61,7 @@ defmodule Mobilizon.Events.EventOptions do field(:program, :string) field(:comment_moderation, CommentModeration) field(:show_participation_price, :boolean) + field(:hide_number_of_participants, :boolean, default: false) field(:show_start_time, :boolean, default: true) field(:show_end_time, :boolean, default: true) field(:timezone, :string) diff --git a/priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs b/priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs deleted file mode 100644 index 0d12b8692..000000000 --- a/priv/repo/migrations/20240212164455_add_hide_number_of_participants_to_events.exs +++ /dev/null @@ -1,9 +0,0 @@ -defmodule Mobilizon.Storage.Repo.Migrations.AddHideNumberOfParticipantsToEvents do - use Ecto.Migration - - def change do - alter table(:events) do - add(:hide_number_of_participants, :boolean, default: false, null: false) - end - end -end diff --git a/src/components/Event/EventActionSection.vue b/src/components/Event/EventActionSection.vue index 051905426..eb8e3d41b 100644 --- a/src/components/Event/EventActionSection.vue +++ b/src/components/Event/EventActionSection.vue @@ -25,7 +25,7 @@ class="inline-flex gap-2 ml-auto" v-if=" event.joinOptions !== EventJoinOptions.EXTERNAL && - !event.hideNumberOfParticipants + !event.options.hideNumberOfParticipants " > diff --git a/src/graphql/event.ts b/src/graphql/event.ts index 340c8352a..0d7afa535 100644 --- a/src/graphql/event.ts +++ b/src/graphql/event.ts @@ -24,7 +24,6 @@ const FULL_EVENT_FRAGMENT = gql` joinOptions externalParticipationUrl draft - hideNumberOfParticipants language category picture { @@ -206,7 +205,6 @@ export const CREATE_EVENT = gql` $joinOptions: EventJoinOptions $externalParticipationUrl: String $draft: Boolean - $hideNumberOfParticipants: Boolean $tags: [String] $picture: MediaInput $onlineAddress: String @@ -229,7 +227,6 @@ export const CREATE_EVENT = gql` joinOptions: $joinOptions externalParticipationUrl: $externalParticipationUrl draft: $draft - hideNumberOfParticipants: $hideNumberOfParticipants tags: $tags picture: $picture onlineAddress: $onlineAddress @@ -258,7 +255,6 @@ export const EDIT_EVENT = gql` $joinOptions: EventJoinOptions $externalParticipationUrl: String $draft: Boolean - $hideNumberOfParticipants: Boolean $tags: [String] $picture: MediaInput $onlineAddress: String @@ -282,7 +278,6 @@ export const EDIT_EVENT = gql` joinOptions: $joinOptions externalParticipationUrl: $externalParticipationUrl draft: $draft - hideNumberOfParticipants: $hideNumberOfParticipants tags: $tags picture: $picture onlineAddress: $onlineAddress @@ -470,7 +465,6 @@ export const FETCH_GROUP_EVENTS = gql` beginsOn status draft - hideNumberOfParticipants options { ...EventOptions } diff --git a/src/graphql/event_options.ts b/src/graphql/event_options.ts index ca521506b..caf19579f 100644 --- a/src/graphql/event_options.ts +++ b/src/graphql/event_options.ts @@ -6,6 +6,7 @@ export const EVENT_OPTIONS_FRAGMENT = gql` remainingAttendeeCapacity showRemainingAttendeeCapacity anonymousParticipation + hideNumberOfParticipants showStartTime showEndTime timezone diff --git a/src/types/event-options.model.ts b/src/types/event-options.model.ts index 420e21919..cec98a8ef 100644 --- a/src/types/event-options.model.ts +++ b/src/types/event-options.model.ts @@ -24,6 +24,7 @@ export interface IEventOptions { program: string; commentModeration: CommentModeration; showParticipationPrice: boolean; + hideNumberOfParticipants: boolean; showStartTime: boolean; showEndTime: boolean; timezone: string | null; @@ -53,6 +54,8 @@ export class EventOptions implements IEventOptions { showParticipationPrice = false; + hideNumberOfParticipants = false; + showStartTime = true; showEndTime = true; diff --git a/src/types/event.model.ts b/src/types/event.model.ts index 6a26aa08e..77b545e4f 100644 --- a/src/types/event.model.ts +++ b/src/types/event.model.ts @@ -46,7 +46,6 @@ interface IEventEditJSON { joinOptions: EventJoinOptions; externalParticipationUrl: string | null; draft: boolean; - hideNumberOfParticipants: boolean; picture?: IMedia | { mediaId: string } | null; attributedToId: string | null; organizerActorId?: string; @@ -77,7 +76,6 @@ export interface IEvent { joinOptions: EventJoinOptions; externalParticipationUrl: string | null; draft: boolean; - hideNumberOfParticipants: boolean; picture: IMedia | null; @@ -144,8 +142,6 @@ export class EventModel implements IEvent { draft = true; - hideNumberOfParticipants = false; - publishAt = new Date().toISOString(); language = "und"; @@ -211,7 +207,6 @@ export class EventModel implements IEvent { this.joinOptions = hash.joinOptions; this.externalParticipationUrl = hash.externalParticipationUrl; this.draft = hash.draft; - this.hideNumberOfParticipants = hash.hideNumberOfParticipants; this.picture = hash.picture; @@ -264,7 +259,6 @@ export function toEditJSON(event: IEditableEvent): IEventEditJSON { joinOptions: event.joinOptions, externalParticipationUrl: event.externalParticipationUrl, draft: event.draft, - hideNumberOfParticipants: event.hideNumberOfParticipants, tags: event.tags.map((t) => t.title), onlineAddress: event.onlineAddress, phoneAddress: event.phoneAddress, diff --git a/src/views/Event/EditView.vue b/src/views/Event/EditView.vue index d04f43b08..3445928b1 100644 --- a/src/views/Event/EditView.vue +++ b/src/views/Event/EditView.vue @@ -1128,10 +1128,10 @@ const needsApproval = computed({ const hideParticipants = computed({ get(): boolean { - return event.value?.hideNumberOfParticipants; + return event.value?.options.hideNumberOfParticipants; }, set(value: boolean) { - event.value.hideNumberOfParticipants = value; + event.value.options.hideNumberOfParticipants = value; }, });