Skip to content

Commit

Permalink
Add required marks and labels
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Dec 5, 2024
1 parent 19ca25c commit 3b18f14
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
21 changes: 14 additions & 7 deletions modules/costs/app/components/time_entries/time_entry_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class TimeEntryForm < ApplicationForm
f.autocompleter(
name: :user_id,
label: TimeEntry.human_attribute_name(:user),
required: true,
autocomplete_options: {
defaultData: true,
component: "opce-user-autocompleter",
Expand All @@ -26,30 +27,36 @@ class TimeEntryForm < ApplicationForm
# https://github.com/opf/openproject/pull/17223/commits/db765ac3862ded78139e6b8827e33cf2b8b3bce8
f.text_field name: :spent_on,
type: "date",
label: "Date"
required: true,
label: TimeEntry.human_attribute_name(:spent_on)

f.group(layout: :horizontal) do |g|
# TODO: Add a time picker based on the date picker linked above
g.text_field name: :start_time,
label: "Start time",
required: true,
label: TimeEntry.human_attribute_name(:start_time),
data: { "time-entry-target" => "startTimeInput" }

g.text_field name: :end_time,
label: "Finish time",
required: true,
label: TimeEntry.human_attribute_name(:end_time),
data: { "time-entry-target" => "endTimeInput" }
end

f.text_field name: :hours,
label: "Hours",
required: true,
label: TimeEntry.human_attribute_name(:hours),
data: { "time-entry-target" => "hoursInput" }

if show_work_package_field?
f.work_package_autocompleter name: :work_package_id,
label: "Work package",
label: TimeEntry.human_attribute_name(:work_package),
autocomplete_options: {
focusDirectly: false,
append_to: "#time-entry-dialog",
filters: [{ name: "project_id", operator: "=", values: [model.project_id] }]
filters: [
{ name: "project_id", operator: "=", values: [model.project_id] }
]
}
end

Expand All @@ -60,7 +67,7 @@ class TimeEntryForm < ApplicationForm
end
end

f.text_area name: :comments, label: "Comments"
f.text_area name: :comments, label: TimeEntry.human_attribute_name(:comments)

render_custom_fields(form: f)
end
Expand Down
11 changes: 11 additions & 0 deletions modules/costs/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ en:
rate: "Rate"
user:
default_rates: "Default rates"
time_entry:
project: Project
user: User
work_package: Work package
hours: Hours
comments: Comment
activity: Activity
spent_on: Date
start_time: Start time
end_time: Finish time

models:
cost_type:
one: "Cost type"
Expand Down

0 comments on commit 3b18f14

Please sign in to comment.