Sha256: b3d952fad9712402487eb274c4b5bd657a0821d6e2f13a4ee1bc4395b494b82f
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
import React from "react"; import { render } from "react-dom"; import { Controllers } from "loco-js"; import store from "stores/main"; import CommentList from "containers/main/articles/StatefulCommentList"; import CommentsNumber from "containers/main/articles/CommentsNumber"; import Article from "models/Article"; import Comment from "models/article/Comment"; import Show from "views/main/articles/Show"; class Articles extends Controllers.Base { show() { const newComment = new Comment({ articleId: this.params.id }); const view = new Show({ comment: newComment }); view.render(); Article.find(this.params.id).then(article => { store.dispatch({ type: "SET_ARTICLES", payload: { articles: [article] } }); view.renderArticle(article); }); Comment.get("count", { articleId: this.params.id }).then(res => { Comment.all({ articleId: this.params.id, total: res.total }).then( comments => { store.dispatch({ type: "SET_COMMENTS", payload: { articleId: this.params.id, comments } }); render( React.createElement(CommentList, { articleId: this.params.id, comments }), document.getElementById("comments") ); render( React.createElement(CommentsNumber, { articleId: this.params.id, comments }), document.getElementById("comments_count") ); } ); }); } } export default Articles;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loco-rails-3.0.4 | test/dummy/frontend/js/controllers/main/Articles.js |