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
[34257] Allow localized input of overridden costs (#8656)
Oliver Günther73352fe2d491
diff --git a/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts b/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.tsindex 2b0a9e40669..8cb0e3bb06c 100644--- a/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts+++ b/frontend/src/app/modules/common/remote-field-updater/remote-field-updater.component.ts@@ -109,7 +109,13 @@ export class RemoteFieldUpdaterComponent implements OnInit {this.target.html(response);} else {_.each(response, (val:string, selector:string) => {- jQuery('#' + selector).html(val);+ let element = document.getElementById(selector) as HTMLElement|HTMLInputElement;++ if (element instanceof HTMLInputElement) {+ element.value = val;+ } else if (element) {+ element.textContent = val;+ }});}});diff --git a/modules/budgets/app/controllers/budgets_controller.rb b/modules/budgets/app/controllers/budgets_controller.rbindex 99484b8e242..c35c74f69e9 100644--- a/modules/budgets/app/controllers/budgets_controller.rb+++ b/modules/budgets/app/controllers/budgets_controller.rb@@ -51,6 +51,7 @@ class BudgetsController < ApplicationControllerhelper :budgetsinclude BudgetsHelperinclude PaginationHelper+ include ::Costs::NumberHelperdef indexsort_init 'id', 'desc'@@ -234,7 +235,7 @@ class BudgetsController < ApplicationControllerif current_user.allowed_to?(permission, project)response["#{element_id}_costs"] = number_to_currency(costs)- response["#{element_id}_cost_value"] = costs+ response["#{element_id}_cost_value"] = unitless_currency_number(costs)endresponsediff --git a/modules/budgets/app/views/budgets/items/_labor_budget_item.html.erb b/modules/budgets/app/views/budgets/items/_labor_budget_item.html.erbindex d2c7fd7832b..449055c1661 100644--- a/modules/budgets/app/views/budgets/items/_labor_budget_item.html.erb+++ b/modules/budgets/app/views/budgets/items/_labor_budget_item.html.erb@@ -91,7 +91,8 @@ See docs/COPYRIGHT.rdoc for more details.<% cost_value = labor_budget_item.amount || labor_budget_item.calculated_costs(@budget.fixed_date, @budget.project_id) %><%= cost_form.hidden_field :currency, index: id_or_index, value: Setting.plugin_costs['costs_currency'] %><cost-unit-subform obj-id="<%= id_prefix %>"- obj-name="<%= "#{name_prefix}[amount]" %>">+ obj-name="<%= "#{name_prefix}[amount]" %>"+ data-placeholder="<%= t(:label_example_placeholder, decimal: unitless_currency_number(1000.50)) %>" %><a id="<%= "#{id_prefix}_costs" %>" class="costs--edit-planned-costs-btn icon-context icon-edit" title="<%= t(:help_click_to_edit) %>"><% if labor_budget_item.costs_visible_by?(User.current) %><%= cost_form.hidden_field :cost_value, index: id_or_index, value: unitless_currency_number(cost_value) %>diff --git a/modules/budgets/app/views/budgets/items/_material_budget_item.html.erb b/modules/budgets/app/views/budgets/items/_material_budget_item.html.erbindex 99293ed56c2..4109616486a 100644--- a/modules/budgets/app/views/budgets/items/_material_budget_item.html.erb+++ b/modules/budgets/app/views/budgets/items/_material_budget_item.html.erb@@ -95,7 +95,8 @@ See docs/COPYRIGHT.rdoc for more details.<%= cost_form.hidden_field :cost_value, index: id_or_index, value: unitless_currency_number(cost_value) %><cost-unit-subform obj-id="<%= id_prefix %>"- obj-name="<%= "#{name_prefix}[amount]" %>">+ obj-name="<%= "#{name_prefix}[amount]" %>"+ data-placeholder="<%= t(:label_example_placeholder, decimal: unitless_currency_number(1000.50)) %>" %><a id="<%= id_prefix %>_costs" class="costs--edit-planned-costs-btn icon-context icon-edit" role="button" title="<%= t(:help_click_to_edit) %>"><%= number_to_currency(cost_value) %></a>diff --git a/modules/budgets/frontend/module/augment/planned-costs-form.ts b/modules/budgets/frontend/module/augment/planned-costs-form.tsindex 8d0fdfde3cc..78018353a7b 100644--- a/modules/budgets/frontend/module/augment/planned-costs-form.ts+++ b/modules/budgets/frontend/module/augment/planned-costs-form.ts@@ -31,6 +31,7 @@ export class PlannedCostsFormAugment {public obj:JQuery;public objId:string;public objName:string;+ public placeholder:string;static listen() {jQuery(document).on('click', '.costs--edit-planned-costs-btn', (evt) => {@@ -43,6 +44,7 @@ export class PlannedCostsFormAugment {this.objId = this.$element.attr('obj-id')!;this.objName = this.$element.attr('obj-name')!;this.obj = jQuery(`#${this.objId}_costs`) as any;+ this.placeholder = this.$element.data('placeholder');this.makeEditable();}@@ -73,6 +75,7 @@ export class PlannedCostsFormAugment {let currency = this.getCurrency();let value = this.getValue();let name = this.objName;+ let placeholder = this.placeholder;let template = `<section class="form--section" id="${id}_section">@@ -80,7 +83,13 @@ export class PlannedCostsFormAugment {<div class="form--field-container"><div id="${id}_cancel" class="form--field-affix -transparent icon icon-close"></div><div id="${id}_editor" class="form--text-field-container">- <input id="${id}_edit" class="form--text-field" name="${name}" value="${value}" class="currency" type="text" />+ <input id="${id}_edit"+ class="form--text-field"+ name="${name}"+ value="${value}"+ placeholder="${placeholder}"+ class="currency"+ type="text" /></div><div class="form--field-affix" id="${id}_affix">${currency}</div></div>diff --git a/modules/costs/app/controllers/costlog_controller.rb b/modules/costs/app/controllers/costlog_controller.rbindex f05f329c30b..931dcda3eec 100644--- a/modules/costs/app/controllers/costlog_controller.rb+++ b/modules/costs/app/controllers/costlog_controller.rb@@ -163,7 +163,14 @@ class CostlogController < ApplicationController@cost_entry.work_package = @work_package@cost_entry.cost_type = @cost_type- @cost_entry.attributes = permitted_params.cost_entry+ attributes = permitted_params.cost_entry+ attributes[:units] = Rate.parse_number_string_to_number(attributes[:units])++ if attributes.key?(:overridden_costs)+ attributes[:overridden_costs] = Rate.parse_number_string_to_number(attributes[:overridden_costs])+ end++ @cost_entry.attributes = attributesendprivatediff --git a/modules/costs/app/views/costlog/edit.html.erb b/modules/costs/app/views/costlog/edit.html.erbindex 19aa82069d9..9b945b58d6a 100644--- a/modules/costs/app/views/costlog/edit.html.erb+++ b/modules/costs/app/views/costlog/edit.html.erb@@ -31,105 +31,124 @@ See docs/COPYRIGHT.rdoc for more details.<h2><%= t(:label_log_costs) %></h2><% url = @cost_entry.new_record? ?- { action: 'create', project_id: @project.id } :- { action: 'update', id: @cost_entry } %>+ { action: 'create', project_id: @project.id } :+ { action: 'update', id: @cost_entry } %><% method = @cost_entry.new_record? ?- :post :- :put %>+ :post :+ :put %><remote-field-updater data-url="<%= url_for(controller: :budgets, action: :update_material_budget_item, project_id: @cost_entry.project) %>"data-mode="json"></remote-field-updater><%= labelled_tabular_form_for @cost_entry, url: url, html: { method: method } do |f| %>- <%= 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' } %>+ <%= 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' } %>- <div class="form--field -required">- <%= f.text_field :work_package_id,- size: 6,- required: true,- autofocus: true,- container_class: '-xslim' %>-- <% if @cost_entry.work_package %>- <div class="form--field-instructions">- <%= h("#{@cost_entry.work_package.to_s}") %>- </div>- <% end %>- </div>- <div class="form--field -required">- <%= f.text_field :spent_on,- size: 10,- required: true,- class: 'remote-field--input -augmented-datepicker',- data: { :'remote-field-key' =>'fixed_date' },- container_class: '-xslim' %>- <label for="cost_entry_spent_on" class="hidden-for-sighted"><%= l(:label_date) %> <%=l(:text_hint_date_format) %></label>- </div>- <% if User.current.allowed_to? :log_costs, @project %>- <div class="form--field">- <%# Without knowing why `prompt` is in this case responsible for no blank line in the selection options %>- <%= f.select :user_id,- user_collection_for_select_options,+ <div class="form--field -required">+ <%= f.text_field :work_package_id,+ size: 6,required: true,- prompt: true,- container_class: '-middle' %>+ autofocus: true,+ container_class: '-xslim' %>++ <% if @cost_entry.work_package %>+ <div class="form--field-instructions">+ <%= h("#{@cost_entry.work_package.to_s}") %></div>- <% else %>- <%= f.hidden_field :user_id, value: User.current.id %><% end %>- <div class="form--field -required">- <%# see above %>- <%= f.select :cost_type_id,- cost_types_collection_for_select_options,- { prompt: true,- container_class: '-middle' },- {+ </div>+ <div class="form--field -required">+ <%= f.text_field :spent_on,+ size: 10,required: true,- class: 'remote-field--input',- data: { :'remote-field-key' => 'cost_type_id' }- } %></p>- </div>- <div class="form--field -required">- <% if @cost_entry.cost_type.nil? %>- <%= f.text_field :units, size: 6, required: true, container_class: '-slim' %>- <% else %>- <% suffix = @cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural %>- <%= f.text_field :units,- size: 6,- required: true,- suffix: h(suffix),- suffix_id: 'cost_entry_unit_name',- class: 'remote-field--input',- data: { :'remote-field-key' => 'units' },- container_class: '-slim' %>- <% end %>+ class: 'remote-field--input -augmented-datepicker',+ data: { :'remote-field-key' => 'fixed_date' },+ container_class: '-xslim' %>+ <label for="cost_entry_spent_on" class="hidden-for-sighted"><%= l(:label_date) %> <%= l(:text_hint_date_format) %></label>+ </div>+ <% if User.current.allowed_to? :log_costs, @project %>+ <div class="form--field">+ <%# Without knowing why `prompt` is in this case responsible for no blank line in the selection options %>+ <%= f.select :user_id,+ user_collection_for_select_options,+ required: true,+ prompt: true,+ container_class: '-middle' %></div>+ <% else %>+ <%= f.hidden_field :user_id, value: User.current.id %>+ <% end %>+ <div class="form--field -required">+ <%# see above %>+ <%= f.select :cost_type_id,+ cost_types_collection_for_select_options,+ { prompt: true,+ container_class: '-middle' },+ {+ required: true,+ class: 'remote-field--input',+ data: { :'remote-field-key' => 'cost_type_id' }+ } %></p>+ </div>+ <div class="form--field -required">+ <% if @cost_entry.cost_type.nil? %>+ <%= f.text_field :units,+ value: unitless_currency_number(@cost_entry.units),+ size: 6,+ required: true,+ container_class: '-slim' %>+ <% else %>+ <% suffix = @cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural %>+ <%= f.text_field :units,+ size: 6,+ 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' %>+ <% end %>+ </div>+ <cost-unit-subform obj-id="cost_entry"+ obj-name="cost_entry[overridden_costs]"+ data-placeholder="<%= t(:label_example_placeholder, decimal: unitless_currency_number(1000.50)) %>" %><div class="form--field"><label for="cost_entry_costs_edit" class="form--label"><%= CostEntry.human_attribute_name(:costs) %></label><span class="form--field-container">- <cost-unit-subform obj-id="cost_entry"- obj-name="cost_entry[overridden_costs]" %>- <% if User.current.allowed_to? :view_cost_rates, @cost_entry.project %>- <a href="#" id="cost_entry_costs" class="costs--edit-planned-costs-btn icon-context icon-edit" title="<%= t(:help_click_to_edit) %>">+ <%= hidden_field_tag :currency, Setting.plugin_costs['costs_currency'], id: 'cost_entry_currency' %>+ <% if User.current.allowed_to?(:view_cost_rates, @cost_entry.project) %>+ <%= hidden_field_tag :cost_value, unitless_currency_number(@cost_entry.real_costs), id: 'cost_entry_cost_value' %>+ <a href="#"+ id="cost_entry_costs"+ class="costs--edit-planned-costs-btn icon-context icon-edit"+ title="<%= t(:help_click_to_edit) %>"><%= number_to_currency(@cost_entry.real_costs) %></a>+ </span><% else %>- <span id="cost_entry_costs_editor" class="form--text-field-container">- <input class="currency form--text-field" value="<%= number_to_currency(@cost_entry.overridden_costs, unit: "").strip if @cost_entry.overridden_costs %>" size="7" name="cost_entry[overridden_costs]" id="cost_entry_costs_edit"/> <%= Setting.plugin_costs['costs_currency'] %>- </span>- <br /><em><%= t(:help_override_rate) %></em>+ <%= f.text_field :overridden_costs,+ 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.plugin_costs['costs_currency'],+ id: 'cost_entry_cost_value',+ container_class: '-middle',+ size: 7 %>+ </span>+ <div class="form--field-instructions">+ <p><%= t(:help_override_rate) %></p>+ </div><% end %>- </cost-unit-subform>- </span>- </div>+ </div>+ </cost-unit-subform>- <div class="form--field">- <%= f.text_field :comments, size: 100, container_class: '-wide' %>- </div>+ <div class="form--field">+ <%= 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' %><% end %>diff --git a/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.ts b/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.tsdeleted file mode 100644index 9935951dfc9..00000000000--- a/modules/costs/frontend/module/augment/cost-budget-subform.augment.service.ts+++ /dev/null@@ -1,122 +0,0 @@-// -- copyright-// OpenProject is an open source project management software.-// Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.-// ++--import {Injectable} from "@angular/core";-import {HttpClient} from '@angular/common/http';-import {HalResourceNotificationService} from "core-app/modules/hal/services/hal-resource-notification.service";--@Injectable()-export class CostBudgetSubformAugmentService {-- constructor(private halNotification:HalResourceNotificationService,- private http:HttpClient) {- }-- listen() {- jQuery('costs-budget-subform').each((i, match) => {- let el = jQuery(match);-- const container = el.find('.budget-item-container');- const templateEl = el.find('.budget-row-template');- templateEl.detach();- const template = templateEl[0].outerHTML;- let rowIndex = parseInt(el.attr('item-count') as string);-- // Refresh row on changes- el.on('change', '.budget-item-value', (evt) => {- let row = jQuery(evt.target).closest('.cost_entry');- this.refreshRow(el, row.attr('id') as string);- });-- el.on('click', '.delete-budget-item', (evt) => {- evt.preventDefault();- jQuery(evt.target).closest('.cost_entry').remove();- return false;- });-- // Add new row handler- el.find('.budget-add-row').click((evt) => {- evt.preventDefault();- let row = jQuery(template.replace(/INDEX/g, rowIndex.toString()));- row.show();- row.removeClass('budget-row-template');- container.append(row);- rowIndex += 1;- return false;- });- });- }-- /**- * Refreshes the given row after updating values- */- public refreshRow(el:JQuery, row_identifier:string) {- let row = el.find('#' + row_identifier);- let request = this.buildRefreshRequest(row, row_identifier);-- this.http- .post(- el.attr('update-url')!,- request,- {- headers: { 'Accept': 'application/json' },- withCredentials: true- })- .subscribe(- (data:any) => {- _.each(data, (val:string, selector:string) => {- let element = document.getElementById(selector) as HTMLElement|HTMLInputElement|undefined;- if (element instanceof HTMLInputElement) {- element.value = val;- } else if (element) {- element.textContent = val;- }- });- },- (error:any) => this.halNotification.handleRawError(error)- );- }-- /**- * Returns the params for the update request- */- private buildRefreshRequest(row:JQuery, row_identifier:string) {- let request:any = {- element_id: row_identifier,- fixed_date: jQuery('#budget_fixed_date').val()- };-- // Augment common values with specific values for this type- row.find('.budget-item-value').each((_i:number, el:any) => {- let field = jQuery(el);- request[field.data('requestKey')] = field.val() || '0';- });-- return request;- }-}diff --git a/modules/costs/frontend/module/augment/cost-subform.augment.service.ts b/modules/costs/frontend/module/augment/cost-subform.augment.service.tsdeleted file mode 100644index 71564a76512..00000000000--- a/modules/costs/frontend/module/augment/cost-subform.augment.service.ts+++ /dev/null@@ -1,67 +0,0 @@-// -- copyright-// OpenProject is an open source project management software.-// Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.-// ++--import {Injectable} from "@angular/core";--@Injectable()-export class CostSubformAugmentService {-- constructor() {- jQuery('costs-subform').each((i, match) => {- let el = jQuery(match);-- const container = el.find('.subform-container');-- const templateEl = el.find('.subform-row-template');- templateEl.detach();- const template = templateEl[0].outerHTML;- let rowIndex = parseInt(el.attr('item-count')!);-- el.on('click', '.delete-row-button,.delete-budget-item', (evt:any) => {- jQuery(evt.target).closest('.subform-row').remove();- return false;- });-- // Add new row handler- el.find('.add-row-button,.wp-inline-create--add-link').click((evt:any) => {- evt.preventDefault();- let row = jQuery(template.replace(/INDEX/g, rowIndex.toString()));- row.show();- row.removeClass('subform-row-template');- container.append(row);- rowIndex += 1;-- container.find('.subform-row:last-child input:first').focus();-- return false;- });- });- }-}--diff --git a/modules/costs/frontend/module/augment/planned-costs-form.ts b/modules/costs/frontend/module/augment/planned-costs-form.tsdeleted file mode 100644index 8d0fdfde3cc..00000000000--- a/modules/costs/frontend/module/augment/planned-costs-form.ts+++ /dev/null@@ -1,101 +0,0 @@-// -- copyright-// OpenProject is an open source project management software.-// Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.-// ++--export class PlannedCostsFormAugment {-- public obj:JQuery;- public objId:string;- public objName:string;-- static listen() {- jQuery(document).on('click', '.costs--edit-planned-costs-btn', (evt) => {- const form = jQuery(evt.target as any).closest('cost-unit-subform') as JQuery;- new PlannedCostsFormAugment(form);- });- }-- constructor(public $element:JQuery) {- this.objId = this.$element.attr('obj-id')!;- this.objName = this.$element.attr('obj-name')!;- this.obj = jQuery(`#${this.objId}_costs`) as any;-- this.makeEditable();- }-- public makeEditable() {- this.edit_and_focus();- }-- private edit_and_focus() {- this.edit();-- jQuery('#' + this.objId + '_costs_edit').trigger('focus');- jQuery('#' + this.objId + '_costs_edit').trigger('select');- }-- private getCurrency() {- return jQuery('#' + this.objId + '_currency').val();- }-- private getValue() {- return jQuery('#' + this.objId + '_cost_value').val();- }-- private edit() {- this.obj.hide();-- let id = this.obj[0].id;- let currency = this.getCurrency();- let value = this.getValue();- let name = this.objName;-- let template = `- <section class="form--section" id="${id}_section">- <div class="form--field">- <div class="form--field-container">- <div id="${id}_cancel" class="form--field-affix -transparent icon icon-close"></div>- <div id="${id}_editor" class="form--text-field-container">- <input id="${id}_edit" class="form--text-field" name="${name}" value="${value}" class="currency" type="text" />- </div>- <div class="form--field-affix" id="${id}_affix">${currency}</div>- </div>- </div>- </section>- `;-- jQuery(template).insertAfter(this.obj);-- let that = this;- jQuery('#' + id + '_cancel').on('click', function () {- jQuery('#' + id + '_section').remove();- that.obj.show();- return false;- });- }-}-diff --git a/modules/costs/spec/features/add_cost_entry_spec.rb b/modules/costs/spec/features/add_cost_entry_spec.rbindex e61bcaaf86d..2781469b5b8 100644--- a/modules/costs/spec/features/add_cost_entry_spec.rb+++ b/modules/costs/spec/features/add_cost_entry_spec.rb@@ -61,11 +61,10 @@ describe 'Work Package cost fields', type: :feature, js: true dobefore dologin_as(user)- full_view.visit!endit 'does not show read-only fields' do-+ full_view.visit!# Go to add cost entry pagefind('#action-show-more-dropdown-menu .button').clickfind('.menu-item', text: 'Log unit costs').click@@ -89,7 +88,7 @@ describe 'Work Package cost fields', type: :feature, js: true do# Override costsfind('#cost_entry_costs').click- fill_in 'cost_entry_costs_edit', with: '15'+ fill_in 'cost_entry_costs_edit', with: '15.52'click_on 'Save'@@ -99,9 +98,58 @@ describe 'Work Package cost fields', type: :feature, js: true doexpect(entry.cost_type_id).to eq(cost_type2.id)expect(entry.units).to eq(2.0)expect(entry.costs).to eq(4.0)- expect(entry.real_costs).to eq(15.0)+ expect(entry.real_costs).to eq(15.52)visit edit_cost_entry_path(entry)- expect(page).to have_selector('#cost_entry_costs', text: '15.00 EUR')+ expect(page).to have_selector('#cost_entry_costs', text: '15.52 EUR')+ end++ context 'with german locale' do+ it 'creates the budget including the given cost items with german locale' do+ user.update!(language: :de)+ I18n.locale = :de++ full_view.visit!++ # Go to add cost entry page+ find('#action-show-more-dropdown-menu .button').click+ find('.menu-item', text: I18n.t(:button_log_costs)).click++ fill_in 'cost_entry_units', with: '1,42'+ select 'B', from: 'cost_entry_cost_type_id'+ expect(page).to have_selector('#cost_entry_unit_name', text: 'B plural')+ expect(page).to have_selector('#cost_entry_costs', text: '2,84 EUR')++ # Override costs+ find('#cost_entry_costs').click+ fill_in 'cost_entry_costs_edit', with: '1.350,25'++ click_on I18n.t(:button_save)++ # Expect correct costs+ expect(page).to have_selector('.flash.notice', text: I18n.t(:notice_cost_logged_successfully))+ entry = CostEntry.last+ expect(entry.cost_type_id).to eq(cost_type2.id)+ expect(entry.units).to eq(1.42)+ expect(entry.costs).to eq(2.84)+ expect(entry.real_costs).to eq(1350.25)++ # Can edit the costs again+ visit edit_cost_entry_path(entry)+ expect(page).to have_selector('#cost_entry_costs', text: '1.350,25 EUR')++ # Toggle the cost button+ find('#cost_entry_costs').click++ # Update the costs in german locale+ fill_in 'cost_entry_costs_edit', with: '55.000,55'+ click_on I18n.t(:button_save)++ expect(page).to have_selector('#cost_entry_costs', text: '55.000,55 EUR')+ entry.reload+ expect(entry.units).to eq(1.42)+ expect(entry.costs).to eq(2.84)+ expect(entry.real_costs).to eq(55000.55)+ endendend