2017-01-12 17:30:25 +09:00
|
|
|
import { Components, registerComponent, getRawComponent } from 'meteor/nova:core';
|
2016-12-20 09:27:16 +09:00
|
|
|
import SmartForm from "meteor/nova:forms";
|
2016-12-08 09:42:50 +01:00
|
|
|
import { ShowIf, withMessages } from 'meteor/nova:core';
|
2016-12-01 16:12:39 +01:00
|
|
|
import Posts from "meteor/nova:posts";
|
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-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-03-31 09:36:25 +09:00
|
|
|
return (
|
2016-12-01 16:09:54 +09:00
|
|
|
<ShowIf
|
|
|
|
check={Posts.options.mutations.new.check}
|
2016-12-14 11:29:52 +09:00
|
|
|
failureComponent={<Components.UsersAccountForm />}
|
2016-11-04 14:14:19 +01:00
|
|
|
>
|
|
|
|
<div className="posts-new-form">
|
2016-12-20 09:27:16 +09:00
|
|
|
<SmartForm
|
2016-11-04 14:14:19 +01:00
|
|
|
collection={Posts}
|
2016-12-18 19:04:11 +09:00
|
|
|
fragment={getRawComponent('PostsPage').fragment}
|
2016-11-04 14:14:19 +01:00
|
|
|
successCallback={post => {
|
2017-01-10 17:49:03 +09:00
|
|
|
props.closeModal();
|
2016-12-15 12:07:13 +09:00
|
|
|
// props.router.push({pathname: Posts.getPageUrl(post)});
|
2016-11-04 14:14:19 +01:00
|
|
|
props.flash(context.intl.formatMessage({id: "posts.created_message"}), "success");
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2016-12-01 16:09:54 +09:00
|
|
|
</ShowIf>
|
2016-11-04 13:57:27 +01:00
|
|
|
);
|
|
|
|
};
|
2016-03-31 09:36:25 +09:00
|
|
|
|
2016-11-05 18:37:46 +09:00
|
|
|
PostsNewForm.propTypes = {
|
2017-01-10 17:49:03 +09:00
|
|
|
closeModal: React.PropTypes.func,
|
2016-11-05 18:37:46 +09:00
|
|
|
router: React.PropTypes.object,
|
2016-11-07 11:46:58 +09:00
|
|
|
flash: React.PropTypes.func,
|
2016-11-05 18:37:46 +09:00
|
|
|
}
|
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
PostsNewForm.contextTypes = {
|
2016-11-08 14:56:48 +09:00
|
|
|
closeCallback: React.PropTypes.func,
|
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-12-08 09:42:50 +01:00
|
|
|
registerComponent('PostsNewForm', PostsNewForm, withRouter, withMessages);
|