|
| 1 | +#-- copyright |
| 2 | +# OpenProject is an open source project management software. |
| 3 | +# Copyright (C) the OpenProject GmbH |
| 4 | +# |
| 5 | +# This program is free software; you can redistribute it and/or |
| 6 | +# modify it under the terms of the GNU General Public License version 3. |
| 7 | +# |
| 8 | +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
| 9 | +# Copyright (C) 2006-2013 Jean-Philippe Lang |
| 10 | +# Copyright (C) 2010-2013 the ChiliProject Team |
| 11 | +# |
| 12 | +# This program is free software; you can redistribute it and/or |
| 13 | +# modify it under the terms of the GNU General Public License |
| 14 | +# as published by the Free Software Foundation; either version 2 |
| 15 | +# of the License, or (at your option) any later version. |
| 16 | +# |
| 17 | +# This program is distributed in the hope that it will be useful, |
| 18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +# GNU General Public License for more details. |
| 21 | +# |
| 22 | +# You should have received a copy of the GNU General Public License |
| 23 | +# along with this program; if not, write to the Free Software |
| 24 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 25 | +# |
| 26 | +# See COPYRIGHT and LICENSE files for more details. |
| 27 | +#++ |
| 28 | + |
| 29 | +module Projects |
| 30 | + module Concerns |
| 31 | + module TableComponent |
| 32 | + module StreamablePaginationLinksConstraints |
| 33 | + # @override optional_pagination_options are passed to the pagination_options |
| 34 | + # which are passed to #pagination_links_full in pagination_helper.rb |
| 35 | + # |
| 36 | + # In Turbo streamable components, we need to be able to specify the url_for(action:) so that links are |
| 37 | + # generated in the context of the component index action, instead of any turbo stream actions performing |
| 38 | + # partial updates on the page. |
| 39 | + # |
| 40 | + # params[:url_for_action] is passed to the pagination_options making it's way down to any pagination links |
| 41 | + # that are generated via link_to which calls url_for which uses the params[:url_for_action] to specify |
| 42 | + # the controller action that link_to should use. |
| 43 | + # |
| 44 | + # data-turbo-action="advance" is added to the pagination links ensure links pushState to the browser |
| 45 | + # |
| 46 | + def optional_pagination_options |
| 47 | + super.tap do |options| |
| 48 | + options[:params] = { action: params[:url_for_action] } if params[:url_for_action] |
| 49 | + options[:turbo_action] = "advance" |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | + end |
| 54 | + end |
| 55 | +end |
0 commit comments