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

reorganise components in overviews module: rename constants

Ivan Kuchin2af3f02058c3
diff --git a/app/forms/projects/life_cycles/form.rb b/app/forms/projects/life_cycles/form.rb
index 52a764f544c..4ab76c6b1e3 100644
--- a/app/forms/projects/life_cycles/form.rb
+++ b/app/forms/projects/life_cycles/form.rb
@@ -42,7 +42,7 @@ module Projects::LifeCycles
label:,
leading_visual: { icon: :calendar },
datepicker_options: {
- inDialog: ProjectLifeCycles::Sections::EditDialogComponent::DIALOG_ID,
+ inDialog: Overviews::ProjectPhases::EditDialogComponent::DIALOG_ID,
data: { action: "change->overview--project-life-cycles-form#previewForm" }
},
wrapper_data_attributes: {
diff --git a/modules/overviews/app/components/_index.sass b/modules/overviews/app/components/_index.sass
index fc1fdcf84e0..3ffde8d69d3 100644
--- a/modules/overviews/app/components/_index.sass
+++ b/modules/overviews/app/components/_index.sass
@@ -1 +1 @@
-@import "./project_custom_fields/sections/project_custom_fields/show_component.sass"
+@import "./overviews/project_custom_fields/item_component.sass"
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/edit_component.rb b/modules/overviews/app/components/overviews/project_custom_fields/edit_component.rb
index ebf29c10644..93f842255f5 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/edit_component.rb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/edit_component.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectCustomFields
- module Sections
+module Overviews
+ module ProjectCustomFields
class EditComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.html.erb b/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.html.erb
index f91bbdc89b2..2ffb36b5c94 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.html.erb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.html.erb
@@ -8,7 +8,7 @@
) do |d|
d.with_header(variant: :large)
d.with_body(classes: "Overlay-body_autocomplete_height") do
- render(::ProjectCustomFields::Sections::EditComponent.new(project_custom_field_section: @project_custom_field_section, project: @project))
+ render(Overviews::ProjectCustomFields::EditComponent.new(project_custom_field_section: @project_custom_field_section, project: @project))
end
d.with_footer do
component_collection do |footer_collection|
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.rb b/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.rb
index 102d7b04746..2702b6d417a 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.rb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/edit_dialog_component.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectCustomFields
- module Sections
+module Overviews
+ module ProjectCustomFields
class EditDialogComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb b/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb
index a8681d715e5..389317a2486 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/item_component.rb
@@ -26,78 +26,76 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectCustomFields
- module Sections
- module ProjectCustomFields
- class ShowComponent < ApplicationComponent
- include ApplicationHelper
- include CustomFieldsHelper
- include OpPrimer::ComponentHelpers
+module Overviews
+ module ProjectCustomFields
+ class ItemComponent < ApplicationComponent
+ include ApplicationHelper
+ include CustomFieldsHelper
+ include OpPrimer::ComponentHelpers
- def initialize(project_custom_field:, project_custom_field_values:)
- super
+ def initialize(project_custom_field:, project_custom_field_values:)
+ super
- @project_custom_field = project_custom_field
- @project_custom_field_values = project_custom_field_values
- end
+ @project_custom_field = project_custom_field
+ @project_custom_field_values = project_custom_field_values
+ end
- private
+ private
- def not_set?
- @project_custom_field_values.empty? || @project_custom_field_values.all? { |cf_value| cf_value.value.blank? }
- end
+ def not_set?
+ @project_custom_field_values.empty? || @project_custom_field_values.all? { |cf_value| cf_value.value.blank? }
+ end
- def render_value
- case @project_custom_field.field_format
- when "link"
- render_link
- when "text"
- render_long_text
- when "user"
- render_user
- else
- render(Primer::Beta::Text.new) do
- @project_custom_field_values&.map do |cf_value|
- format_value(cf_value.value, @project_custom_field)
- end&.join(", ")
- end
+ def render_value
+ case @project_custom_field.field_format
+ when "link"
+ render_link
+ when "text"
+ render_long_text
+ when "user"
+ render_user
+ else
+ render(Primer::Beta::Text.new) do
+ @project_custom_field_values&.map do |cf_value|
+ format_value(cf_value.value, @project_custom_field)
+ end&.join(", ")
end
end
+ end
- def render_long_text
- render OpenProject::Common::AttributeComponent.new("dialog-cf-#{@project_custom_field.id}",
- @project_custom_field.name,
- @project_custom_field_values&.first&.value,
- lines: 3)
- end
+ def render_long_text
+ render OpenProject::Common::AttributeComponent.new("dialog-cf-#{@project_custom_field.id}",
+ @project_custom_field.name,
+ @project_custom_field_values&.first&.value,
+ lines: 3)
+ end
- def render_user
- if @project_custom_field.multi_value?
- flex_layout do |avatar_container|
- @project_custom_field_values&.each do |cf_value|
- avatar_container.with_row do
- render_avatar(cf_value.typed_value)
- end
+ def render_user
+ if @project_custom_field.multi_value?
+ flex_layout do |avatar_container|
+ @project_custom_field_values&.each do |cf_value|
+ avatar_container.with_row do
+ render_avatar(cf_value.typed_value)
end
end
- else
- render_avatar(@project_custom_field_values&.first&.typed_value)
end
+ else
+ render_avatar(@project_custom_field_values&.first&.typed_value)
end
+ end
- def render_avatar(user)
- render(Users::AvatarComponent.new(user:, size: :mini))
- end
+ def render_avatar(user)
+ render(Users::AvatarComponent.new(user:, size: :mini))
+ end
- def render_link
- href = @project_custom_field_values&.first&.value
- link = Addressable::URI.parse(href)
- return href unless link
+ def render_link
+ href = @project_custom_field_values&.first&.value
+ link = Addressable::URI.parse(href)
+ return href unless link
- target = link.host == Setting.host_without_protocol ? "_top" : "_blank"
- render(Primer::Beta::Link.new(href:, rel: "noopener noreferrer", target:)) do
- href
- end
+ target = link.host == Setting.host_without_protocol ? "_top" : "_blank"
+ render(Primer::Beta::Link.new(href:, rel: "noopener noreferrer", target:)) do
+ href
end
end
end
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/show_component.html.erb b/modules/overviews/app/components/overviews/project_custom_fields/show_component.html.erb
index db29d31d191..bdcaadcbde3 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/show_component.html.erb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/show_component.html.erb
@@ -26,7 +26,7 @@
margin = i == @project_custom_fields.size - 1 ? 0 : 3
details_container.with_row(mb: margin) do
render(
- ProjectCustomFields::Sections::ProjectCustomFields::ShowComponent.new(
+ Overviews::ProjectCustomFields::ItemComponent.new(
project_custom_field:,
project_custom_field_values: get_eager_loaded_project_custom_field_values_for(project_custom_field.id)
)
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/show_component.rb b/modules/overviews/app/components/overviews/project_custom_fields/show_component.rb
index 78137a19d77..a3fa01c4858 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/show_component.rb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/show_component.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectCustomFields
- module Sections
+module Overviews
+ module ProjectCustomFields
class ShowComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.html.erb b/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.html.erb
index b6aa482acd6..2eecef3a612 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.html.erb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.html.erb
@@ -9,7 +9,7 @@
) do |panel|
available_project_custom_fields_grouped_by_section.each do |project_custom_field_section, project_custom_fields|
panel.with_section(
- ProjectCustomFields::Sections::ShowComponent.new(
+ Overviews::ProjectCustomFields::ShowComponent.new(
project: @project,
project_custom_field_section:,
project_custom_fields: project_custom_fields
diff --git a/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.rb b/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.rb
index aae4f5f3874..f5c48591dca 100644
--- a/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.rb
+++ b/modules/overviews/app/components/overviews/project_custom_fields/side_panel_component.rb
@@ -26,23 +26,25 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectCustomFields
- class SidePanelComponent < ApplicationComponent
- include ApplicationHelper
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
+module Overviews
+ module ProjectCustomFields
+ class SidePanelComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
- def initialize(project:)
- super
+ def initialize(project:)
+ super
- @project = project
- end
+ @project = project
+ end
- private
+ private
- def available_project_custom_fields_grouped_by_section
- @available_project_custom_fields_grouped_by_section ||=
- @project.available_custom_fields.group_by(&:project_custom_field_section)
+ def available_project_custom_fields_grouped_by_section
+ @available_project_custom_fields_grouped_by_section ||=
+ @project.available_custom_fields.group_by(&:project_custom_field_section)
+ end
end
end
end
diff --git a/modules/overviews/app/components/overviews/project_phases/edit_component.rb b/modules/overviews/app/components/overviews/project_phases/edit_component.rb
index 69e395d772f..3cbcbc67419 100644
--- a/modules/overviews/app/components/overviews/project_phases/edit_component.rb
+++ b/modules/overviews/app/components/overviews/project_phases/edit_component.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectLifeCycles
- module Sections
+module Overviews
+ module ProjectPhases
class EditComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
diff --git a/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.html.erb b/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.html.erb
index ef4016a23f5..4c5725836bd 100644
--- a/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.html.erb
+++ b/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.html.erb
@@ -8,7 +8,7 @@
) do |d|
d.with_header(variant: :large)
d.with_body do
- render(::ProjectLifeCycles::Sections::EditComponent.new(model))
+ render(Overviews::ProjectPhases::EditComponent.new(model))
end
d.with_footer do
component_collection do |footer_collection|
diff --git a/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.rb b/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.rb
index 9d9a248eda1..3e916d9b167 100644
--- a/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.rb
+++ b/modules/overviews/app/components/overviews/project_phases/edit_dialog_component.rb
@@ -28,8 +28,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectLifeCycles
- module Sections
+module Overviews
+ module ProjectPhases
class EditDialogComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
diff --git a/modules/overviews/app/components/overviews/project_phases/item_component.rb b/modules/overviews/app/components/overviews/project_phases/item_component.rb
index d1e6f09be73..f624c05c051 100644
--- a/modules/overviews/app/components/overviews/project_phases/item_component.rb
+++ b/modules/overviews/app/components/overviews/project_phases/item_component.rb
@@ -26,30 +26,28 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectLifeCycles
- module Sections
- module ProjectLifeCycles
- class ShowComponent < ApplicationComponent
- include ApplicationHelper
- include OpPrimer::ComponentHelpers
+module Overviews
+ module ProjectPhases
+ class ItemComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
- private
+ private
- def not_set?
- model.not_set?
- end
+ def not_set?
+ model.not_set?
+ end
- def icon
- :"op-phase"
- end
+ def icon
+ :"op-phase"
+ end
- def icon_color_class
- helpers.hl_inline_class("project_phase_definition", model.definition)
- end
+ def icon_color_class
+ helpers.hl_inline_class("project_phase_definition", model.definition)
+ end
- def text
- model.name
- end
+ def text
+ model.name
end
end
end
diff --git a/modules/overviews/app/components/overviews/project_phases/show_component.html.erb b/modules/overviews/app/components/overviews/project_phases/show_component.html.erb
index 4823da14107..d9cb21711fd 100644
--- a/modules/overviews/app/components/overviews/project_phases/show_component.html.erb
+++ b/modules/overviews/app/components/overviews/project_phases/show_component.html.erb
@@ -26,7 +26,7 @@
margin = i == @life_cycle_steps.size - 1 ? 0 : 3
details_container.with_row(mb: margin) do
render(
- ProjectLifeCycles::Sections::ProjectLifeCycles::ShowComponent.new(
+ Overviews::ProjectPhases::ItemComponent.new(
life_cycle_step
)
)
diff --git a/modules/overviews/app/components/overviews/project_phases/show_component.rb b/modules/overviews/app/components/overviews/project_phases/show_component.rb
index ff8bfff92a1..3f108716931 100644
--- a/modules/overviews/app/components/overviews/project_phases/show_component.rb
+++ b/modules/overviews/app/components/overviews/project_phases/show_component.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectLifeCycles
- module Sections
+module Overviews
+ module ProjectPhases
class ShowComponent < ApplicationComponent
include ApplicationHelper
include OpPrimer::ComponentHelpers
diff --git a/modules/overviews/app/components/overviews/project_phases/side_panel_component.html.erb b/modules/overviews/app/components/overviews/project_phases/side_panel_component.html.erb
index 230767e0bc9..61a3e308f65 100644
--- a/modules/overviews/app/components/overviews/project_phases/side_panel_component.html.erb
+++ b/modules/overviews/app/components/overviews/project_phases/side_panel_component.html.erb
@@ -6,7 +6,7 @@
test_selector: "project-life-cycles-sidebar-async-content"
)
) do |panel|
- panel.with_section(ProjectLifeCycles::Sections::ShowComponent.new(project: @project))
+ panel.with_section(Overviews::ProjectPhases::ShowComponent.new(project: @project))
end
end
%>
diff --git a/modules/overviews/app/components/overviews/project_phases/side_panel_component.rb b/modules/overviews/app/components/overviews/project_phases/side_panel_component.rb
index d837969ffa3..ac93c9c9d5e 100644
--- a/modules/overviews/app/components/overviews/project_phases/side_panel_component.rb
+++ b/modules/overviews/app/components/overviews/project_phases/side_panel_component.rb
@@ -26,16 +26,18 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ProjectLifeCycles
- class SidePanelComponent < ApplicationComponent
- include ApplicationHelper
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
+module Overviews
+ module ProjectPhases
+ class SidePanelComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
- def initialize(project:)
- super
+ def initialize(project:)
+ super
- @project = project
+ @project = project
+ end
end
end
end
diff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rb
index 976d38d23ef..d1a324001cc 100644
--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb
+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb
@@ -46,7 +46,7 @@ module ::Overviews
def project_custom_field_section_dialog
respond_with_dialog(
- ProjectCustomFields::Sections::EditDialogComponent.new(
+ Overviews::ProjectCustomFields::EditDialogComponent.new(
project: @project,
project_custom_field_section: find_project_custom_field_section
)
@@ -82,7 +82,7 @@ module ::Overviews
def project_life_cycles_dialog
respond_with_dialog(
- ProjectLifeCycles::Sections::EditDialogComponent.new(@project)
+ Overviews::ProjectPhases::EditDialogComponent.new(@project)
)
end
@@ -94,7 +94,7 @@ module ::Overviews
.call(permitted_params.project_phases)
update_via_turbo_stream(
- component: ProjectLifeCycles::Sections::EditComponent.new(service_call.result),
+ component: Overviews::ProjectPhases::EditComponent.new(service_call.result),
method: "morph"
)
# TODO: :unprocessable_entity is not nice, change the dialog logic to accept :ok
@@ -109,11 +109,11 @@ module ::Overviews
if service_call.success?
update_via_turbo_stream(
- component: ProjectLifeCycles::SidePanelComponent.new(project: @project)
+ component: Overviews::ProjectPhases::SidePanelComponent.new(project: @project)
)
else
update_via_turbo_stream(
- component: ProjectLifeCycles::Sections::EditComponent.new(service_call.result)
+ component: Overviews::ProjectPhases::EditComponent.new(service_call.result)
)
end
@@ -145,7 +145,7 @@ module ::Overviews
def handle_errors(project_with_errors, section)
update_via_turbo_stream(
- component: ProjectCustomFields::Sections::EditComponent.new(
+ component: Overviews::ProjectCustomFields::EditComponent.new(
project: project_with_errors,
project_custom_field_section: section
)
@@ -154,7 +154,7 @@ module ::Overviews
def update_sidebar_component
update_via_turbo_stream(
- component: ProjectCustomFields::SidePanelComponent.new(project: @project)
+ component: Overviews::ProjectCustomFields::SidePanelComponent.new(project: @project)
)
end
end
diff --git a/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb b/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb
index 63d2b46f856..b04c17adec2 100644
--- a/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb
+++ b/modules/overviews/app/views/overviews/overviews/project_custom_fields_sidebar.html.erb
@@ -27,5 +27,5 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%= content_tag("turbo-frame", id: "project-custom-fields-sidebar") do %>
- <%= render(ProjectCustomFields::SidePanelComponent.new(project: @project)) %>
+ <%= render(Overviews::ProjectCustomFields::SidePanelComponent.new(project: @project)) %>
<% end %>
diff --git a/modules/overviews/app/views/overviews/overviews/project_life_cycles_sidebar.html.erb b/modules/overviews/app/views/overviews/overviews/project_life_cycles_sidebar.html.erb
index 1b05538bb3c..5821f23a127 100644
--- a/modules/overviews/app/views/overviews/overviews/project_life_cycles_sidebar.html.erb
+++ b/modules/overviews/app/views/overviews/overviews/project_life_cycles_sidebar.html.erb
@@ -27,5 +27,5 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%= content_tag("turbo-frame", id: "project-life-cycles-sidebar") do %>
- <%= render(ProjectLifeCycles::SidePanelComponent.new(project: @project)) %>
+ <%= render(Overviews::ProjectPhases::SidePanelComponent.new(project: @project)) %>
<% end %>
diff --git a/spec/support/components/projects/project_life_cycles/edit_dialog.rb b/spec/support/components/projects/project_life_cycles/edit_dialog.rb
index 17db68ba13b..3837cbf17dd 100644
--- a/spec/support/components/projects/project_life_cycles/edit_dialog.rb
+++ b/spec/support/components/projects/project_life_cycles/edit_dialog.rb
@@ -54,7 +54,7 @@ module Components
end
def set_date_for(step, values:)
- dialog_selector = "##{::ProjectLifeCycles::Sections::EditDialogComponent::DIALOG_ID}"
+ dialog_selector = "##{Overviews::ProjectPhases::EditDialogComponent::DIALOG_ID}"
datepicker = Components::RangeDatepicker.new(dialog_selector)