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
reenable template toggle functionality
ulfertsc943ae3ed378
diff --git a/app/controllers/projects/templated_controller.rb b/app/controllers/projects/templated_controller.rbnew file mode 100644index 00000000000..3c2a5ae64b5--- /dev/null+++ b/app/controllers/projects/templated_controller.rb@@ -0,0 +1,59 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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.+#++++class Projects::TemplatedController < ApplicationController+ before_action :find_project+ before_action :authorize++ def create+ change_templated_action(true)+ end++ def destroy+ change_templated_action(false)+ end++ private++ def change_templated_action(templated)+ service_call = Projects::UpdateService+ .new(user: current_user,+ model: @project)+ .call(templated: templated)++ if service_call.success?+ flash[:notice] = t(:notice_successful_update)+ redirect_to settings_general_project_path(@project)+ else+ @errors = service_call.errors+ render template: 'project_settings/general'+ end+ end+enddiff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rbindex 4f58d6c060f..0af5263f4e5 100644--- a/app/controllers/projects_controller.rb+++ b/app/controllers/projects_controller.rb@@ -65,7 +65,9 @@ class ProjectsController < ApplicationControllerrender layout: 'no_menu'end- def copy; end+ def copy+ render+ enddef update_identifierservice_call = Projects::UpdateServicediff --git a/app/views/projects/_toolbar.html.erb b/app/views/projects/_toolbar.html.erbindex 820a870c197..1e72290c867 100644--- a/app/views/projects/_toolbar.html.erb+++ b/app/views/projects/_toolbar.html.erb@@ -65,25 +65,22 @@ See COPYRIGHT and LICENSE files for more details.<% end %></li><li class="toolbar-item hidden-for-mobile">- <%= form_for(@project,- html: { class: 'toolbar-item'},- url: project_path(@project),- method: :patch) do |f| %>- <%= f.hidden_field :templated, value: [email protected] %>- <% label = @project.templated ? 'remove_from_templates' : 'make_template' %>- <button class="button" title="<%= t("project.template.#{label}") %>">- <%= op_icon('button--icon icon-duplicate') unless @project.templated %>- <span class="button--text"><%= t("project.template.#{label}") %></span>- </button>- </li>+ <% label = @project.templated ? 'remove_from_templates' : 'make_template' %>+ <%= link_to(templated_project_path(@project),+ method: @project.templated ? :delete : :post,+ title: t("project.template.#{label}"),+ class: 'button') do %>+ <%= op_icon('button--icon icon-duplicate') unless @project.templated %>+ <span class="button--text"><%= t("project.template.#{label}") %></span><% end %>- <li class="toolbar-item">- <%= link_to confirm_destroy_project_path(@project),- class: 'button delete',- title: t(:label_delete_project) do %>- <%= op_icon('button--icon icon-delete') %>- <span class="button--text"><%= t(:button_delete) %></span>- <% end %>- </li>+ </li>+ <li class="toolbar-item">+ <%= link_to confirm_destroy_project_path(@project),+ class: 'button delete',+ title: t(:label_delete_project) do %>+ <%= op_icon('button--icon icon-delete') %>+ <span class="button--text"><%= t(:button_delete) %></span>+ <% end %>+ </li><% end %><% end %>diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex 5fb54b384dd..427eb8065be 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -76,7 +76,8 @@ OpenProject::AccessControl.map do |map|map.permission :edit_project,{projects: %i[custom_fields],- 'project_settings/general': %i[show]+ 'project_settings/general': %i[show],+ 'projects/templated': %i[create destroy]},require: :member,contract_actions: { projects: %i[update] }diff --git a/config/routes.rb b/config/routes.rbindex ba34b2e37f7..0f5f3236bb9 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -175,8 +175,13 @@ OpenProject::Application.routes.draw domatch '/unwatch' => 'watchers#unwatch', via: :deleteend- resources :projects, except: %i[show edit create] do+ resources :projects, except: %i[show edit create update] domember do+ scope module: 'projects' do+ post :templated, controller: 'templated', action: :create+ delete :templated, controller: 'templated', action: :destroy+ end+ProjectSettingsHelper.project_settings_tabs.each do |tab|get "settings/#{tab[:name]}",controller: "project_settings/#{tab[:name]}",@@ -200,8 +205,6 @@ OpenProject::Application.routes.draw doput :unarchivepatch :types- get 'column_sums', controller: 'work_packages'-# Destroy uses a get request to prompt the user before the actual DELETE requestget :destroy_info, as: 'confirm_destroy'enddiff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rbindex 2d7568f830c..9d5b9181979 100644--- a/spec/routing/project_routing_spec.rb+++ b/spec/routing/project_routing_spec.rb@@ -79,6 +79,22 @@ describe ProjectsController, type: :routing doendend+ describe 'templated' do+ it do+ expect(delete('/projects/123/templated'))+ .to route_to(+ controller: 'projects/templated', action: 'destroy', id: '123'+ )+ end++ it do+ expect(post('/projects/123/templated'))+ .to route_to(+ controller: 'projects/templated', action: 'create', id: '123'+ )+ end+ end+describe 'miscellaneous' doit doexpect(put('projects/123/modules')).to route_to(