Files
DiceCloud/app/imports/api/properties/Containers.js
Jonpot 1759427ca7 Fixes incorrect comment in Containers.js
I don't know which way this bug goes, but right now the comment on `contentsWeight` says it's 0 if contentsWeightless is checked. This isn't the case (however carriedWeight does follow this rule)
2024-01-24 12:29:02 -08:00

72 lines
1.6 KiB
JavaScript

import SimpleSchema from 'simpl-schema';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js';
let ContainerSchema = createPropertySchema({
name: {
type: String,
optional: true,
trim: false,
max: STORAGE_LIMITS.name,
},
carried: {
type: Boolean,
defaultValue: true,
optional: true,
},
contentsWeightless: {
type: Boolean,
optional: true,
},
weight: {
type: Number,
min: 0,
optional: true,
},
value: {
type: Number,
min: 0,
optional: true,
},
description: {
type: 'inlineCalculationFieldToCompute',
optional: true,
},
});
const ComputedOnlyContainerSchema = createPropertySchema({
description: {
type: 'computedOnlyInlineCalculationField',
optional: true,
},
// Weight of all the contents.
contentsWeight: {
type: Number,
optional: true,
removeBeforeCompute: true,
},
// Weight of all the carried contents (some sub-containers might not be carried)
// zero if `contentsWeightless` is true
carriedWeight: {
type: Number,
optional: true,
removeBeforeCompute: true,
},
contentsValue: {
type: Number,
optional: true,
removeBeforeCompute: true,
},
carriedValue: {
type: Number,
optional: true,
removeBeforeCompute: true,
},
});
const ComputedContainerSchema = new SimpleSchema()
.extend(ComputedOnlyContainerSchema)
.extend(ContainerSchema);
export { ContainerSchema, ComputedOnlyContainerSchema, ComputedContainerSchema };