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

Move cost types into admin namespace and format ERB files

Klaus Zanders54acaf0d3408
diff --git a/modules/costs/app/controllers/admin/cost_types_controller.rb b/modules/costs/app/controllers/admin/cost_types_controller.rb
new file mode 100644
index 00000000000..a20fc8637d0
--- /dev/null
+++ b/modules/costs/app/controllers/admin/cost_types_controller.rb
@@ -0,0 +1,162 @@
+# frozen_string_literal: true
+
+#-- 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 Admin
+ class CostTypesController < ApplicationController
+ # Allow only admins here
+ before_action :require_admin
+ before_action :find_cost_type, only: %i[edit update set_rate destroy restore]
+ layout "admin"
+ menu_item :cost_types
+
+ helper :sort
+ include SortHelper
+ helper :cost_types
+ include CostTypesHelper
+
+ def index # rubocop:disable Metrics/AbcSize
+ sort_init "name", "asc"
+ sort_columns = { "name" => "#{CostType.table_name}.name",
+ "unit" => "#{CostType.table_name}.unit",
+ "unit_plural" => "#{CostType.table_name}.unit_plural" }
+ sort_update sort_columns
+
+ @cost_types = CostType.order(sort_clause)
+
+ if params[:clear_filter]
+ @fixed_date = Time.zone.today
+ @include_deleted = nil
+ else
+ @fixed_date = begin
+ Date.parse(params[:fixed_date])
+ rescue StandardError
+ Time.zone.today
+ end
+ @include_deleted = params[:include_deleted]
+ end
+
+ render action: "index", layout: !request.xhr?
+ end
+
+ def edit
+ render action: :edit, layout: !request.xhr?
+ end
+
+ def update
+ @cost_type.attributes = permitted_params.cost_type
+
+ if @cost_type.save
+ flash[:notice] = t(:notice_successful_update)
+ redirect_back_or_default(action: "index")
+ else
+ render action: :edit, status: :unprocessable_entity, layout: !request.xhr?
+ end
+ rescue ActiveRecord::StaleObjectError
+ # Optimistic locking exception
+ flash.now[:error] = t(:notice_locking_conflict)
+ end
+
+ def new
+ @cost_type = CostType.new
+
+ @cost_type.rates.build(valid_from: Time.zone.today) if @cost_type.rates.empty?
+
+ render action: :edit, layout: !request.xhr?
+ end
+
+ def create # rubocop:disable Metrics/AbcSize
+ @cost_type = CostType.new(permitted_params.cost_type)
+
+ if @cost_type.save
+ flash[:notice] = t(:notice_successful_update)
+ redirect_back_or_default(action: "index")
+ else
+ @cost_type.rates.build(valid_from: Time.zone.today) if @cost_type.rates.empty?
+ render action: :edit, status: :unprocessable_entity, layout: !request.xhr?
+ end
+ rescue ActiveRecord::StaleObjectError
+ # Optimistic locking exception
+ flash.now[:error] = t(:notice_locking_conflict)
+ end
+
+ def destroy
+ @cost_type.deleted_at = DateTime.now
+ @cost_type.default = false
+
+ if @cost_type.save
+ flash[:notice] = t(:notice_successful_lock)
+
+ redirect_back_or_default(action: "index")
+ end
+ end
+
+ def restore
+ @cost_type.deleted_at = nil
+ @cost_type.default = false
+
+ if @cost_type.save
+ flash[:notice] = t(:notice_successful_restore)
+
+ redirect_back_or_default(action: "index")
+ end
+ end
+
+ def set_rate # rubocop:disable Metrics/AbcSize
+ today = Time.zone.today
+
+ rate = @cost_type.rate_at(today)
+ rate ||= CostRate.new.tap do |cr|
+ cr.cost_type = @cost_type
+ cr.valid_from = today
+ end
+
+ rate.rate = CostRate.parse_number_string_to_number(params[:rate])
+ if rate.save
+ flash[:notice] = t(:notice_successful_update)
+ else
+ # FIXME: Do some real error handling here
+ flash[:error] = t(:notice_something_wrong)
+ end
+ redirect_to action: "index"
+ end
+
+ private
+
+ def find_cost_type
+ @cost_type = CostType.find(params[:id])
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
+ def show_local_breadcrumb
+ false
+ end
+ end
+end
diff --git a/modules/costs/app/controllers/costs_settings_controller.rb b/modules/costs/app/controllers/admin/costs_settings_controller.rb
similarity index 92%
rename from modules/costs/app/controllers/costs_settings_controller.rb
rename to modules/costs/app/controllers/admin/costs_settings_controller.rb
index f6a66fec713..28a71168d4f 100644
--- a/modules/costs/app/controllers/costs_settings_controller.rb
+++ b/modules/costs/app/controllers/admin/costs_settings_controller.rb
@@ -25,7 +25,8 @@
#
# See COPYRIGHT and LICENSE files for more details.
#++
-
-class CostsSettingsController < Admin::SettingsController
- menu_item :costs_settings
+module Admin
+ class CostsSettingsController < SettingsController
+ menu_item :costs_settings
+ end
end
diff --git a/modules/costs/app/controllers/cost_types_controller.rb b/modules/costs/app/controllers/cost_types_controller.rb
deleted file mode 100644
index 099e123d435..00000000000
--- a/modules/costs/app/controllers/cost_types_controller.rb
+++ /dev/null
@@ -1,158 +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.
-#++
-
-class CostTypesController < ApplicationController
- # Allow only admins here
- before_action :require_admin
- before_action :find_cost_type, only: %i[edit update set_rate destroy restore]
- layout "admin"
-
- helper :sort
- include SortHelper
- helper :cost_types
- include CostTypesHelper
-
- def index
- sort_init "name", "asc"
- sort_columns = { "name" => "#{CostType.table_name}.name",
- "unit" => "#{CostType.table_name}.unit",
- "unit_plural" => "#{CostType.table_name}.unit_plural" }
- sort_update sort_columns
-
- @cost_types = CostType.order(sort_clause)
-
- if params[:clear_filter]
- @fixed_date = Date.today
- @include_deleted = nil
- else
- @fixed_date = begin
- Date.parse(params[:fixed_date])
- rescue StandardError
- Date.today
- end
- @include_deleted = params[:include_deleted]
- end
-
- render action: "index", layout: !request.xhr?
- end
-
- def edit
- render action: :edit, layout: !request.xhr?
- end
-
- def update
- @cost_type.attributes = permitted_params.cost_type
-
- if @cost_type.save
- flash[:notice] = t(:notice_successful_update)
- redirect_back_or_default(action: "index")
- else
- render action: :edit, status: :unprocessable_entity, layout: !request.xhr?
- end
- rescue ActiveRecord::StaleObjectError
- # Optimistic locking exception
- flash.now[:error] = t(:notice_locking_conflict)
- end
-
- def new
- @cost_type = CostType.new
-
- @cost_type.rates.build(valid_from: Date.today) if @cost_type.rates.empty?
-
- render action: :edit, layout: !request.xhr?
- end
-
- def create # rubocop:disable Metrics/AbcSize
- @cost_type = CostType.new(permitted_params.cost_type)
-
- if @cost_type.save
- flash[:notice] = t(:notice_successful_update)
- redirect_back_or_default(action: "index")
- else
- @cost_type.rates.build(valid_from: Date.today) if @cost_type.rates.empty?
- render action: :edit, status: :unprocessable_entity, layout: !request.xhr?
- end
- rescue ActiveRecord::StaleObjectError
- # Optimistic locking exception
- flash.now[:error] = t(:notice_locking_conflict)
- end
-
- def destroy
- @cost_type.deleted_at = DateTime.now
- @cost_type.default = false
-
- if @cost_type.save
- flash[:notice] = t(:notice_successful_lock)
-
- redirect_back_or_default(action: "index")
- end
- end
-
- def restore
- @cost_type.deleted_at = nil
- @cost_type.default = false
-
- if @cost_type.save
- flash[:notice] = t(:notice_successful_restore)
-
- redirect_back_or_default(action: "index")
- end
- end
-
- def set_rate
- today = Date.today
-
- rate = @cost_type.rate_at(today)
- rate ||= CostRate.new.tap do |cr|
- cr.cost_type = @cost_type
- cr.valid_from = today
- end
-
- rate.rate = CostRate.parse_number_string_to_number(params[:rate])
- if rate.save
- flash[:notice] = t(:notice_successful_update)
- redirect_to action: "index"
- else
- # FIXME: Do some real error handling here
- flash[:error] = t(:notice_something_wrong)
- redirect_to action: "index"
- end
- end
-
- private
-
- def find_cost_type
- @cost_type = CostType.find(params[:id])
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
- def show_local_breadcrumb
- false
- end
-end
diff --git a/modules/costs/app/views/cost_types/_list.html.erb b/modules/costs/app/views/admin/cost_types/_list.html.erb
similarity index 78%
rename from modules/costs/app/views/cost_types/_list.html.erb
rename to modules/costs/app/views/admin/cost_types/_list.html.erb
index f5c50f77d51..cdb2f86a895 100644
--- a/modules/costs/app/views/cost_types/_list.html.erb
+++ b/modules/costs/app/views/admin/cost_types/_list.html.erb
@@ -46,9 +46,9 @@ See COPYRIGHT and LICENSE files for more details.
</colgroup>
<thead>
<tr>
- <%= sort_header_tag 'name', :caption => CostType.model_name.human %>
- <%= sort_header_tag 'unit', :caption => CostType.human_attribute_name(:unit) %>
- <%= sort_header_tag 'unit_plural', :caption => CostType.human_attribute_name(:unit_plural) %>
+ <%= sort_header_tag "name", caption: CostType.model_name.human %>
+ <%= sort_header_tag "unit", caption: CostType.human_attribute_name(:unit) %>
+ <%= sort_header_tag "unit_plural", caption: CostType.human_attribute_name(:unit_plural) %>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
@@ -82,15 +82,15 @@ See COPYRIGHT and LICENSE files for more details.
<tbody>
<% cost_types.each do |cost_type| %>
<tr>
- <%= content_tag :td, link_to(cost_type.name, {:controller => '/cost_types', :action => 'edit', :id => cost_type}) %>
+ <%= content_tag :td, link_to(cost_type.name, { controller: "/admin/cost_types", action: "edit", id: cost_type }) %>
<%= content_tag :td, cost_type.unit %>
<%= content_tag :td, cost_type.unit_plural %>
- <%= content_tag :td, to_currency_with_empty(cost_type.rate_at(@fixed_date)), :class => "currency", :id => "cost_type_#{cost_type.id}_rate"%>
+ <%= content_tag :td, to_currency_with_empty(cost_type.rate_at(@fixed_date)), class: "currency", id: "cost_type_#{cost_type.id}_rate" %>
<td>
- <%= form_for cost_type, :url => { :controller => '/cost_types', :action => 'set_rate', :id => cost_type }, method: :put, html: { class: 'inline-label' } do |f| %>
+ <%= form_for cost_type, url: { controller: "/admin/cost_types", action: "set_rate", id: cost_type }, method: :put, html: { class: "inline-label" } do |f| %>
<label class="hidden-for-sighted" for="<%= "rate_field_#{cost_type.id}" %>"><%= t(:caption_set_rate) %></label>
<%= content_tag :input,
- '',
+ "",
value: "",
name: :rate,
size: 7,
@@ -102,25 +102,25 @@ See COPYRIGHT and LICENSE files for more details.
</span>
<button type="submit"
class="button submit_cost_type">
- <%= icon_wrapper('icon icon-save', I18n.t(:caption_save_rate)) %>
+ <%= icon_wrapper("icon icon-save", I18n.t(:caption_save_rate)) %>
</button>
<% end %>
</td>
- <%= content_tag :td, cost_type.is_default? ? icon_wrapper('icon icon-checkmark', I18n.t(:general_text_Yes)) : "" %>
+ <%= content_tag :td, cost_type.is_default? ? icon_wrapper("icon icon-checkmark", I18n.t(:general_text_Yes)) : "" %>
<td class="buttons">
- <%= form_for cost_type, url: cost_type_path(cost_type),
+ <%= form_for cost_type, url: admin_cost_type_path(cost_type),
method: :delete,
- html: { id: "delete_cost_type_#{cost_type.id}",
- class: 'delete_cost_type',
- title: t(:button_lock) } do |f| %>
+ html: { id: "delete_cost_type_#{cost_type.id}",
+ class: "delete_cost_type",
+ title: t(:button_lock) } do |f| %>
<button type="submit"
class="button--link submit_cost_type">
- <%= icon_wrapper('icon icon-locked', I18n.t(:button_lock)) %>
+ <%= icon_wrapper("icon icon-locked", I18n.t(:button_lock)) %>
</button>
<% end %>
</td>
</tr>
- <tr style="display:none;" >
+ <tr style="display:none;">
</tr>
<% end %>
</tbody>
diff --git a/modules/costs/app/views/cost_types/_list_deleted.html.erb b/modules/costs/app/views/admin/cost_types/_list_deleted.html.erb
similarity index 85%
rename from modules/costs/app/views/cost_types/_list_deleted.html.erb
rename to modules/costs/app/views/admin/cost_types/_list_deleted.html.erb
index 7b618f93677..f38ff7c72b6 100644
--- a/modules/costs/app/views/cost_types/_list_deleted.html.erb
+++ b/modules/costs/app/views/admin/cost_types/_list_deleted.html.erb
@@ -45,9 +45,9 @@ See COPYRIGHT and LICENSE files for more details.
</colgroup>
<thead>
<tr>
- <%= sort_header_tag("name", :caption => CostType.model_name.human) %>
- <%= sort_header_tag("unit", :caption => CostType.human_attribute_name(:unit)) %>
- <%= sort_header_tag("unit_plural", :caption => CostType.human_attribute_name(:unit_plural)) %>
+ <%= sort_header_tag("name", caption: CostType.model_name.human) %>
+ <%= sort_header_tag("unit", caption: CostType.human_attribute_name(:unit)) %>
+ <%= sort_header_tag("unit_plural", caption: CostType.human_attribute_name(:unit_plural)) %>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
@@ -75,16 +75,16 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_tag :td, cost_type.name %>
<%= content_tag :td, cost_type.unit %>
<%= content_tag :td, cost_type.unit_plural %>
- <%= content_tag :td, to_currency_with_empty(cost_type.rate_at(@fixed_date)), :class => "currency" %>
+ <%= content_tag :td, to_currency_with_empty(cost_type.rate_at(@fixed_date)), class: "currency" %>
<%= content_tag :td, cost_type.deleted_at.to_date %>
<td class="buttons">
- <%= form_for cost_type, url: restore_cost_type_path(cost_type),
+ <%= form_for cost_type, url: restore_admin_cost_type_path(cost_type),
method: :patch,
html: { id: "restore_cost_type_#{cost_type.id}",
- class: 'restore_cost_type' } do |f| %>
+ class: "restore_cost_type" } do |f| %>
<button type="submit"
class="button--link submit_cost_type">
- <%= icon_wrapper('icon icon-unlocked', I18n.t(:button_unlock)) %>
+ <%= icon_wrapper("icon icon-unlocked", I18n.t(:button_unlock)) %>
</button>
<% end %>
</td>
diff --git a/modules/costs/app/views/cost_types/_rate.html.erb b/modules/costs/app/views/admin/cost_types/_rate.html.erb
similarity index 83%
rename from modules/costs/app/views/cost_types/_rate.html.erb
rename to modules/costs/app/views/admin/cost_types/_rate.html.erb
index 91ca6a373f8..2b2c9178921 100644
--- a/modules/costs/app/views/cost_types/_rate.html.erb
+++ b/modules/costs/app/views/admin/cost_types/_rate.html.erb
@@ -30,33 +30,31 @@ See COPYRIGHT and LICENSE files for more details.
<%-
templated ||= false
index ||= "INDEX"
- new_or_existing = rate.new_record? ? 'new' : 'existing'
+ new_or_existing = rate.new_record? ? "new" : "existing"
id_or_index = rate.new_record? ? index : rate.id
prefix = "cost_type[#{new_or_existing}_rate_attributes][]"
id_prefix = "cost_type_#{new_or_existing}_rate_attributes_#{id_or_index}"
@rate = rate
- error_messages = error_messages_for 'rate'
+ error_messages = error_messages_for "rate"
-%>
-
<% unless error_messages.blank? %>
<tr><td colspan="3"><%= error_messages %></td></tr>
<% end %>
<%= fields_for prefix, rate, builder: TabularFormBuilder do |rate_form| %>
<%= content_tag(:tr,
id: id_prefix,
- data: templated ? { 'row-target': 'true' } : {},
- style: templated ? 'display: none;' : ''
- ) do %>
+ data: templated ? { "row-target": "true" } : {},
+ style: templated ? "display: none;" : "") do %>
<td class="-no-ellipsis">
<label class="hidden-for-sighted" for="<%= "#{id_prefix}_valid_from" %>"><%= Rate.human_attribute_name(:valid_from) %></label>
<%= rate_form.date_picker :valid_from,
- index: id_or_index,
- class: 'date costs-date-picker',
- no_field_container: true,
- no_label: true,
- required: templated ? false : true %>
+ index: id_or_index,
+ class: "date costs-date-picker",
+ no_field_container: true,
+ no_label: true,
+ required: templated ? false : true %>
</td>
<td class="currency">
<span class="inline-label">
@@ -79,7 +77,7 @@ See COPYRIGHT and LICENSE files for more details.
<a href="#"
class="delete-row-button no-decoration-on-hover"
data-action="subform#deleteRow">
- <%= op_icon('icon-context icon-delete', title: t(:button_delete)) %>
+ <%= op_icon("icon-context icon-delete", title: t(:button_delete)) %>
</a>
</td>
<% end %>
diff --git a/modules/costs/app/views/cost_types/edit.html.erb b/modules/costs/app/views/admin/cost_types/edit.html.erb
similarity index 67%
rename from modules/costs/app/views/cost_types/edit.html.erb
rename to modules/costs/app/views/admin/cost_types/edit.html.erb
index da0359006e9..a499a89da7b 100644
--- a/modules/costs/app/views/cost_types/edit.html.erb
+++ b/modules/costs/app/views/admin/cost_types/edit.html.erb
@@ -28,36 +28,39 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% if(@cost_type.id) %>
- <% html_title t(:label_cost_type_specific, id: @cost_type.id, name: @cost_type.name) %>
+ <% html_title t(:label_cost_type_specific, id: @cost_type.id, name: @cost_type.name) %>
<% title = @cost_type.name %>
<% else %>
<% html_title t(:label_administration), t(:label_cost_type_plural) %>
- <% title = t(:label_new) + ' ' + I18n.t('activerecord.models.cost_type.one') %>
+ <% title = "#{t(:label_new)} #{I18n.t('activerecord.models.cost_type.one')}" %>
<% end %>
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { title }
- header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
- { href: url_for({ controller: "/admin/settings", action: "show_plugin", id: :costs }), text: t(:project_module_costs) },
- { href: cost_types_path, text: t(:label_cost_type_plural) },
- title])
+ header.with_breadcrumbs([
+ { href: admin_index_path, text: t("label_administration") },
+ { href: url_for({ controller: "/admin/costs_settings", action: "show" }), text: t(:project_module_costs) },
+ { href: admin_cost_types_path, text: t(:label_cost_type_plural) },
+ title
+ ])
end
%>
<%= labelled_tabular_form_for @cost_type,
- data: { controller: 'subform', 'application-target': 'dynamic' } do |f| %>
- <%= error_messages_for 'cost_type' %>
+ url: @cost_type.persisted? ? admin_cost_type_path(@cost_type) : admin_cost_types_path,
+ data: { controller: "subform", "application-target": "dynamic" } do |f| %>
+ <%= error_messages_for "cost_type" %>
<%= back_url_hidden_field_tag %>
<div class="form--field -required">
- <%= f.text_field :name, required: true, container_class: '-wide' %>
+ <%= f.text_field :name, required: true, container_class: "-wide" %>
</div>
<div class="form--field -required">
- <%= f.text_field :unit, required: true, container_class: '-middle' %>
+ <%= f.text_field :unit, required: true, container_class: "-middle" %>
</div>
<div class="form--field -required">
- <%= f.text_field :unit_plural, required: true, container_class: '-middle' %>
+ <%= f.text_field :unit_plural, required: true, container_class: "-middle" %>
</div>
<div class="form--field">
<%= f.check_box :default %>
@@ -97,19 +100,18 @@ See COPYRIGHT and LICENSE files for more details.
</thead>
<tbody id="rates_body" class="subform-container" data-subform-target="table">
<%= render partial: "rate", object: CostRate.new(valid_from: Date.current), locals: { templated: true } %>
- <% @cost_type.rates.sort do |a,b|
- case
- when !a.valid? && !b.valid?
- 0
- when !a.valid?
- -1
- when !b.valid?
- 1
- else
- b.valid_from <=> a.valid_from
- end
- end.each_with_index do |rate, index| %>
- <%= render partial: 'rate', object: rate, locals: {index: index} %>
+ <% @cost_type.rates.sort do |a, b|
+ if !a.valid? && !b.valid?
+ 0
+ elsif !a.valid?
+ -1
+ elsif !b.valid?
+ 1
+ else
+ b.valid_from <=> a.valid_from
+ end
+ end.each_with_index do |rate, index| %>
+ <%= render partial: "rate", object: rate, locals: { index: index } %>
<%- end -%>
</tbody>
</table>
@@ -117,15 +119,15 @@ See COPYRIGHT and LICENSE files for more details.
</div>
</div>
<div class="wp-inline-create-button">
- <label class="hidden-for-sighted" for="add_rate_date" %>"><%= t(:description_date_for_new_rate) %></label>
+ <label class="hidden-for-sighted" for="add_rate_date" <%= t(:description_date_for_new_rate) %>>
<a id="add_rate_date"
href="#"
class="add-row-button wp-inline-create--add-link"
title="<%= t(:button_add_rate) %>"
data-action="subform#addRow">
- <%= op_icon('icon icon-add') %>
+ <%= op_icon("icon icon-add") %>
</a>
</div>
- <%= styled_button_tag t(:button_save), class: '-with-icon icon-checkmark' %>
+ <%= styled_button_tag t(:button_save), class: "-with-icon icon-checkmark" %>
<% end %>
</costs-subform>
diff --git a/modules/costs/app/views/cost_types/index.html.erb b/modules/costs/app/views/admin/cost_types/index.html.erb
similarity index 67%
rename from modules/costs/app/views/cost_types/index.html.erb
rename to modules/costs/app/views/admin/cost_types/index.html.erb
index 4e0d119c86e..6770c674650 100644
--- a/modules/costs/app/views/cost_types/index.html.erb
+++ b/modules/costs/app/views/admin/cost_types/index.html.erb
@@ -32,48 +32,49 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { I18n.t(:label_cost_type_plural) }
- header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
- { href: url_for({ controller: "/admin/settings", action: "show_plugin", id: :costs }), text: t(:project_module_costs) },
- I18n.t(:label_cost_type_plural)])
+ header.with_breadcrumbs([
+ { href: admin_index_path, text: t("label_administration") },
+ { href: url_for({ controller: "/admin/costs_settings", action: "show" }), text: t(:project_module_costs) },
+ I18n.t(:label_cost_type_plural)
+ ])
end
%>
<%= render(Primer::OpenProject::SubHeader.new) do |subheader| %>
<% subheader.with_action_button(scheme: :primary,
- aria: { label: I18n.t(:button_add_cost_type) },
- title: I18n.t(:button_add_cost_type),
- tag: :a,
- href: new_cost_type_path) do |button|
- button.with_leading_visual_icon(icon: :plus)
- CostType.model_name.human
- end %>
+ aria: { label: I18n.t(:button_add_cost_type) },
+ title: I18n.t(:button_add_cost_type),
+ tag: :a,
+ href: new_admin_cost_type_path) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ CostType.model_name.human
+ end %>
<% subheader.with_bottom_pane_component do %>
- <%= styled_form_tag(cost_types_path, { method: :get, id: 'query_form' }) do %>
+ <%= styled_form_tag(cost_types_path, { method: :get, id: "query_form" }) do %>
<fieldset id="filters" class="simple-filters--container">
<legend><%= t(:label_filter_plural) %></legend>
<ul class="simple-filters--filters">
<li class="simple-filters--filter">
- <%= styled_label_tag :fixed_date, t(:'attributes.fixed_date'), class: 'simple-filters--filter-name' %>
+ <%= styled_label_tag :fixed_date, t(:"attributes.fixed_date"), class: "simple-filters--filter-name" %>
<div class='simple-filters--filter-value'>
- <%= angular_component_tag 'opce-basic-single-date-picker',
+ <%= angular_component_tag "opce-basic-single-date-picker",
inputs: {
value: @fixed_date,
id: :start_date,
name: :fixed_date
- }
- %>
+ } %>
</div>
</li>
<li class="simple-filters--filter">
- <%= styled_label_tag :include_deleted, t(:caption_show_locked), class: 'simple-filters--filter-name -small' %>
+ <%= styled_label_tag :include_deleted, t(:caption_show_locked), class: "simple-filters--filter-name -small" %>
<div class="simple-filters--filter-value">
<%= styled_check_box_tag :include_deleted, "1", @include_deleted, autocomplete: "off" %>
</div>
</li>
<li class="simple-filters--controls">
- <%= submit_tag t(:button_apply), class: 'button -primary -small' %>
- <%= link_to t(:button_clear), cost_types_path, class: 'button -small -with-icon icon-undo' %>
+ <%= submit_tag t(:button_apply), class: "button -primary -small" %>
+ <%= link_to t(:button_clear), cost_types_path, class: "button -small -with-icon icon-undo" %>
</li>
</ul>
</fieldset>
@@ -81,11 +82,11 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>
-<%= render partial: 'list' %>
+<%= render partial: "list" %>
<% if @include_deleted %>
<div class="cost-types--list-deleted">
<h3><%= t(:label_locked_cost_types) %></h3>
- <%= render partial: 'list_deleted' %>
+ <%= render partial: "list_deleted" %>
</div>
<% end %>
diff --git a/modules/costs/app/views/costs_settings/show.html.erb b/modules/costs/app/views/admin/costs_settings/show.html.erb
similarity index 94%
rename from modules/costs/app/views/costs_settings/show.html.erb
rename to modules/costs/app/views/admin/costs_settings/show.html.erb
index 1f4be12f663..7125ea549c4 100644
--- a/modules/costs/app/views/costs_settings/show.html.erb
+++ b/modules/costs/app/views/admin/costs_settings/show.html.erb
@@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= styled_form_tag(
admin_costs_settings_path,
method: :patch,
- class: 'op-costs-admin-settings'
+ class: "op-costs-admin-settings"
) do %>
<section class="form--section">
@@ -63,6 +63,5 @@ See COPYRIGHT and LICENSE files for more details.
<%- end %>
</section>
-
- <%= styled_button_tag t(:button_save), class: '-primary -with-icon icon-checkmark' %>
+ <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>
<% end %>
diff --git a/modules/costs/app/views/costlog/edit.html.erb b/modules/costs/app/views/costlog/edit.html.erb
index 32a26bcab40..fde91db2d0a 100644
--- a/modules/costs/app/views/costlog/edit.html.erb
+++ b/modules/costs/app/views/costlog/edit.html.erb
@@ -30,36 +30,40 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_log_costs) %>
<h2><%= t(:label_log_costs) %></h2>
-<% url = @cost_entry.new_record? ?
- { action: 'create', project_id: @project.id } :
- { action: 'update', id: @cost_entry } %>
-
-<% method = @cost_entry.new_record? ?
- :post :
- :put %>
+<% url = if @cost_entry.new_record?
+ { action: "create", project_id: @project.id }
+ else
+ { action: "update", id: @cost_entry }
+ end %>
+
+<% method = if @cost_entry.new_record?
+ :post
+ else
+ :put
+ end %>
<%= labelled_tabular_form_for @cost_entry, url: url, html: { method: method } do |f| %>
- <%= error_messages_for 'cost_entry' %>
+ <%= error_messages_for "cost_entry" %>
<%= back_url_hidden_field_tag %>
- <%= f.hidden_field :element_id, value: 'cost_entry', class: 'remote-field--input', data: { :'remote-field-key' => 'element_id' } %>
+ <%= f.hidden_field :element_id, value: "cost_entry", class: "remote-field--input", data: { "remote-field-key": "element_id" } %>
<div class="form--field -required">
<%= f.text_field :work_package_id,
size: 6,
required: true,
autofocus: true,
- container_class: '-xslim' %>
+ container_class: "-xslim" %>
<% if @cost_entry.work_package %>
<div class="form--field-instructions">
- <%= h("#{@cost_entry.work_package.to_s}") %>
+ <%= h(@cost_entry.work_package.to_s.to_s) %>
</div>
<% end %>
</div>
<div class="form--field -required">
<%= f.date_picker :spent_on,
required: true,
- data: { :'remote-field-key' => 'fixed_date' } %>
+ data: { "remote-field-key": "fixed_date" } %>
<label for="cost_entry_spent_on" class="hidden-for-sighted"><%= t(:label_date) %> <%= t(:text_hint_date_format) %></label>
</div>
<% if User.current.allowed_in_project? :log_costs, @project %>
@@ -69,7 +73,7 @@ See COPYRIGHT and LICENSE files for more details.
user_collection_for_select_options,
required: true,
prompt: true,
- container_class: '-middle' %>
+ container_class: "-middle" %>
</div>
<% else %>
<%= f.hidden_field :user_id, value: User.current.id %>
@@ -79,11 +83,11 @@ See COPYRIGHT and LICENSE files for more details.
<%= f.select :cost_type_id,
cost_types_collection_for_select_options,
{ prompt: true,
- container_class: '-middle' },
+ container_class: "-middle" },
{
required: true,
- class: 'remote-field--input',
- data: { :'remote-field-key' => 'cost_type_id' }
+ class: "remote-field--input",
+ data: { "remote-field-key": "cost_type_id" }
} %></p>
</div>
<div class="form--field -required">
@@ -92,7 +96,7 @@ See COPYRIGHT and LICENSE files for more details.
value: unitless_currency_number(@cost_entry.units),
size: 6,
required: true,
- container_class: '-slim' %>
+ container_class: "-slim" %>
<% else %>
<% suffix = @cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural %>
<%= f.text_field :units,
@@ -100,10 +104,10 @@ See COPYRIGHT and LICENSE files for more details.
value: unitless_currency_number(@cost_entry.units),
required: true,
suffix: h(suffix),
- suffix_id: 'cost_entry_unit_name',
- class: 'remote-field--input',
- data: { :'remote-field-key' => 'units' },
- container_class: '-slim' %>
+ suffix_id: "cost_entry_unit_name",
+ class: "remote-field--input",
+ data: { "remote-field-key": "units" },
+ container_class: "-slim" %>
<% end %>
</div>
@@ -118,23 +122,22 @@ See COPYRIGHT and LICENSE files for more details.
title="<%= t(:help_click_to_edit) %>">
<%= number_to_currency(@cost_entry.real_costs) %>
</a>
- <%= render partial: '/budgets/items/budget_override_cost_form',
+ <%= render partial: "/budgets/items/budget_override_cost_form",
locals: {
field_name: "cost_entry[overridden_costs]",
- cost_value: unitless_currency_number(@cost_entry.real_costs),
- }
- %>
+ cost_value: unitless_currency_number(@cost_entry.real_costs)
+ } %>
</span>
<% else %>
<span class="form--field-container">
<%= f.text_field :overridden_costs,
- value: @cost_entry.overridden_costs ? unitless_currency_number(@cost_entry.overridden_costs).strip : '',
+ value: @cost_entry.overridden_costs ? unitless_currency_number(@cost_entry.overridden_costs).strip : "",
placeholder: t(:label_example_placeholder, decimal: unitless_currency_number(1000.50)),
no_label: true,
suffix: Setting.costs_currency,
- id: 'cost_entry_cost_value',
- container_class: '-middle',
+ id: "cost_entry_cost_value",
+ container_class: "-middle",
size: 7 %>
</span>
<div class="form--field-instructions">
@@ -144,10 +147,10 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<div class="form--field">
- <%= f.text_field :comments, size: 100, container_class: '-wide' %>
+ <%= f.text_field :comments, size: 100, container_class: "-wide" %>
</div>
- <%= styled_button_tag t(:button_save), class: '-with-icon icon-checkmark' %>
+ <%= styled_button_tag t(:button_save), class: "-with-icon icon-checkmark" %>
<opce-remote-field-updater data-url="<%= url_for(controller: :budgets, action: :update_material_budget_item, project_id: @cost_entry.project) %>"
data-mode="json">
diff --git a/modules/costs/app/views/hourly_rates/_list.html.erb b/modules/costs/app/views/hourly_rates/_list.html.erb
index df54cd6e45c..ed6214e8d94 100644
--- a/modules/costs/app/views/hourly_rates/_list.html.erb
+++ b/modules/costs/app/views/hourly_rates/_list.html.erb
@@ -28,5 +28,5 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% @rates.each_pair do |project, rates| %>
- <%= render :partial => 'hourly_rates/list_project', :locals => { rates: rates, project: project, all_rates: @rates } %>
+ <%= render partial: "hourly_rates/list_project", locals: { rates: rates, project: project, all_rates: @rates } %>
<% end %>
diff --git a/modules/costs/app/views/hourly_rates/_list_default.html.erb b/modules/costs/app/views/hourly_rates/_list_default.html.erb
index 609dc98ecba..58c4c650d07 100644
--- a/modules/costs/app/views/hourly_rates/_list_default.html.erb
+++ b/modules/costs/app/views/hourly_rates/_list_default.html.erb
@@ -28,7 +28,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<div class="user-rate-history-list">
<div class="contextual">
- <%= link_to t(:button_update), edit_hourly_rate_path(@user), :class => 'icon icon-edit', :accesskey => accesskey(:edit) %>
+ <%= link_to t(:button_update), edit_hourly_rate_path(@user), class: "icon icon-edit", accesskey: accesskey(:edit) %>
</div>
<h3><%= User.human_attribute_name(:default_rates) %></h3>
<% if @rates_default.blank? %>
@@ -74,12 +74,12 @@ See COPYRIGHT and LICENSE files for more details.
</tr>
</thead>
<tbody id="rates_body">
- <% current_rate = @user.current_default_rate() %>
+ <% current_rate = @user.current_default_rate %>
<%- @rates_default.each do |rate| -%>
<tr>
<td style="padding-right: 1em;"><%= rate.valid_from %></td>
<td class="currency"><%= number_to_currency(rate.rate) %></td>
- <td><%= rate == current_rate ? icon_wrapper('icon-context icon-checkmark',I18n.t(:general_text_Yes)) : "" %></td>
+ <td><%= rate == current_rate ? icon_wrapper("icon-context icon-checkmark", I18n.t(:general_text_Yes)) : "" %></td>
</tr>
<%- end -%>
</tbody>
diff --git a/modules/costs/app/views/hourly_rates/_list_project.html.erb b/modules/costs/app/views/hourly_rates/_list_project.html.erb
index 4bdd44a8635..5ee89370660 100644
--- a/modules/costs/app/views/hourly_rates/_list_project.html.erb
+++ b/modules/costs/app/views/hourly_rates/_list_project.html.erb
@@ -28,11 +28,11 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%
- rates = @rates unless rates
- project = @project unless project
+ rates ||= @rates
+ project ||= @project
current_rate = if @all_rates
- at_date_in_project_with_ancestors(Date.today, all_rates, project)
+ at_date_in_project_with_ancestors(Time.zone.today, all_rates, project)
else
@user.current_rate(project)
end
@@ -40,10 +40,10 @@ See COPYRIGHT and LICENSE files for more details.
<div class="user-rate-history-list">
<div class="contextual">
<% if project && User.current.allowed_in_project?({:controller => '/hourly_rates', :action => 'edit'}, project) %>
- <%= link_to t(:button_update), {:controller => '/hourly_rates', :action => 'edit', :project_id => project, :id => @user}, :class => 'icon icon-edit', :accesskey => accesskey(:edit) %>
+ <%= link_to t(:button_update), { controller: "/hourly_rates", action: "edit", project_id: project, id: @user }, class: "icon icon-edit", accesskey: accesskey(:edit) %>
<% end %>
</div>
-<h3><%=h project.name %><%= (" - " + number_to_currency(current_rate.rate)) if current_rate %></h3>
+<h3><%= h project.name %><%= " - #{number_to_currency(current_rate.rate)}" if current_rate %></h3>
<% if rates.empty? %>
<%= no_results_box %>
<% else %>
@@ -91,7 +91,7 @@ See COPYRIGHT and LICENSE files for more details.
<tr>
<td style="padding-right: 1em;"><%= rate.valid_from %></td>
<td class="currency"><%= number_to_currency(rate.rate) %></td>
- <td><%= rate == current_rate ? icon_wrapper('icon-context icon-checkmark',I18n.t(:general_text_Yes)) : "" %></td>
+ <td><%= rate == current_rate ? icon_wrapper("icon-context icon-checkmark", I18n.t(:general_text_Yes)) : "" %></td>
</tr>
<%- end -%>
</tbody>
diff --git a/modules/costs/app/views/hourly_rates/_rate.html.erb b/modules/costs/app/views/hourly_rates/_rate.html.erb
index 63f6755b886..ecf991fd6dd 100644
--- a/modules/costs/app/views/hourly_rates/_rate.html.erb
+++ b/modules/costs/app/views/hourly_rates/_rate.html.erb
@@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%-
templated ||= false
index ||= "INDEX"
- new_or_existing = rate.new_record? ? 'new' : 'existing'
+ new_or_existing = rate.new_record? ? "new" : "existing"
id_or_index = rate.new_record? ? index : rate.id
prefix = "user[#{new_or_existing}_rate_attributes][]"
id_prefix = "user_#{new_or_existing}_rate_attributes_#{id_or_index}"
@@ -40,14 +40,13 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_tag(:tr,
class: "subform-row",
id: id_prefix,
- data: templated ? { 'row-target': 'true' } : {},
- style: templated ? 'display: none;' : ''
- ) do %>
+ data: templated ? { "row-target": "true" } : {},
+ style: templated ? "display: none;" : "") do %>
<td>
<label class="hidden-for-sighted" for="<%= "#{id_prefix}_valid_from" %>"><%= Rate.human_attribute_name(:valid_from) %></label>
<%= rate_form.date_picker :valid_from,
index: id_or_index,
- class: 'date costs-date-picker',
+ class: "date costs-date-picker",
no_label: true,
no_field_container: true %>
</td>
@@ -67,7 +66,7 @@ See COPYRIGHT and LICENSE files for more details.
</td>
<td class="buttons">
<a href="#" class="delete-row-button no-decoration-on-hover" data-action="subform#deleteRow">
- <%= op_icon('icon-context icon-delete', title: t(:button_delete)) %>
+ <%= op_icon("icon-context icon-delete", title: t(:button_delete)) %>
</a>
</td>
<% end %>
diff --git a/modules/costs/app/views/hourly_rates/edit.html.erb b/modules/costs/app/views/hourly_rates/edit.html.erb
index 96a630f690c..31d9c009a5e 100644
--- a/modules/costs/app/views/hourly_rates/edit.html.erb
+++ b/modules/costs/app/views/hourly_rates/edit.html.erb
@@ -31,36 +31,35 @@ See COPYRIGHT and LICENSE files for more details.
<%
breadcrumb_items = if @project
- [{href: project_overview_path(@project.identifier), text: @project.name},
- {href: projects_budgets_path(@project.identifier), text: I18n.t(:label_budget_plural)}]
+ [{ href: project_overview_path(@project.identifier), text: @project.name },
+ { href: projects_budgets_path(@project.identifier), text: I18n.t(:label_budget_plural) }]
else
- [{ href: home_path, text: organization_name}]
+ [{ href: home_path, text: organization_name }]
end
%>
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:caption_default_rate_history_for, user: @user.name) }
- header.with_breadcrumbs([*(breadcrumb_items),
+ header.with_breadcrumbs([*breadcrumb_items,
t(:caption_default_rate_history_for, user: @user.name)])
end
%>
-
<%- default_rate = @user.current_default_rate -%>
-<% if default_rate%>
-<p><strong><%= t(:label_current_default_rate) %>:</strong> <%= number_to_currency(default_rate.rate)%></p>
+<% if default_rate %>
+<p><strong><%= t(:label_current_default_rate) %>:</strong> <%= number_to_currency(default_rate.rate) %></p>
<% end %>
<%= labelled_tabular_form_for @user,
- url: {action: 'update', project_id: @project},
- data: { controller: 'subform', 'application-target': 'dynamic' },
+ url: { action: "update", project_id: @project },
+ data: { controller: "subform", "application-target": "dynamic" },
method: :put do |f| %>
<%= back_url_hidden_field_tag %>
- <%= error_messages_for 'user' %>
+ <%= error_messages_for "user" %>
<%- @rates.each do |rate| -%>
<%- @rate = rate -%>
- <%= error_messages_for 'rate' %>
+ <%= error_messages_for "rate" %>
<%- end -%>
<div class="generic-table--container">
<div class="generic-table--results-container">
@@ -96,7 +95,7 @@ See COPYRIGHT and LICENSE files for more details.
<tbody id="rates_body" class="subform-container" data-subform-target="table">
<%= render partial: "hourly_rates/rate", object: HourlyRate.new(valid_from: Date.current), locals: { templated: true } %>
<%- @rates.each_with_index do |rate, index| -%>
- <%= render partial: 'rate', object: rate, locals: {index: index} %>
+ <%= render partial: "rate", object: rate, locals: { index: index } %>
<%- end -%>
</tbody>
</table>
@@ -105,11 +104,11 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<div class="wp-inline-create-button">
<a href="#" class="add-row-button wp-inline-create--add-link" data-action="subform#addRow">
- <%= op_icon('icon icon-add') %>
+ <%= op_icon("icon icon-add") %>
<%= t(:button_add_rate) %>
</a>
</div>
<div class="generic-table--action-buttons">
- <%= styled_button_tag t(:button_save), class: '-with-icon icon-checkmark' %>
+ <%= styled_button_tag t(:button_save), class: "-with-icon icon-checkmark" %>
</div>
<% end %>
diff --git a/modules/costs/app/views/hourly_rates/show.html.erb b/modules/costs/app/views/hourly_rates/show.html.erb
index 58ff0dee390..485beb94358 100644
--- a/modules/costs/app/views/hourly_rates/show.html.erb
+++ b/modules/costs/app/views/hourly_rates/show.html.erb
@@ -31,17 +31,17 @@ See COPYRIGHT and LICENSE files for more details.
<%
breadcrumb_items = if @project
- [{href: project_overview_path(@project.identifier), text: @project.name},
- {href: projects_budgets_path(@project.identifier), text: I18n.t(:label_budget_plural)}]
+ [{ href: project_overview_path(@project.identifier), text: @project.name },
+ { href: projects_budgets_path(@project.identifier), text: I18n.t(:label_budget_plural) }]
else
- [{ href: home_path, text: organization_name}]
+ [{ href: home_path, text: organization_name }]
end
%>
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:caption_default_rate_history_for, user: @user.name) }
- header.with_breadcrumbs([*(breadcrumb_items),
+ header.with_breadcrumbs([*breadcrumb_items,
t(:caption_default_rate_history_for, user: @user.name)])
end
%>
@@ -49,8 +49,8 @@ See COPYRIGHT and LICENSE files for more details.
<% if @project %>
<% html_title t(:caption_rate_history_for, user: @user.name) %>
- <%= render :partial => 'list_project' %>
+ <%= render partial: "list_project" %>
<% else %>
- <%= render :partial => 'list_default' %>
- <%= render :partial => 'list' %>
+ <%= render partial: "list_default" %>
+ <%= render partial: "list" %>
<% end %>
diff --git a/modules/costs/app/views/my/timer/_menu.html.erb b/modules/costs/app/views/my/timer/_menu.html.erb
index 4dbdc7a8944..7ca61540218 100644
--- a/modules/costs/app/views/my/timer/_menu.html.erb
+++ b/modules/costs/app/views/my/timer/_menu.html.erb
@@ -1 +1 @@
-<%= angular_component_tag 'opce-timer-account-menu' %>
+<%= angular_component_tag "opce-timer-account-menu" %>
diff --git a/modules/costs/app/views/my/timer/show.html.erb b/modules/costs/app/views/my/timer/show.html.erb
index e0f1162c35b..f0c511e37ae 100644
--- a/modules/costs/app/views/my/timer/show.html.erb
+++ b/modules/costs/app/views/my/timer/show.html.erb
@@ -3,14 +3,10 @@
class="op-menu--item-action"
data-controller="my--timers"
data-my--timers-start-value="'<%= @timer.created_at %>'"
- data-application-target="dynamic"
- >
+ data-application-target="dynamic">
<span
- data-my--timers-target="elapsedTime"
+ data-my--timers-target="elapsedTime"></span>
- ></span>
-
-
</div>
<% end %>
diff --git a/modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb b/modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
index e551605c032..232505fab8e 100644
--- a/modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
+++ b/modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
@@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details.
.each do |activity| %>
<div class="form--field">
<%= styled_label_tag "time_entry_activities_project_#{activity.id}_active", activity.name %>
- <div class="form--field-container" >
+ <div class="form--field-container">
<%= hidden_field_tag "time_entry_activities_project[][activity_id]",
activity.id %>
<%= styled_check_box_tag "time_entry_activities_project[][active]",
@@ -45,5 +45,5 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<div class="generic-table--action-buttons">
- <%= styled_button_tag t(:button_save), class: '-primary -with-icon icon-checkmark' %>
+ <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>
</div>
diff --git a/modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb b/modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
index e4efde66e1e..4f9d1546028 100644
--- a/modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
+++ b/modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
@@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render Primer::OpenProject::PageHeader.new do |header|
header.with_title { t(:enumeration_activities) }
- header.with_breadcrumbs([{ href: project_overview_path(@project.id), text: @project.name },
+ header.with_breadcrumbs([{ href: project_overview_path(@project.id), text: @project.name },
{ href: project_settings_general_path(@project.id), text: I18n.t(:label_project_settings) },
t(:enumeration_activities)])
end
@@ -40,11 +40,11 @@ See COPYRIGHT and LICENSE files for more details.
<%= labelled_tabular_form_for @project,
url: project_settings_time_entry_activities_path(@project) do %>
- <%= render partial: '/projects/settings/time_entry_activities/activities',
+ <%= render partial: "/projects/settings/time_entry_activities/activities",
locals: { project: @project } %>
<% end %>
- <br/>
+ <br>
<% else %>
- <%= no_results_box custom_title: t('projects.settings.activities.no_results_title_text') %>
+ <%= no_results_box custom_title: t("projects.settings.activities.no_results_title_text") %>
<% end %>
diff --git a/modules/costs/app/views/users/_rates.html.erb b/modules/costs/app/views/users/_rates.html.erb
index 356eae0392c..996e0cc446f 100644
--- a/modules/costs/app/views/users/_rates.html.erb
+++ b/modules/costs/app/views/users/_rates.html.erb
@@ -32,5 +32,5 @@ See COPYRIGHT and LICENSE files for more details.
@rates_default = @rates.delete(nil)
%>
-<%= render :partial => 'hourly_rates/list_default' %>
-<%= render :partial => 'hourly_rates/list' %>
+<%= render partial: "hourly_rates/list_default" %>
+<%= render partial: "hourly_rates/list" %>
diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rb
index bf5540981ee..1b9dc1a5690 100644
--- a/modules/costs/config/routes.rb
+++ b/modules/costs/config/routes.rb
@@ -63,21 +63,23 @@ Rails.application.routes.draw do
resources :cost_entries, controller: "costlog", only: %i[edit update destroy]
- resources :cost_types, only: %i[index new edit update create destroy] do
- member do
- # TODO: check if this can be replaced with update method
- put :set_rate
- patch :restore
- end
- end
+ get "/cost_types", to: redirect("/admin/cost_types")
# TODO: this is a duplicate from a route defined under project/:project_id, check whether we really want to do that
resources :hourly_rates, only: %i[edit update]
- scope :admin do
+ namespace :admin do
+ resources :cost_types, only: %i[index new edit update create destroy] do
+ member do
+ # TODO: check if this can be replaced with update method
+ put :set_rate
+ patch :restore
+ end
+ end
+
resource :costs,
only: %i[show update],
- controller: :costs_settings,
- as: "admin_costs_settings"
+ controller: "costs_settings",
+ as: "costs_settings"
end
end
diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb
index 553062b1338..c196ed508db 100644
--- a/modules/costs/lib/costs/engine.rb
+++ b/modules/costs/lib/costs/engine.rb
@@ -118,7 +118,7 @@ module Costs
# Menu extensions
menu :admin_menu,
:admin_costs,
- { controller: "/costs_settings", action: :show },
+ { controller: "/admin/costs_settings", action: :show },
if: Proc.new { User.current.admin? },
caption: :project_module_costs,
after: :enterprise,
@@ -126,14 +126,14 @@ module Costs
menu :admin_menu,
:costs_settings,
- { controller: "/costs_settings", action: :show },
+ { controller: "/admin/costs_settings", action: :show },
if: Proc.new { User.current.admin? },
caption: :label_setting_plural,
parent: :admin_costs
menu :admin_menu,
:cost_types,
- { controller: "/cost_types", action: "index" },
+ { controller: "/admin/cost_types", action: "index" },
if: ->(*) { User.current.admin? },
parent: :admin_costs,
caption: :label_cost_type_plural