improvements

This commit is contained in:
2015-02-18 23:42:56 +01:00
parent c1858455e9
commit a1474e934a
4 changed files with 15 additions and 9 deletions
@@ -28,6 +28,9 @@ App.EditCurrencyComponent = Ember.Component.extend
return_value = return_value.toFixed(2) if typeof return_value is 'number'
return_value
actions:
action: ->
@sendAction('action') if @action
#didInsertElement: ->
#@addObserver "model.#{@attribute}", (attribute)=>
#if value = @get("model.#{@attribute}")
@@ -1,5 +1,5 @@
attr = DS.attr
App.Product = DS.Model.extend
App.Product = DS.Model.extend Ember.Validations.Mixin,
name: attr 'string'
price: attr 'number'
code: attr 'string'
@@ -17,8 +17,11 @@ App.Product = DS.Model.extend
image
).property('image')
isValid: (->
return false unless price = @get('price')
return false unless "#{price}".match(/^[+-]?\d+(\.?\d?\d)?$/)
true
).property('price')
#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)?$/}
@@ -1,3 +1,3 @@
.large-2.columns: label.prefix= currencySymbol
.large-4.columns.end= input valueBinding="inputValue" placeholder=placeholder
.large-4.columns.end= input valueBinding="inputValue" placeholder=placeholder action="action"
@@ -1,10 +1,10 @@
if editMode
.row
.small-3.columns.name
= input value=product.name placeholder=namePlaceholder
= input value=product.name placeholder=namePlaceholder action="save"
= errors product.errors.name
.small-3.columns.price
= edit-currency value=product.price validatePresence=true
= edit-currency value=product.price validatePresence=true action="save"
= errors product.errors.price
.small-3.columns.code= input value=product.code placeholder=codePlaceholder
.small-3.columns.actions