App.TablesIndexController = Ember.Controller.extend
  tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
  actions:
    newTable: ->
      section = @get('globals.active_section') || @store.peekAll('section').toArray()[0]
      table = @store.createRecord('table', section: section)
      @modal 'table_edit',
        model: table
        close: -> table.deleteRecord()
    destroyTable: (table)->
      @modal 'confirm',
        title: t('table.destroy.modal.title', number: table.get('number'))
        ok: -> table.destroyRecord()
