Add section elements
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
module SvgElementDefaults
|
||||
extend ActiveSupport::Concern
|
||||
included do
|
||||
property :svg
|
||||
property :name
|
||||
property :dpm, type: Float, default: 300
|
||||
property :box_width, type: Float, default: 300
|
||||
property :box_height, type: Float, default: 300
|
||||
validates :dpm, numericality: {greater_than: 0}
|
||||
end
|
||||
end
|
||||
@@ -10,6 +10,7 @@ class Section
|
||||
has_many :tables
|
||||
has_many :lists
|
||||
has_many :orders
|
||||
has_many :section_elements
|
||||
|
||||
attr_protected :supplier_id
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class SectionElement
|
||||
include SimplyStored::Couch
|
||||
include ActiveModel::SerializerSupport
|
||||
include SvgElementDefaults
|
||||
property :position_x, type: Float
|
||||
property :position_y, type: Float
|
||||
property :rotation, type: Float
|
||||
belongs_to :section
|
||||
belongs_to :supplier
|
||||
belongs_to :svg_element
|
||||
|
||||
view :by_supplier_id, key: :supplier_id
|
||||
|
||||
def self.for_supplier(supplier)
|
||||
find_all_by_supplier_id(supplier.id)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class SvgElement
|
||||
include SimplyStored::Couch
|
||||
include ActiveModel::SerializerSupport
|
||||
include SvgElementDefaults
|
||||
property :snap_code
|
||||
has_many :section_elements
|
||||
end
|
||||
Reference in New Issue
Block a user