Defect #43589
openEstimated Hours Field Placeholder Does Not Reflect Selected Time Span Format
0%
Description
Redmine allows switching the Time span format between 0.75 and 0:45 h in the settings.
However, the placeholder of the Hours input field is fixed as h:mm , regardless of the selected format.
This affects not only the Issue form (Estimated hours field) but also the Log time form, where the same Hours input field is used.
Would it be possible to update the placeholder dynamically to match the chosen format? For example, when the format is 0.75 , the placeholder should reflect that style instead of h:mm .
The placeholder appears to have been introduced in issue #2464.
The corresponding line can be found here:
source:/branches/6.1-stable/lib/redmine/views/labelled_form_builder.rb@24209#L52
Updated by Go MAEDA about 1 month ago
Even when the Time span format is set to a decimal style (`0.75`), Redmine still accepts input in the h:mm format. Because of this, I think it is acceptable to keep the placeholder fixed as h:mm.
Updated by Yasu Saku about 1 month ago
Go MAEDA wrote in #note-1:
Even when the Time span format is set to a decimal style (`0.75`), Redmine still accepts input in the h:mm format. Because of this, I think it is acceptable to keep the placeholder fixed as h:mm.
I understand that input in the h:mm format is supported. However, I usually use the 0.75 format, and the difference between the display format and the edit format can be a bit confusing for users.
To improve clarity and consistency, could the placeholder reflect the selected time span format?
For example: e.g., h:mm or 0.75
Updated by Go MAEDA 10 days ago
I propose the following change to the placeholder behavior.
In the following patch, the "h:mm" placeholder is shown only when the "Time span format" is set to "minutes".
If the "Time span format" is set to "decimal", no placeholder is shown.
I am not sure what placeholder would be appropriate when the format is "decimal". In addition, the placeholder logic would become a bit complicated because it would need to handle internationalized decimal separators ('.' and ',').
diff --git a/lib/redmine/views/labelled_form_builder.rb b/lib/redmine/views/labelled_form_builder.rb
index c08030d93..951dcbca7 100644
--- a/lib/redmine/views/labelled_form_builder.rb
+++ b/lib/redmine/views/labelled_form_builder.rb
@@ -49,7 +49,7 @@ class Redmine::Views::LabelledFormBuilder < ActionView::Helpers::FormBuilder
# display the value before type cast when the entered value is not valid
if @object.errors[field].blank?
options = options.merge(:value => format_hours(@object.send field))
- .with_defaults(:placeholder => 'h:mm')
+ .with_defaults(:placeholder => Setting.timespan_format == 'minutes' ? 'h:mm' : '')
end
text_field field, options
end
Updated by Marius BĂLTEANU 10 days ago
What about showing the same value from administration setting, but localized?
diff --git a/lib/redmine/views/labelled_form_builder.rb b/lib/redmine/views/labelled_form_builder.rb
index c08030d93..d89b86277 100644
--- a/lib/redmine/views/labelled_form_builder.rb
+++ b/lib/redmine/views/labelled_form_builder.rb
@@ -48,8 +48,10 @@ class Redmine::Views::LabelledFormBuilder < ActionView::Helpers::FormBuilder
def hours_field(field, options={})
# display the value before type cast when the entered value is not valid
if @object.errors[field].blank?
+ placeholder = (Setting.timespan_format == 'minutes' ? 'h:mm' : number_with_delimiter(0.75))
+
options = options.merge(:value => format_hours(@object.send field))
- .with_defaults(:placeholder => 'h:mm')
+ .with_defaults(:placeholder => placeholder)
end
text_field field, options
end
Updated by Go MAEDA 10 days ago
Marius BĂLTEANU wrote in #note-4:
What about showing the same value from administration setting, but localized?
The purpose of the placeholder added in #2464 is to indicate one of the expected time formats other than non-decimal values. Therefore, in my opinion, displaying a placeholder such as "0.75" is inappropriate. Moreover, I am concerned that showing a specific numeric value may confuse users.