mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
mutations: form HOC type based on the document prop & fix collection.edit.validate cb by assigning it to the modifier
This commit is contained in:
parent
29585b2e9f
commit
3c913c437b
3 changed files with 9 additions and 7 deletions
|
@ -13,14 +13,15 @@ export default function withEdit(WrappedComponent, options) {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { mutationName, fragment, resultQuery, collection } = this.props
|
||||
|
||||
// if the mutation given to NovaForm isn't about editing an existing document, do nothing
|
||||
if (mutationName.indexOf('Edit') === -1) {
|
||||
// if the NovaForm mutation isn't about editing an existing document (it doesn't have one), do nothing
|
||||
if (!this.props.document) {
|
||||
|
||||
return <WrappedComponent {...this.props} />
|
||||
|
||||
} else {
|
||||
|
||||
const { mutationName, fragment, resultQuery, collection } = this.props;
|
||||
|
||||
const collectionName = collection._name;
|
||||
|
||||
|
|
|
@ -12,15 +12,16 @@ export default function withNew(WrappedComponent, options) {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { mutationName, fragment, resultQuery, collection } = this.props
|
||||
|
||||
// if the mutation given to NovaForm isn't about creating a new document, do nothing
|
||||
if (mutationName.indexOf('New') === -1) {
|
||||
// if the NovaForm mutation isn't about creating a new document (it already has one), do nothing
|
||||
if (this.props.document) {
|
||||
|
||||
return <WrappedComponent {...this.props} />
|
||||
|
||||
} else {
|
||||
|
||||
const { mutationName, fragment, resultQuery, collection } = this.props;
|
||||
|
||||
const collectionName = collection._name;
|
||||
|
||||
const ComponentWithMutation = graphql(gql`
|
||||
|
|
|
@ -131,7 +131,7 @@ const editMutation = ({ action, collection, documentId, set, unset, currentUser,
|
|||
collection.simpleSchema().namedContext(`${collectionName}.edit`).validate(modifier, {modifier: true});
|
||||
|
||||
// run validation callbacks
|
||||
document = Telescope.callbacks.run(`${collectionName}.edit.validate`, modifier, document, currentUser);
|
||||
modifier = Telescope.callbacks.run(`${collectionName}.edit.validate`, modifier, document, currentUser);
|
||||
}
|
||||
|
||||
// run sync callbacks (on mongo modifier)
|
||||
|
|
Loading…
Add table
Reference in a new issue