methods now use correct mixins
This commit is contained in:
@@ -11,26 +11,35 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Actions = new Mongo.Collection('actions');
|
let Actions = new Mongo.Collection('actions');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions are things a character can do
|
* Actions are things a character can do
|
||||||
|
* Any rolls that are children of actions will be rolled when taking the action
|
||||||
|
* Any actions that are children of this action will be considered alternatives
|
||||||
|
* to this action
|
||||||
*/
|
*/
|
||||||
let ActionSchema = schema({
|
let ActionSchema = schema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
// What time-resource is used to take the action in combat
|
// What time-resource is used to take the action in combat
|
||||||
|
// long actions take longer than 1 round to cast
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
allowedValues: ['attack', 'action', 'bonus', 'reaction', 'free'],
|
allowedValues: ['action', 'bonus', 'attack', 'reaction', 'free', 'long'],
|
||||||
defaultValue: 'action',
|
defaultValue: 'action',
|
||||||
},
|
},
|
||||||
// Who is the action directed at
|
// Who is the action directed at
|
||||||
@@ -42,8 +51,8 @@ let ActionSchema = schema({
|
|||||||
'multipleTargets',
|
'multipleTargets',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// Adjustments applied when taking this action, regardless of roll outcomes
|
// Adjustments applied when taking this action
|
||||||
// If these adjustments can't be made, the action should be unusable
|
// Ideally, if these adjustments can't be made, the action should be unusable
|
||||||
adjustments: {
|
adjustments: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
@@ -51,7 +60,7 @@ let ActionSchema = schema({
|
|||||||
'adjustments.$': {
|
'adjustments.$': {
|
||||||
type: AdjustmentSchema,
|
type: AdjustmentSchema,
|
||||||
},
|
},
|
||||||
// Buffs applied when taking this action, regardless of roll outcomes
|
// Buffs applied when taking this action
|
||||||
buffs: {
|
buffs: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
@@ -60,7 +69,8 @@ let ActionSchema = schema({
|
|||||||
type: StoredBuffSchema,
|
type: StoredBuffSchema,
|
||||||
},
|
},
|
||||||
// Calculation of how many times this action can be used
|
// Calculation of how many times this action can be used
|
||||||
// Only set if this action tracks its own uses
|
// Only set if this action tracks its own uses, rather than adjusting
|
||||||
|
// resources
|
||||||
uses: {
|
uses: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -104,18 +114,13 @@ const insertAction = new ValidatedMethod({
|
|||||||
const updateAction = new ValidatedMethod({
|
const updateAction = new ValidatedMethod({
|
||||||
name: 'Actions.methods.update',
|
name: 'Actions.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Actions,
|
collection: Actions,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: ActionSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: ActionSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Actions.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Actions;
|
export default Actions;
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ let AttributeSchema = schema({
|
|||||||
});
|
});
|
||||||
|
|
||||||
AttributeSchema.extend(ColorSchema);
|
AttributeSchema.extend(ColorSchema);
|
||||||
AttributeSchema.extend(PropertySchema);
|
|
||||||
|
|
||||||
const ComputedAttributeSchema = schema({
|
const ComputedAttributeSchema = schema({
|
||||||
// The computed value of the attribute
|
// The computed value of the attribute
|
||||||
@@ -94,6 +93,7 @@ const ComputedAttributeSchema = schema({
|
|||||||
},
|
},
|
||||||
}).extend(AttributeSchema);
|
}).extend(AttributeSchema);
|
||||||
|
|
||||||
|
Attributes.attachSchema(PropertySchema);
|
||||||
Attributes.attachSchema(ComputedAttributeSchema);
|
Attributes.attachSchema(ComputedAttributeSchema);
|
||||||
Attributes.attachSchema(ChildSchema);
|
Attributes.attachSchema(ChildSchema);
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ const updateAttribute = new ValidatedMethod({
|
|||||||
],
|
],
|
||||||
collection: Attributes,
|
collection: Attributes,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
updateSchema: AttributeSchema,
|
schema: AttributeSchema.omit(['adjutment']),
|
||||||
skipRecompute({update}){
|
skipRecompute({update}){
|
||||||
let fields = getModifierFields(update);
|
let fields = getModifierFields(update);
|
||||||
return !fields.hasAny([
|
return !fields.hasAny([
|
||||||
@@ -134,9 +134,6 @@ const updateAttribute = new ValidatedMethod({
|
|||||||
'baseValue',
|
'baseValue',
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
run({_id, update}) {
|
|
||||||
return Attributes.update(_id, update);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const adjustAttribute = new ValidatedMethod({
|
const adjustAttribute = new ValidatedMethod({
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Buffs = new Mongo.Collection('buffs');
|
let Buffs = new Mongo.Collection('buffs');
|
||||||
|
|
||||||
@@ -99,18 +101,13 @@ const insertBuff = new ValidatedMethod({
|
|||||||
const updateBuff = new ValidatedMethod({
|
const updateBuff = new ValidatedMethod({
|
||||||
name: 'Buffs.methods.update',
|
name: 'Buffs.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Buffs,
|
collection: Buffs,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: BuffSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: BuffSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Buffs.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Buffs;
|
export default Buffs;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let ClassLevels = new Mongo.Collection("classLevels");
|
let ClassLevels = new Mongo.Collection("classLevels");
|
||||||
|
|
||||||
@@ -17,6 +19,10 @@ let ClassLevelSchema = schema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
// The name of this class level's variable
|
// The name of this class level's variable
|
||||||
variableName: {
|
variableName: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -66,18 +72,13 @@ const insertClassLevel = new ValidatedMethod({
|
|||||||
const updateClassLevel = new ValidatedMethod({
|
const updateClassLevel = new ValidatedMethod({
|
||||||
name: 'ClassLevels.methods.update',
|
name: 'ClassLevels.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: ClassLevels,
|
collection: ClassLevels,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: ClassLevelSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: ClassLevelSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return ClassLevels.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ClassLevels;
|
export default ClassLevels;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Classes = new Mongo.Collection("classes");
|
let Classes = new Mongo.Collection("classes");
|
||||||
|
|
||||||
@@ -51,18 +53,13 @@ const insertClass = new ValidatedMethod({
|
|||||||
const updateClass = new ValidatedMethod({
|
const updateClass = new ValidatedMethod({
|
||||||
name: 'Classes.methods.update',
|
name: 'Classes.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Classes,
|
collection: Classes,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: ClassSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: ClassSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Classes.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Classes;
|
export default Classes;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let DamageMultipliers = new Mongo.Collection("damageMultipliers");
|
let DamageMultipliers = new Mongo.Collection("damageMultipliers");
|
||||||
|
|
||||||
@@ -42,12 +44,12 @@ DamageMultipliers.attachSchema(ChildSchema);
|
|||||||
const insertDamageMultiplier = new ValidatedMethod({
|
const insertDamageMultiplier = new ValidatedMethod({
|
||||||
name: 'DamageMultipliers.methods.insert',
|
name: 'DamageMultipliers.methods.insert',
|
||||||
mixins: [
|
mixins: [
|
||||||
creaturePermissionMixin,
|
|
||||||
setDocAncestryMixin,
|
setDocAncestryMixin,
|
||||||
ensureAncestryContainsCharIdMixin,
|
ensureAncestryContainsCharIdMixin,
|
||||||
recomputeCreatureMixin,
|
recomputeCreatureMixin,
|
||||||
setDocToLastMixin,
|
setDocToLastMixin,
|
||||||
simpleSchemaMixin,
|
simpleSchemaMixin,
|
||||||
|
creaturePermissionMixin,
|
||||||
],
|
],
|
||||||
collection: DamageMultipliers,
|
collection: DamageMultipliers,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
@@ -60,19 +62,14 @@ const insertDamageMultiplier = new ValidatedMethod({
|
|||||||
const updateDamageMultiplier = new ValidatedMethod({
|
const updateDamageMultiplier = new ValidatedMethod({
|
||||||
name: 'DamageMultipliers.methods.update',
|
name: 'DamageMultipliers.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
creaturePermissionMixin,
|
|
||||||
recomputeCreatureMixin,
|
recomputeCreatureMixin,
|
||||||
simpleSchemaMixin,
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
|
creaturePermissionMixin,
|
||||||
],
|
],
|
||||||
collection: DamageMultipliers,
|
collection: DamageMultipliers,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: DamageMultiplierSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: DamageMultiplierSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return DamageMultipliers.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default DamageMultipliers;
|
export default DamageMultipliers;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Effects = new Mongo.Collection('effects');
|
let Effects = new Mongo.Collection('effects');
|
||||||
|
|
||||||
@@ -81,18 +83,21 @@ const insertEffect = new ValidatedMethod({
|
|||||||
const updateEffect = new ValidatedMethod({
|
const updateEffect = new ValidatedMethod({
|
||||||
name: 'Effects.methods.update',
|
name: 'Effects.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
creaturePermissionMixin,
|
|
||||||
recomputeCreatureMixin,
|
recomputeCreatureMixin,
|
||||||
simpleSchemaMixin,
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
|
creaturePermissionMixin,
|
||||||
],
|
],
|
||||||
collection: Effects,
|
collection: Effects,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: EffectSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
skipRecompute({update}){
|
||||||
update: EffectSchema.omit('name'),
|
let fields = getModifierFields(update);
|
||||||
}),
|
return !fields.hasAny([
|
||||||
run({_id, update}) {
|
'operation',
|
||||||
return Effects.update(_id, {$set: update});
|
'calculation',
|
||||||
|
'stat',
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Experiences = new Mongo.Collection("experience");
|
let Experiences = new Mongo.Collection("experience");
|
||||||
|
|
||||||
@@ -77,16 +79,14 @@ const insertExperience = new ValidatedMethod({
|
|||||||
const updateExperience = new ValidatedMethod({
|
const updateExperience = new ValidatedMethod({
|
||||||
name: 'Experiences.methods.update',
|
name: 'Experiences.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
creaturePermissionMixin,
|
|
||||||
recomputeCreatureMixin,
|
recomputeCreatureMixin,
|
||||||
simpleSchemaMixin,
|
ropagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
|
creaturePermissionMixin,
|
||||||
],
|
],
|
||||||
collection: Experiences,
|
collection: Experiences,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: ExperienceSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: ExperienceSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
skipRecompute({update}){
|
skipRecompute({update}){
|
||||||
return !('value' in update);
|
return !('value' in update);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
|||||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||||
|
|
||||||
// Mixins
|
// Mixins
|
||||||
import recomputeCreatureMixin from '/imports/api/mixins/recomputeCreatureMixin.js';
|
|
||||||
import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin.js';
|
import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin.js';
|
||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Features = new Mongo.Collection('features');
|
let Features = new Mongo.Collection('features');
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ let FeatureSchema = schema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -57,18 +62,13 @@ const insertFeature = new ValidatedMethod({
|
|||||||
const updateFeature = new ValidatedMethod({
|
const updateFeature = new ValidatedMethod({
|
||||||
name: 'Features.methods.update',
|
name: 'Features.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Features,
|
collection: Features,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: FeatureSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: FeatureSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Features.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Features;
|
export default Features;
|
||||||
|
|||||||
@@ -8,18 +8,25 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Folders = new Mongo.Collection('folders');
|
let Folders = new Mongo.Collection('folders');
|
||||||
|
|
||||||
|
// Folders organize a character sheet into a tree, particularly to group things
|
||||||
|
// like 'race' and 'background'
|
||||||
let FolderSchema = schema({
|
let FolderSchema = schema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
});
|
enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
}).extend(PropertySchema);
|
||||||
|
|
||||||
Folders.attachSchema(FolderSchema);
|
Folders.attachSchema(FolderSchema);
|
||||||
Folders.attachSchema(PropertySchema);
|
|
||||||
Folders.attachSchema(ChildSchema);
|
Folders.attachSchema(ChildSchema);
|
||||||
|
|
||||||
const insertFolder = new ValidatedMethod({
|
const insertFolder = new ValidatedMethod({
|
||||||
@@ -42,18 +49,13 @@ const insertFolder = new ValidatedMethod({
|
|||||||
const updateFolder = new ValidatedMethod({
|
const updateFolder = new ValidatedMethod({
|
||||||
name: 'Folders.methods.update',
|
name: 'Folders.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Folders,
|
collection: Folders,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: FolderSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: FolderSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Folders.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Folders;
|
export default Folders;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Notes = new Mongo.Collection("notes");
|
let Notes = new Mongo.Collection("notes");
|
||||||
|
|
||||||
@@ -47,18 +49,13 @@ const insertNote = new ValidatedMethod({
|
|||||||
const updateNote = new ValidatedMethod({
|
const updateNote = new ValidatedMethod({
|
||||||
name: 'Notes.methods.update',
|
name: 'Notes.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Notes,
|
collection: Notes,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: NoteSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: NoteSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Notes.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Notes;
|
export default Notes;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Proficiencies = new Mongo.Collection("proficiencies");
|
let Proficiencies = new Mongo.Collection("proficiencies");
|
||||||
|
|
||||||
@@ -55,18 +57,20 @@ const insertProficiency = new ValidatedMethod({
|
|||||||
const updateProficiency = new ValidatedMethod({
|
const updateProficiency = new ValidatedMethod({
|
||||||
name: 'Proficiencies.methods.update',
|
name: 'Proficiencies.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
creaturePermissionMixin,
|
|
||||||
recomputeCreatureMixin,
|
recomputeCreatureMixin,
|
||||||
simpleSchemaMixin,
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
|
creaturePermissionMixin,
|
||||||
],
|
],
|
||||||
collection: Proficiencies,
|
collection: Proficiencies,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: ProficiencySchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
skipRecompute({update}){
|
||||||
update: ProficiencySchema.omit('name'),
|
let fields = getModifierFields(update);
|
||||||
}),
|
return !fields.hasAny([
|
||||||
run({_id, update}) {
|
'value',
|
||||||
return Proficiencies.update(_id, {$set: update});
|
'skill',
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Rolls = new Mongo.Collection('rolls');
|
let Rolls = new Mongo.Collection('rolls');
|
||||||
|
|
||||||
let RollChildrenSchema = new SimpleSchema({
|
let RollChildrenSchema = new SimpleSchema({
|
||||||
name: {
|
|
||||||
type: String,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
// The adjustments to be applied
|
// The adjustments to be applied
|
||||||
adjustments: {
|
adjustments: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -91,12 +89,8 @@ let RollSchema = new SimpleSchema({
|
|||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
// The buffs and adjustments to apply based on the outcome of the roll
|
// The buffs and adjustments to apply based on the outcome of the roll
|
||||||
hit: {
|
hit: RollChildrenSchema,
|
||||||
type: RollChildrenSchema,
|
miss: RollChildrenSchema,
|
||||||
},
|
|
||||||
miss: {
|
|
||||||
type: RollChildrenSchema,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Rolls.attachSchema(RollSchema);
|
Rolls.attachSchema(RollSchema);
|
||||||
@@ -123,18 +117,13 @@ const insertRoll = new ValidatedMethod({
|
|||||||
const updateRoll = new ValidatedMethod({
|
const updateRoll = new ValidatedMethod({
|
||||||
name: 'Rolls.methods.update',
|
name: 'Rolls.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Rolls,
|
collection: Rolls,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: RollSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: RollSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Rolls.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Rolls;
|
export default Rolls;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let Skills = new Mongo.Collection("skills");
|
let Skills = new Mongo.Collection("skills");
|
||||||
|
|
||||||
@@ -124,18 +126,23 @@ const insertSkill = new ValidatedMethod({
|
|||||||
const updateSkill = new ValidatedMethod({
|
const updateSkill = new ValidatedMethod({
|
||||||
name: 'Skills.methods.update',
|
name: 'Skills.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
creaturePermissionMixin,
|
|
||||||
recomputeCreatureMixin,
|
recomputeCreatureMixin,
|
||||||
simpleSchemaMixin,
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
|
creaturePermissionMixin,
|
||||||
],
|
],
|
||||||
collection: Skills,
|
collection: Skills,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: SkillSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
skipRecompute({update}){
|
||||||
update: SkillSchema.omit('name'),
|
let fields = getModifierFields(update);
|
||||||
}),
|
return !fields.hasAny([
|
||||||
run({_id, update}) {
|
'variableName',
|
||||||
return Skills.update(_id, {$set: update});
|
'ability',
|
||||||
|
'type',
|
||||||
|
'baseValue',
|
||||||
|
'baseProficiency',
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
let SpellLists = new Mongo.Collection("spellLists");
|
let SpellLists = new Mongo.Collection("spellLists");
|
||||||
|
|
||||||
@@ -64,18 +66,13 @@ const insertSpellList = new ValidatedMethod({
|
|||||||
const updateSpellList = new ValidatedMethod({
|
const updateSpellList = new ValidatedMethod({
|
||||||
name: 'SpellLists.methods.update',
|
name: 'SpellLists.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: SpellLists,
|
collection: SpellLists,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: SpellListSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: SpellListSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return SpellLists.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default SpellLists;
|
export default SpellLists;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
|||||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||||
|
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||||
|
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||||
|
|
||||||
const magicSchools = [
|
const magicSchools = [
|
||||||
'Abjuration',
|
'Abjuration',
|
||||||
@@ -28,11 +30,18 @@ let SpellSchema = schema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
prepared: {
|
// If it's always prepared, it doesn't count against the number of spells
|
||||||
type: String,
|
// prepared in a spell list, and enabled should be true
|
||||||
defaultValue: 'prepared',
|
alwaysPrepared: {
|
||||||
allowedValues: ['prepared', 'unprepared', 'always'],
|
type: Boolean,
|
||||||
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
// Spells are enabled when they are prepared, so that unprepared spells don't
|
||||||
|
// show their actions
|
||||||
|
enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -108,18 +117,13 @@ const insertSpell = new ValidatedMethod({
|
|||||||
const updateSpell = new ValidatedMethod({
|
const updateSpell = new ValidatedMethod({
|
||||||
name: 'Spells.methods.update',
|
name: 'Spells.methods.update',
|
||||||
mixins: [
|
mixins: [
|
||||||
|
propagateInheritanceUpdateMixin,
|
||||||
|
updateSchemaMixin,
|
||||||
creaturePermissionMixin,
|
creaturePermissionMixin,
|
||||||
simpleSchemaMixin,
|
|
||||||
],
|
],
|
||||||
collection: Spells,
|
collection: Spells,
|
||||||
permission: 'edit',
|
permission: 'edit',
|
||||||
schema: new SimpleSchema({
|
schema: SpellSchema,
|
||||||
_id: SimpleSchema.RegEx.Id,
|
|
||||||
update: SpellSchema.omit('name'),
|
|
||||||
}),
|
|
||||||
run({_id, update}) {
|
|
||||||
return Spells.update(_id, {$set: update});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Spells;
|
export default Spells;
|
||||||
|
|||||||
@@ -12,16 +12,12 @@ import SimpleSchema from 'simpl-schema';
|
|||||||
export default function updateSchemaMixin(methodOptions) {
|
export default function updateSchemaMixin(methodOptions) {
|
||||||
// If the user didn't give us a schema and they did give us a validate, assume
|
// If the user didn't give us a schema and they did give us a validate, assume
|
||||||
// that they are choosing to use the validate way of doing things in this call.
|
// that they are choosing to use the validate way of doing things in this call.
|
||||||
// If they've built a wrapper around ValidateMethod that includes this mixin
|
|
||||||
// all the time, this could happen semi-"intentionally". There may be times they
|
|
||||||
// just don't want to use a schema and have specified a "validate" option. So
|
|
||||||
// returning the unchanged options instead of an error seems proper.
|
|
||||||
if ((
|
if ((
|
||||||
typeof methodOptions.updateSchema === 'undefined' &&
|
typeof methodOptions.schema === 'undefined' &&
|
||||||
typeof methodOptions.validate !== 'undefined'
|
typeof methodOptions.validate !== 'undefined'
|
||||||
) || (
|
) || (
|
||||||
typeof methodOptions.updateSchema !== 'undefined' &&
|
typeof methodOptions.schema !== 'undefined' &&
|
||||||
methodOptions.updateSchema === null &&
|
methodOptions.schema === null &&
|
||||||
typeof methodOptions.validate !== 'undefined' &&
|
typeof methodOptions.validate !== 'undefined' &&
|
||||||
methodOptions.validate !== null
|
methodOptions.validate !== null
|
||||||
)) {
|
)) {
|
||||||
@@ -46,10 +42,10 @@ export default function updateSchemaMixin(methodOptions) {
|
|||||||
|
|
||||||
// Make the update schema a SimpleSchema, if it isn't already
|
// Make the update schema a SimpleSchema, if it isn't already
|
||||||
let updateSchema;
|
let updateSchema;
|
||||||
if (methodOptions.updateSchema instanceof SimpleSchema) {
|
if (methodOptions.schema instanceof SimpleSchema) {
|
||||||
updateSchema = methodOptions.updateSchema;
|
updateSchema = methodOptions.schema;
|
||||||
} else {
|
} else {
|
||||||
updateSchema = new SimpleSchema(methodOptions.updateSchema);
|
updateSchema = new SimpleSchema(methodOptions.schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the new validation
|
// Set up the new validation
|
||||||
@@ -57,5 +53,12 @@ export default function updateSchemaMixin(methodOptions) {
|
|||||||
argumentSchema.validate(args);
|
argumentSchema.validate(args);
|
||||||
updateSchema.validate(args.update, methodOptions.schemaValidatorOptions);
|
updateSchema.validate(args.update, methodOptions.schemaValidatorOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Give a default run function if one isn't supplied
|
||||||
|
if (!methodOptions.run){
|
||||||
|
methodOptions.run = function({_id, update}){
|
||||||
|
return MethodOptions.collection.update(_id, {$set: update});
|
||||||
|
};
|
||||||
|
}
|
||||||
return methodOptions;
|
return methodOptions;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user