Skip to content

Commit

Permalink
Add resource_actions and picture to service_template copy function.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcculloug committed Jul 16, 2019
1 parent 4c3f832 commit d84fc61
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/service_template/copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def template_copy(new_name = "Copy of " + name + Time.zone.now.to_s)
dup.tap do |template|
template.update_attributes(:name => new_name, :display => false)
service_resources.each { |service_resource| resource_copy(service_resource, template) }
resource_action_copy(template)
picture_copy(template) if picture

direct_custom_buttons.each { |custom_button| custom_button_copy(custom_button, template) }
custom_button_sets.each { |custom_button_set| custom_button_set_copy(custom_button_set, template) }
end.save!
Expand All @@ -26,4 +29,12 @@ def custom_button_copy(custom_button, template)
def custom_button_set_copy(custom_button_set, template)
custom_button_set.deep_copy(:owner => template)
end

def resource_action_copy(template)
template.resource_actions << resource_actions.collect(&:dup)
end

def picture_copy(template)
template.picture = picture.dup
end
end

0 comments on commit d84fc61

Please sign in to comment.