Files
mozo-backend/app/assets/javascripts/supplier/app/models/product.js.coffee
T
2015-02-18 23:42:56 +01:00

28 lines
800 B
CoffeeScript

attr = DS.attr
App.Product = DS.Model.extend Ember.Validations.Mixin,
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)?$/)
#true
#).property('price')
validations:
name: {presence: true}
price: {format: /^[+-]?\d+(\.?\d?\d)?$/}