mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
Merge branch 'devel' of https://github.com/VulcanJS/Vulcan into devel
This commit is contained in:
commit
d0395661ed
3 changed files with 30 additions and 29 deletions
|
@ -227,7 +227,7 @@ class SmartForm extends Component {
|
|||
- Nested array item: 'addresses.1.city'
|
||||
|
||||
*/
|
||||
compactParent(data, path);
|
||||
compactParent(data, path);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -572,10 +572,10 @@ class SmartForm extends Component {
|
|||
|
||||
// default to overwriting old value with new
|
||||
const { mode = 'overwrite' } = options;
|
||||
|
||||
|
||||
// keep the previous ones and extend (with possible replacement) with new ones
|
||||
this.setState(prevState => {
|
||||
|
||||
|
||||
// keep only the relevant properties
|
||||
const { currentValues, currentDocument, deletedValues } = cloneDeep(prevState);
|
||||
const newState = { currentValues, currentDocument, deletedValues, foo: {} };
|
||||
|
@ -811,7 +811,7 @@ class SmartForm extends Component {
|
|||
|
||||
// if there's a submit callback, run it
|
||||
if (this.props.submitCallback) {
|
||||
data = this.props.submitCallback(data);
|
||||
data = this.props.submitCallback(data) || data;
|
||||
}
|
||||
|
||||
if (this.getFormType() === 'new') {
|
||||
|
|
|
@ -58,8 +58,8 @@ export const createMutator = async ({ collection, document, data, currentUser, v
|
|||
const validationErrors = validateDocument(newDocument, collection, context);
|
||||
|
||||
// run validation callbacks
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.create.validate`, iterator: newDocument, properties: { currentUser, validationErrors }});
|
||||
newDocument = await runCallbacks({ name: `*.create.validate`, iterator: newDocument, properties: { currentUser, validationErrors }});
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.create.validate`, iterator: newDocument, properties: { currentUser, validationErrors, collection }});
|
||||
newDocument = await runCallbacks({ name: `*.create.validate`, iterator: newDocument, properties: { currentUser, validationErrors, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
newDocument = await runCallbacks(`${collectionName.toLowerCase()}.new.validate`, newDocument, currentUser, validationErrors);
|
||||
|
||||
|
@ -109,8 +109,8 @@ export const createMutator = async ({ collection, document, data, currentUser, v
|
|||
// }
|
||||
|
||||
// run sync callbacks
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.create.before`, iterator: newDocument, properties: { currentUser }});
|
||||
newDocument = await runCallbacks({ name: `*.create.before`, iterator: newDocument, properties: { currentUser }});
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.create.before`, iterator: newDocument, properties: { currentUser, collection }});
|
||||
newDocument = await runCallbacks({ name: `*.create.before`, iterator: newDocument, properties: { currentUser, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
newDocument = await runCallbacks(`${collectionName.toLowerCase()}.new.before`, newDocument, currentUser);
|
||||
newDocument = await runCallbacks(`${collectionName.toLowerCase()}.new.sync`, newDocument, currentUser);
|
||||
|
@ -119,8 +119,8 @@ export const createMutator = async ({ collection, document, data, currentUser, v
|
|||
newDocument._id = await Connectors.create(collection, newDocument);
|
||||
|
||||
// run any post-operation sync callbacks
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.create.after`, iterator: newDocument, properties: { currentUser }});
|
||||
newDocument = await runCallbacks({ name: `*.create.after`, iterator: newDocument, properties: { currentUser }});
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.create.after`, iterator: newDocument, properties: { currentUser, collection }});
|
||||
newDocument = await runCallbacks({ name: `*.create.after`, iterator: newDocument, properties: { currentUser, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
newDocument = await runCallbacks(`${collectionName.toLowerCase()}.new.after`, newDocument, currentUser);
|
||||
|
||||
|
@ -177,8 +177,8 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
|
|||
let validationErrors;
|
||||
|
||||
validationErrors = validateData(data, document, collection, context);
|
||||
data = await runCallbacks({ name: `${typeName.toLowerCase()}.update.validate`, iterator: data, properties: { document, currentUser, validationErrors }});
|
||||
data = await runCallbacks({ name: `*.update.validate`, iterator: data, properties: { document, currentUser, validationErrors }});
|
||||
data = await runCallbacks({ name: `${typeName.toLowerCase()}.update.validate`, iterator: data, properties: { document, currentUser, validationErrors, collection }});
|
||||
data = await runCallbacks({ name: `*.update.validate`, iterator: data, properties: { document, currentUser, validationErrors, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
data = modifierToData(await runCallbacks(`${collectionName.toLowerCase()}.edit.validate`, dataToModifier(data), document, currentUser, validationErrors));
|
||||
|
||||
|
@ -214,8 +214,8 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
|
|||
}
|
||||
|
||||
// run sync callbacks
|
||||
data = await runCallbacks({ name: `${typeName.toLowerCase()}.update.before`, iterator: data, properties: { document, currentUser, newDocument }});
|
||||
data = await runCallbacks({ name: `*.update.before`, iterator: data, properties: { document, currentUser, newDocument }});
|
||||
data = await runCallbacks({ name: `${typeName.toLowerCase()}.update.before`, iterator: data, properties: { document, currentUser, newDocument, collection }});
|
||||
data = await runCallbacks({ name: `*.update.before`, iterator: data, properties: { document, currentUser, newDocument, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
data = modifierToData(await runCallbacks(`${collectionName.toLowerCase()}.edit.before`, dataToModifier(data), document, currentUser, newDocument));
|
||||
data = modifierToData(await runCallbacks(`${collectionName.toLowerCase()}.edit.sync`, dataToModifier(data), document, currentUser, newDocument));
|
||||
|
@ -247,8 +247,8 @@ export const updateMutator = async ({ collection, documentId, selector, data, se
|
|||
}
|
||||
|
||||
// run any post-operation sync callbacks
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.update.after`, iterator: newDocument, properties: { document, currentUser }});
|
||||
newDocument = await runCallbacks({ name: `*.update.after`, iterator: newDocument, properties: { document, currentUser }});
|
||||
newDocument = await runCallbacks({ name: `${typeName.toLowerCase()}.update.after`, iterator: newDocument, properties: { document, currentUser, collection }});
|
||||
newDocument = await runCallbacks({ name: `*.update.after`, iterator: newDocument, properties: { document, currentUser, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
newDocument = await runCallbacks(`${collectionName.toLowerCase()}.edit.after`, newDocument, document, currentUser);
|
||||
|
||||
|
@ -293,8 +293,8 @@ export const deleteMutator = async ({ collection, documentId, selector, currentU
|
|||
|
||||
// if document is not trusted, run validation callbacks
|
||||
if (validate) {
|
||||
document = await runCallbacks({ name: `${typeName.toLowerCase()}.delete.validate`, iterator: document, properties: { currentUser }});
|
||||
document = await runCallbacks({ name: `*.delete.validate`, iterator: document, properties: { currentUser }});
|
||||
document = await runCallbacks({ name: `${typeName.toLowerCase()}.delete.validate`, iterator: document, properties: { currentUser, collection }});
|
||||
document = await runCallbacks({ name: `*.delete.validate`, iterator: document, properties: { currentUser, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
document = await runCallbacks(`${collectionName.toLowerCase()}.remove.validate`, document, currentUser);
|
||||
}
|
||||
|
@ -311,8 +311,8 @@ export const deleteMutator = async ({ collection, documentId, selector, currentU
|
|||
}
|
||||
}
|
||||
|
||||
await runCallbacks({ name: `${typeName.toLowerCase()}.delete.before`, iterator: document, properties: { currentUser }});
|
||||
await runCallbacks({ name: `*.delete.before`, iterator: document, properties: { currentUser }});
|
||||
await runCallbacks({ name: `${typeName.toLowerCase()}.delete.before`, iterator: document, properties: { currentUser, collection }});
|
||||
await runCallbacks({ name: `*.delete.before`, iterator: document, properties: { currentUser, collection }});
|
||||
// OpenCRUD backwards compatibility
|
||||
await runCallbacks(`${collectionName.toLowerCase()}.remove.before`, document, currentUser);
|
||||
await runCallbacks(`${collectionName.toLowerCase()}.remove.sync`, document, currentUser);
|
||||
|
|
|
@ -53,9 +53,10 @@ const schema = {
|
|||
type: String,
|
||||
optional: true,
|
||||
canRead: ['guests'],
|
||||
canUpdate: ['admins'],
|
||||
canCreate: ['members'],
|
||||
onInsert: user => {
|
||||
if (user.services && user.services.twitter && user.services.twitter.screenName) {
|
||||
if ((!user.username) && user.services && user.services.twitter && user.services.twitter.screenName) {
|
||||
return user.services.twitter.screenName;
|
||||
}
|
||||
},
|
||||
|
@ -202,7 +203,7 @@ const schema = {
|
|||
fieldName: 'avatarUrl',
|
||||
type: 'String',
|
||||
resolver: async (user, args, { Users }) => {
|
||||
|
||||
|
||||
if (_.isEmpty(user)) return null;
|
||||
|
||||
if (user.avatarUrl) {
|
||||
|
@ -213,7 +214,7 @@ const schema = {
|
|||
const fullUser = await Users.loader.load(user._id);
|
||||
return Users.avatar.getUrl(fullUser);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -232,9 +233,9 @@ const schema = {
|
|||
return Utils.getUnusedSlugByCollectionName('Users', basicSlug);
|
||||
}
|
||||
},
|
||||
/**
|
||||
The user's Twitter username
|
||||
*/
|
||||
/**
|
||||
The user's Twitter username
|
||||
*/
|
||||
twitterUsername: {
|
||||
type: String,
|
||||
optional: true,
|
||||
|
@ -269,7 +270,7 @@ const schema = {
|
|||
form: {
|
||||
options: function () {
|
||||
const groups = _.without(_.keys(getCollection('Users').groups), "guests", "members", "admins");
|
||||
return groups.map(group => {return {value: group, label: group};});
|
||||
return groups.map(group => { return { value: group, label: group }; });
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -289,7 +290,7 @@ const schema = {
|
|||
resolver: (user, args, { Users }) => {
|
||||
return Users.getProfileUrl(user, true);
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
editUrl: {
|
||||
|
@ -301,7 +302,7 @@ const schema = {
|
|||
resolver: (user, args, { Users }) => {
|
||||
return Users.getEditUrl(user, true);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue