App.modals.AddSectionController = @App.modals.BaseController.extend
  section_title: ''
  section_width: 15
  section_height: 8
  title_path: 'section.add_section.modal.title'
  actions:
    addSection: ->
      @set 'alert_message', null
      title = @get('section_title')
      width = @get('section_width')
      height = @get('section_height')
      unless title
        @set 'alert_message', error_message
          attribute: t('attributes.section.title')
          message: 'blank'
        return
      unless parseInt(width) > 0
        @set 'alert_message', error_message
          attribute: t('attributes.section.width')
          message: 'greater_than'
          count: 0
        return
      unless parseInt(height) > 0
        @set 'alert_message', error_message
          attribute: t('attributes.section.height')
          message: 'greater_than'
          count: 0
        return
      section = @store.createRecord 'section',
        title: title
        width: width
        height: height
      section.save().then (s)=>
        @set 'section_title', ''
        @send 'closeModal'
        @transitionToRoute 'section', s.id
      , @save_error.bind(@)

