allow empty groups in type form configuration

pull/5461/head
Jens Ulferts 8 years ago
parent be2667812d
commit 2672fb20ae
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 3
      app/models/type/attribute_groups.rb
  2. 4
      frontend/app/components/types/form-configuration/types-form-configuration.controller.ts
  3. 16
      spec/models/type/attribute_groups_spec.rb

@ -92,7 +92,6 @@ module Type::AttributeGroups
groups.each do |_, attributes|
attributes.select! { |attribute| valid_keys.include? attribute }
end
groups.select! { |_,attributes| attributes.any? }
groups.presence || default_attribute_groups
end
@ -163,7 +162,7 @@ module Type::AttributeGroups
def validate_attribute_group_names
seen = Set.new
attribute_groups.each do |group_key,_|
attribute_groups.each do |group_key, _|
errors.add(:attribute_groups, :group_without_name) unless group_key.present?
errors.add(:attribute_groups, :duplicate_group, group: group_key) if seen.add?(group_key).nil?
end

@ -167,9 +167,7 @@ function typesFormConfigurationCtrl(
}
});
if (attrKeys.length > 0) {
newAttrGroups.push([groupKey, attrKeys]);
}
newAttrGroups.push([groupKey, attrKeys]);
});

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
@ -49,11 +50,10 @@ describe ::Type, type: :model do
expect(type.attribute_groups).to eq [['foo', ['date']]]
end
it 'removes groups without attributes' do
it 'keeps groups without attributes' do
type.attribute_groups = [['foo', []], ['bar', ['date']]]
expect(type.attribute_groups).to eq [['bar', ['date']]]
expect(type.attribute_groups).to eq [['foo', []], ['bar', ['date']]]
end
end
describe '#default_attribute_groups' do
@ -167,15 +167,15 @@ describe ::Type, type: :model do
end
describe 'custom fields' do
let!(:custom_field) {
let!(:custom_field) do
FactoryGirl.create(
:work_package_custom_field,
field_format: 'string',
field_format: 'string'
)
}
let(:cf_identifier) {
end
let(:cf_identifier) do
:"custom_field_#{custom_field.id}"
}
end
it 'can be put into attribute groups' do
# Is in inactive group

Loading…
Cancel
Save