2018-01-03 15:13:50 +09:00
|
|
|
import { Components, registerComponent } from 'meteor/vulcan:lib';
|
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
|
|
|
|
|
2018-03-28 11:13:39 +09:00
|
|
|
const NewButton = ({ collection, size, style = 'primary', ...props }, { intl }) => (
|
|
|
|
<Components.ModalTrigger
|
|
|
|
label={intl.formatMessage({ id: 'datatable.new' })}
|
|
|
|
component={
|
2018-04-23 09:47:04 +09:00
|
|
|
<Components.Button variant={style} size={size}>
|
2018-03-28 11:13:39 +09:00
|
|
|
<FormattedMessage id="datatable.new" />
|
2018-04-23 09:47:04 +09:00
|
|
|
</Components.Button>
|
2018-03-28 11:13:39 +09:00
|
|
|
}
|
2018-01-03 15:13:50 +09:00
|
|
|
>
|
2018-02-15 12:04:51 +09:00
|
|
|
<Components.NewForm collection={collection} {...props} />
|
2018-01-03 15:13:50 +09:00
|
|
|
</Components.ModalTrigger>
|
2018-03-28 11:13:39 +09:00
|
|
|
);
|
2018-01-03 15:13:50 +09:00
|
|
|
|
|
|
|
NewButton.contextTypes = {
|
2018-03-28 11:13:39 +09:00
|
|
|
intl: intlShape,
|
2018-01-03 15:13:50 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
NewButton.displayName = 'NewButton';
|
|
|
|
|
2018-02-15 12:04:51 +09:00
|
|
|
registerComponent('NewButton', NewButton);
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
NewForm Component
|
|
|
|
|
|
|
|
*/
|
2018-03-28 11:13:39 +09:00
|
|
|
const NewForm = ({ closeModal, successCallback, ...props }) => {
|
|
|
|
|
|
|
|
const success = successCallback
|
|
|
|
? () => {
|
|
|
|
successCallback();
|
|
|
|
closeModal();
|
|
|
|
}
|
|
|
|
: closeModal;
|
|
|
|
|
|
|
|
return <Components.SmartForm successCallback={success} {...props} />;
|
|
|
|
};
|
2018-02-15 12:04:51 +09:00
|
|
|
registerComponent('NewForm', NewForm);
|