Skip to content

Commit

Permalink
DEV: merge discourse post event settings to calendar
Browse files Browse the repository at this point in the history
Before, site settings were divided into `discourse calendar` and `discourse events`.

This PR is merging them. Also, translation were moved under `discourse_calendar` key.
  • Loading branch information
lis2 committed Dec 4, 2023
1 parent d27e52e commit e02293d
Show file tree
Hide file tree
Showing 36 changed files with 415 additions and 172 deletions.
12 changes: 9 additions & 3 deletions app/controllers/discourse_post_event/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ def csv_bulk_invite
else
render json:
failed_json.merge(
errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")],
errors: [
I18n.t("discourse_calendar.discourse_post_event.errors.bulk_invite.error"),
],
),
status: 422
end
rescue StandardError
render json:
failed_json.merge(
errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")],
errors: [
I18n.t("discourse_calendar.discourse_post_event.errors.bulk_invite.error"),
],
),
status: 422
end
Expand All @@ -101,7 +105,9 @@ def bulk_invite
rescue StandardError
render json:
failed_json.merge(
errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")],
errors: [
I18n.t("discourse_calendar.discourse_post_event.errors.bulk_invite.error"),
],
),
status: 422
end
Expand Down
22 changes: 16 additions & 6 deletions app/models/discourse_post_event/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def raw_invitees_length
if self.raw_invitees && self.raw_invitees.length > 10
errors.add(
:base,
I18n.t("discourse_post_event.errors.models.event.raw_invitees_length", count: 10),
I18n.t(
"discourse_calendar.discourse_post_event.errors.models.event.raw_invitees_length",
count: 10,
),
)
end
end
Expand All @@ -138,7 +141,9 @@ def raw_invitees_are_groups
if self.raw_invitees && User.select(:id).where(username: self.raw_invitees).limit(1).count > 0
errors.add(
:base,
I18n.t("discourse_post_event.errors.models.event.raw_invitees.only_group"),
I18n.t(
"discourse_calendar.discourse_post_event.errors.models.event.raw_invitees.only_group",
),
)
end
end
Expand All @@ -149,7 +154,9 @@ def ends_before_start
self.original_starts_at >= self.original_ends_at
errors.add(
:base,
I18n.t("discourse_post_event.errors.models.event.ends_at_before_starts_at"),
I18n.t(
"discourse_calendar.discourse_post_event.errors.models.event.ends_at_before_starts_at",
),
)
end
end
Expand All @@ -161,7 +168,10 @@ def allowed_custom_fields
if !allowed_custom_fields.include?(key)
errors.add(
:base,
I18n.t("discourse_post_event.errors.models.event.custom_field_is_invalid", field: key),
I18n.t(
"discourse_calendar.discourse_post_event.errors.models.event.custom_field_is_invalid",
field: key,
),
)
end
end
Expand Down Expand Up @@ -199,9 +209,9 @@ def create_notification!(user, post, predefined_attendance: false)

message =
if predefined_attendance
"discourse_post_event.notifications.invite_user_predefined_attendance_notification"
"discourse_calendar.discourse_post_event.notifications.invite_user_predefined_attendance_notification"
else
"discourse_post_event.notifications.invite_user_notification"
"discourse_calendar.discourse_post_event.notifications.invite_user_notification"
end

attrs = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<DButton
@label="discourse_post_event.bulk_invite_modal.download_sample_csv"
@label="discourse_calendar.discourse_post_event.bulk_invite_modal.download_sample_csv"
@action={{action "downloadSampleCsv"}}
/>
9 changes: 6 additions & 3 deletions assets/javascripts/discourse/components/event-date.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ export default class EventDate extends Component {
}

get timeRemainingContent() {
return I18n.t("discourse_post_event.topic_title.ends_in_duration", {
duration: this.eventEndedAt.from(moment()),
});
return I18n.t(
"discourse_calendar.discourse_post_event.topic_title.ends_in_duration",
{
duration: this.eventEndedAt.from(moment()),
}
);
}

_parsedDate(date) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DModal
@title={{i18n
(concat
"discourse_post_event.builder_modal."
"discourse_calendar.discourse_post_event.builder_modal."
(if @model.event.isNew "create_event_title" "update_event_title")
)
}}
Expand All @@ -23,41 +23,43 @@

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

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

<EventField
@class="timezone"
@label="discourse_post_event.builder_modal.timezone.label"
@label="discourse_calendar.discourse_post_event.builder_modal.timezone.label"
>
<TimezoneInput
@value={{@model.event.timezone}}
@onChange={{this.setNewTimezone}}
@class="input-xxlarge"
@none="discourse_post_event.builder_modal.timezone.remove_timezone"
@none="discourse_calendar.discourse_post_event.builder_modal.timezone.remove_timezone"
/>
</EventField>

<EventField @label="discourse_post_event.builder_modal.status.label">
<EventField
@label="discourse_calendar.discourse_post_event.builder_modal.status.label"
>
<label class="radio-label">
<RadioButton
@name="status"
Expand All @@ -67,11 +69,13 @@
/>
<span class="message">
<span class="title">
{{i18n "discourse_post_event.models.event.status.public.title"}}
{{i18n
"discourse_calendar.discourse_post_event.models.event.status.public.title"
}}
</span>
<span class="description">
{{i18n
"discourse_post_event.models.event.status.public.description"
"discourse_calendar.discourse_post_event.models.event.status.public.description"
}}
</span>
</span>
Expand All @@ -86,12 +90,12 @@
<span class="message">
<span class="title">
{{i18n
"discourse_post_event.models.event.status.private.title"
"discourse_calendar.discourse_post_event.models.event.status.private.title"
}}
</span>
<span class="description">
{{i18n
"discourse_post_event.models.event.status.private.description"
"discourse_calendar.discourse_post_event.models.event.status.private.description"
}}
</span>
</span>
Expand All @@ -106,12 +110,12 @@
<span class="message">
<span class="title">
{{i18n
"discourse_post_event.models.event.status.standalone.title"
"discourse_calendar.discourse_post_event.models.event.status.standalone.title"
}}
</span>
<span class="description">
{{i18n
"discourse_post_event.models.event.status.standalone.description"
"discourse_calendar.discourse_post_event.models.event.status.standalone.description"
}}
</span>
</span>
Expand All @@ -120,7 +124,7 @@

<EventField
@enabled={{eq @model.event.status "private"}}
@label="discourse_post_event.builder_modal.invitees.label"
@label="discourse_calendar.discourse_post_event.builder_modal.invitees.label"
>
<GroupSelector
@fullWidthWrap={{true}}
Expand All @@ -133,7 +137,7 @@

<EventField
@class="reminders"
@label="discourse_post_event.builder_modal.reminders.label"
@label="discourse_calendar.discourse_post_event.builder_modal.reminders.label"
>
<div class="reminders-list">
{{#each @model.event.reminders as |reminder|}}
Expand All @@ -151,7 +155,7 @@
min={{0}}
@value={{reminder.value}}
placeholder={{i18n
"discourse_post_event.builder_modal.name.placeholder"
"discourse_calendar.discourse_post_event.builder_modal.name.placeholder"
}}
/>

Expand Down Expand Up @@ -185,46 +189,46 @@
class="add-reminder"
@disabled={{this.addReminderDisabled}}
@icon="plus"
@label="discourse_post_event.builder_modal.add_reminder"
@label="discourse_calendar.discourse_post_event.builder_modal.add_reminder"
@action={{@model.addReminder}}
/>
</EventField>

<EventField
@class="recurrence"
@label="discourse_post_event.builder_modal.recurrence.label"
@label="discourse_calendar.discourse_post_event.builder_modal.recurrence.label"
>
<ComboBox
@class="available-recurrences"
@value={{@model.event.recurrence}}
@content={{this.availableRecurrences}}
@options={{hash
none="discourse_post_event.builder_modal.recurrence.none"
none="discourse_calendar.discourse_post_event.builder_modal.recurrence.none"
}}
/>
</EventField>

<EventField
@class="minimal-event"
@label="discourse_post_event.builder_modal.minimal.label"
@label="discourse_calendar.discourse_post_event.builder_modal.minimal.label"
>
<label class="checkbox-label">
<Input @type="checkbox" @checked={{@model.event.minimal}} />
<span class="message">
{{i18n
"discourse_post_event.builder_modal.minimal.checkbox_label"
"discourse_calendar.discourse_post_event.builder_modal.minimal.checkbox_label"
}}
</span>
</label>
</EventField>

{{#if this.allowedCustomFields.length}}
<EventField
@label="discourse_post_event.builder_modal.custom_fields.label"
@label="discourse_calendar.discourse_post_event.builder_modal.custom_fields.label"
>
<p class="event-field-description">
{{i18n
"discourse_post_event.builder_modal.custom_fields.description"
"discourse_calendar.discourse_post_event.builder_modal.custom_fields.description"
}}
</p>
{{#each this.allowedCustomFields as |allowedCustomField|}}
Expand All @@ -237,7 +241,7 @@
(get @model.event.custom_fields allowedCustomField)
}}
placeholder={{i18n
"discourse_post_event.builder_modal.custom_fields.placeholder"
"discourse_calendar.discourse_post_event.builder_modal.custom_fields.placeholder"
}}
{{on "input" (fn this.setCustomField allowedCustomField)}}
/>
Expand All @@ -252,15 +256,15 @@
<DButton
@type="button"
class="btn-primary"
@label="discourse_post_event.builder_modal.create"
@label="discourse_calendar.discourse_post_event.builder_modal.create"
@icon="calendar-day"
@action={{this.createEvent}}
/>
{{else}}
<DButton
@type="button"
class="btn-primary"
@label="discourse_post_event.builder_modal.update"
@label="discourse_calendar.discourse_post_event.builder_modal.update"
@icon="calendar-day"
@action={{this.updateEvent}}
/>
Expand Down
Loading

0 comments on commit e02293d

Please sign in to comment.