-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[#69073] Rework template selector on Project create form #20986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f19a585
Add Inline SVG dependency
myabc 2c3a84d
Implement advanced check, radio form controls
myabc d18e913
[#69073] Rework Template Selector on Create form
myabc fc0df1c
Limit (clamp) UG template description to 3 lines
myabc cc0c239
Pass :current_user explicitly to component
myabc 6f69140
Indent caption, aligning with label text
myabc de219c8
Remove redundant name parameter from radio_button calls in specs (#21…
Copilot 5e7841f
reorder allowed types to put them in order portfolio > program > project
toy 2b134e9
cleanup using tap and memoization Projects::IndexSubHeaderComponent#a…
toy 65b48bd
remove unnecessary usage of Project.workspace_types[:xxx]
toy 6aa6e00
keep workspace type url when selecting template
toy 4cb4ed7
Explicit value for key :project instead of defaulting to it
toy ae50386
Fix bug on calling workspace_icon with the wrong argument, fix specs.
dombesz 5fe87f7
Merge pull request #21062 from opf/new-project-template-selector-fixes
toy e858346
Use the apropriate project, portfolio, program name for the blank pro…
dombesz a4fa97d
Remove unnecessary .html_safe methods.
dombesz c516e42
Remove icon from the template selector
HDinger 79bf18c
Move component specific styles to an own file
HDinger 2d3c093
Merge branch 'dev' into feature/68856-new-project-template-selector
dombesz 7c6ef35
Update specs to use accessible_description from capybara.
dombesz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # 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 Projects | ||
| class TemplateSelectForm < ApplicationForm | ||
| extend Dry::Initializer[undefined: false] | ||
| include OpenProject::TextFormatting | ||
|
|
||
| BLANK_VALUE = "" | ||
| private_constant :BLANK_VALUE | ||
|
|
||
| option :template_id | ||
| option :parent_id, optional: true | ||
| option :workspace_type | ||
| option :current_user, default: -> { User.current } | ||
|
|
||
| delegate :strip_tags, to: :@view_context | ||
|
|
||
| form do |f| | ||
| f.advanced_radio_button_group( | ||
| name: :template_id, | ||
| label: I18n.t("create_project.template_label"), | ||
| scope_name_to_model: false, | ||
| data: { | ||
| action: "change->auto-submit#submit", | ||
| qa_field_name: "use_template" | ||
| } | ||
| ) do |group| | ||
| group.radio_button( | ||
| value: BLANK_VALUE, | ||
| label: blank_template_label, | ||
| id: "template_id_blank", | ||
| caption: blank_template_caption, | ||
| checked: template_id.blank? | ||
| ) | ||
|
|
||
| available_templates.each do |template| | ||
| group.radio_button( | ||
| value: template.id, | ||
| label: template.name, | ||
| caption: format_caption(template.description), | ||
| checked: template.id == template_id | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| f.hidden(name: :parent_id, value: parent_id, scope_name_to_model: false) if parent_id | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def available_templates | ||
| @available_templates ||= Project | ||
| .visible(current_user) | ||
| .active | ||
| .templated | ||
| .order(name: :asc) | ||
| end | ||
|
|
||
| def format_caption(text) | ||
|
myabc marked this conversation as resolved.
|
||
| return I18n.t("create_project.blank_description") if text.blank? | ||
|
|
||
| render(Primer::Beta::Text.new(classes: %w[line-clamp-3 lh-default])) do | ||
| strip_tags(format_text(text)) | ||
| end | ||
| end | ||
|
|
||
| def blank_template_label | ||
| return unless Project.workspace_types.key?(workspace_type) | ||
|
|
||
| I18n.t("create_#{workspace_type}.blank_template.label") | ||
| end | ||
|
|
||
| def blank_template_caption | ||
| return unless Project.workspace_types.key?(workspace_type) | ||
|
|
||
| I18n.t("create_#{workspace_type}.blank_template.description") | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| @for $i from 1 through 6 | ||
| .line-clamp-#{$i} | ||
| @include line-clamp($i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import "advanced_form_group" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.