End of day commit

This commit is contained in:
2015-02-16 17:53:01 +01:00
parent 5eb3d15638
commit f7d8c4cc7c
27 changed files with 190 additions and 13 deletions
@@ -2,12 +2,13 @@
#= require handlebars
#= require ember
#= require ember-data
#= require ember-validations
#= require_directory ./modifications
#= require shared-ember-helpers/all
#= require ./app
#= require ./controllers/modals/base_controller
#= require ion.sound
#= require_tree .
@$assets_path = '/assets/';
@$assets_path = '/assets/'
@EmberENV = {FEATURES: {'query-params-new': true}}
@$days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
@@ -25,8 +25,7 @@ App.MenuProductComponent = Ember.Component.extend
save: ->
return unless @get('product.isValid')
if @get('product.isDirty')
@get('product').save().then((-> true), (-> true))
@set 'editMode', false
@get('product').save().then((=> @set 'editMode', false), (-> true))
destroyProduct: (product)->
if product.get('isNew')
product.deleteRecord()
@@ -0,0 +1,16 @@
App.EmployeesIndexController = Ember.ArrayController.extend
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
actions:
newEmployee: ->
employee = @store.createRecord('employee')
@modal 'employee_edit',
model: employee
close: -> employee.deleteRecord()
editEmployee: (employee)->
@modal 'employee_edit',
model: employee
close: -> employee.rollback()
destroyEmployee: (employee)->
@modal 'confirm',
title: t('employee.destroy.modal.title', employee.serialize())
ok: -> employee.destroyRecord()
@@ -3,7 +3,7 @@ App.MenuController = Ember.ObjectController.extend
product_code_filter: ''
product_categories: (-> @store.all('product_category')).property()
filter: null
sorted_product_categories: (->
sorted_product_categories: (->
list = @get('product_categories')
if filter_day = @get('filter.day')
list = list.filterBy "active_on_#{filter_day}"
@@ -36,8 +36,9 @@
@send 'closeModal' unless @preventClose
confirm: -> @send('ok')
save: ->
@get('model').save()
@send 'closeModal' unless @preventClose
if @get('model.isValid')
@get('model').save().then((=> @send 'closeModal' ), (-> true))
#@send 'closeModal' unless @preventClose
destroy: ->
@modal 'confirm',
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
@@ -3,10 +3,13 @@ Ember.Handlebars.helper 'errors', (errors, params..., options)->
result = ""
model_name = options.hash.includeAttribute
for error in errors
if model_name
attribute = ttry("attributes.#{model_name}.#{error.attribute}")
message = "#{attribute} #{error.message}"
if typeof error is "string"
message = error
else
message = error.message
if model_name
attribute = ttry("attributes.#{model_name}.#{error.attribute}")
message = "#{attribute} #{error.message}"
else
message = error.message
result += "<div class='error'>#{message}</div>"
new Ember.Handlebars.SafeString(result)
result.htmlSafe()
@@ -0,0 +1,8 @@
attr = DS.attr
App.Employee= DS.Model.extend Ember.Validations.Mixin,
name: attr 'string'
email: attr 'string'
validations:
name:
presence: true
@@ -17,7 +17,7 @@ App.Product = DS.Model.extend
image
).property('image')
isValid: (->
isValid: (->
return false unless price = @get('price')
return false unless "#{price}".match(/^[+-]?\d+(\.?\d?\d)?$/)
true
@@ -12,6 +12,8 @@ App.Router.map ->
@resource 'table', path: ':table_id'
@resource 'lists', ->
@resource 'list', path: ':list_id'
@resource 'employees', ->
@resource 'employee', path: ':employee_id'
@route 'orders_display' # chromecast etc
@route 'menu'
@route 'settings'
@@ -0,0 +1,2 @@
App.EmployeesRoute = Ember.Route.extend
model: -> @store.find 'employee'
@@ -0,0 +1 @@
= outlet
@@ -0,0 +1,21 @@
.row: .small-12.columns
h1=t 'models.plural.employee'
if employees
table.table
thead
tr
th.name=t 'attributes.employee.name'
th.email=t 'attributes.employee.email'
th.actions=t 'helpers.actions.title'
tbody
each employee in employees
tr
td: link-to 'employee' employee: span= employee.name
td.email
= employee.email
= errors employee.errors.email
td.actions
a.table-edit{ action 'editEmployee' employee }: span
a.table-destroy{ action 'destroyEmployee' employee }: span
.form-actions
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
@@ -13,6 +13,8 @@ header.top-menu
= t 'models.plural.table'
= link-to "lists" class="top-menu-lists"
= t 'models.plural.list'
= link-to "employees" class="top-menu-employees"
= t 'models.plural.employee'
.extra-info{action "showSupplierStatusInfo"}
.supplier-info-row
.counter.supplier-orders-placed-count
@@ -0,0 +1,14 @@
p=t 'employee.edit.modal.body_header'
.form-row.name
.form-label=t 'attributes.employee.name'
.form-field
= input valueBinding="model.name"
= errors model.errors.name
.form-row.name
.form-label=t 'attributes.employee.email'
.form-field
= input type="email" valueBinding="model.email"
= errors model.errors.email
hr
button.modal-close{action "close"}=t 'section.add_employees.modal.close_button'
button.modal-confirm.right{action "save"}=t 'section.add_employees.modal.add_button'
@@ -3,7 +3,7 @@ App.BooleanButtonView = Ember.View.extend
href: '#'
classNames: "button"
# templateName: "form_elements/boolean_switch"
template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
#template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
classNameBindings: ['rounded:round', 'active:active:disabled']
text: Ember.computed 'text_path', ->