Skip to content

FEATURE: Add event location/description and "My Events" filter #746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/discourse_post_event/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def filtered_events_params
:include_expired,
:limit,
:before,
:attending_user,
)
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/discourse_post_event/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def self.update_from_raw(post)
original_starts_at: parsed_starts_at,
original_ends_at: parsed_ends_at,
url: event_params[:url],
description: event_params[:description],
location: event_params[:location],
recurrence: event_params[:recurrence],
recurrence_until: parsed_recurrence_until,
timezone: event_params[:timezone],
Expand Down Expand Up @@ -420,6 +422,8 @@ def calculate_next_date
# raw_invitees :string is an Array
# name :string
# url :string(1000)
# description :string(1000)
# location :string(1000)
# custom_fields :jsonb not null
# reminders :string
# recurrence :string
Expand Down
6 changes: 6 additions & 0 deletions app/serializers/discourse_post_event/event_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class EventSerializer < ApplicationSerializer
attributes :timezone
attributes :show_local_time
attributes :url
attributes :description
attributes :location
attributes :watching_invitee
attributes :chat_enabled
attributes :channel
Expand Down Expand Up @@ -135,6 +137,10 @@ def category_id
object.post.topic.category_id
end

def include_url?
object.url.present?
end

def include_recurrence_rule?
object.recurring?
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CookText from "discourse/components/cook-text";

const DiscoursePostEventDescription = <template>
{{#if @description}}
<section class="event__section event-description">
<CookText @rawText={{@description}} />
</section>
{{/if}}
</template>;

export default DiscoursePostEventDescription;
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import routeAction from "discourse/helpers/route-action";
import ChatChannel from "./chat-channel";
import Creator from "./creator";
import Dates from "./dates";
import Description from "./description";
import EventStatus from "./event-status";
import Invitees from "./invitees";
import Location from "./location";
import MoreMenu from "./more-menu";
import Status from "./status";
import Url from "./url";
Expand Down Expand Up @@ -130,16 +132,20 @@ export default class DiscoursePostEvent extends Component {
event=@event
Section=(component InfoSection event=@event)
Url=(component Url url=@event.url)
Description=(component Description description=@event.description)
Location=(component Location location=@event.location)
Dates=(component Dates event=@event)
Invitees=(component Invitees event=@event)
Status=(component Status event=@event)
ChatChannel=(component ChatChannel event=@event)
}}
>
<Url @url={{@event.url}} />
<Dates @event={{@event}} />
<Location @location={{@event.location}} />
<Url @url={{@event.url}} />
<ChatChannel @event={{@event}} />
<Invitees @event={{@event}} />
<Description @description={{@event.description}} />
{{#if @event.canUpdateAttendance}}
<Status @event={{@event}} />
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import CookText from "discourse/components/cook-text";
import icon from "discourse/helpers/d-icon";

const DiscoursePostEventLocation = <template>
{{#if @location}}
<section class="event__section event-location">
{{icon "location-pin"}}

<CookText @rawText={{@location}} />
</section>
{{/if}}
</template>;

export default DiscoursePostEventLocation;
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { hash } from "@ember/helper";
import EmberObject, { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import DropdownMenu from "discourse/components/dropdown-menu";
import concatClass from "discourse/helpers/concat-class";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { downloadCalendar } from "discourse/lib/download-calendar";
import { exportEntity } from "discourse/lib/export-csv";
Expand All @@ -27,6 +29,8 @@ export default class DiscoursePostEventMoreMenu extends Component {
@service siteSettings;
@service store;

@tracked isSavingEvent = false;

get expiredOrClosed() {
return this.args.event.isExpired || this.args.event.isClosed;
}
Expand Down Expand Up @@ -147,6 +151,8 @@ export default class DiscoursePostEventMoreMenu extends Component {
this.dialog.yesNoConfirm({
message: i18n("discourse_post_event.builder_modal.confirm_open"),
didConfirm: async () => {
this.isSavingEvent = true;

try {
const post = await this.store.find("post", this.args.event.id);
this.args.event.isClosed = false;
Expand All @@ -172,6 +178,8 @@ export default class DiscoursePostEventMoreMenu extends Component {
}
} catch (e) {
popupAjaxError(e);
} finally {
this.isSavingEvent = false;
}
},
});
Expand Down Expand Up @@ -208,6 +216,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
this.dialog.yesNoConfirm({
message: i18n("discourse_post_event.builder_modal.confirm_close"),
didConfirm: () => {
this.isSavingEvent = true;
return this.store.find("post", this.args.event.id).then((post) => {
this.args.event.isClosed = true;

Expand All @@ -226,10 +235,14 @@ export default class DiscoursePostEventMoreMenu extends Component {
edit_reason: i18n("discourse_post_event.edit_reason_closed"),
};

return cook(newRaw).then((cooked) => {
props.cooked = cooked.string;
return post.save(props);
});
return cook(newRaw)
.then((cooked) => {
props.cooked = cooked.string;
return post.save(props);
})
.finally(() => {
this.isSavingEvent = false;
});
}
});
},
Expand All @@ -239,7 +252,10 @@ export default class DiscoursePostEventMoreMenu extends Component {
<template>
<DMenu
@identifier="discourse-post-event-more-menu"
@triggerClass="more-dropdown"
@triggerClass={{concatClass
"more-dropdown"
(if this.isSavingEvent "--saving")
}}
@icon="ellipsis"
@onRegisterApi={{this.registerMenuApi}}
>
Expand Down Expand Up @@ -333,6 +349,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
class="btn-transparent"
@label="discourse_post_event.open_event"
@action={{this.openEvent}}
@disabled={{this.isSavingEvent}}
/>
</dropdown.item>
{{else}}
Expand All @@ -351,6 +368,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
@icon="xmark"
@label="discourse_post_event.close_event"
@action={{this.closeEvent}}
@disabled={{this.isSavingEvent}}
class="btn-transparent btn-danger"
/>
</dropdown.item>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Input } from "@ember/component";
import { Input, Textarea } from "@ember/component";
import { concat, fn, get } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
Expand Down Expand Up @@ -110,6 +110,10 @@ export default class PostEventBuilder extends Component {
];
}

get shouldRenderUrl() {
return this.args.model.event.url !== undefined;
}

get availableRecurrences() {
return [
{
Expand Down Expand Up @@ -364,13 +368,39 @@ export default class PostEventBuilder extends Component {
</EventField>

<EventField
@label="discourse_post_event.builder_modal.url.label"
class="url"
@label="discourse_post_event.builder_modal.location.label"
class="location"
>
<Input
@value={{@model.event.url}}
@value={{@model.event.location}}
placeholder={{i18n
"discourse_post_event.builder_modal.location.placeholder"
}}
/>
</EventField>

{{#if this.shouldRenderUrl}}
<EventField
@label="discourse_post_event.builder_modal.url.label"
class="url"
>
<Input
@value={{@model.event.url}}
placeholder={{i18n
"discourse_post_event.builder_modal.url.placeholder"
}}
/>
</EventField>
{{/if}}

<EventField
@label="discourse_post_event.builder_modal.description.label"
class="description"
>
<Textarea
@value={{@model.event.description}}
placeholder={{i18n
"discourse_post_event.builder_modal.url.placeholder"
"discourse_post_event.builder_modal.description.placeholder"
}}
/>
</EventField>
Expand All @@ -383,7 +413,6 @@ export default class PostEventBuilder extends Component {
@value={{@model.event.timezone}}
@onChange={{this.setNewTimezone}}
@none="discourse_post_event.builder_modal.timezone.remove_timezone"
class="input-xxlarge"
/>
</EventField>

Expand Down
Loading