Sha256: a782b8ddffee3fb3b2362e460edb23e1bb6ecea67a762b7f206585e8b74058e0

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

Contents

class App.Controllers.Main.Articles extends App.Controllers.Base
  show: ->
    newComment = new App.Models.Article.Comment articleId: @params.id
    @view = new App.Views.Main.Articles.Show comment: newComment
    @view.render()
    this.connectWith [App.Models.Article.Comment]
    App.Models.Article.find(@params.id).then (article) =>
      @view.renderArticle article
    App.Models.Article.Comment.get("count", articleId: @params.id).then (res) =>
      App.Models.Article.Comment
        .all(articleId: @params.id, total: res.total)
        .then (comments) => @view.renderComments comments

  receivedSignal: (signal, data) ->
    switch signal
      when 'Article.Comment created'
        return if data.article_id isnt @params.id
        App.Models.Article.Comment.find(id: data.id, articleId: data.article_id)
        .then (comment) => @view.renderComments [comment]

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/app/assets/javascripts/controllers/main/articles.coffee
loco-rails-3.0.2 test/dummy/app/assets/javascripts/controllers/main/articles.coffee
loco-rails-3.0.1 test/dummy/app/assets/javascripts/controllers/main/articles.coffee