Spec squashing

This commit is contained in:
2015-09-21 18:25:37 +02:00
parent 61dba311fa
commit ee199d7da8
18 changed files with 82 additions and 73 deletions
@@ -1,5 +1,5 @@
App.DashboardActiveOrderComponent = Ember.Component.extend
tagName: 'tr'
layoutName: 'dashboard/active-order'
classNameBindings: ['content.active:active', 'content.delivered:delivered', 'classIdentifier']
classNameBindings: ['order.active:active', 'order.delivered:delivered', 'classIdentifier']
classIdentifier: Ember.computed 'order.id', -> "order-row-#{@get('order.id')}"
@@ -17,6 +17,13 @@ App.MySelectComponent = Ember.Component.extend
@set('content', []) unless @get('content')
).on('init')
didRender: ->
# Set select to current value if can be found
key = @get('optionValuePath')
index = @get('content').mapBy(key).indexOf(@get("selection.#{key}"))
if index > -1
@$('select:first').prop('selectedIndex', index)
actions:
change: ->
selectedIndex = @$('select:first').get(0).selectedIndex
@@ -25,7 +32,7 @@ App.MySelectComponent = Ember.Component.extend
hasPrompt = !!@get('prompt')
contentIndex = if hasPrompt then selectedIndex - 1 else selectedIndex
selection = @get('content')[contentIndex]
selection = @get('content').toArray()[contentIndex]
# set the local, shadowed selection to avoid leaking
# changes to `selection` out via 2-way binding
@@ -0,0 +1,3 @@
App.EmployeesController = Ember.Controller.extend
employeeSorting: ['name']
employees: Ember.computed.sort 'model', 'employeeSorting'
@@ -1,2 +0,0 @@
App.EmployeesIndexController = Ember.Controller.extend
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
@@ -3,10 +3,5 @@ App.modals.TableEditController = App.modals.BaseController.extend
sections: (-> @store.peekAll('section')).property()
#setSelectedSection: (-> @set 'selectedSection', @get('model.section')).on('init')
actions:
confirm: ->
@get('model').then (l)->l.close()
@send 'closeModal'
saveTable: ->
#@set 'model.section', @get('selectedSection')
@set 'model.section', @get('model.section')
@send 'save'
@@ -2,7 +2,8 @@ App.TablesIndexController = Ember.Controller.extend
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
actions:
newTable: ->
table = @store.createRecord('table')
section = @get('globals.active_section') || @store.peekAll('section').toArray()[0]
table = @store.createRecord('table', section: section)
@modal 'table_edit',
model: table
close: -> table.deleteRecord()
@@ -0,0 +1,22 @@
App.EmployeeActionsMixin = Ember.Mixin.create
actions:
newEmployee: ->
employee = @store.createRecord('employee')
@get('controller').modal 'employee_edit',
model: employee
title_path: 'employee.modal.new_title'
close: -> employee.deleteRecord()
editEmployee: (employee)->
@get('controller').modal 'employee_edit',
model: employee
title_path: 'employee.modal.edit_title'
close: -> employee.rollbackAttributes()
destroyEmployee: (employee)->
ac = @controllerFor('application')
if @get('globals.current_employee.id') isnt employee.id
ac.modal 'confirm',
title: t('employee.destroy.modal.title', employee.toJSON())
ok: -> employee.destroyRecord()
else
ac.modal 'alert',
title: 'You cannot remove yourself'
@@ -12,8 +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 'employees'
@route 'employee', path: '/employees/:employee_id'
@resource 'pages', ->
@resource 'page', path: ':page_id'
@route 'orders_display' # chromecast etc
@@ -0,0 +1 @@
App.EmployeeRoute = Ember.Route.extend App.EmployeeActionsMixin
@@ -1,23 +1,2 @@
App.EmployeesRoute = Ember.Route.extend
model: -> @store.peekAll 'employee'
actions:
newEmployee: ->
employee = @store.createRecord('employee')
@get('controller').modal 'employee_edit',
model: employee
title_path: 'employee.modal.new_title'
close: -> employee.deleteRecord()
editEmployee: (employee)->
@get('controller').modal 'employee_edit',
model: employee
title_path: 'employee.modal.edit_title'
close: -> employee.rollbackAttributes()
destroyEmployee: (employee)->
ac = @controllerFor('application')
if ac.get('employee.id') isnt employee.id
ac.modal 'confirm',
title: t('employee.destroy.modal.title', employee.toJSON())
ok: -> employee.destroyRecord()
else
ac.modal 'alert',
title: 'You cannot remove yourself'
App.EmployeesRoute = Ember.Route.extend App.EmployeeActionsMixin,
model: -> @store.findAll 'employee'
@@ -1 +1,29 @@
= outlet
.row: .small-12.columns
h2.main-section-header=t 'models.plural.employee'
if employees
table.table
thead
tr
th.name=t 'attributes.employee.name'
th.email=t 'attributes.employee.email'
th.boolean= t 'attributes.employee.manager'
th.boolean= t 'attributes.employee.active'
th.colorbox= t 'attributes.employee.color'
th.actions=t 'helpers.actions.title'
tbody
each employees as |employee|
tr
td: link-to 'employee' employee: span= employee.name
td.email
= employee.email
= errors employee.errors.email
td.boolean= boolean employee.manager
td.boolean= boolean employee.active
td.colorbox= colorbox employee.color
td.actions
if (can "manage" "employees")
a.table-edit{ action 'editEmployee' employee }: span
a.table-destroy{ action 'destroyEmployee' employee }: span
.form-actions
if (can "manage" "employees")
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
@@ -1,29 +0,0 @@
.row: .small-12.columns
h2.main-section-header=t 'models.plural.employee'
if employees
table.table
thead
tr
th.name=t 'attributes.employee.name'
th.email=t 'attributes.employee.email'
th.boolean= t 'attributes.employee.manager'
th.boolean= t 'attributes.employee.active'
th.colorbox= t 'attributes.employee.color'
th.actions=t 'helpers.actions.title'
tbody
each employees as |employee|
tr
td: link-to 'employee' employee: span= employee.name
td.email
= employee.email
= errors employee.errors.email
td.boolean= boolean employee.manager
td.boolean= boolean employee.active
td.colorbox= colorbox employee.color
td.actions
if (can "manage" "sections")
a.table-edit{ action 'editEmployee' employee }: span
a.table-destroy{ action 'destroyEmployee' employee }: span
.form-actions
if (can "manage" "employees")
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
@@ -13,5 +13,5 @@ p=t 'table.modal.body_header'
.form-field= number-field numericValue=model.height
hr
button.modal-close{action "close"}=t 'table.modal.close_button'
button.modal-confirm.right{action "save"}=t 'table.modal.save_button'
button.modal-confirm.right{action "saveTable"}=t 'table.modal.save_button'
= qr-codes-link table=model