FEATURE: Add minimal option to events (#362)
It allows hiding the Going/Not going buttons and invitees status
This commit is contained in:
parent
80122f23e4
commit
188270539f
|
@ -313,6 +313,7 @@ module DiscoursePostEvent
|
|||
reminders: event_params[:reminders],
|
||||
raw_invitees:
|
||||
event_params[:"allowed-groups"] ? event_params[:"allowed-groups"].split(",") : nil,
|
||||
minimal: event_params[:minimal],
|
||||
}
|
||||
|
||||
params[:custom_fields] = {}
|
||||
|
@ -418,4 +419,5 @@ end
|
|||
# reminders :string
|
||||
# recurrence :string
|
||||
# timezone :string
|
||||
# minimal :boolean default(FALSE), not null
|
||||
#
|
||||
|
|
|
@ -26,6 +26,7 @@ module DiscoursePostEvent
|
|||
attributes :is_standalone
|
||||
attributes :reminders
|
||||
attributes :recurrence
|
||||
attributes :minimal
|
||||
|
||||
def can_act_on_discourse_post_event
|
||||
scope.can_act_on_discourse_post_event?(object)
|
||||
|
|
|
@ -187,6 +187,15 @@
|
|||
}}
|
||||
{{/event-field}}
|
||||
|
||||
{{#event-field class="minimal-event" label="discourse_post_event.builder_modal.minimal.label"}}
|
||||
<label class="checkbox-label">
|
||||
<Input @type="checkbox" @checked={{model.eventModel.minimal}} />
|
||||
<span class="message">
|
||||
{{i18n "discourse_post_event.builder_modal.minimal.checkbox_label"}}
|
||||
</span>
|
||||
</label>
|
||||
{{/event-field}}
|
||||
|
||||
{{#if allowedCustomFields.length}}
|
||||
{{#event-field
|
||||
label="discourse_post_event.builder_modal.custom_fields.label"
|
||||
|
|
|
@ -13,8 +13,12 @@ export default createWidget("discourse-post-event-status", {
|
|||
},
|
||||
|
||||
template: hbs`
|
||||
{{attach widget="going-button"}}
|
||||
{{#unless attrs.minimal}}
|
||||
{{attach widget="going-button"}}
|
||||
{{/unless}}
|
||||
{{attach widget="interested-button"}}
|
||||
{{attach widget="not-going-button"}}
|
||||
{{#unless attrs.minimal}}
|
||||
{{attach widget="not-going-button"}}
|
||||
{{/unless}}
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -237,6 +237,7 @@ export default createWidget("discourse-post-event", {
|
|||
widget="discourse-post-event-status"
|
||||
attrs=(hash
|
||||
watchingInvitee=this.state.eventModel.watching_invitee
|
||||
minimal=this.state.eventModel.minimal
|
||||
)
|
||||
}}
|
||||
</section>
|
||||
|
@ -261,13 +262,15 @@ export default createWidget("discourse-post-event", {
|
|||
)
|
||||
}}
|
||||
|
||||
{{#if state.eventModel.should_display_invitees}}
|
||||
<hr />
|
||||
{{#unless state.eventModel.minimal}}
|
||||
{{#if state.eventModel.should_display_invitees}}
|
||||
<hr />
|
||||
|
||||
{{attach widget="discourse-post-event-invitees"
|
||||
attrs=(hash eventModel=state.eventModel)
|
||||
}}
|
||||
{{/if}}
|
||||
{{attach widget="discourse-post-event-invitees"
|
||||
attrs=(hash eventModel=state.eventModel)
|
||||
}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
`,
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ function _attachWidget(api, cooked, eventModel) {
|
|||
let widgetHeight =
|
||||
datesHeight + headerHeight + bordersHeight + separatorsHeight + margins;
|
||||
|
||||
if (eventModel.should_display_invitees) {
|
||||
if (eventModel.should_display_invitees && !eventModel.minimal) {
|
||||
widgetHeight += 110;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ export function buildParams(startsAt, endsAt, eventModel, siteSettings) {
|
|||
params.recurrence = eventModel.recurrence;
|
||||
}
|
||||
|
||||
if (eventModel.minimal) {
|
||||
params.minimal = "true";
|
||||
}
|
||||
|
||||
if (endsAt) {
|
||||
params.end = moment(endsAt).tz(eventTz).format("YYYY-MM-DD HH:mm");
|
||||
}
|
||||
|
|
|
@ -149,7 +149,8 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.radio-label {
|
||||
.radio-label,
|
||||
.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 1em;
|
||||
|
|
|
@ -411,6 +411,9 @@ en:
|
|||
every_weekday: "Every weekday"
|
||||
every_week: "Every week at this weekday"
|
||||
every_two_weeks: "Every two weeks at this weekday"
|
||||
minimal:
|
||||
label: "Minimal event"
|
||||
checkbox_label: "Hide Going/Not going buttons and invitees status"
|
||||
url:
|
||||
label: "URL"
|
||||
placeholder: "Optional"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMinimalOptionToCalendarEvent < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :discourse_post_event_events, :minimal, :boolean
|
||||
end
|
||||
end
|
|
@ -10,6 +10,7 @@ VALID_OPTIONS = [
|
|||
:reminders,
|
||||
:recurrence,
|
||||
:timezone,
|
||||
:minimal,
|
||||
]
|
||||
|
||||
module DiscoursePostEvent
|
||||
|
|
Loading…
Reference in New Issue