Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Implement ending blankslate for meetings

Oliver Güntherad55b39627d9
diff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
index 232fd2110bd..ff87c48517b 100644
--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
@@ -46,7 +46,7 @@
item.with_leading_visual_icon(icon: :mail)
end
- if @meeting.start_time.to_date < Time.zone.today
+ if [email protected]_ended? && @meeting.start_time.to_date < Time.zone.today
menu.with_item(
label: t(:label_recurring_meeting_series_end),
href: end_series_dialog_recurring_meeting_path(@meeting),
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index 3620a91a0a8..7518dcad936 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -282,7 +282,7 @@ class RecurringMeetingsController < ApplicationController
@max_count =
if @direction == "past"
@recurring_meeting.scheduled_instances(upcoming: false).count
- elsif @recurring_meeting.ending?
+ elsif @recurring_meeting.will_end?
open = @recurring_meeting.upcoming_instantiated_meetings
@recurring_meeting.remaining_occurrences.count - open.count
end
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index 63a240f725a..927097dcd97 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -97,8 +97,12 @@ class RecurringMeeting < ApplicationRecord
nil
end
- def ending?
- !end_after_never?
+ def will_end?
+ last_occurrence.present?
+ end
+
+ def has_ended?
+ will_end? && last_occurrence < Time.zone.now
end
def human_frequency
@@ -118,7 +122,7 @@ class RecurringMeeting < ApplicationRecord
end
def schedule
- @schedule ||= IceCube::Schedule.new(start_time, end_time: modified_end_date).tap do |s|
+ @schedule ||= IceCube::Schedule.new(start_time, duration: template&.duration).tap do |s|
s.add_recurrence_rule count_rule(frequency_rule)
exclude_non_working_days(s) if frequency_working_days?
end
@@ -144,15 +148,20 @@ class RecurringMeeting < ApplicationRecord
end
def full_schedule_in_words
- if end_after_never?
- I18n.t("recurring_meeting.in_words.never_ending",
+ if has_ended?
+ I18n.t("recurring_meeting.in_words.full_past",
base: base_schedule,
- time: format_time(start_time, include_date: false))
- else
+ time: format_time(start_time, include_date: false),
+ end_date: format_date(last_occurrence))
+ elsif will_end?
I18n.t("recurring_meeting.in_words.full",
base: base_schedule,
time: format_time(start_time, include_date: false),
end_date: format_date(last_occurrence))
+ else
+ I18n.t("recurring_meeting.in_words.never_ending",
+ base: base_schedule,
+ time: format_time(start_time, include_date: false))
end
end
@@ -167,11 +176,13 @@ class RecurringMeeting < ApplicationRecord
end
def first_occurrence
- schedule.first
+ @first_occurrence ||= schedule.first
end
def last_occurrence
- schedule.last
+ return if end_after_never?
+
+ @last_occurrence ||= schedule.last
end
def next_occurrence(from_time: Time.current)
@@ -181,7 +192,7 @@ class RecurringMeeting < ApplicationRecord
def remaining_occurrences
case end_after
when "specific_date"
- schedule.occurrences_between(Time.current, modified_end_date)
+ schedule.occurrences_between(Time.current, end_date.to_time(:utc).end_of_day)
when "iterations"
schedule.remaining_occurrences(Time.current)
end
@@ -218,11 +229,8 @@ class RecurringMeeting < ApplicationRecord
def unset_schedule
@schedule = nil
- end
-
- # Because IceCube is exclusive by default for end_time for a schedule
- def modified_end_date
- @modified_end_date ||= end_date + 1.day
+ @first_occurence = nil
+ @last_occurrence = nil
end
def end_date_constraints
@@ -264,7 +272,7 @@ class RecurringMeeting < ApplicationRecord
def count_rule(rule)
case end_after
when "specific_date"
- rule.until(modified_end_date.to_time(:utc))
+ rule.until((end_date + 1.day).to_time(:utc))
when "iterations"
rule.count(iterations)
else
@@ -273,7 +281,7 @@ class RecurringMeeting < ApplicationRecord
end
def set_defaults
- self.end_date ||= 1.year.from_now
+ self.end_date ||= 1.year.from_now if end_after_specific_date?
end
def remove_jobs
diff --git a/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb b/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb
new file mode 100644
index 00000000000..dc82f85fe84
--- /dev/null
+++ b/modules/meeting/app/views/recurring_meetings/_show_upcoming.html.erb
@@ -0,0 +1,71 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2024 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<% if @recurring_meeting.has_ended? -%>
+ <%= render(Primer::Beta::Blankslate.new(border: true)) do |component|
+ component.with_visual_icon(icon: :book)
+ component.with_heading(tag: :h2).with_content(t("recurring_meeting.ended_blankslate.title"))
+ component.with_description do
+ concat render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { t("recurring_meeting.ended_blankslate.message")}
+ concat render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { t("recurring_meeting.ended_blankslate.action")}
+ end
+ end %>
+<% else -%>
+ <%= render RecurringMeetings::TableHeaderComponent.new(
+ meeting: @recurring_meeting,
+ title: I18n.t("recurring_meeting.open.title"),
+ subtitle: I18n.t("recurring_meeting.open.subtitle")
+ ) %>
+ <%= render RecurringMeetings::TableComponent.new(
+ rows: @meetings,
+ current_project: @project,
+ count: @count,
+ direction: @direction,
+ max_count: @max_count,
+ test_selector: "agenda-opened-table",
+ blankslate_title: I18n.t("recurring_meeting.open.blankslate.title"),
+ blankslate_desc: I18n.t("recurring_meeting.open.blankslate.desc")
+ ) %>
+ <%= render RecurringMeetings::TableHeaderComponent.new(
+ meeting: @recurring_meeting,
+ title: I18n.t("recurring_meeting.planned.title"),
+ subtitle: I18n.t("recurring_meeting.planned.subtitle"),
+ planned: true
+ ) %>
+ <%= render RecurringMeetings::TableComponent.new(
+ rows: @planned_meetings,
+ current_project: @project,
+ count: @count,
+ direction: @direction,
+ max_count: @max_count,
+ test_selector: "planned-table",
+ blankslate_title: I18n.t("recurring_meeting.planned.blankslate.title"),
+ blankslate_desc: I18n.t("recurring_meeting.planned.blankslate.desc")
+ ) %>
+<% end -%>
diff --git a/modules/meeting/app/views/recurring_meetings/show.html.erb b/modules/meeting/app/views/recurring_meetings/show.html.erb
index 23f3078e505..40437599ef9 100644
--- a/modules/meeting/app/views/recurring_meetings/show.html.erb
+++ b/modules/meeting/app/views/recurring_meetings/show.html.erb
@@ -44,36 +44,6 @@ See COPYRIGHT and LICENSE files for more details.
max_count: @max_count
) %>
<% else -%>
- <%= render RecurringMeetings::TableHeaderComponent.new(
- meeting: @recurring_meeting,
- title: I18n.t("recurring_meeting.open.title"),
- subtitle: I18n.t("recurring_meeting.open.subtitle")
- ) %>
- <%= render RecurringMeetings::TableComponent.new(
- rows: @meetings,
- current_project: @project,
- count: @count,
- direction: @direction,
- max_count: @max_count,
- test_selector: "agenda-opened-table",
- blankslate_title: I18n.t("recurring_meeting.open.blankslate.title"),
- blankslate_desc: I18n.t("recurring_meeting.open.blankslate.desc")
- ) %>
- <%= render RecurringMeetings::TableHeaderComponent.new(
- meeting: @recurring_meeting,
- title: I18n.t("recurring_meeting.planned.title"),
- subtitle: I18n.t("recurring_meeting.planned.subtitle"),
- planned: true
- ) %>
- <%= render RecurringMeetings::TableComponent.new(
- rows: @planned_meetings,
- current_project: @project,
- count: @count,
- direction: @direction,
- max_count: @max_count,
- test_selector: "planned-table",
- blankslate_title: I18n.t("recurring_meeting.planned.blankslate.title"),
- blankslate_desc: I18n.t("recurring_meeting.planned.blankslate.desc")
- ) %>
- <% end -%>
+ <%= render partial: "show_upcoming" %>
+ <% end -%>
<% end -%>
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 001336244a1..16f37be02cc 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -239,6 +239,10 @@ en:
empty_text: "Drag items here or create a new one"
recurring_meeting:
+ ended_blankslate:
+ title: "Meeting series ended"
+ message: "This meeting series has come to an end. There are no upcoming meetings. "
+ action: "You can still view past occurrences or edit the meeting series to extend it."
occurrence:
infoline: "This meeting is part of a recurring meeting series."
error_no_next: "There is no next occurrence for this meeting."
@@ -278,6 +282,7 @@ en:
weekly_interval: "Every %{interval} weeks on %{weekday}"
frequency: "%{base} at %{time}"
full: "%{base} at %{time}, ends on %{end_date}"
+ full_past: "%{base} at %{time}, ended on %{end_date}"
never_ending: "%{base} at %{time}"
open:
title: "Open"