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

Add 'show more' footer

Mir Bhatia81eaf30d2c5b
diff --git a/app/components/op_primer/border_box_table_component.html.erb b/app/components/op_primer/border_box_table_component.html.erb
index 4c96232aa95..a026da0f9aa 100644
--- a/app/components/op_primer/border_box_table_component.html.erb
+++ b/app/components/op_primer/border_box_table_component.html.erb
@@ -58,6 +58,12 @@ See COPYRIGHT and LICENSE files for more details.
end
end
end
+
+ if has_footer?
+ component.with_footer(classes: grid_class, color: :muted) do
+ footer
+ end
+ end
end
%>
diff --git a/app/components/op_primer/border_box_table_component.rb b/app/components/op_primer/border_box_table_component.rb
index 9b8dcc8135e..1e116079096 100644
--- a/app/components/op_primer/border_box_table_component.rb
+++ b/app/components/op_primer/border_box_table_component.rb
@@ -106,6 +106,10 @@ module OpPrimer
false
end
+ def has_footer?
+ false
+ end
+
def sortable?
false
end
@@ -133,5 +137,9 @@ module OpPrimer
def blank_icon
nil
end
+
+ def footer
+ raise ArgumentError, "Need to provide footer content"
+ end
end
end
diff --git a/modules/meeting/app/components/recurring_meetings/footer_component.html.erb b/modules/meeting/app/components/recurring_meetings/footer_component.html.erb
new file mode 100644
index 00000000000..9defd037db8
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/footer_component.html.erb
@@ -0,0 +1,56 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 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.
+
+++#%>
+
+<%=
+ component_wrapper do
+ flex_layout(justify_content: :space_between) do |flex|
+ flex.with_column(classes: "ellipsis") do
+ render(Primer::BaseComponent.new(tag: :span, color: :muted)) do
+ concat render(Primer::Beta::Octicon.new(icon: :iterations, mr: 1, ml: 1))
+ concat render(Primer::Beta::Text.new(font_weight: :bold)) { label }
+ end
+ end
+
+ flex.with_column do
+ render(
+ Primer::Beta::Button.new(
+ scheme: :link,
+ size: :medium,
+ tag: :a,
+ href: polymorphic_path([@project, @meeting], count: @current_count, direction: @direction)
+ )
+ ) do |_c|
+ I18n.t(:label_recurring_meeting_show_more)
+ end
+ end
+ end
+ end
+%>
+
+
diff --git a/modules/meeting/app/components/recurring_meetings/footer_component.rb b/modules/meeting/app/components/recurring_meetings/footer_component.rb
new file mode 100644
index 00000000000..a3666e06393
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/footer_component.rb
@@ -0,0 +1,56 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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.
+#++
+
+module RecurringMeetings
+ class FooterComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, project:, count:, direction:, max_count:)
+ super
+
+ @meeting = meeting
+ @project = project
+ @current_count = count
+ @direction = direction
+ @max_count = max_count
+ end
+
+ def label
+ count = @max_count - @current_count
+ label_suffix = count == 1 ? "_singular" : ""
+
+ if @direction == "past"
+ I18n.t("label_recurring_meeting_more_past#{label_suffix}", count:)
+ else
+ I18n.t("label_recurring_meeting_more#{label_suffix}", count:, schedule: @meeting.schedule_in_words)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/recurring_meetings/table_component.rb b/modules/meeting/app/components/recurring_meetings/table_component.rb
index cd446823d14..720bab91af3 100644
--- a/modules/meeting/app/components/recurring_meetings/table_component.rb
+++ b/modules/meeting/app/components/recurring_meetings/table_component.rb
@@ -30,7 +30,7 @@
module RecurringMeetings
class TableComponent < ::OpPrimer::BorderBoxTableComponent
- options :current_project
+ options :current_project, :count, :direction, :max_count
columns :start_time, :relative_time, :last_edited, :status, :create
@@ -38,6 +38,22 @@ module RecurringMeetings
true
end
+ def has_footer? # rubocop:disable Metrics/AbcSize
+ return false unless recurring_meeting
+
+ options[:max_count] - count > 0
+ end
+
+ def footer
+ render RecurringMeetings::FooterComponent.new(
+ meeting: recurring_meeting,
+ project: options[:current_project],
+ direction: options[:direction],
+ max_count: options[:max_count],
+ count:
+ )
+ end
+
def header_args(column)
if column == :title
{ style: "grid-column: span 2" }
@@ -63,5 +79,15 @@ module RecurringMeetings
def columns
@columns ||= headers.map(&:first)
end
+
+ def recurring_meeting
+ return if model.blank?
+
+ @recurring_meeting ||= model.first.recurring_meeting
+ end
+
+ def count
+ @count ||= [options[:count], rows.count].max
+ end
end
end
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index f84f380d548..9d4024032dc 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -1,4 +1,5 @@
class RecurringMeetingsController < ApplicationController
+ include RecurringMeetingsHelper
include Layout
include PaginationHelper
include OpTurbo::ComponentStream
@@ -34,17 +35,16 @@ class RecurringMeetingsController < ApplicationController
@recurring_meeting = RecurringMeeting.new(project: @project)
end
- def show # rubocop:disable Metrics/AbcSize
+ def show
@direction = params[:direction]
- if params[:direction] == "past"
- @meetings = @recurring_meeting
- .scheduled_instances(upcoming: false)
- .page(page_param)
- .per_page(per_page_param)
- else
- @meetings = upcoming_meetings
- @total_count = @recurring_meeting.remaining_occurrences.count - @meetings.count
- end
+ @max_count = max_count
+ @count = [(params[:count].to_i + 5), @max_count].min
+
+ @meetings = if @direction == "past"
+ @recurring_meeting.scheduled_instances(upcoming: false).limit(@count)
+ else
+ upcoming_meetings(count: @count)
+ end
respond_to do |format|
format.html do
@@ -154,13 +154,13 @@ class RecurringMeetingsController < ApplicationController
private
- def upcoming_meetings
+ def upcoming_meetings(count:)
meetings = @recurring_meeting
.scheduled_instances(upcoming: true)
.index_by(&:start_time)
merged = @recurring_meeting
- .scheduled_occurrences(limit: 5)
+ .scheduled_occurrences(limit: count)
.map do |start_time|
meetings.delete(start_time) || scheduled_meeting(start_time)
end
diff --git a/modules/meeting/app/helpers/recurring_meetings_helper.rb b/modules/meeting/app/helpers/recurring_meetings_helper.rb
new file mode 100644
index 00000000000..fb36af0f88d
--- /dev/null
+++ b/modules/meeting/app/helpers/recurring_meetings_helper.rb
@@ -0,0 +1,37 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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.
+#++
+
+module RecurringMeetingsHelper
+ def max_count
+ if @direction == "past"
+ @recurring_meeting.scheduled_instances(upcoming: false).count
+ else
+ @recurring_meeting.remaining_occurrences.count
+ end
+ end
+end
diff --git a/modules/meeting/app/views/recurring_meetings/show.html.erb b/modules/meeting/app/views/recurring_meetings/show.html.erb
index 21fcdc45647..476c3b1dbdd 100644
--- a/modules/meeting/app/views/recurring_meetings/show.html.erb
+++ b/modules/meeting/app/views/recurring_meetings/show.html.erb
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
+
<% html_title t(:label_recurring_meeting_plural) %>
<%= render(RecurringMeetings::ShowPageHeaderComponent.new(project: @project, meeting: @recurring_meeting)) %>
@@ -34,5 +35,5 @@ See COPYRIGHT and LICENSE files for more details.
<% if @recurring_meeting.nil? -%>
<%= no_results_box %>
<% else -%>
- <%= render RecurringMeetings::TableComponent.new(rows: @meetings, current_project: @project) %>
+ <%= render RecurringMeetings::TableComponent.new(rows: @meetings, current_project: @project, count: @count, direction: @direction, max_count: @max_count) %>
<% end -%>
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 437e2daea45..cf7cd35fa90 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -143,6 +143,11 @@ en:
Any meeting information not in the template will be lost.
Do you want to continue?
label_recurring_meeting_restore: "Restore this occurrence"
+ label_recurring_meeting_more: "There are %{count} more scheduled meetings (%{schedule})."
+ label_recurring_meeting_more_singular: "There is %{count} more scheduled meeting (%{schedule})."
+ label_recurring_meeting_more_past: "There are %{count} more past meetings."
+ label_recurring_meeting_more_past_singular: "There is %{count} more past meeting."
+ label_recurring_meeting_show_more: "Show more"
label_recurring_meeting_series_edit: "Edit meeting series"
label_recurring_meeting_series_delete: "Delete meeting series"
label_my_meetings: "My meetings"