2018-01-03 15:13:50 +09:00
|
|
|
import { Components, registerComponent } from 'meteor/vulcan:lib';
|
|
|
|
import React from 'react';
|
|
|
|
import Button from 'react-bootstrap/lib/Button';
|
|
|
|
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
|
|
|
|
|
2018-02-15 09:32:41 +09:00
|
|
|
const NewButton = ({ collection, bsStyle = 'primary', ...props }, {intl}) =>
|
2018-01-03 15:13:50 +09:00
|
|
|
<Components.ModalTrigger
|
|
|
|
label={intl.formatMessage({id: 'datatable.new'})}
|
|
|
|
component={<Button bsStyle={bsStyle}><FormattedMessage id="datatable.new" /></Button>}
|
|
|
|
>
|
2018-02-15 12:04:51 +09:00
|
|
|
<Components.NewForm collection={collection} {...props} />
|
2018-01-03 15:13:50 +09:00
|
|
|
</Components.ModalTrigger>
|
|
|
|
|
|
|
|
NewButton.contextTypes = {
|
|
|
|
intl: intlShape
|
|
|
|
};
|
|
|
|
|
|
|
|
NewButton.displayName = 'NewButton';
|
|
|
|
|
2018-02-15 12:04:51 +09:00
|
|
|
registerComponent('NewButton', NewButton);
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
NewForm Component
|
|
|
|
|
|
|
|
*/
|
|
|
|
const NewForm = ({ collection, closeModal, options, ...props }) =>
|
|
|
|
<Components.SmartForm
|
|
|
|
{...props}
|
|
|
|
collection={collection}
|
|
|
|
successCallback={document => {
|
|
|
|
closeModal();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
registerComponent('NewForm', NewForm);
|