OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#55299] Project attributes: Fix phrasing of "required" and "visible" options
Dombi Attiladb2a0af498d7
diff --git a/app/models/project_custom_field.rb b/app/models/project_custom_field.rbindex bad5d57e5c9..df4c67428ff 100644--- a/app/models/project_custom_field.rb+++ b/app/models/project_custom_field.rb@@ -43,9 +43,9 @@ class ProjectCustomField < CustomFieldif user.admin?allelsif user.allowed_in_any_project?(:select_project_custom_fields) || user.allowed_globally?(:add_project)- where(visible: true)+ where(admin_only: false)else- where(visible: true).where(mappings_with_view_project_attributes_permission(user, project).exists)+ where(admin_only: false).where(mappings_with_view_project_attributes_permission(user, project).exists)endenddiff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erbindex 1ad88132a6c..6372aff3fc2 100644--- a/app/views/custom_fields/_form.html.erb+++ b/app/views/custom_fields/_form.html.erb@@ -192,9 +192,9 @@ See COPYRIGHT and LICENSE files for more details.</div></div><div class="form--field">- <%= f.check_box :visible %>+ <%= f.check_box :admin_only %><div class="form--field-instructions">- <p><%= t('custom_fields.instructions.visible') %></p>+ <p><%= t('custom_fields.instructions.admin_only') %></p></div></div><div class="form--field">@@ -211,9 +211,9 @@ See COPYRIGHT and LICENSE files for more details.</div></div><div class="form--field">- <%= f.check_box :visible %>+ <%= f.check_box :admin_only %><div class="form--field-instructions">- <p><%= t('custom_fields.instructions.visible') %></p>+ <p><%= t('custom_fields.instructions.admin_only') %></p></div></div><div class="form--field" <%= format_dependent.attributes(:searchable) %>>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex d1d6884fe85..886dcf57174 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -235,11 +235,11 @@ en:reorder_alphabetical: "Reorder values alphabetically"reorder_confirmation: "Warning: The current order of available values will be lost. Continue?"instructions:- is_required: "Mark the custom field as required. This will make it mandatory to fill in the field when creating new or updating existing resources."+ is_required: "Check to enable this attribute and make it required in all projects. It cannot be deactived for individual projects."is_for_all: "Mark the custom field as available in all existing and new projects."- searchable: "Include the field values when using the global search functionality."+ searchable: "Check to make this attribute available as a filter in project lists."editable: "Allow the field to be editable by users themselves."- visible: "Make field visible for all users (non-admins) in the project overview and displayed in the project details widget on the Project Overview."+ admin_only: "Check to make this attribute only visible to administrators. Users without admin rights will not be able to view or edit it."is_filter: >Allow the custom field to be used in a filter in work package views.Note that only with 'For all projects' selected, the custom field will show up in global views.@@ -684,14 +684,14 @@ en:editable: "Editable"field_format: "Format"is_filter: "Used as a filter"- is_required: "Required"+ is_required: "Required for all projects"max_length: "Maximum length"min_length: "Minimum length"multi_value: "Allow multi-select"possible_values: "Possible values"regexp: "Regular expression"searchable: "Searchable"- visible: "Visible"+ admin_only: "Admin-only"custom_value:value: "Value"doorkeeper/application:diff --git a/db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rb b/db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rbnew file mode 100644index 00000000000..ca00f1180eb--- /dev/null+++ b/db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rb@@ -0,0 +1,40 @@+#-- 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.+#++++require_relative "migration_utils/utils"++class RenameVisibleToAdminOnlyInCustomFields < ActiveRecord::Migration[7.1]+ include ::Migration::Utils++ def change+ rename_column :custom_fields, :visible, :admin_only+ change_column_default :custom_fields, :admin_only, from: true, to: false++ execute_sql("UPDATE custom_fields SET admin_only = NOT admin_only")+ end+enddiff --git a/spec/factories/custom_field_factory.rb b/spec/factories/custom_field_factory.rbindex 36b8e3122da..4ce3ad45948 100644--- a/spec/factories/custom_field_factory.rb+++ b/spec/factories/custom_field_factory.rb@@ -49,7 +49,7 @@ FactoryBot.define domax_length { false }editable { true }possible_values { "" }- visible { true }+ admin_only { false }field_format { "bool" }after(:create) dodiff --git a/spec/migrations/rename_visible_to_admin_only_in_custom_fields_spec.rb b/spec/migrations/rename_visible_to_admin_only_in_custom_fields_spec.rbnew file mode 100644index 00000000000..50035e0d7fa--- /dev/null+++ b/spec/migrations/rename_visible_to_admin_only_in_custom_fields_spec.rb@@ -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.+#++++require "spec_helper"+require Rails.root.join("db/migrate/20240805104004_rename_visible_to_admin_only_in_custom_fields.rb")++RSpec.describe RenameVisibleToAdminOnlyInCustomFields, type: :model do+ after do+ # Reset after each spec to ensure we have the column information up to date.+ ProjectCustomField.reset_column_information+ end++ context "when migrating up" do+ # Roll back the migration so we can migrate up+ before do+ ActiveRecord::Migration.suppress_messages { described_class.new.migrate(:down) }+ end++ # Silencing migration logs, since we are not interested in that during testing+ subject { ActiveRecord::Migration.suppress_messages { described_class.new.migrate(:up) } }++ it "changes the visible field to admin_only and flips the value" do+ ProjectCustomField.new(visible: false).save(validate: false)++ expect { subject }+ .to change { CustomField.first.attributes.slice("visible", "admin_only") }+ .from("visible" => false)+ .to("admin_only" => true)+ end+ end++ context "when migrating down" do+ subject { ActiveRecord::Migration.suppress_messages { described_class.new.migrate(:down) } }++ it "rolls back the admin_only field to visible and flips the value" do+ ProjectCustomField.new(admin_only: false).save(validate: false)++ expect { subject }+ .to change { CustomField.first.attributes.slice("visible", "admin_only") }+ .from("admin_only" => false)+ .to("visible" => true)+ end+ end+end