Files
mozo-backend/app/assets/javascripts/supplier/app/models/product.js.coffee
T

24 lines
675 B
CoffeeScript

attr = DS.attr
App.Product = DS.Model.extend
name: attr 'string'
price: attr 'number'
code: attr 'string'
description: attr 'string'
visible: attr('boolean', defaultValue: true)
position: attr('number', defaultValue: 0)
image: attr()
product_category: DS.belongsTo('product_category')
product_orders: DS.hasMany('product_order')
image_src: (->
image = @get('image')
return "" unless image
return image.small if image.small and typeof(image.small) is "string"
image
).property('image')
isValid: (->
return false unless price = @get('price')
return false unless "#{price}".match(/^[+-]?\d+(\.?\d?\d)?$/)
).property('price')