       false
 
     saveNewAuthor: (newAuthor) ->
+      newAuthor.position = @get('authors.length') + 1
       author = @store.createRecord('author', newAuthor)
       author.set('authorGroup', @get('model'))
       author.save().then (author) =>

      author.destroyRecord().then (author) =>
        @updateAuthorPositions(author, @get('authors'), 'remove')

    changeAuthorGroup: (author, position) ->
      @updateAuthorPositions(author, author.get('authorGroup.authors'), 'remove')

      author.set('authorGroup', @get('model'))
      author.set('position', position)
      author.save()

      @updateAuthorPositions(author, @get('authors'), 'add')

    op = {add: 'incrementProperty', remove: 'decrementProperty'}
    relevantAuthors.invoke(op[operation], 'position')

  shiftAuthorPositions: (author, authorList, oldPosition, newPosition)->
    if oldPosition < newPosition
      newPosition = newPosition - 1
      relevantAuthors = authorList.filter (a)->
        a != author && (a.get('position') > oldPosition) && (a.get('position') <= newPosition)
      relevantAuthors.invoke('decrementProperty', 'position')

    else
      relevantAuthors = authorList.filter (a)->
        a != author && (a.get('position') < oldPosition) && (a.get('position') >= newPosition)
      relevantAuthors.invoke('incrementProperty', 'position')

    author.set('position', newPosition)
    author.save()

  actions:
    toggleAuthorForm: (authorGroup=null) ->
      @set('currentAuthorGroup', authorGroup)
