import Ember from 'ember'
export default Ember.Controller.extend
  actions:
    sortTrackerGroups: ->
      @modal "sort-records", model: @get("model.tracker_groups")

    newTrackerGroup: ->
      tracker_groups = @get("model.tracker_groups")
      @modal "edit-tracker-group",
        model: tracker_groups.createRecord(position: tracker_groups.get('length'))
        title: t('action.new_model', model: t('models.tracker_group'))

    editTrackerGroup: (tracker_group) ->
      @modal "edit-tracker-group", model: tracker_group

    newTrackerItem: (tracker_group)->
      tracker_items = tracker_group.get("tracker_items")
      tracker_items.createRecord(position: tracker_items.get("length"), isEditing: true)

    sortTrackerItems: (tracker_group) ->
      @modal "sort-records", model: tracker_group.get("tracker_items")

