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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
implement the form
Klaus Zanders047063e40c3e
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.erbindex aa1e7808f0a..fc783e2b845 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,5 +1,4 @@<%= render(Primer::Alpha::Dialog.new(title: 'Log Time', size: :large, id: MODAL_ID)) do |d| %><% d.with_header(variant: :large, mb: 3) %>- <%- pp(time_entry) %><%= 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.rbindex 695f0d27ab0..09d6879cf47 100644--- a/modules/costs/app/components/time_entries/time_entry_form.rb+++ b/modules/costs/app/components/time_entries/time_entry_form.rb@@ -1,4 +1,46 @@module TimeEntriesclass TimeEntryForm < ApplicationForm+ include CustomFields::CustomFieldRendering++ form do |f|+ if show_user_field?+ f.text_field name: :user_id, label: "User"+ 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: :end_time, label: "Finish time"+ end+ f.text_field name: :hours, label: "Hours"+ if show_work_package_field?+ f.text_field name: :work_package_id, label: "Work package"+ end+ f.text_field name: :activity, label: "Activity"+ f.text_field name: :comments, label: "Comments"++ render_custom_fields(form: f)+ end++ private++ delegate :project, :work_package, to: :model++ def custom_fields+ @custom_fields ||= model.available_custom_fields+ end++ def show_work_package_field?+ work_package.blank?+ end++ def show_user_field?+ # Only allow setting a different user, when the user has the+ # permission to log time for others in the project+ User.current.allowed_in_project?(:log_time, project)+ end++ def show_start_and_end_time_fields?+ TimeEntry.can_track_start_and_end_time?+ endendenddiff --git a/modules/costs/app/components/time_entries/time_entry_form_component.html.erb b/modules/costs/app/components/time_entries/time_entry_form_component.html.erbindex e81e59cee2c..f09289b5028 100644--- a/modules/costs/app/components/time_entries/time_entry_form_component.html.erb+++ b/modules/costs/app/components/time_entries/time_entry_form_component.html.erb@@ -31,26 +31,10 @@ See COPYRIGHT and LICENSE files for more details.component_wrapper doprimer_form_with(**form_options) do |form|component_collection do |collection|- collection.with_component(Primer::Alpha::Dialog::Body.new(- aria: { label: I18n.t("my.access_token.new_access_token_dialog_title") }- )) do- flex_layout(my: 3) do |body|- body.with_row do- render(Primer::Alpha::Banner.new(scheme: :warning)) do- I18n.t("my.access_token.new_access_token_dialog_attention_text")- end- end-- body.with_row(mt: 3) do- render(Primer::Beta::Text.new(tag: :p)) do- I18n.t("my.access_token.new_access_token_dialog_text")- end- end-- body.with_row do- content_tag(:pre, time_entry.pretty_inspect)- # render(My::AccessToken::NewAccessTokenForm.new(form))- end+ collection.with_component(Primer::Alpha::Dialog::Body.new) do+ component_collection do |coll|+ # coll.with_component content_tag(:pre, time_entry.pretty_inspect)+ coll.with_component render(TimeEntries::TimeEntryForm.new(form))endenddiff --git a/modules/costs/app/components/time_entries/time_entry_form_component.rb b/modules/costs/app/components/time_entries/time_entry_form_component.rbindex 365c3c669e5..b41aaf120f8 100644--- a/modules/costs/app/components/time_entries/time_entry_form_component.rb+++ b/modules/costs/app/components/time_entries/time_entry_form_component.rb@@ -44,20 +44,6 @@ module TimeEntriesdelegate :project, :work_package, to: :time_entry- def show_work_package_field?- work_package.blank?- end-- def show_user_field?- # Only allow setting a different user, when the user has the- # permission to log time for others in the project- User.current.allowed_in_project?(:log_time, project)- end-- def show_start_and_end_time_fields?- TimeEntry.can_track_start_and_end_time?- end-def form_optionsbase = {model: time_entry,