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; }, });