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(: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")

View File

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

View File

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

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"
v-if="
event.joinOptions !== EventJoinOptions.EXTERNAL &&
!event.hideNumberOfParticipants
!event.options.hideNumberOfParticipants
"
>
<TicketConfirmationOutline />

View File

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

View File

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

View File

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

View File

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

View File

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