-
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 #16627 from opf/implementation/57579-define-add-pr…
…ojects-dialog-for-multi-project-activation Implementation/57579 define custom fields add projects dialog for multi project activation
- Loading branch information
Showing
23 changed files
with
834 additions
and
161 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
70 changes: 70 additions & 0 deletions
70
...min/custom_fields/custom_field_projects/new_custom_field_projects_form_modal_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,70 @@ | ||
#-- 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 Admin | ||
module CustomFields | ||
module CustomFieldProjects | ||
class NewCustomFieldProjectsFormModalComponent < ApplicationComponent | ||
include OpTurbo::Streamable | ||
|
||
DIALOG_ID = "new-custom-field-projects-modal".freeze | ||
DIALOG_BODY_ID = "new-custom-field-projects-modal-body".freeze | ||
|
||
def initialize(custom_field_project_mapping:, custom_field:, **) | ||
@custom_field_project_mapping = custom_field_project_mapping | ||
@custom_field = custom_field | ||
|
||
super(@custom_field_project_mapping, **) | ||
end | ||
|
||
private | ||
|
||
def url | ||
url_helpers.custom_field_projects_path(@custom_field) | ||
end | ||
|
||
def dialog_id = DIALOG_ID | ||
def dialog_body_id = DIALOG_BODY_ID | ||
|
||
attr_reader :custom_field_project_mapping, :custom_field | ||
|
||
def title | ||
I18n.t(:label_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 |
18 changes: 18 additions & 0 deletions
18
...in/custom_fields/custom_field_projects/new_custom_field_projects_modal_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,18 @@ | ||
<%= | ||
render( | ||
Primer::Alpha::Dialog.new( | ||
id: dialog_id, | ||
title:, | ||
test_selector: dialog_id, | ||
size: :large | ||
) | ||
) do |dialog| | ||
dialog.with_header( | ||
show_divider: false, | ||
visually_hide_title: false, | ||
variant: :large | ||
) | ||
|
||
render(form_modal_component) | ||
end | ||
%> |
64 changes: 64 additions & 0 deletions
64
...ts/admin/custom_fields/custom_field_projects/new_custom_field_projects_modal_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,64 @@ | ||
#-- 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 Admin | ||
module CustomFields | ||
module CustomFieldProjects | ||
class NewCustomFieldProjectsModalComponent < ApplicationComponent | ||
include OpTurbo::Streamable | ||
|
||
def initialize(custom_field_project_mapping:, custom_field:, **) | ||
@custom_field_project_mapping = custom_field_project_mapping | ||
@custom_field = custom_field | ||
super(@custom_field_project_mapping, **) | ||
end | ||
|
||
def render? | ||
!custom_field.is_for_all? | ||
end | ||
|
||
private | ||
|
||
attr_reader :custom_field_project_mapping, :custom_field | ||
|
||
def dialog_id = NewCustomFieldProjectsFormModalComponent::DIALOG_ID | ||
def dialog_body_id = NewCustomFieldProjectsFormModalComponent::DIALOG_BODY_ID | ||
|
||
def title | ||
I18n.t(:label_add_projects) | ||
end | ||
|
||
def form_modal_component | ||
Admin::CustomFields::CustomFieldProjects::NewCustomFieldProjectsFormModalComponent.new( | ||
custom_field_project_mapping:, custom_field: | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
18 changes: 0 additions & 18 deletions
18
...project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb
This file was deleted.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
app/contracts/custom_fields/custom_field_projects/base_contract.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,52 @@ | ||
#-- 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 CustomFields | ||
module CustomFieldProjects | ||
class BaseContract < ::ModelContract | ||
attribute :project_id | ||
attribute :custom_field_id | ||
|
||
validate :select_custom_fields_permission | ||
validate :not_for_all | ||
|
||
def select_custom_fields_permission | ||
return if user.allowed_in_project?(:select_custom_fields, model.project) | ||
|
||
errors.add :base, :error_unauthorized | ||
end | ||
|
||
def not_for_all | ||
# Only mappings of custom fields which are not enabled for all projects can be manipulated by the user | ||
return if model.custom_field.nil? || !model.custom_field.is_for_all? | ||
|
||
errors.add :custom_field_id, :is_for_all_cannot_modify | ||
end | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
app/contracts/custom_fields/custom_field_projects/update_contract.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,34 @@ | ||
#-- 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 CustomFields | ||
module CustomFieldProjects | ||
class UpdateContract < BaseContract | ||
end | ||
end | ||
end |
Oops, something went wrong.