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

Remove datepicker on mobile and use native date fields instead

Henriette Dargea40aa8847bc6
diff --git a/app/components/work_packages/date_picker/date_form_component.rb b/app/components/work_packages/date_picker/date_form_component.rb
index 51e279880e5..905d8ebd338 100644
--- a/app/components/work_packages/date_picker/date_form_component.rb
+++ b/app/components/work_packages/date_picker/date_form_component.rb
@@ -80,7 +80,7 @@ module WorkPackages
show_clear_button: !disabled?(name) && !duration_field?(name),
classes: "op-datepicker-modal--date-field #{'op-datepicker-modal--date-field_current' if @focused_field == name}",
validation_message: validation_message(name),
- type: duration_field?(name) ? :number : :text
+ type: field_type(name)
)
if duration_field?(name)
@@ -177,6 +177,12 @@ module WorkPackages
end
end
+ def field_type(name)
+ return :number if duration_field?(name)
+
+ helpers.browser.device.mobile? ? :date : :text
+ end
+
def validation_message(name)
# it's ok to take the first error only, that's how primer_view_component does it anyway.
message = @work_package.errors.messages_for(name).first
diff --git a/app/components/work_packages/date_picker/dialog_content_component.sass b/app/components/work_packages/date_picker/dialog_content_component.sass
index c7f0f4fc4a1..3f2370e71c4 100644
--- a/app/components/work_packages/date_picker/dialog_content_component.sass
+++ b/app/components/work_packages/date_picker/dialog_content_component.sass
@@ -22,8 +22,10 @@ $body-height: 460px
@media screen and (max-width: $breakpoint-sm)
.wp-datepicker-dialog
- &--UnderlineNav
+ &--UnderlineNav,
+ &--date-picker-instance
display: none !important
+
&--body
padding-top: var(--stack-padding-normal)
min-height: unset
diff --git a/app/components/work_packages/date_picker/form_component.html.erb b/app/components/work_packages/date_picker/form_component.html.erb
index 72f50f2efff..e3cd37f7df1 100644
--- a/app/components/work_packages/date_picker/form_component.html.erb
+++ b/app/components/work_packages/date_picker/form_component.html.erb
@@ -97,7 +97,7 @@
)
end
- body.with_row("aria-hidden": true) do
+ body.with_row("aria-hidden": true, classes: "wp-datepicker-dialog--date-picker-instance") do
helpers.angular_component_tag "opce-wp-date-picker-instance",
inputs: {
start_date: work_package.start_date,