Sha256: a0a2d7c84fefb0247f34830eeb52ec0b8c225ab49c104b6bfcb56737895a64f9

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

Volontariat.CommunityEditFeedbackRoute = Ember.Route.extend
  model: (params) ->
    @controllerFor('community.edit_feedback').set 'communitySlug', @modelFor('community').slug
    @controllerFor('community.edit_feedback').set 'slug', params.feedback_slug    
    
    Ember.$.getJSON("/api/v1/feedbacks/#{params.feedback_slug}?community_slug=#{@modelFor('community').slug}").then (json) =>
      @controllerFor('community.edit_feedback').set 'name', json.feedback.name
      @controllerFor('community.edit_feedback').set 'text', json.feedback.text
      @controllerFor('community.edit_feedback').set 'moodText', json.feedback.mood_text
      
      setTimeout (=>
        $('#feedback_feedback_type').val(json.feedback.feedback_type)
        
        unless json.feedback.mood_type == null
          $('input[name="feedback[mood_type]"][value="' + json.feedback.mood_type + '"]').click()
      ), 100
      
    Ember.$.getJSON(
      "/api/v1/community_categories.json?community_slug=#{@modelFor('community').slug}"
    ).then (json) =>
      @controllerFor('community.edit_feedback').set 'categories', json.community_categories
      
      Ember.$.getJSON(
        "/api/v1/community_categories.json?community_slug=#{@modelFor('community').slug}&feedback_slug=#{params.feedback_slug}"
      ).then (json) =>
        setTimeout (->
          jQuery.each json.community_categories, (i, category) ->
            $("input[name='category_ids[]'][value='#{category.id}']").click()
        ), 100

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voluntary_feedback-0.1.0 app/assets/javascripts/voluntary_feedback/routes/community/edit_feedback_route.js.coffee