Sha256: fe2d6276bf8a6ce3e10bd973c5454a9d17c0862f51258dec4a7f6ad4ac54fd90

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

Volontariat.CommunityFeedbackRoute = Ember.Route.extend
  model: (params) ->
    @controllerFor('community.feedback').set 'page', parseInt(params.page)
    @controllerFor('community.feedback').set 'communitySlug', @modelFor('community').slug
    @controllerFor('community.feedback').set 'slug', params.feedback_slug
    
    Ember.$.getJSON("/api/v1/feedbacks/#{params.feedback_slug}?community_slug=#{@modelFor('community').slug}").then (json) =>
      @controllerFor('community.feedback').set 'feedbackType', json.feedback.feedback_type
      
      Ember.$.getJSON(
        "/api/v1/replies?feedback_id=#{json.feedback.id}&page=#{params.page}"
      ).then (replyJson) =>
        @controllerFor('community.feedback').set 'metadata', replyJson.meta
        
        replies = $.map replyJson.replies, (reply, i) ->
          reply.replies = $.map reply.replies, (subReply, i) ->
            subReply.reply
            
          reply
        
        @controllerFor('community.feedback').set 'replies', replies
        @controllerFor('community.feedback').send 'goToPageWithoutRedirect', parseInt(params.page)
      
      json.feedback
      
  setupController: (controller, model) ->
    controller.send('goToPageWithoutRedirect', controller.get('page'))
    controller.set('model', model)

Version data entries

1 entries across 1 versions & 1 rubygems

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