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
render the activity form
Klaus Zanders73d1c3e57daa
diff --git a/modules/costs/app/components/time_entries/activity_form.rb b/modules/costs/app/components/time_entries/activity_form.rbindex 7096d40528d..e8c50a5d0c7 100644--- a/modules/costs/app/components/time_entries/activity_form.rb+++ b/modules/costs/app/components/time_entries/activity_form.rb@@ -34,12 +34,15 @@ module TimeEntriesf.autocompleter(name: :activity_id,label: TimeEntry.human_attribute_name(:activity),+ visually_hide_label: true,required: false,include_blank: true,autocomplete_options: {+ placeholder: placeholder_text,focusDirectly: false,multiple: false,decorated: true,+ disabled: project.blank?,append_to: "#time-entry-dialog"}) do |select|@@ -53,6 +56,14 @@ module TimeEntriesdelegate :project, to: :model+ def placeholder_text+ if project.blank?+ I18n.t("time_entry.activity_select_project_first")+ else+ I18n.t("time_entry.activity_select")+ end+ end+def activitiesreturn [] if project.blank?diff --git a/modules/costs/app/components/time_entries/activity_form_component.rb b/modules/costs/app/components/time_entries/activity_form_component.rbnew file mode 100644index 00000000000..591f94a86ed--- /dev/null+++ b/modules/costs/app/components/time_entries/activity_form_component.rb@@ -0,0 +1,18 @@+module TimeEntries+ class ActivityFormComponent < ApplicationComponent+ include OpTurbo::Streamable++ attr_reader :form++ def initialize(form:)+ super()+ @form = form+ end++ def call+ component_wrapper do+ render(TimeEntries::ActivityForm.new(form))+ end+ end+ end+enddiff --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 51f396438dc..c129af7fb19 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@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.body.with_row(mb: 3) { render(TimeEntries::UserForm.new(form)) }body.with_row(mb: 3) { render(TimeEntries::DaysAndHoursForm.new(form)) }body.with_row(mb: 3) { render(TimeEntries::WorkPackageForm.new(form)) }- body.with_row(mb: 3) { render(TimeEntries::ActivityForm.new(form)) }+ body.with_row(mb: 3) { render(TimeEntries::ActivityFormComponent.new(form: form)) }body.with_row(mb: 3) { render(TimeEntries::CommentsForm.new(form)) }body.with_row(mb: 3) { render(TimeEntries::CustomFieldsForm.new(form)) }enddiff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rbindex 2562415d637..14092dd3d45 100644--- a/modules/costs/app/controllers/time_entries_controller.rb+++ b/modules/costs/app/controllers/time_entries_controller.rb@@ -66,6 +66,21 @@ class TimeEntriesController < ApplicationControllerenddef time_entry_activities+ work_package = WorkPackage.visible.find_by(id: params[:work_package_id])++ time_entry = TimeEntry.new(project: work_package.project, work_package: work_package)++ form = Primer::Forms::Builder.new(+ TimeEntry.model_name.param_key,+ time_entry,+ helpers,+ {}+ )++ replace_via_turbo_stream(+ component: TimeEntries::ActivityFormComponent.new(form:)+ )+respond_with_turbo_streamsend@@ -76,9 +91,7 @@ class TimeEntriesController < ApplicationController@time_entry = call.result- if call.success?- # TODO: just close here?- else+ unless call.success?form_component = TimeEntries::TimeEntryFormComponent.new(time_entry: @time_entry)update_via_turbo_stream(component: form_component, status: :bad_request)@@ -95,9 +108,7 @@ class TimeEntriesController < ApplicationController@time_entry = call.result- if call.success?- # TODO: just close here?- else+ unless call.success?form_component = TimeEntries::TimeEntryFormComponent.new(time_entry: @time_entry)update_via_turbo_stream(component: form_component, status: :bad_request)diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rbindex 451daa5b046..6e8716ce941 100644--- a/modules/costs/config/routes.rb+++ b/modules/costs/config/routes.rb@@ -30,7 +30,7 @@ Rails.application.routes.draw doresources :time_entries, only: %i[create update] doget :dialog, on: :collectionget "/users/:user_id/tz_caption", action: :user_tz_caption, on: :collection- get "/work_packages/:work_package_id/time_entry_activities", action: :change_activities_input, on: :collection+ get "/work_packages/:work_package_id/time_entry_activities", action: :time_entry_activities, on: :collectionendscope "projects/:project_id", as: "projects" do