Feature #43589
closed
Show the "h:mm" placeholder in hours fields only when the time span format is "minutes"
Added by Yasu Saku 10 months ago.
Updated about 9 hours ago.
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
Files
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.
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
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
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
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.
- Related to Feature #2464: Add placeholder "h:mm" to hours field for better user guidance added
I am attaching a patch based on the change proposed in #note-3.
With this patch, the "h:mm" placeholder is shown only when the "Time span format" setting is "minutes". When the setting is "decimal", no placeholder is shown.
The only difference from #note-3 is that the patch passes nil instead of an empty string, so that the placeholder attribute is not rendered at all instead of being rendered as placeholder="".
- Target version changed from Candidate for next minor release to 7.0.2
Setting the target version to 7.0.2.
- Tracker changed from Defect to Feature
- Subject changed from Estimated Hours Field Placeholder Does Not Reflect Selected Time Span Format to Show the "h:mm" placeholder in hours fields only when the time span format is "minutes"
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Target version changed from 7.0.2 to 7.1.0
- Resolution set to Fixed
- Affected version deleted (
6.0.0)
Committed the patch in r25136.
Go MAEDA
Thank you for your support as always.
Also available in: Atom
PDF