-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15700 from opf/implementation/54749-create-add-pr…
- Loading branch information
Showing
16 changed files
with
608 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
42 changes: 42 additions & 0 deletions
42
...project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb
This file contains 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,42 @@ | ||
<%= | ||
component_wrapper do | ||
render( | ||
Primer::Alpha::Dialog.new( | ||
id: dialog_id, | ||
title:, | ||
test_selector: dialog_id, | ||
size: :large | ||
) | ||
) do |dialog| | ||
dialog.with_show_button(scheme: :primary) do |button| | ||
button.with_leading_visual_icon(icon: 'op-include-projects') | ||
show_button_text | ||
end | ||
|
||
dialog.with_header( | ||
show_divider: false, | ||
visually_hide_title: false | ||
) | ||
|
||
primer_form_with( | ||
class: "op-new-project-mapping-form", | ||
model: @project_mapping, | ||
url: link_admin_settings_project_custom_field_path(@project_custom_field), | ||
data: { turbo: true }, | ||
method: :post | ||
) do |form| | ||
concat(render(Primer::Alpha::Dialog::Body.new( | ||
id: dialog_body_id, test_selector: dialog_body_id, aria: { label: title }, | ||
style: "min-height: 300px" | ||
)) do | ||
render(Projects::CustomFields::CustomFieldMappingForm.new(form, project_custom_field: @project_custom_field)) | ||
end) | ||
|
||
concat(render(Primer::Alpha::Dialog::Footer.new(show_divider: false)) do | ||
concat(render(Primer::ButtonComponent.new(data: { 'close-dialog-id': dialog_id })) { cancel_button_text }) | ||
concat(render(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) { submit_button_text }) | ||
end) | ||
end | ||
end | ||
end | ||
%> |
68 changes: 68 additions & 0 deletions
68
...tings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.rb
This file contains 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,68 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2023 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 ProjectCustomFields | ||
module ProjectCustomFieldMapping | ||
class NewProjectMappingComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent | ||
include OpTurbo::Streamable | ||
|
||
options dialog_id: "settings--new-project-custom-field-mapping-component", | ||
dialog_body_id: "settings--new-project-custom-field-mapping-body-component" | ||
|
||
def initialize(project_mapping:, project_custom_field:, **) | ||
@project_mapping = project_mapping | ||
@project_custom_field = project_custom_field | ||
super(@project_mapping, **) | ||
end | ||
|
||
def render? | ||
!@project_custom_field.required? | ||
end | ||
|
||
private | ||
|
||
def title | ||
I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.add_projects") | ||
end | ||
|
||
def show_button_text | ||
I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.add_projects") | ||
end | ||
|
||
def cancel_button_text | ||
I18n.t("button_cancel") | ||
end | ||
|
||
def submit_button_text | ||
I18n.t("button_add") | ||
end | ||
end | ||
end | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
...ngs/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.sass
This file contains 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,8 @@ | ||
@import 'helpers' | ||
|
||
.op-new-project-mapping-form | ||
.ng-placeholder | ||
@extend .icon-search | ||
&:before | ||
@include icon-font-common | ||
margin-right: 10px |
This file contains 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 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
69 changes: 69 additions & 0 deletions
69
app/forms/projects/custom_fields/custom_field_mapping_form.rb
This file contains 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,69 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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::CustomFields | ||
class CustomFieldMappingForm < ApplicationForm | ||
form do |f| | ||
f.group(layout: :horizontal) do |f_group| | ||
f_group.project_autocompleter( | ||
name: :id, | ||
label: Project.model_name.human, | ||
visually_hide_label: true, | ||
autocomplete_options: { | ||
openDirectly: false, | ||
focusDirectly: false, | ||
dropdownPosition: "bottom", | ||
disabledProjects: projects_with_custom_field_mapping, | ||
inputName: "project_custom_field_project_mapping[project_id]" | ||
} | ||
) | ||
|
||
f_group.check_box( | ||
name: :include_sub_projects, | ||
label: I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.include_sub_projects"), | ||
checked: false, | ||
label_arguments: { class: "no-wrap" } | ||
) | ||
end | ||
end | ||
|
||
def initialize(project_custom_field:) | ||
super() | ||
@project_custom_field = project_custom_field | ||
end | ||
|
||
private | ||
|
||
def projects_with_custom_field_mapping | ||
ProjectCustomFieldProjectMapping | ||
.where(project_custom_field: @project_custom_field) | ||
.pluck(:project_id) | ||
.to_h { |id| [id, id] } | ||
end | ||
end | ||
end |
This file contains 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
Oops, something went wrong.