Sha256: 6a2c6309d14f48bdced1718329e4eecd3bd057982aa8aa51a78d40ba335ce320

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

Volontariat.BrainstormingIdeaVoteComponent = Ember.Component.extend
  actions:
    up: ->
      if Volontariat.User.current() == undefined
        alert Volontariat.t('general.exceptions.access_denied')
        
        return
        
      @set 'count', @get('count') + 1
      @set 'vote', true
      
      @sendAction 'setDirtyAction'
      
      $.ajax(type: 'POST', url: '/api/v1/brainstorming_idea_votes', data: { idea_id: @get('ideaId') }).success((data) =>
        if data.errors
          alert "#{Volontariat.t('brainstorming_idea_votes.create.failed')}: #{JSON.stringify(data.errors)}"
          @set 'count', @get('count') - 1
          @set 'vote', false
        else
          @sendAction 'reloadAction'
          alert Volontariat.t('brainstorming_idea_votes.create.successfully')
      ).fail((data) =>
        alert "#{Volontariat.t('brainstorming_idea_votes.create.failed')}!"
        @set 'count', @get('count') - 1
        @set 'vote', false
      )  
      
    down: ->
      if Volontariat.User.current() == undefined
        alert Volontariat.t('general.exceptions.access_denied')
        
        return
      
      @set 'count', @get('count') - 1
      @set 'vote', false
    
      @sendAction 'setDirtyAction'
      
      $.ajax("/api/v1/brainstorming_idea_votes/0", type: 'DELETE', data: { idea_id: @get('ideaId') }).done((data) =>
        @sendAction 'reloadAction'
        alert Volontariat.t('brainstorming_idea_votes.destroy.successful')
      ).fail((data) =>
        alert Volontariat.t('activerecord.errors.models.brainstorming_idea_vote.attributes.base.deletion_failed')
        @set 'count', @get('count') + 1
        @set 'vote', true
      )  

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voluntary_brainstorming-0.0.2 app/assets/javascripts/voluntary_brainstorming/components/brainstorming_idea_vote_component.js.coffee