app/models/alchemy/page/page_elements.rb in alchemy_cms-3.4.2 vs app/models/alchemy/page/page_elements.rb in alchemy_cms-3.5.0.rc1

- old
+ new

@@ -22,17 +22,10 @@ join_table: ElementToPage.table_name after_create :autogenerate_elements, unless: -> { systempage? || do_not_autogenerate } after_update :trash_not_allowed_elements!, if: :page_layout_changed? after_update :autogenerate_elements, if: :page_layout_changed? - - after_destroy do - elements.each do |element| - next if element.trashed? - element.destroy - end - end end module ClassMethods # Copy page elements # @@ -146,9 +139,19 @@ # Warning: Since elements can be unique or limited in number, # it is more safe to ask for +available_element_definitions+ # def element_definitions @_element_definitions ||= element_definitions_by_name(element_definition_names) + end + + # All element definitions defined for page's page layout including nestable element definitions + # + def descendent_element_definitions + definitions = element_definitions_by_name(element_definition_names) + definitions.select { |d| d.key?('nestable_elements') }.each do |d| + definitions += element_definitions_by_name(d['nestable_elements']) + end + definitions.uniq { |d| d['name'] } end # All names of elements that are defined in the corresponding # page and cell definition. #