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

Fix/34144 avoid not focusable input error (#8607)

Aleix Suau4d553ae60d20
diff --git a/modules/budgets/frontend/module/augment/cost-subform.augment.service.ts b/modules/budgets/frontend/module/augment/cost-subform.augment.service.ts
index 71564a76512..a6583493782 100644
--- a/modules/budgets/frontend/module/augment/cost-subform.augment.service.ts
+++ b/modules/budgets/frontend/module/augment/cost-subform.augment.service.ts
@@ -53,6 +53,9 @@ export class CostSubformAugmentService {
let row = jQuery(template.replace(/INDEX/g, rowIndex.toString()));
row.show();
row.removeClass('subform-row-template');
+ row.find('input.costs-date-picker').prop('required', true);
+ row.find('input[id^="cost_type_new_rate_attributes"]').prop('required', true);
+
container.append(row);
rowIndex += 1;
diff --git a/modules/costs/spec/features/cost_types/create_cost_type_spec.rb b/modules/costs/spec/features/cost_types/create_cost_type_spec.rb
new file mode 100644
index 00000000000..d11bc2b1ff1
--- /dev/null
+++ b/modules/costs/spec/features/cost_types/create_cost_type_spec.rb
@@ -0,0 +1,65 @@
+#-- 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-2017 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.
+#++
+
+require 'spec_helper'
+
+describe 'creating a cost type', type: :feature, js: true do
+ let!(:user) { FactoryBot.create :admin }
+ let!(:cost_type) {
+ type = FactoryBot.create :cost_type, name: 'Translations'
+ FactoryBot.create :cost_rate, cost_type: type, rate: 1.00
+ type
+ }
+
+ before do
+ login_as user
+ end
+
+ it 'can create a cost type' do
+ visit "/cost_types/new"
+
+ fill_in 'cost_type_name', with: 'Test day rate'
+ fill_in 'cost_type_unit', with: 'dayUnit'
+ fill_in 'cost_type_unit_plural', with: 'dayUnitPlural'
+ fill_in 'cost_type_new_rate_attributes_0_rate', with: '5'
+
+ sleep 1
+
+ scroll_to_and_click(find('button.-with-icon.icon-checkmark'))
+
+ expect_angular_frontend_initialized
+ expect(page).to have_selector '.generic-table', wait: 10
+
+ cost_type_row = find('tr', text: 'Test day rate')
+
+ expect(cost_type_row).to have_selector('td a', text: 'Test day rate')
+ expect(cost_type_row).to have_selector('td', text: 'dayUnit')
+ expect(cost_type_row).to have_selector('td', text: 'dayUnitPlural')
+ expect(cost_type_row).to have_selector('td.currency', text: '5')
+ end
+end
diff --git a/modules/costs/spec/features/cost_types/delete_cost_type_spec.rb b/modules/costs/spec/features/cost_types/delete_cost_type_spec.rb
index 07a7e15d584..7aecfc54317 100644
--- a/modules/costs/spec/features/cost_types/delete_cost_type_spec.rb
+++ b/modules/costs/spec/features/cost_types/delete_cost_type_spec.rb
@@ -43,7 +43,7 @@ describe 'deleting a cost type', type: :feature, js: true do
it 'can delete the cost type' do
visit cost_types_path
- within ("#delete_cost_type_#{cost_type.id}") do
+ within("#delete_cost_type_#{cost_type.id}") do
scroll_to_and_click(find('button.submit_cost_type'))
end