mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
@@ -31,7 +31,6 @@
|
||||
module Portfolios
|
||||
class IndexPageHeaderComponent < ApplicationComponent
|
||||
include OpPrimer::ComponentHelpers
|
||||
include Primer::FetchOrFallbackHelper
|
||||
include OpTurbo::Streamable
|
||||
|
||||
attr_accessor :current_user,
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
href: new_portfolio_path,
|
||||
scheme: :primary,
|
||||
leading_icon: :plus,
|
||||
label: new_portfolio_label,
|
||||
label: t(:label_portfolio),
|
||||
disabled: @disable_buttons,
|
||||
size: :medium,
|
||||
data: { "test-selector": "portfolio-new-button" }
|
||||
) do
|
||||
new_portfolio_label
|
||||
t(:label_portfolio)
|
||||
end
|
||||
|
||||
subheader.with_bottom_pane_component(mt: 0) do
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
# ++
|
||||
|
||||
module Portfolios
|
||||
# rubocop:disable OpenProject/AddPreviewForViewComponent
|
||||
class IndexSubHeaderComponent < ApplicationComponent
|
||||
# rubocop:enable OpenProject/AddPreviewForViewComponent
|
||||
include ApplicationHelper
|
||||
include OpTurbo::Streamable
|
||||
|
||||
@@ -70,9 +68,5 @@ module Portfolios
|
||||
def clear_button_id
|
||||
"portfolio-filters-form-clear-button"
|
||||
end
|
||||
|
||||
def new_portfolio_label
|
||||
I18n.t(:label_portfolio)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
"aria-label": "TODO",
|
||||
mr: 1
|
||||
)
|
||||
) + content_tag(:span, program_count_label)
|
||||
) + content_tag(:span, t("program.count", count: all_subprograms.count))
|
||||
end
|
||||
|
||||
footer.with_column(mr: 3) do
|
||||
@@ -63,7 +63,7 @@
|
||||
"aria-label": "TODO",
|
||||
mr: 1
|
||||
)
|
||||
) + content_tag(:span, project_count_label)
|
||||
) + content_tag(:span, t("project.count", count: all_subprojects.count))
|
||||
end
|
||||
|
||||
# TODO: WP-68872 render budget
|
||||
@@ -75,7 +75,7 @@
|
||||
# "aria-label": "TODO",
|
||||
# mr: 1
|
||||
# )
|
||||
# ) + content_tag(:span, budget_label)
|
||||
# ) + content_tag(:span, "34,000 EUR budget - 12,000 EUR spent")
|
||||
# end
|
||||
|
||||
footer.with_column do
|
||||
@@ -85,7 +85,7 @@
|
||||
data: { test_selector: "op-portfolios--updated-at" }
|
||||
)
|
||||
) do
|
||||
updated_at_label
|
||||
t(:label_updated_time, value: distance_of_time_in_words(Time.current, portfolio.updated_at))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,21 +46,12 @@ module Portfolios
|
||||
@currently_favorited ||= favorited_project_ids.include?(portfolio.id)
|
||||
end
|
||||
|
||||
def program_count_label
|
||||
I18n.t("program.count", count: all_subprograms.count)
|
||||
def all_subprograms
|
||||
all_descendants.filter { it.workspace_type == "program" }
|
||||
end
|
||||
|
||||
def project_count_label
|
||||
I18n.t("project.count", count: all_subprojects.count)
|
||||
end
|
||||
|
||||
def budget_label
|
||||
# TODO: WP-68872 replace dummy text
|
||||
"34,000 EUR budget - 12,000 EUR spent"
|
||||
end
|
||||
|
||||
def updated_at_label
|
||||
I18n.t(:label_updated_time, value: distance_of_time_in_words(Time.current, portfolio.updated_at))
|
||||
def all_subprojects
|
||||
all_descendants.filter { it.workspace_type == "project" }
|
||||
end
|
||||
|
||||
private
|
||||
@@ -84,13 +75,5 @@ module Portfolios
|
||||
|
||||
@descendants
|
||||
end
|
||||
|
||||
def all_subprograms
|
||||
all_descendants.filter { it.workspace_type == "program" }
|
||||
end
|
||||
|
||||
def all_subprojects
|
||||
all_descendants.filter { it.workspace_type == "project" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ module Portfolios
|
||||
@controller_path = controller_path
|
||||
@current_user = current_user
|
||||
|
||||
super(view_type:, project:, params:)
|
||||
super(view_type:, params:, project: nil)
|
||||
end
|
||||
|
||||
def menu_items
|
||||
@@ -64,10 +64,6 @@ module Portfolios
|
||||
end
|
||||
end
|
||||
|
||||
def favorited?(query_params)
|
||||
query_params[:query_id].in?(favorited_ids)
|
||||
end
|
||||
|
||||
def query_path(query_params)
|
||||
portfolios_path(query_params)
|
||||
end
|
||||
@@ -75,12 +71,14 @@ module Portfolios
|
||||
private
|
||||
|
||||
def main_static_filters
|
||||
static_filters [
|
||||
main_filters = [
|
||||
ProjectQueries::Static::ACTIVE_PORTFOLIOS,
|
||||
current_user.logged? ? ProjectQueries::Static::MY_PORTFOLIOS : nil,
|
||||
current_user.logged? ? ProjectQueries::Static::FAVORITED_PORTFOLIOS : nil,
|
||||
current_user.admin? ? ProjectQueries::Static::ARCHIVED_PORTFOLIOS : nil
|
||||
].compact
|
||||
]
|
||||
|
||||
static_filters(main_filters.compact)
|
||||
end
|
||||
|
||||
def static_filters(ids)
|
||||
@@ -89,17 +87,6 @@ module Portfolios
|
||||
end
|
||||
end
|
||||
|
||||
def persisted_filters
|
||||
@persisted_filters ||= ::ProjectQuery
|
||||
.visible(current_user)
|
||||
.with_favorited_by_user(current_user)
|
||||
.order(favorited: :desc, name: :asc)
|
||||
end
|
||||
|
||||
def favorited_ids
|
||||
@favorited_ids ||= persisted_filters.select(&:favorited).to_set(&:id)
|
||||
end
|
||||
|
||||
def modification_params?
|
||||
params.values_at(:filters, :sortBy).any?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user