Skip to content
Snippets Groups Projects
Commit 8e112b7c authored by Arnaud Levy's avatar Arnaud Levy
Browse files

climate

parent bba015e0
No related branches found
No related tags found
No related merge requests found
......@@ -8,15 +8,7 @@ module Communication::Block::Template::Base::WithData
next unless json.has_key? component.property
component.data = json[component.property]
end
return unless has_element_class? # Template is not supposed to have elements at all
return unless json.has_key?('elements') # Template has no element yet
# Objects are initialized from the database,
# then data from the form replaces data from the db.
# We need to reset elements, otherwise it's never deleted.
@elements = []
json['elements'].each do |json|
@elements << default_element(json)
end
initialize_elements json
end
# Reads the data from the components
......@@ -64,6 +56,18 @@ module Communication::Block::Template::Base::WithData
!self.class.element_class.nil?
end
def initialize_elements(json)
return unless has_element_class? # Template is not supposed to have elements at all
return unless json.has_key?('elements') # Template has no element yet
# Objects are initialized from the database,
# then data from the form replaces data from the db.
# We need to reset elements, otherwise it's never deleted.
@elements = []
json['elements'].each do |json|
@elements << default_element(json)
end
end
def json_from(value)
if value.is_a? String
JSON.parse(value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment