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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
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.erbindex 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.endendend++ if has_footer?+ component.with_footer(classes: grid_class, color: :muted) do+ footer+ end+ endend%>diff --git a/app/components/op_primer/border_box_table_component.rb b/app/components/op_primer/border_box_table_component.rbindex 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 OpPrimerfalseend+ def has_footer?+ false+ end+def sortable?falseend@@ -133,5 +137,9 @@ module OpPrimerdef blank_iconnilend++ def footer+ raise ArgumentError, "Need to provide footer content"+ endendenddiff --git a/modules/meeting/app/components/recurring_meetings/footer_component.html.erb b/modules/meeting/app/components/recurring_meetings/footer_component.html.erbnew file mode 100644index 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.rbnew file mode 100644index 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+enddiff --git a/modules/meeting/app/components/recurring_meetings/table_component.rb b/modules/meeting/app/components/recurring_meetings/table_component.rbindex 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 RecurringMeetingsclass TableComponent < ::OpPrimer::BorderBoxTableComponent- options :current_project+ options :current_project, :count, :direction, :max_countcolumns :start_time, :relative_time, :last_edited, :status, :create@@ -38,6 +38,22 @@ module RecurringMeetingstrueend+ 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 RecurringMeetingsdef 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+ endendenddiff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rbindex 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 RecurringMeetingsHelperinclude Layoutinclude PaginationHelperinclude 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)+ endrespond_to do |format|format.html do@@ -154,13 +154,13 @@ class RecurringMeetingsController < ApplicationControllerprivate- 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)enddiff --git a/modules/meeting/app/helpers/recurring_meetings_helper.rb b/modules/meeting/app/helpers/recurring_meetings_helper.rbnew file mode 100644index 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+enddiff --git a/modules/meeting/app/views/recurring_meetings/show.html.erb b/modules/meeting/app/views/recurring_meetings/show.html.erbindex 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.ymlindex 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"