gem 'jquery-ui-rails'
# To use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.0.0'
+gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
end
def remove au
- d = false
- ground_colors_attributes = {}
- self.panel.ground_colors.each do |ground_color|
- attr = ground_color.attributes
- if ground_color == self
- attr['_destroy'] = true
- d = true
- else
- if d
- attr['t'] -= 1
- end
- end
- ground_colors_attributes[ground_color.id] = attr
- end
- self.panel.attributes = {:ground_colors_attributes => ground_colors_attributes}
- self.panel.store({}, au)
+ self.panel.remove_element(self, au)
end
def scenario
end
def remove au
- d = false
- ground_pictures_attributes = {}
- self.panel.ground_pictures.each do |ground_picture|
- attr = ground_picture.attributes
- if ground_picture == self
- attr['_destroy'] = true
- d = true
- else
- if d
- # attr['t'] -= 1
- end
- end
- ground_pictures_attributes[ground_picture.id] = attr
- end
- self.panel.attributes = {:ground_pictures_attributes => ground_pictures_attributes}
- self.panel.store({}, au)
+ self.panel.remove_element(self, au)
end
def scenario
res
end
+ def remove_element target, au
+ ct = target.t
+ cz = target.z
+ panel_attributes = {}
+ self.panel_elements.each do |elm|
+ attr = elm.attributes
+ if elm == target
+ attr['_destroy'] = true
+ end
+ if elm.t > ct
+ attr['t'] -= 1
+ end
+ if elm.z > cz
+ attr['z'] -= 1
+ end
+ panel_attributes[elm.class.to_s.tableize + '_attributes'] ||= {}
+ panel_attributes[elm.class.to_s.tableize + '_attributes'][elm.id] = attr
+ end
+ self.store(panel_attributes, au)
+ end
+
def destroy_with_elements
res = false
Panel.transaction do
end
def remove au
- d = false
- panel_pictures_attributes = {}
- self.panel.panel_pictures.each do |panel_picture|
- attr = panel_picture.attributes
- if panel_picture == self
- attr['_destroy'] = true
- d = true
- else
- if d
- attr['t'] -= 1
- end
- end
- panel_pictures_attributes[panel_picture.id] = attr
- end
- self.panel.attributes = {:panel_pictures_attributes => panel_pictures_attributes}
- self.panel.store({}, au)
+ self.panel.remove_element(self, au)
end
def scenario
end
def remove au
- d = false
- speech_balloons_attributes = {}
- self.panel.speech_balloons.each do |speech_balloon|
- attr = speech_balloon.attributes
- if speech_balloon == self
- attr['_destroy'] = true
- d = true
- else
- if d
- attr['t'] -= 1
- end
- end
- speech_balloons_attributes[speech_balloon.id] = attr
- end
- self.panel.attributes = {:speech_balloons_attributes => speech_balloons_attributes}
- self.panel.store({}, au)
+ self.panel.remove_element(self, au)
end
def scenario