import ModalBase from 'ember-cli-dunlop/mixins/modal-base'
export default ModalBase.extend
  sorted_records: Ember.computed 'model.@each.position', ->
    @get('model').sortBy 'position'
  actions:
    reorderItems: (records)->
      (records || []).forEach (record, position) ->
        if record.get('position') isnt position
          record.set 'position', position
          record.save()
