Skip to content

Commit

Permalink
Adapt withEdit/withNew to support new fragments API
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Feb 3, 2017
1 parent a2f7592 commit afebadb
Show file tree
Hide file tree
Showing 5 changed files with 465 additions and 38 deletions.
12 changes: 7 additions & 5 deletions packages/nova-cloudinary/lib/server/cloudinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CloudinaryUtils = {
return data;
} catch (error) {
console.log("// Cloudinary upload failed for URL: "+imageUrl); // eslint-disable-line
console.log(error.stack); // eslint-disable-line
console.log(error); // eslint-disable-line
}
},

Expand Down Expand Up @@ -92,10 +92,12 @@ function cachePostThumbnailOnSubmit (post) {
if (post.thumbnailUrl) {

const data = CloudinaryUtils.uploadImage(post.thumbnailUrl);
Posts.update(post._id, {$set:{
cloudinaryId: data.cloudinaryId,
cloudinaryUrls: data.urls
}});
if (data) {
Posts.update(post._id, {$set:{
cloudinaryId: data.cloudinaryId,
cloudinaryUrls: data.urls
}});
}

}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/nova-core/lib/containers/withDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default function withDocument (options) {
const { ownProps, data } = returnedProps;
return {
loading: data.networkStatus === 1,
document: Utils.convertDates(collection, data[singleResolverName]),
// document: Utils.convertDates(collection, data[singleResolverName]),
document: data[singleResolverName],
fragmentName,
fragment,
};
Expand Down
6 changes: 4 additions & 2 deletions packages/nova-core/lib/containers/withEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ Child Props:
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import { getFragment, getFragmentName } from 'meteor/nova:core';

export default function withEdit(options) {

const {collection, fragment } = options,
fragmentName = fragment.definitions[0].name.value,
const {collection } = options,
fragment = options.fragment || getFragment(options.fragmentName),
fragmentName = getFragmentName(fragment),
collectionName = collection._name,
mutationName = collection.options.mutations.edit.name;

Expand Down
6 changes: 4 additions & 2 deletions packages/nova-core/lib/containers/withNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ Child Props:
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import { getFragment, getFragmentName } from 'meteor/nova:core';

export default function withNew(options) {

// get options
const { collection, fragment } = options,
fragmentName = fragment.definitions[0].name.value,
const { collection } = options,
fragment = options.fragment || getFragment(options.fragmentName),
fragmentName = getFragmentName(fragment),
collectionName = collection._name,
mutationName = collection.options.mutations.new.name;

Expand Down
Loading

0 comments on commit afebadb

Please sign in to comment.