From 799692d59005340f520732e27c8c3cb8238f83a1 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Wed, 11 Dec 2024 13:44:10 +0100 Subject: [PATCH] wip index --- .../index_component.html.erb | 87 +++++++++++++++++++ .../index_component.rb | 48 ++++++++++ .../row_component.html.erb | 48 ++++++++++ .../row_component.rb | 39 +++++++++ ..._life_cycle_step_definitions_controller.rb | 7 ++ .../index.html.erb | 1 + config/locales/en.yml | 4 + 7 files changed, 234 insertions(+) create mode 100644 app/components/settings/project_life_cycle_step_definitions/index_component.html.erb create mode 100644 app/components/settings/project_life_cycle_step_definitions/index_component.rb create mode 100644 app/components/settings/project_life_cycle_step_definitions/row_component.html.erb create mode 100644 app/components/settings/project_life_cycle_step_definitions/row_component.rb diff --git a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb new file mode 100644 index 000000000000..e86855649e38 --- /dev/null +++ b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb @@ -0,0 +1,87 @@ +<%#-- 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. + +++#%> + +<%= + flex_layout(data: wrapper_data_attributes) do |flex| + flex.with_row do + render(Primer::OpenProject::SubHeader.new) do |subheader| + subheader.with_filter_input( + name: "border-box-filter", + label: t("settings.project_life_cycle_step_definitions.filter.label"), + visually_hide_label: true, + placeholder: t("settings.project_life_cycle_step_definitions.filter.label"), + leading_visual: { + icon: :search, + size: :small + }, + show_clear_button: true, + data: { + action: "input->projects--settings--border-box-filter#filterLists", + "projects--settings--border-box-filter-target": "filter" + } + ) + end + end + + flex.with_row do + render(border_box_container(mb: 3)) do |component| + component.with_header(font_weight: :bold, py: 2) do + flex_layout(justify_content: :space_between, align_items: :center) do |header_container| + header_container.with_column do + render(Primer::Beta::Text.new(font_weight: :bold)) do + I18n.t("settings.project_life_cycle_step_definitions.section_header") + end + end + end + end + if definitions.empty? + component.with_row do + render(Primer::Beta::Text.new(color: :subtle)) { t("settings.project_life_cycle_step_definitions.non_defined") } + end + else + definitions.each do |definition| + component.with_row(data: { "projects--settings--border-box-filter-target": "searchItem" }) do + render(Settings::ProjectLifeCycleStepDefinitions::RowComponent.new(definition)) + end + end + end + end + end + flex.with_row do + render Primer::Beta::Text.new( + display: :none, + data: { + "projects--settings--border-box-filter-target": "noResultsText", + } + ) do + I18n.t("js.autocompleter.notFoundText") + end + end + end +%> diff --git a/app/components/settings/project_life_cycle_step_definitions/index_component.rb b/app/components/settings/project_life_cycle_step_definitions/index_component.rb new file mode 100644 index 000000000000..aea68cdca81e --- /dev/null +++ b/app/components/settings/project_life_cycle_step_definitions/index_component.rb @@ -0,0 +1,48 @@ +#-- 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 Settings + module ProjectLifeCycleStepDefinitions + class IndexComponent < ApplicationComponent + include ApplicationHelper + include OpPrimer::ComponentHelpers + include OpTurbo::Streamable + + options :definitions + + private + + def wrapper_data_attributes + { + controller: "projects--settings--border-box-filter", + "application-target": "dynamic" + } + end + end + end +end diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb new file mode 100644 index 000000000000..711efabbe011 --- /dev/null +++ b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb @@ -0,0 +1,48 @@ +<%#-- 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. + +++#%> + +<%= + flex_layout(align_items: :center, + justify_content: :space_between) do |step_container| + step_container.with_column(flex_layout: true) do |title_container| + title_container.with_column(pt: 1, mr: 3) do + render(Primer::Beta::Link.new( + classes: 'filter-target-visible-text', + href: edit_admin_settings_project_life_cycle_step_definition_path(definition), + font_weight: :bold + )) do + definition.name + end + end + title_container.with_column(pt: 1) do + render(Projects::LifeCycleTypeComponent.new(definition)) + end + end + end +%> diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.rb b/app/components/settings/project_life_cycle_step_definitions/row_component.rb new file mode 100644 index 000000000000..19c88cafc88c --- /dev/null +++ b/app/components/settings/project_life_cycle_step_definitions/row_component.rb @@ -0,0 +1,39 @@ +#-- 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 Settings + module ProjectLifeCycleStepDefinitions + class RowComponent < ApplicationComponent + include ApplicationHelper + include OpPrimer::ComponentHelpers + include OpTurbo::Streamable + + alias_method :definition, :model + end + end +end diff --git a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb index 1d7360c20fb9..584804e477ad 100644 --- a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb +++ b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb @@ -32,8 +32,11 @@ class ProjectLifeCycleStepDefinitionsController < ::Admin::SettingsController before_action :check_feature_flag + before_action :find_definitions, only: %i[index] before_action :find_definition, only: %i[edit update] + def index; end + def new_stage @definition = Project::StageDefinition.new @@ -76,6 +79,10 @@ def check_feature_flag render_404 unless OpenProject::FeatureDecisions.stages_and_gates_active? end + def find_definitions + @definitions = Project::LifeCycleStepDefinition.all + end + def find_definition @definition = Project::LifeCycleStepDefinition.find(params[:id]) end diff --git a/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb b/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb index 246406272120..cf8877a719e5 100644 --- a/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb +++ b/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb @@ -30,3 +30,4 @@ See COPYRIGHT and LICENSE files for more details. <% html_title t(:label_administration), t("settings.project_life_cycle_step_definitions.heading") %> <%= render Settings::ProjectLifeCycleStepDefinitions::IndexHeaderComponent.new %> +<%= render Settings::ProjectLifeCycleStepDefinitions::IndexComponent.new(definitions: @definitions) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e238cacadb3b..1d50ec75ce68 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3707,6 +3707,10 @@ en: label_add_description: "Add lifecycle definition" label_add_stage: "Stage" label_add_gate: "Gate" + filter: + label: "Search project stage or gate" + section_header: "Stages and gates" + non_defined: "Neither stages nor gates are currently defined." new: description: "Changes to this project step will be reflected in all projects where it is enabled." new_stage: