diff --git a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts new file mode 100644 index 000000000000..35a1287e46ec --- /dev/null +++ b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts @@ -0,0 +1,44 @@ +/* + * -- copyright + * OpenProject is an open source project management software. + * Copyright (C) the OpenProject GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 3. + * + * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: + * Copyright (C) 2006-2013 Jean-Philippe Lang + * Copyright (C) 2010-2013 the ChiliProject Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * See COPYRIGHT and LICENSE files for more details. + * ++ + */ + +import { Controller } from '@hotwired/stimulus'; + +export default class TimeEntryController extends Controller { + static targets = ['startTimeInput', 'endTimeInput', 'hoursInput']; + + declare readonly startTimeInputTarget:HTMLInputElement; + declare readonly endTimeInputTarget:HTMLInputElement; + declare readonly choursInputTarget:HTMLInputElement; + + startTimeInputTargetConnected() { + // console.log('We have a start input'); + this.startTimeInputTarget.value = '12:00'; + } +} diff --git a/modules/costs/app/components/time_entries/entry_dialog_component.html.erb b/modules/costs/app/components/time_entries/entry_dialog_component.html.erb index fc783e2b8452..c53510ac2725 100644 --- a/modules/costs/app/components/time_entries/entry_dialog_component.html.erb +++ b/modules/costs/app/components/time_entries/entry_dialog_component.html.erb @@ -1,4 +1,4 @@ -<%= render(Primer::Alpha::Dialog.new(title: 'Log Time', size: :large, id: MODAL_ID)) do |d| %> +<%= render(Primer::Alpha::Dialog.new(title: 'Log Time', size: :large, id: MODAL_ID, data: { "controller" => "time-entry", "application-target" => "dynamic" })) do |d| %> <% d.with_header(variant: :large, mb: 3) %> <%= render(TimeEntries::TimeEntryFormComponent.new(time_entry: time_entry)) %> <% end %> 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 09d6879cf479..f7291a1e3de8 100644 --- a/modules/costs/app/components/time_entries/time_entry_form.rb +++ b/modules/costs/app/components/time_entries/time_entry_form.rb @@ -8,7 +8,9 @@ class TimeEntryForm < ApplicationForm end f.text_field name: :spent_on, label: "Date" f.group(layout: :horizontal) do |g| - g.text_field name: :start_time, label: "Start time" + g.text_field name: :start_time, + label: "Start time", + data: { "time-entry-target" => "startTimeInput" } g.text_field name: :end_time, label: "Finish time" end f.text_field name: :hours, label: "Hours"