2016-03-31 09:36:25 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-06-10 10:25:38 +09:00
|
|
|
import { intlShape } from 'react-intl';
|
2016-04-04 10:21:18 +09:00
|
|
|
import NovaForm from "meteor/nova:forms";
|
2016-06-14 10:01:44 +09:00
|
|
|
import { withRouter } from 'react-router'
|
2016-03-31 09:36:25 +09:00
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
const PostsNewForm = (props, context) => {
|
2016-06-14 10:01:44 +09:00
|
|
|
|
|
|
|
const router = props.router;
|
2016-03-31 09:36:25 +09:00
|
|
|
|
|
|
|
return (
|
2016-05-22 16:42:24 +09:00
|
|
|
<Telescope.components.CanCreatePost>
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="posts-new-form">
|
2016-04-04 10:21:18 +09:00
|
|
|
<NovaForm
|
2016-03-31 09:36:25 +09:00
|
|
|
collection={Posts}
|
|
|
|
currentUser={context.currentUser}
|
|
|
|
methodName="posts.new"
|
|
|
|
successCallback={(post)=>{
|
2016-06-14 17:03:35 +09:00
|
|
|
this.context.messages.flash(context.intl.formatMessage({id: "posts.created_message"}), "success");
|
2016-06-14 10:17:11 +09:00
|
|
|
router.push({pathname: Posts.getPageUrl(post)});
|
2016-03-31 09:36:25 +09:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2016-05-22 16:42:24 +09:00
|
|
|
</Telescope.components.CanCreatePost>
|
2016-03-31 09:36:25 +09:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
PostsNewForm.contextTypes = {
|
2016-06-10 10:25:38 +09:00
|
|
|
currentUser: React.PropTypes.object,
|
2016-06-14 17:03:35 +09:00
|
|
|
messages: React.PropTypes.object,
|
2016-06-10 10:25:38 +09:00
|
|
|
intl: intlShape
|
2016-03-31 09:36:25 +09:00
|
|
|
};
|
|
|
|
|
2016-05-22 16:42:24 +09:00
|
|
|
PostsNewForm.displayName = "PostsNewForm";
|
|
|
|
|
2016-06-14 10:01:44 +09:00
|
|
|
module.exports = withRouter(PostsNewForm);
|
|
|
|
export default withRouter(PostsNewForm);
|