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
Replace form with method attribute
Oliver Günther4c546cd0895c
diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rbindex ff4a4f06395..0b549e71f46 100644--- a/app/controllers/favorites_controller.rb+++ b/app/controllers/favorites_controller.rb@@ -60,7 +60,7 @@ class FavoritesController < ApplicationController@favored.set_favored(user, favored:)respond_to do |format|- format.html { redirect_back(fallback_location: home_url) }+ format.html { redirect_back(fallback_location: home_url, status: 303) }format.json { head :no_content }endenddiff --git a/app/helpers/favorite_helper.rb b/app/helpers/favorite_helper.rbnew file mode 100644index 00000000000..e2a28188ae0--- /dev/null+++ b/app/helpers/favorite_helper.rb@@ -0,0 +1,34 @@+#-- 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.+#++++module FavoriteHelper+ # Call the path helper to create a favorite/unfavorite path+ def build_favorite_path(object, **params)+ favorite_path(object_type: object.model_name.route_key, object_id: object.id, **params)+ end+enddiff --git a/modules/overviews/app/views/overviews/overviews/show.html.erb b/modules/overviews/app/views/overviews/overviews/show.html.erbindex 44d089bccd6..688bcf20b04 100644--- a/modules/overviews/app/views/overviews/overviews/show.html.erb+++ b/modules/overviews/app/views/overviews/overviews/show.html.erb@@ -2,13 +2,9 @@<meta name="sidebar_enabled" data-enabled="<%= @sidebar_enabled %>"><% end -%>-<% favored = @project.favored_by?(User.current) %>+<%=- primer_form_with(- url: favorite_path(object_id: @project.id, object_type: @project.model_name.route_key),- method: favored ? :delete : :post- ) do |_form|- render(Primer::OpenProject::PageHeader.new) do |header|+ render(Primer::OpenProject::PageHeader.new(data: { turbo: true })) do |header|header.with_title(variant: :medium) { t("overviews.label") }header.with_breadcrumbs([@@ -17,17 +13,19 @@])if OpenProject::FeatureDecisions.favorite_projects_active?+ favored = @project.favored_by?(User.current)header.with_action_icon_button(icon: favored ? "star-fill" : "star",mobile_icon: favored ? "star-fill" : "star",size: :medium,- type: :submit,+ tag: :a,+ href: build_favorite_path(@project, format: :html),+ data: { method: favored ? :delete : :post },classes: "op-primer--star-icon",label: favored ? I18n.t(:button_unfavorite) : I18n.t(:button_favorite),aria: { label: favored ? I18n.t(:button_unfavorite) : I18n.t(:button_favorite) },test_selector: 'project-favorite-button')- endendend%>