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

Use show_more helpers

Oliver Günther8ccb6ea07f7e
diff --git a/modules/meeting/app/components/recurring_meetings/footer_component.html.erb b/modules/meeting/app/components/recurring_meetings/footer_component.html.erb
index 2eea8f375ca..f2ad27c9f2e 100644
--- a/modules/meeting/app/components/recurring_meetings/footer_component.html.erb
+++ b/modules/meeting/app/components/recurring_meetings/footer_component.html.erb
@@ -43,7 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
scheme: :link,
size: :medium,
tag: :a,
- href: polymorphic_path([@project, @meeting], count: @current_count, direction: @direction),
+ href: polymorphic_path([@project, @meeting], limit: next_count, direction: @direction),
data: {
keep_scroll_position_target: "triggerButton"
}
@@ -55,5 +55,3 @@ See COPYRIGHT and LICENSE files for more details.
end
end
%>
-
-
diff --git a/modules/meeting/app/components/recurring_meetings/footer_component.rb b/modules/meeting/app/components/recurring_meetings/footer_component.rb
index f0af96a0ded..8ebe2d976b9 100644
--- a/modules/meeting/app/components/recurring_meetings/footer_component.rb
+++ b/modules/meeting/app/components/recurring_meetings/footer_component.rb
@@ -42,6 +42,10 @@ module RecurringMeetings
@max_count = max_count
end
+ def next_count
+ @current_count + PaginationHelper::SHOW_MORE_DEFAULT_INCREMENT
+ end
+
def label
# If it never ends, don't try to count it
return endless_label if @meeting.end_after_never?
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index e543e0fdd4c..3620a91a0a8 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class RecurringMeetingsController < ApplicationController
- include RecurringMeetingsHelper
include Layout
include PaginationHelper
include OpTurbo::ComponentStream
@@ -21,6 +20,7 @@ class RecurringMeetingsController < ApplicationController
before_action :convert_params, only: %i[create update]
before_action :check_template_completable, only: %i[template_completed]
+ before_action :build_meeting_limits, only: %i[show]
menu_item :meetings
@@ -47,13 +47,6 @@ class RecurringMeetingsController < ApplicationController
def show # rubocop:disable Metrics/AbcSize
@direction = params[:direction]
- @max_count = max_count
- @count =
- if @max_count
- [(params[:count].to_i + 5), @max_count].min
- else
- params[:count].to_i + 5
- end
if @direction == "past"
@meetings = @recurring_meeting.scheduled_instances(upcoming: false).limit(@count)
@@ -285,6 +278,18 @@ class RecurringMeetingsController < ApplicationController
[opened.values.sort_by(&:start_time), planned]
end
+ def build_meeting_limits
+ @max_count =
+ if @direction == "past"
+ @recurring_meeting.scheduled_instances(upcoming: false).count
+ elsif @recurring_meeting.ending?
+ open = @recurring_meeting.upcoming_instantiated_meetings
+ @recurring_meeting.remaining_occurrences.count - open.count
+ end
+
+ @count = [show_more_limit_param, @max_count].compact.min
+ end
+
def scheduled_meeting(start_time)
ScheduledMeeting.new(start_time:, recurring_meeting: @recurring_meeting)
end
diff --git a/modules/meeting/app/helpers/recurring_meetings_helper.rb b/modules/meeting/app/helpers/recurring_meetings_helper.rb
deleted file mode 100644
index a42b7e9df3d..00000000000
--- a/modules/meeting/app/helpers/recurring_meetings_helper.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-#-- 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
- open = @recurring_meeting.upcoming_instantiated_meetings
-
- @recurring_meeting.remaining_occurrences&.count&.- open.count
- end
- end
-end
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index dfe9a93c775..63a240f725a 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -97,6 +97,10 @@ class RecurringMeeting < ApplicationRecord
nil
end
+ def ending?
+ !end_after_never?
+ end
+
def human_frequency
I18n.t("recurring_meeting.frequency.#{frequency}")
end