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

[52107] Translate field labels in backlogs forms

Christophe Bliard55b110e26b38
diff --git a/frontend/src/app/features/backlogs/backlogs-page/styles/taskboard.sass b/frontend/src/app/features/backlogs/backlogs-page/styles/taskboard.sass
index 873c8fe6bd5..969f504104e 100644
--- a/frontend/src/app/features/backlogs/backlogs-page/styles/taskboard.sass
+++ b/frontend/src/app/features/backlogs/backlogs-page/styles/taskboard.sass
@@ -241,10 +241,11 @@
/* item editor */
#task_editor
+ label:first-letter
+ text-transform: capitalize
label
display: block
font-size: 11px
- text-transform: capitalize
width: 100%
.editor
font-size: 11px
diff --git a/frontend/src/stimulus/controllers/dynamic/backlogs/model.js b/frontend/src/stimulus/controllers/dynamic/backlogs/model.js
index 09fcf2f31b2..27c1b0c4990 100644
--- a/frontend/src/stimulus/controllers/dynamic/backlogs/model.js
+++ b/frontend/src/stimulus/controllers/dynamic/backlogs/model.js
@@ -156,17 +156,13 @@ RB.Model = (function ($) {
const field = $(this);
const fieldId = field.attr('field_id');
const fieldName = field.attr('fieldname');
+ const fieldLabel = field.attr('fieldlabel');
const fieldOrder = parseInt(field.attr('fieldorder'), 10);
const fieldType = field.attr('fieldtype') || 'input';
- let fieldLabel = field.attr('fieldlabel');
let typeId;
let statusId;
let input;
- if (!fieldLabel) {
- fieldLabel = fieldName.replace(/_/ig, " ").replace(/ id$/ig, "");
- }
-
if (fieldType === 'select') {
// Special handling for status_id => they are dependent of type_id
if (fieldName === 'status_id') {
diff --git a/modules/backlogs/app/views/rb_impediments/_impediment.html.erb b/modules/backlogs/app/views/rb_impediments/_impediment.html.erb
index 19d0f62b3f7..9ba0dfc0477 100644
--- a/modules/backlogs/app/views/rb_impediments/_impediment.html.erb
+++ b/modules/backlogs/app/views/rb_impediments/_impediment.html.erb
@@ -28,18 +28,40 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% prevent_edit = User.current.allowed_in_project?(:edit_work_packages, defined?(project) ? project : impediment.project) ? '' : 'prevent_edit'%>
-<div class="model work_package impediment <%= color_contrast_class(impediment) %> <%= prevent_edit %> <%= mark_if_closed(impediment) %><%= color_contrast_class(impediment) %>" id="work_package_<%= impediment.id %>" <%= build_inline_style(impediment) %>>
+<div class="model work_package impediment <%= color_contrast_class(impediment) %> <%= prevent_edit %> <%= mark_if_closed(impediment) %><%= color_contrast_class(impediment) %>"
+ id="work_package_<%= impediment.id %>"
+ <%= build_inline_style(impediment) %>>
<div class="id">
<div class="t"><%= work_package_link_or_empty(impediment) %></div>
<div class="v"><%= id_or_empty(impediment) %></div>
</div>
- <div class="subject editable" fieldtype="textarea" fieldname="subject" field_id=<%= impediment.id %>><%= impediment.subject %></div>
- <div class="blocks editable" fieldname="blocks_ids" fieldlabel="<%= t(:label_blocks_ids) %>" field_id=<%= impediment.id %>><%= blocks_ids(impediment.blocks_ids) %></div>
- <div class="assigned_to_id editable" fieldtype="select" fieldname="assigned_to_id" field_id=<%= impediment.id %>>
+ <div class="subject editable"
+ fieldtype="textarea"
+ fieldname="subject"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:subject) %>"
+ field_id="<%= impediment.id %>">
+ <%= impediment.subject %>
+ </div>
+ <div class="blocks editable"
+ fieldname="blocks_ids"
+ fieldlabel="<%= t(:label_blocks_ids) %>"
+ field_id="<%= impediment.id %>">
+ <%= blocks_ids(impediment.blocks_ids) %>
+ </div>
+ <div class="assigned_to_id editable"
+ fieldtype="select"
+ fieldname="assigned_to_id"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:assigned_to) %>"
+ field_id="<%= impediment.id %>">
<div class="t"><%= assignee_name_or_empty(impediment) %></div>
<div class="v"><%= assignee_id_or_empty(impediment) %></div>
</div>
- <div class="remaining_hours editable<%= ' empty' if remaining_hours(impediment).blank? %>" fieldname="remaining_hours" field_id=<%= impediment.id %>><%= remaining_hours(impediment) %></div>
+ <div class="remaining_hours editable<%= ' empty' if remaining_hours(impediment).blank? %>"
+ fieldname="remaining_hours"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:remaining_hours) %>"
+ field_id="<%= impediment.id %>">
+ <%= remaining_hours(impediment) %>
+ </div>
<div class="indicator"> </div>
<div class="meta">
<div class="story_id"><%= impediment.parent_id %></div>
diff --git a/modules/backlogs/app/views/rb_sprints/_sprint.html.erb b/modules/backlogs/app/views/rb_sprints/_sprint.html.erb
index 6cd874d1a62..e2d4733ffb1 100644
--- a/modules/backlogs/app/views/rb_sprints/_sprint.html.erb
+++ b/modules/backlogs/app/views/rb_sprints/_sprint.html.erb
@@ -36,13 +36,24 @@ See COPYRIGHT and LICENSE files for more details.
<% User.current.allowed_in_project?(:update_sprints, @project) ? editable = "editable" : editable = "" %>
<div class="show">
- <div class="effective_date date <%= editable %>" fieldname="effective_date" field_id=<%= sprint.id %>>
+ <div class="effective_date date <%= editable %>"
+ fieldname="effective_date"
+ fieldlabel="<%= Version.human_attribute_name(:effective_date) %>"
+ field_id="<%= sprint.id %>">
<%= sprint.effective_date %>
</div>
- <div class="start_date <%= editable %> date" fieldname="start_date" field_id=<%= sprint.id %>>
+ <div class="start_date <%= editable %> date"
+ fieldname="start_date"
+ fieldlabel="<%= Version.human_attribute_name(:start_date) %>"
+ field_id="<%= sprint.id %>">
<%= sprint.start_date %>
</div>
- <div class="name <%= editable %>" fieldname="name" field_id="<%= sprint.id %>"><%= sprint.name %></div>
+ <div class="name <%= editable %>"
+ fieldname="name"
+ fieldlabel="<%= Version.human_attribute_name(:name) %>"
+ field_id="<%= sprint.id %>">
+ <%= sprint.name %>
+ </div>
</div>
<% if User.current.allowed_in_project?(:update_sprints, @project) %>
diff --git a/modules/backlogs/app/views/rb_stories/_story.html.erb b/modules/backlogs/app/views/rb_stories/_story.html.erb
index 39f78a80ef3..f1045acc0b0 100644
--- a/modules/backlogs/app/views/rb_stories/_story.html.erb
+++ b/modules/backlogs/app/views/rb_stories/_story.html.erb
@@ -32,16 +32,39 @@ See COPYRIGHT and LICENSE files for more details.
<div class="t"><%= work_package_link_or_empty(story) %></div>
<div class="v"><%= id_or_empty(story) %></div>
</div>
- <div class="story_points editable" fieldname="story_points" fieldorder="4" field_id=<%= story.id %>><%= story_points_or_empty(story) %></div>
- <div class="status_id editable" fieldtype="select" fieldname="status_id" fieldorder="3" field_id=<%= story.id %>>
+ <div class="story_points editable"
+ fieldname="story_points"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:story_points) %>"
+ fieldorder="4"
+ field_id="<%= story.id %>">
+ <%= story_points_or_empty(story) %>
+ </div>
+ <div class="status_id editable"
+ fieldtype="select"
+ fieldname="status_id"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:status) %>"
+ fieldorder="3"
+ field_id="<%= story.id %>">
<div class="t ellipsis" title="<%= status_label_or_default(story) %>"><%= status_label_or_default(story) %></div>
<div class="v"><%= status_id_or_default(story) %></div>
</div>
- <div class="type_id editable" fieldtype="select" fieldname="type_id" fieldorder="1" field_id=<%= story.id %>>
+ <div class="type_id editable"
+ fieldtype="select"
+ fieldname="type_id"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:type) %>"
+ fieldorder="1"
+ field_id="<%= story.id %>">
<div class="t"><%= type_name_or_empty(story) %>: </div>
<div class="v"><%= type_id_or_empty(story) %></div>
</div>
- <div class="subject editable ellipsis" fieldname="subject" fieldorder="2" title="<%= h story.subject %>" field_id=<%= story.id %>><%=h story.subject %></div>
+ <div class="subject editable ellipsis"
+ fieldname="subject"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:subject) %>"
+ fieldorder="2"
+ title="<%= h story.subject %>"
+ field_id="<%= story.id %>">
+ <%=h story.subject %>
+ </div>
<div class="version_id"><%= story.version_id %></div>
<div class="higher_item_id"><%= !defined?(higher_item) || higher_item.nil? ? '' : higher_item.id %></div>
<div class="meta">
diff --git a/modules/backlogs/app/views/rb_tasks/_task.html.erb b/modules/backlogs/app/views/rb_tasks/_task.html.erb
index 8ac0b429579..265f0a79ae1 100644
--- a/modules/backlogs/app/views/rb_tasks/_task.html.erb
+++ b/modules/backlogs/app/views/rb_tasks/_task.html.erb
@@ -33,12 +33,26 @@ See COPYRIGHT and LICENSE files for more details.
<div class="t"><%= work_package_link_or_empty(task) %></div>
<div class="v"><%= id_or_empty(task) %></div>
</div>
- <div class="subject editable" fieldtype="textarea" fieldname="subject" field_id=<%= task.id %>><%= task.subject %></div>
- <div class="assigned_to_id editable" fieldtype="select" fieldname="assigned_to_id" field_id=<%= task.id %>>
+ <div class="subject editable"
+ fieldtype="textarea"
+ fieldname="subject"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:subject) %>"
+ field_id="<%= task.id %>">
+ <%= task.subject %>
+ </div>
+ <div class="assigned_to_id editable"
+ fieldtype="select"
+ fieldname="assigned_to_id"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:assigned_to) %>"
+ field_id="<%= task.id %>">
<div class="t"><%= assignee_name_or_empty(task) %></div>
<div class="v"><%= assignee_id_or_empty(task) %></div>
</div>
- <div class="remaining_hours editable<%= ' empty' if remaining_hours(task).blank? %>" fieldname="remaining_hours"><%= remaining_hours(task) %></div>
+ <div class="remaining_hours editable<%= ' empty' if remaining_hours(task).blank? %>"
+ fieldname="remaining_hours"
+ fieldlabel="<%= WorkPackage.human_attribute_name(:remaining_hours) %>">
+ <%= remaining_hours(task) %>
+ </div>
<div class="indicator"> </div>
<div class="meta">
<div class="story_id"><%= task.parent_id %></div>
diff --git a/modules/backlogs/spec/features/backlogs/create_story_spec.rb b/modules/backlogs/spec/features/backlogs/create_story_spec.rb
index 0449829b25e..61f1b7d206b 100644
--- a/modules/backlogs/spec/features/backlogs/create_story_spec.rb
+++ b/modules/backlogs/spec/features/backlogs/create_story_spec.rb
@@ -106,15 +106,15 @@ RSpec.describe 'Backlogs', :js, :with_cuprite do
menu = find('.backlog-menu')
menu.click
click_link 'New Story'
- fill_in 'subject', with: "The new story"
- fill_in 'story points', with: "5"
+ fill_in 'Subject', with: "The new story"
+ fill_in 'Story Points', with: "5"
# inactive types should not be selectable
# but the user can choose from the active types
expect(page)
.to have_no_css('option', text: inactive_story_type.name)
- select story_type2.name, from: 'type'
+ select story_type2.name, from: 'Type'
# saving the new story
find(:css, 'input[name=subject]').native.send_key :return
@@ -126,7 +126,7 @@ RSpec.describe 'Backlogs', :js, :with_cuprite do
# this will ensure that the page refresh is through before we check the order
menu.click
click_link 'New Story'
- fill_in 'subject', with: "Another story"
+ fill_in 'Subject', with: "Another story"
end
# the order is kept even after a page refresh -> it is persisted in the db
diff --git a/modules/backlogs/spec/features/stories_in_backlog_spec.rb b/modules/backlogs/spec/features/stories_in_backlog_spec.rb
index 8cc3d8f1b05..8900c4b216b 100644
--- a/modules/backlogs/spec/features/stories_in_backlog_spec.rb
+++ b/modules/backlogs/spec/features/stories_in_backlog_spec.rb
@@ -224,6 +224,9 @@ RSpec.describe 'Stories in backlog', :js,
backlogs_page
.drag_in_sprint(sprint_story1, new_story)
+ # wait for backend to process the reordering
+ sleep(0.5)
+
backlogs_page
.expect_stories_in_order(sprint, sprint_story1, new_story, sprint_story2)
@@ -234,6 +237,7 @@ RSpec.describe 'Stories in backlog', :js,
backlogs_page
.drag_in_sprint(sprint_story1, sprint_story2, before: false)
+ # wait for backend to process the reordering
sleep(0.5)
backlogs_page
@@ -248,6 +252,7 @@ RSpec.describe 'Stories in backlog', :js,
backlogs_page
.drag_in_sprint(backlog_story1, sprint_story2, before: false)
+ # wait for backend to process the reordering
sleep(0.5)
backlogs_page
diff --git a/modules/backlogs/spec/support/pages/backlogs.rb b/modules/backlogs/spec/support/pages/backlogs.rb
index 68e1d8e9e7c..721ff468159 100644
--- a/modules/backlogs/spec/support/pages/backlogs.rb
+++ b/modules/backlogs/spec/support/pages/backlogs.rb
@@ -54,13 +54,13 @@ module Pages
attributes.each do |key, value|
case key
when :subject
- fill_in 'subject', with: value
+ fill_in 'Subject', with: value
when :story_points
- fill_in 'story points', with: value
+ fill_in 'Story Points', with: value
when :status
- select value, from: 'status'
+ select value, from: 'Status'
when :type
- select value, from: 'type'
+ select value, from: 'Type'
else
raise NotImplementedError
end
diff --git a/modules/backlogs/spec/support/pages/taskboard.rb b/modules/backlogs/spec/support/pages/taskboard.rb
index 6c23d3b4896..37e71332d3f 100644
--- a/modules/backlogs/spec/support/pages/taskboard.rb
+++ b/modules/backlogs/spec/support/pages/taskboard.rb
@@ -116,11 +116,11 @@ module Pages
attributes.each do |key, value|
case key
when :subject
- fill_in 'subject', with: value
+ fill_in 'Subject', with: value
when :assignee
- select value, from: 'assigned to'
+ select value, from: 'Assignee'
when :remaining_hours
- fill_in 'remaining hours', with: value
+ fill_in 'Remaining work', with: value
end
end