Skip to content

No way to un-set group_by in content_types #1418

@greyskin

Description

@greyskin

Once group_by is set in a content_type definition file and deployed to Engine, there is no way to un-set it and remove the grouping. One would think that one of the following:

  • group_by: ''
  • group_by: nil
  • # group_by: (commented out)

...would achieve this, but from examination of the snippet referenced above, it becomes clear that in fact the code doesn't allow for it.

My understanding of the snippet from engine/app/models/lcoomotive/concerns/content_type/default_values.rb is as follows:

def set_group_by

    if @group_by
    # If @group_by (the field name from YAML) has a value (is not nil or false)...

        if field = self.find_entries_custom_field(@group_by)
        # ...try to find the actual field object using the name stored in @group_by

            self.group_by_field_id = field._id
            # If a field is found, its _id is assigned to self.group_by_field_id.
            # self.group_by_field_id is the attribute that's actually saved to the database
            # and used by the GroupBy concern to determine the grouping.

        end
        # ELSE (if field is NOT found, e.g., a typo in YAML or invalid field name),
        # In this case, self.group_by_field_id is NOT changed. It keeps its existing value.

    end
    # ELSE (if @group_by is nil or blank, e.g., group_by line commented out),
    # In this case, the entire 'if @group_by' block is skipped.
    # Again, self.group_by_field_id is NOT changed. It keeps its existing value.

end

The only way at present to unset group_by on a content_type is to delete the content_type (and any related content_types) from Engine and re-deploy. This is troublesome with large databases and shouldn't be necessary.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions