Sha256: 73c6f8d869ebdbd675e3bd9c9755637fe25e329ab3783d475c9768879b8fb697

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

Volontariat.BrainstormingIdeaCellComponent = Ember.Component.extend
  editMode: (-> @get('selectedId') == @get('ideaId')).property('selectedId', 'ideaId')

  actions:
    
    cancel: ->
      @sendAction 'leaveEditIdeaModeAction'
    
    save: ->
      @sendAction 'setDirtyAction'
      
      $.ajax(
        type: if @get('ideaId') then 'PUT' else 'POST'
        url: '/api/v1/brainstorming_ideas' + if @get('ideaId') then "/#{@get('ideaId')}" else '', 
        data: { 
          user_slug: @get('userSlug'), brainstorming_slug: @get('slug'),
          brainstorming_idea: { 
            name: $('#brainstorming_idea_name').val(), text: $('#brainstorming_idea_text').val() 
          } 
        }
      ).success((data) =>
        if data.errors
          alert "#{Volontariat.t('brainstorming_ideas.save.failed')}: #{JSON.stringify(data.errors)}"
        else
          unless @get('ideaId')
            @sendAction 'leaveNewIdeaModeAction'
            @set 'ideaName', ''
            @set 'ideaText', ''
          
          @sendAction 'reloadAction'
          alert Volontariat.t('brainstorming_ideas.save.successful')
      ).fail((data) =>
        alert "#{Volontariat.t('brainstorming_ideas.save.failed')}!"
      )  

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_cell_component.js.coffee