mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-28 15:01:26 +08:00
Adds a new admin calendar setting `calendar_upcoming_events_default_view` to control the default view for `/upcoming-events`. ### Details Admins can now set the default Upcoming events view (`Day`, `Week`, `Month`, or `Year`) in `Admin -> Plugins -> Calendar and Events > Settings`. <img width="892" height="218" alt="Calendar and Events - Settings" src="https://github.com/user-attachments/assets/2a737bc4-7efc-4142-be98-9f84bf2ae7c3" /> Source: https://meta.discourse.org/t/add-admin-setting-to-change-default-calendar-view-month-week-year/387389.
22 lines
604 B
Ruby
Vendored
22 lines
604 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
require_dependency "enum_site_setting"
|
|
|
|
class CalendarUpcomingEventsDefaultView < EnumSiteSetting
|
|
def self.valid_value?(val)
|
|
values.any? { |v| v[:value].to_s == val.to_s }
|
|
end
|
|
|
|
def self.values
|
|
@values ||= [
|
|
{ name: "discourse_calendar.toolbar_button.day", value: "day" },
|
|
{ name: "discourse_calendar.toolbar_button.week", value: "week" },
|
|
{ name: "discourse_calendar.toolbar_button.month", value: "month" },
|
|
{ name: "discourse_calendar.toolbar_button.year", value: "year" },
|
|
]
|
|
end
|
|
|
|
def self.translate_names?
|
|
true
|
|
end
|
|
end
|