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

Add a stub for the dialog

Klaus Zanders9b1edc64c373
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
new file mode 100644
index 00000000000..81c48c76136
--- /dev/null
+++ b/modules/costs/app/components/time_entries/entry_dialog_component.html.erb
@@ -0,0 +1,6 @@
+<%= render(Primer::Alpha::Dialog.new(title: 'Log Time', size: :large, id: MODAL_ID)) do |d| %>
+ <% d.with_header(variant: :large, mb: 3) %>
+ <%= d.with_body do %>
+ <h1>Hello, World!</h1>
+ <% end %>
+<% end %>
diff --git a/modules/costs/app/components/time_entries/entry_dialog_component.rb b/modules/costs/app/components/time_entries/entry_dialog_component.rb
new file mode 100644
index 00000000000..d35afcd7c98
--- /dev/null
+++ b/modules/costs/app/components/time_entries/entry_dialog_component.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+# -- 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.
+# ++
+
+module TimeEntries
+ class EntryDialogComponent < ApplicationComponent
+ include OpTurbo::Streamable
+
+ MODAL_ID = "time-entry-dialog"
+
+ def initialize(time_entry:, open: false)
+ super()
+ @time_entry = time_entry
+ @open = open
+ end
+
+ private
+
+ attr_reader :time_entry, :open
+ end
+end
diff --git a/modules/costs/app/controllers/projects/time_entries_controller.rb b/modules/costs/app/controllers/projects/time_entries_controller.rb
index dc696494dd0..8eff458e2e2 100644
--- a/modules/costs/app/controllers/projects/time_entries_controller.rb
+++ b/modules/costs/app/controllers/projects/time_entries_controller.rb
@@ -28,10 +28,22 @@
module Projects
class TimeEntriesController < ApplicationController
+ include OpTurbo::ComponentStream
+ include OpTurbo::DialogStreamHelper
+
before_action :require_login
- before_action :load_and_authorize_in_optional_project
+ before_action :find_project_by_project_id
+
+ authorization_checked! :dialog, :create, :update
- def dialog; end
+ def dialog
+ @time_entry = if params[:time_entry_id]
+ # TODO: Properly handle authorization
+ TimeEntry.find_by(id: params[:time_entry_id])
+ else
+ TimeEntry.new(project: @project)
+ end
+ end
def create; end
diff --git a/modules/costs/app/views/projects/time_entries/dialog.turbo_stream.erb b/modules/costs/app/views/projects/time_entries/dialog.turbo_stream.erb
new file mode 100644
index 00000000000..d3773dd67c9
--- /dev/null
+++ b/modules/costs/app/views/projects/time_entries/dialog.turbo_stream.erb
@@ -0,0 +1,3 @@
+<%= turbo_stream.dialog do
+ render(TimeEntries::EntryDialogComponent.new(time_entry: @entry))
+end %>
diff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rb
index ad24189bd33..07ff015f75e 100644
--- a/modules/costs/config/routes.rb
+++ b/modules/costs/config/routes.rb
@@ -33,10 +33,6 @@ Rails.application.routes.draw do
resources :hourly_rates, only: %i[show edit update] do
post :set_rate, on: :member
end
-
- resources :time_entries, only: %i[create update] do
- get :dialog, on: :collection
- end
end
scope "my" do
@@ -47,6 +43,10 @@ Rails.application.routes.draw do
namespace "settings" do
resource :time_entry_activities, only: %i[show update]
end
+
+ resources :time_entries, only: %i[create update] do
+ get :dialog, on: :collection
+ end
end
scope "work_packages/:work_package_id", as: "work_packages" do