hide_number_of_participants is an EventOptions instead of a new field in Event

This commit is contained in:
Massedil 2024-02-29 19:07:12 +01:00
parent c61815e2f4
commit c4805e7d17
10 changed files with 18 additions and 41 deletions

View File

@ -75,10 +75,6 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
field(:draft, :boolean, description: "Whether or not the event is a draft") 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, field(:participant_stats, :participant_stats,
description: "Statistics on the event", description: "Statistics on the event",
resolve: &Event.stats_participants/3 resolve: &Event.stats_participants/3
@ -267,6 +263,10 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
description: "Whether or not to show the participation price" 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_start_time, :boolean, description: "Show event start time")
field(:show_end_time, :boolean, description: "Show event end 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" 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_start_time, :boolean, description: "Show event start time")
field(:show_end_time, :boolean, description: "Show event end 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" 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(:contacts, list_of(:contact), default_value: [], description: "The events contacts")
arg(:language, :string, description: "The event language", default_value: "und") 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(:options, :event_options_input, description: "The event options")
arg(:metadata, list_of(:event_metadata_input), description: "The event metadata") arg(:metadata, list_of(:event_metadata_input), description: "The event metadata")
arg(:draft, :boolean, description: "Whether or not the event is a draft") 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(:contacts, list_of(:contact), default_value: [], description: "The events contacts")
arg(:language, :string, description: "The event language", default_value: "und") arg(:language, :string, description: "The event language", default_value: "und")

View File

@ -45,7 +45,6 @@ defmodule Mobilizon.Events.Event do
title: String.t(), title: String.t(),
status: atom(), status: atom(),
draft: boolean, draft: boolean,
hide_number_of_participants: boolean,
visibility: atom(), visibility: atom(),
join_options: atom(), join_options: atom(),
external_participation_url: String.t(), external_participation_url: String.t(),
@ -80,7 +79,6 @@ defmodule Mobilizon.Events.Event do
:category, :category,
:status, :status,
:draft, :draft,
:hide_number_of_participants,
:local, :local,
:visibility, :visibility,
:join_options, :join_options,
@ -107,7 +105,6 @@ defmodule Mobilizon.Events.Event do
field(:title, :string) field(:title, :string)
field(:status, EventStatus, default: :confirmed) field(:status, EventStatus, default: :confirmed)
field(:draft, :boolean, default: false) field(:draft, :boolean, default: false)
field(:hide_number_of_participants, :boolean, default: false)
field(:visibility, EventVisibility, default: :public) field(:visibility, EventVisibility, default: :public)
field(:join_options, JoinOptions, default: :free) field(:join_options, JoinOptions, default: :free)
field(:external_participation_url, :string) field(:external_participation_url, :string)

View File

@ -25,6 +25,7 @@ defmodule Mobilizon.Events.EventOptions do
show_participation_price: boolean, show_participation_price: boolean,
offers: [EventOffer.t()], offers: [EventOffer.t()],
participation_condition: [EventParticipationCondition.t()], participation_condition: [EventParticipationCondition.t()],
hide_number_of_participants: boolean,
show_start_time: boolean, show_start_time: boolean,
show_end_time: boolean, show_end_time: boolean,
timezone: String.t() | nil, timezone: String.t() | nil,
@ -41,6 +42,7 @@ defmodule Mobilizon.Events.EventOptions do
:program, :program,
:comment_moderation, :comment_moderation,
:show_participation_price, :show_participation_price,
:hide_number_of_participants,
:show_start_time, :show_start_time,
:show_end_time, :show_end_time,
:timezone, :timezone,
@ -59,6 +61,7 @@ defmodule Mobilizon.Events.EventOptions do
field(:program, :string) field(:program, :string)
field(:comment_moderation, CommentModeration) field(:comment_moderation, CommentModeration)
field(:show_participation_price, :boolean) field(:show_participation_price, :boolean)
field(:hide_number_of_participants, :boolean, default: false)
field(:show_start_time, :boolean, default: true) field(:show_start_time, :boolean, default: true)
field(:show_end_time, :boolean, default: true) field(:show_end_time, :boolean, default: true)
field(:timezone, :string) field(:timezone, :string)

View File

@ -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

View File

@ -25,7 +25,7 @@
class="inline-flex gap-2 ml-auto" class="inline-flex gap-2 ml-auto"
v-if=" v-if="
event.joinOptions !== EventJoinOptions.EXTERNAL && event.joinOptions !== EventJoinOptions.EXTERNAL &&
!event.hideNumberOfParticipants !event.options.hideNumberOfParticipants
" "
> >
<TicketConfirmationOutline /> <TicketConfirmationOutline />

View File

@ -24,7 +24,6 @@ const FULL_EVENT_FRAGMENT = gql`
joinOptions joinOptions
externalParticipationUrl externalParticipationUrl
draft draft
hideNumberOfParticipants
language language
category category
picture { picture {
@ -206,7 +205,6 @@ export const CREATE_EVENT = gql`
$joinOptions: EventJoinOptions $joinOptions: EventJoinOptions
$externalParticipationUrl: String $externalParticipationUrl: String
$draft: Boolean $draft: Boolean
$hideNumberOfParticipants: Boolean
$tags: [String] $tags: [String]
$picture: MediaInput $picture: MediaInput
$onlineAddress: String $onlineAddress: String
@ -229,7 +227,6 @@ export const CREATE_EVENT = gql`
joinOptions: $joinOptions joinOptions: $joinOptions
externalParticipationUrl: $externalParticipationUrl externalParticipationUrl: $externalParticipationUrl
draft: $draft draft: $draft
hideNumberOfParticipants: $hideNumberOfParticipants
tags: $tags tags: $tags
picture: $picture picture: $picture
onlineAddress: $onlineAddress onlineAddress: $onlineAddress
@ -258,7 +255,6 @@ export const EDIT_EVENT = gql`
$joinOptions: EventJoinOptions $joinOptions: EventJoinOptions
$externalParticipationUrl: String $externalParticipationUrl: String
$draft: Boolean $draft: Boolean
$hideNumberOfParticipants: Boolean
$tags: [String] $tags: [String]
$picture: MediaInput $picture: MediaInput
$onlineAddress: String $onlineAddress: String
@ -282,7 +278,6 @@ export const EDIT_EVENT = gql`
joinOptions: $joinOptions joinOptions: $joinOptions
externalParticipationUrl: $externalParticipationUrl externalParticipationUrl: $externalParticipationUrl
draft: $draft draft: $draft
hideNumberOfParticipants: $hideNumberOfParticipants
tags: $tags tags: $tags
picture: $picture picture: $picture
onlineAddress: $onlineAddress onlineAddress: $onlineAddress
@ -470,7 +465,6 @@ export const FETCH_GROUP_EVENTS = gql`
beginsOn beginsOn
status status
draft draft
hideNumberOfParticipants
options { options {
...EventOptions ...EventOptions
} }

View File

@ -6,6 +6,7 @@ export const EVENT_OPTIONS_FRAGMENT = gql`
remainingAttendeeCapacity remainingAttendeeCapacity
showRemainingAttendeeCapacity showRemainingAttendeeCapacity
anonymousParticipation anonymousParticipation
hideNumberOfParticipants
showStartTime showStartTime
showEndTime showEndTime
timezone timezone

View File

@ -24,6 +24,7 @@ export interface IEventOptions {
program: string; program: string;
commentModeration: CommentModeration; commentModeration: CommentModeration;
showParticipationPrice: boolean; showParticipationPrice: boolean;
hideNumberOfParticipants: boolean;
showStartTime: boolean; showStartTime: boolean;
showEndTime: boolean; showEndTime: boolean;
timezone: string | null; timezone: string | null;
@ -53,6 +54,8 @@ export class EventOptions implements IEventOptions {
showParticipationPrice = false; showParticipationPrice = false;
hideNumberOfParticipants = false;
showStartTime = true; showStartTime = true;
showEndTime = true; showEndTime = true;

View File

@ -46,7 +46,6 @@ interface IEventEditJSON {
joinOptions: EventJoinOptions; joinOptions: EventJoinOptions;
externalParticipationUrl: string | null; externalParticipationUrl: string | null;
draft: boolean; draft: boolean;
hideNumberOfParticipants: boolean;
picture?: IMedia | { mediaId: string } | null; picture?: IMedia | { mediaId: string } | null;
attributedToId: string | null; attributedToId: string | null;
organizerActorId?: string; organizerActorId?: string;
@ -77,7 +76,6 @@ export interface IEvent {
joinOptions: EventJoinOptions; joinOptions: EventJoinOptions;
externalParticipationUrl: string | null; externalParticipationUrl: string | null;
draft: boolean; draft: boolean;
hideNumberOfParticipants: boolean;
picture: IMedia | null; picture: IMedia | null;
@ -144,8 +142,6 @@ export class EventModel implements IEvent {
draft = true; draft = true;
hideNumberOfParticipants = false;
publishAt = new Date().toISOString(); publishAt = new Date().toISOString();
language = "und"; language = "und";
@ -211,7 +207,6 @@ export class EventModel implements IEvent {
this.joinOptions = hash.joinOptions; this.joinOptions = hash.joinOptions;
this.externalParticipationUrl = hash.externalParticipationUrl; this.externalParticipationUrl = hash.externalParticipationUrl;
this.draft = hash.draft; this.draft = hash.draft;
this.hideNumberOfParticipants = hash.hideNumberOfParticipants;
this.picture = hash.picture; this.picture = hash.picture;
@ -264,7 +259,6 @@ export function toEditJSON(event: IEditableEvent): IEventEditJSON {
joinOptions: event.joinOptions, joinOptions: event.joinOptions,
externalParticipationUrl: event.externalParticipationUrl, externalParticipationUrl: event.externalParticipationUrl,
draft: event.draft, draft: event.draft,
hideNumberOfParticipants: event.hideNumberOfParticipants,
tags: event.tags.map((t) => t.title), tags: event.tags.map((t) => t.title),
onlineAddress: event.onlineAddress, onlineAddress: event.onlineAddress,
phoneAddress: event.phoneAddress, phoneAddress: event.phoneAddress,

View File

@ -1128,10 +1128,10 @@ const needsApproval = computed({
const hideParticipants = computed({ const hideParticipants = computed({
get(): boolean { get(): boolean {
return event.value?.hideNumberOfParticipants; return event.value?.options.hideNumberOfParticipants;
}, },
set(value: boolean) { set(value: boolean) {
event.value.hideNumberOfParticipants = value; event.value.options.hideNumberOfParticipants = value;
}, },
}); });