1
0

Disallowed moving quantity into parent/child relationship if domains differ

Generalized quantity up/down/left/right actions into 'move'
This commit is contained in:
cryptogopher
2019-11-22 22:43:11 +01:00
parent 0820a90897
commit 8c073494e5
5 changed files with 36 additions and 58 deletions

View File

@@ -23,6 +23,22 @@ class Quantity < ActiveRecord::Base
end
end
def movable?(direction)
case direction
when :up
self.left_sibling.present?
when :down
self.right_sibling.present?
when :left
self.parent.present?
when :right
left = self.left_sibling
left.present? && (left.domain == self.domain)
else
false
end
end
def toggle_primary!
self.toggle!(:primary)
end