move time entry activities to nested settings

pull/9779/head
ulferts 3 years ago
parent ec7bcabe81
commit 81e45a2a9d
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 37
      app/controllers/project_settings/activities_controller.rb
  2. 4
      app/helpers/project_settings_helper.rb
  3. 70
      app/views/projects/form/_project_attributes.html.erb
  4. 39
      app/views/projects/form/_select_template.html.erb
  5. 6
      config/routes.rb
  6. 7
      modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb
  7. 8
      modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
  8. 6
      modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
  9. 2
      modules/costs/lib/costs/engine.rb
  10. 18
      modules/costs/spec/features/time_entry/activity_spec.rb
  11. 4
      spec/routing/project_settings_routing_spec.rb
  12. 38
      spec/routing/projects/time_entry_activities_spec.rb

@ -1,37 +0,0 @@
#-- 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 ProjectSettings::ActivitiesController < ProjectSettingsController
menu_item :settings_activities
def show
render template: 'project_settings/activities'
end
end

@ -69,8 +69,8 @@ module ProjectSettingsHelper
label: :label_repository
},
{
name: 'activities',
action: { controller: '/project_settings/activities', action: 'show' },
name: 'time_entry_activities',
action: { controller: '/projects/settings/time_entry_activities', action: 'show' },
label: :enumeration_activities
},
{

@ -1,70 +0,0 @@
<%#-- 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.
++#%>
<% all_fields = (render_advanced) ? false : true %>
<%= render partial: "projects/form/attributes/name",
locals: { form: form } %>
<% if project.new_record? && !is_copy %>
<%= render partial: "projects/form/select_template",
locals: { project: project, form: form } %>
<% end %>
<%= render partial: "customizable/form",
locals: { form: form, help_text: { 'attribute-scope': :Project }, all_fields: all_fields, only_required: render_advanced } %>
<% if render_advanced %>
<fieldset id="advanced-project-settings" class="form--fieldset -collapsible collapsed">
<legend class="form--fieldset-legend" title="<%=t(:label_show_hide)%>" >
<a href="#"><%= t(:label_advanced_settings) %></a>
</legend>
<div style="display:none;" class="advanced-settings-inner">
<% end %>
<%= render partial: "projects/form/attributes/parent_id",
locals: { form: form } %>
<%= render partial: "projects/form/attributes/description",
locals: { form: form } %>
<%= render partial: "projects/form/attributes/public",
locals: { form: form } %>
<%= render partial: "projects/form/attributes/status",
locals: { form: form } %>
<% unless all_fields %>
<%= render partial: "customizable/form",
locals: { form: form, help_text: { 'attribute-scope': :Project }, all_fields: false, only_required: false } %>
<% end %>
<% if render_advanced %>
</div>
</fieldset>
<% end %>
<% unless form.object.errors[:identifier].blank? %>
<%= nonced_javascript_tag do %>
jQuery('#advanced-project-settings > .advanced-settings-inner').show();
<% end %>
<% end %>

@ -1,39 +0,0 @@
<%#-- 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.
++#%>
<div class="form--field">
<%= styled_label_tag 'from_template', t('project.template.use_template') %>
<div class="form--field-container">
<%= styled_select_tag :from_template,
options_for_select(project_options_for_templated, @template_project&.id),
id: 'project-select-template',
prompt: "(#{t(:label_none)})",
container_class: '-wide' %>
</div>
</div>

@ -184,7 +184,7 @@ OpenProject::Application.routes.draw do
namespace 'settings' do
ProjectSettingsHelper
.project_settings_tabs
.select { |s| %w[modules general types custom_fields versions categories repository].include?(s[:name]) }
.select { |s| %w[modules general types custom_fields versions categories repository time_entry_activities].include?(s[:name]) }
.each do |tab|
get tab[:name],
controller: tab[:name],
@ -198,7 +198,7 @@ OpenProject::Application.routes.draw do
ProjectSettingsHelper
.project_settings_tabs
.reject { |s| %w[modules general types custom_fields versions categories repository].include?(s[:name]) }
.reject { |s| %w[modules general types custom_fields versions categories repository time_entry_activities].include?(s[:name]) }
.each do |tab|
get "settings/#{tab[:name]}",
controller: "project_settings/#{tab[:name]}",
@ -228,8 +228,6 @@ OpenProject::Application.routes.draw do
get :level_list
end
resource :time_entry_activities, controller: 'projects/time_entry_activities', only: %i[update]
resources :versions, only: %i[new create] do
collection do
put :close_completed

@ -28,15 +28,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++
class Projects::TimeEntryActivitiesController < ApplicationController
before_action :find_project_by_project_id
before_action :authorize
class Projects::Settings::TimeEntryActivitiesController < ProjectSettingsController
menu_item :settings_time_entry_activities
def update
TimeEntryActivitiesProject.upsert_all(update_params, unique_by: %i[project_id activity_id])
flash[:notice] = t(:notice_successful_update)
redirect_to settings_activities_project_path(@project)
redirect_to time_entry_activities_settings_project_path(@project)
end
private

@ -44,8 +44,6 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<% end %>
<% if withControlls == true %>
<div class="generic-table--action-buttons">
<%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>
</div>
<% end %>
<div class="generic-table--action-buttons">
<%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>
</div>

@ -32,10 +32,10 @@ See COPYRIGHT and LICENSE files for more details.
<% if TimeEntryActivity.any? %>
<%= labelled_tabular_form_for @project,
url: project_time_entry_activities_path(@project),
method: :put do %>
url: time_entry_activities_settings_project_path(@project) do %>
<%= render partial: 'projects/form/activities', locals: { project: @project, withControlls: true } %>
<%= render partial: '/projects/settings/time_entry_activities/activities',
locals: { project: @project } %>
<% end %>
<br/>

@ -60,7 +60,7 @@ module Costs
require: :loggedin
permission :manage_project_activities,
{ 'projects/time_entry_activities': %i[update] },
{ 'projects/settings/time_entry_activities': %i[show update] },
require: :member
permission :view_own_hourly_rate, {}
permission :view_hourly_rates, {}

@ -30,6 +30,7 @@ require 'spec_helper'
describe 'Time entry activity', type: :feature do
shared_let(:admin) { FactoryBot.create :admin }
let(:project) { FactoryBot.create(:project) }
before do
login_as(admin)
@ -48,5 +49,22 @@ describe 'Time entry activity', type: :feature do
expect(page)
.to have_content('A new activity')
visit general_settings_project_path(project)
click_on "Time tracking activities"
expect(page)
.to have_field('A new activity', checked: true)
uncheck 'A new activity'
click_on 'Save'
expect(page)
.to have_content "Successful update."
expect(page)
.to have_field('A new activity', checked: false)
end
end

@ -87,9 +87,9 @@ describe ProjectSettingsController, type: :routing do
end
it do
expect(get('/projects/123/settings/activities'))
expect(get('/projects/123/settings/time_entry_activities'))
.to route_to(
controller: 'project_settings/activities', action: 'show', id: '123'
controller: 'projects/settings/time_entry_activities', action: 'show', id: '123'
)
end

@ -1,38 +0,0 @@
#-- 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.
#++
require 'spec_helper'
describe 'project/time_entry_activities routes', type: :routing do
describe 'update' do
it 'links PUT /projects/:project_id/time_entry_activities' do
expect(put('/projects/64/time_entry_activities'))
.to route_to('projects/time_entry_activities#update', project_id: '64')
end
end
end
Loading…
Cancel
Save