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

enable time inputs and fix CSS for time pickers

Klaus Zanders15764f1da55f
diff --git a/frontend/src/global_styles/content/_datepicker.sass b/frontend/src/global_styles/content/_datepicker.sass
index 73689037926..dc40f90109d 100644
--- a/frontend/src/global_styles/content/_datepicker.sass
+++ b/frontend/src/global_styles/content/_datepicker.sass
@@ -52,10 +52,6 @@ $datepicker--selected-border-radius: 5px
.flatpickr-current-month
display: flex !important
-.flatpickr-calendar .numInputWrapper
- position: fixed
- left: 65%
-
.flatpickr-prev-month, .flatpickr-next-month
svg:hover
fill: var(--control-checked-color) !important
diff --git a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts
index 35a1287e46e..fc2b5888658 100644
--- a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts
@@ -29,16 +29,31 @@
*/
import { Controller } from '@hotwired/stimulus';
+import flatpickr from 'flatpickr';
export default class TimeEntryController extends Controller {
static targets = ['startTimeInput', 'endTimeInput', 'hoursInput'];
declare readonly startTimeInputTarget:HTMLInputElement;
declare readonly endTimeInputTarget:HTMLInputElement;
- declare readonly choursInputTarget:HTMLInputElement;
+ declare readonly hoursInputTarget:HTMLInputElement;
startTimeInputTargetConnected() {
- // console.log('We have a start input');
- this.startTimeInputTarget.value = '12:00';
+ this.initTimePicker(this.startTimeInputTarget);
+ }
+
+ endTimeInputTargetConnected() {
+ this.initTimePicker(this.endTimeInputTarget);
+ }
+
+ initTimePicker(field:HTMLInputElement) {
+ flatpickr(field, {
+ enableTime: true,
+ noCalendar: true,
+ dateFormat: 'H:i',
+ time_24hr: true,
+ static: true,
+ appendTo: document.querySelector('#time-entry-dialog') as HTMLElement,
+ });
}
}
diff --git a/modules/costs/app/components/time_entries/time_entry_form.rb b/modules/costs/app/components/time_entries/time_entry_form.rb
index 89fd91565c4..cdc14754e5b 100644
--- a/modules/costs/app/components/time_entries/time_entry_form.rb
+++ b/modules/costs/app/components/time_entries/time_entry_form.rb
@@ -34,11 +34,13 @@ module TimeEntries
g.text_field name: :start_time,
required: true,
label: TimeEntry.human_attribute_name(:start_time),
+ value: model.start_timestamp&.strftime("%H:%M"),
data: { "time-entry-target" => "startTimeInput" }
g.text_field name: :end_time,
required: true,
label: TimeEntry.human_attribute_name(:end_time),
+ value: model.end_timestamp&.strftime("%H:%M"),
data: { "time-entry-target" => "endTimeInput" }
end