2017-10-26 16:04:26 +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-03-20 14:56:09 +09:00
|
|
|
const EditButton = ({ style = 'primary', size, ...props }, {intl}) =>
|
2017-10-26 16:04:26 +09:00
|
|
|
<Components.ModalTrigger
|
|
|
|
label={intl.formatMessage({id: 'datatable.edit'})}
|
2018-03-20 14:56:09 +09:00
|
|
|
component={<Button bsSize={size} bsStyle={style}><FormattedMessage id="datatable.edit" /></Button>}
|
2017-10-26 16:04:26 +09:00
|
|
|
>
|
2018-03-20 14:56:09 +09:00
|
|
|
<Components.EditForm {...props} />
|
2017-10-26 16:04:26 +09:00
|
|
|
</Components.ModalTrigger>
|
|
|
|
|
|
|
|
EditButton.contextTypes = {
|
|
|
|
intl: intlShape
|
|
|
|
};
|
|
|
|
|
|
|
|
EditButton.displayName = 'EditButton';
|
|
|
|
|
2018-02-15 12:04:51 +09:00
|
|
|
registerComponent('EditButton', EditButton);
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
EditForm Component
|
|
|
|
|
|
|
|
*/
|
2018-03-20 14:56:09 +09:00
|
|
|
const EditForm = ({ closeModal, ...props }) =>
|
2018-02-15 12:04:51 +09:00
|
|
|
<Components.SmartForm
|
|
|
|
successCallback={document => {
|
|
|
|
closeModal();
|
|
|
|
}}
|
|
|
|
removeSuccessCallback={document => {
|
|
|
|
closeModal();
|
|
|
|
}}
|
2018-03-20 14:56:09 +09:00
|
|
|
{...props}
|
2018-02-15 12:04:51 +09:00
|
|
|
/>
|
|
|
|
registerComponent('EditForm', EditForm);
|