Skip to content

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

Hide "allowed options" section for User CF

Henriette Darge5dc11b869c5d
diff --git a/frontend/src/stimulus/controllers/dynamic/admin/custom-fields.controller.ts b/frontend/src/stimulus/controllers/dynamic/admin/custom-fields.controller.ts
index fad3b6c613d..fbb4d74b139 100644
--- a/frontend/src/stimulus/controllers/dynamic/admin/custom-fields.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/admin/custom-fields.controller.ts
@@ -304,6 +304,7 @@ export default class CustomFieldsController extends Controller {
this.unsearchable();
break;
case 'user':
+ this.activate(this.possibleValuesTargets, false);
this.show(...this.multiSelectTargets);
this.activate(this.multiSelectTargets);
this.hide(...this.lengthTargets, ...this.regexpTargets, ...this.defaultValueTargets);
diff --git a/spec/features/admin/custom_fields/user_custom_field_spec.rb b/spec/features/admin/custom_fields/user_custom_field_spec.rb
new file mode 100644
index 00000000000..e2e513c15ce
--- /dev/null
+++ b/spec/features/admin/custom_fields/user_custom_field_spec.rb
@@ -0,0 +1,71 @@
+#-- 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.
+#++
+
+require 'spec_helper'
+
+RSpec.describe 'User custom fields edit',
+ js: true,
+ with_cuprite: true do
+ shared_let(:admin) { create(:admin) }
+ let(:cf_page) { Pages::CustomFields.new }
+
+ before do
+ login_as(admin)
+ visit custom_fields_path
+ end
+
+ it 'can create and edit user custom fields (#48725)' do
+ # Create CF
+ click_link 'Create a new custom field'
+
+ wait_for_reload
+
+ fill_in 'custom_field_name', with: 'My User CF'
+ select 'User', from: 'custom_field_field_format'
+
+ expect(page).not_to have_field('custom_field_custom_options_attributes_0_value')
+
+ click_on 'Save'
+
+ # Expect field to be created
+ cf = CustomField.last
+ expect(cf.name).to eq('My User CF')
+
+ # Edit again
+ find('a', text: 'My User CF').click
+
+ expect(page).not_to have_field('custom_field_custom_options_attributes_0_value')
+ fill_in 'custom_field_name', with: 'My User CF (edited)'
+
+ click_on 'Save'
+
+ # Expect field to be saved
+ cf = CustomField.last
+ expect(cf.name).to eq('My User CF (edited)')
+ end
+end