{"size": 1384, "ext": "js", "max_stars_repo_path": "app/post/route.js", "max_stars_repo_name": "Paul-Hess/ember-built-blog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/post/route.js", "max_issues_repo_name": "Paul-Hess/ember-built-blog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/post/route.js", "max_forks_repo_name": "Paul-Hess/ember-built-blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.68, "max_line_length": 69, "alphanum_fraction": 0.5534682081}
import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    return Ember.RSVP.hash({
      singlePost: this.store.findRecord('post', params.post_id),
      allPost: this.store.findAll('post')
    })
  },
  actions: {
    delete(model){
      if(confirm('Are you sure you want to delete this post?')){
        model.destroyRecord();
        this.transitionTo('index');
      }
    },
      deleteComment(comment){
        if(confirm('Are you sure you want to delete your comment?')){
          comment.destroyRecord();
        }
      },
      update3(post, params){
        Object.keys(params).forEach(function(key){
          if(params[key]!==undefined){
            post.set(key,params[key]);
          }
        });
        post.save();
        this.transitionTo('index');
      },
      saveComment3(params){
        var addComment = this.store.createRecord('comment', params);
        var post = params.post;
        post.get('comments').addObject(addComment);
        addComment.save().then(function(){
          return post.save();
        });
        this.transitionTo('model.singlePost', params.post);
      },
      updateComment3(comment, params){
        Object.keys(params).forEach(function(key) {
          if(params[key]!==undefined){
            comment.set(key,params[key]);
          }
        });
        comment.save();
      }
    }
});
