diff --git a/app/imports/api/properties/Actions.js b/app/imports/api/properties/Actions.js index f563c19c..3ce4bcd5 100644 --- a/app/imports/api/properties/Actions.js +++ b/app/imports/api/properties/Actions.js @@ -1,5 +1,5 @@ import SimpleSchema from 'simpl-schema'; -import ResourceSchema from '/imports/api/properties/subSchemas/ResourceSchema.js' +import ResourcesSchema from '/imports/api/properties/subSchemas/ResourcesSchema.js' import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js'; /* @@ -8,9 +8,7 @@ import ResultsSchema from '/imports/api/properties/subSchemas/ResultsSchema.js'; * Any actions that are children of this action will be considered alternatives * to this action */ -let ActionSchema = new SimpleSchema({}) -.extend(ResourceSchema) -.extend({ +let ActionSchema = new SimpleSchema({ name: { type: String, optional: true, @@ -47,6 +45,10 @@ let ActionSchema = new SimpleSchema({}) type: ResultsSchema, defaultValue: {}, }, + resources: { + type: ResourcesSchema, + defaultValue: {}, + }, // Calculation of how many times this action can be used // Only set if this action tracks its own uses, rather than adjusting // resources diff --git a/app/imports/api/properties/subSchemas/AttributeConsumedSchema.js b/app/imports/api/properties/subSchemas/AttributeConsumedSchema.js new file mode 100644 index 00000000..8c85d13f --- /dev/null +++ b/app/imports/api/properties/subSchemas/AttributeConsumedSchema.js @@ -0,0 +1,22 @@ +import SimpleSchema from 'simpl-schema'; +import { Random } from 'meteor/random'; + +const AttributeConsumedSchema = new SimpleSchema({ + _id: { + type: String, + regEx: SimpleSchema.RegEx.Id, + autoValue(){ + if (!this.isSet) return Random.id(); + } + }, + variableName: { + type: String, + optional: true, + }, + quantity: { + type: Number, + defaultValue: 1, + }, +}); + +export default AttributeConsumedSchema; diff --git a/app/imports/api/properties/subSchemas/ItemConsumedSchema.js b/app/imports/api/properties/subSchemas/ItemConsumedSchema.js new file mode 100644 index 00000000..ecfe56b1 --- /dev/null +++ b/app/imports/api/properties/subSchemas/ItemConsumedSchema.js @@ -0,0 +1,22 @@ +import SimpleSchema from 'simpl-schema'; +import { Random } from 'meteor/random'; + +const ItemConsumedSchema = new SimpleSchema({ + _id: { + type: String, + regEx: SimpleSchema.RegEx.Id, + autoValue(){ + if (!this.isSet) return Random.id(); + } + }, + tag: { + type: String, + optional: true, + }, + quantity: { + type: Number, + defaultValue: 1, + }, +}); + +export default ItemConsumedSchema; diff --git a/app/imports/api/properties/subSchemas/ResourceSchema.js b/app/imports/api/properties/subSchemas/ResourceSchema.js deleted file mode 100644 index 412f0b82..00000000 --- a/app/imports/api/properties/subSchemas/ResourceSchema.js +++ /dev/null @@ -1,34 +0,0 @@ -import SimpleSchema from 'simpl-schema'; - -const ResourceSchema = new SimpleSchema({ - itemsConsumed: { - type: Array, - defaultValue: [], - }, - 'itemsConsumed.$': { - type: Object, - }, - 'itemsConsumed.$.tag': { - type: String, - }, - 'itemsConsumed.$.quantity': { - type: Number, - defaultValue: 1, - }, - attributesConsumed: { - type: Array, - defaultValue: [], - }, - 'attributesConsumed.$': { - type: Object, - }, - 'attributesConsumed.$.variableName': { - type: String, - }, - 'attributesConsumed.$.quantity': { - type: Number, - defaultValue: 1, - }, -}); - -export default ResourceSchema; diff --git a/app/imports/api/properties/subSchemas/ResourcesSchema.js b/app/imports/api/properties/subSchemas/ResourcesSchema.js new file mode 100644 index 00000000..bc7ae9da --- /dev/null +++ b/app/imports/api/properties/subSchemas/ResourcesSchema.js @@ -0,0 +1,22 @@ +import SimpleSchema from 'simpl-schema'; +import ItemConsumedSchema from '/imports/api/properties/subSchemas/ItemConsumedSchema.js'; +import AttributeConsumedSchema from '/imports/api/properties/subSchemas/AttributeConsumedSchema.js'; + +const ResourcesSchema = new SimpleSchema({ + itemsConsumed: { + type: Array, + defaultValue: [], + }, + 'itemsConsumed.$': { + type: ItemConsumedSchema, + }, + attributesConsumed: { + type: Array, + defaultValue: [], + }, + 'attributesConsumed.$': { + type: AttributeConsumedSchema, + }, +}); + +export default ResourcesSchema; diff --git a/app/imports/ui/properties/forms/ActionForm.vue b/app/imports/ui/properties/forms/ActionForm.vue index 380c4e67..48fa296b 100644 --- a/app/imports/ui/properties/forms/ActionForm.vue +++ b/app/imports/ui/properties/forms/ActionForm.vue @@ -42,6 +42,14 @@ @pull="({path, ack}) => $emit('pull', {path: ['results', ...path], ack})" /> + + + import FormSection, {FormSections} from '/imports/ui/properties/forms/shared/FormSection.vue'; import ResultsForm from '/imports/ui/properties/forms/ResultsForm.vue'; + import ResourcesForm from '/imports/ui/properties/forms/ResourcesForm.vue'; export default { components: { FormSection, FormSections, ResultsForm, + ResourcesForm, }, props: { stored: { diff --git a/app/imports/ui/properties/forms/AttributeConsumedForm.vue b/app/imports/ui/properties/forms/AttributeConsumedForm.vue new file mode 100644 index 00000000..efaa6d01 --- /dev/null +++ b/app/imports/ui/properties/forms/AttributeConsumedForm.vue @@ -0,0 +1,41 @@ + + + diff --git a/app/imports/ui/properties/forms/AttributesConsumedListForm.vue b/app/imports/ui/properties/forms/AttributesConsumedListForm.vue new file mode 100644 index 00000000..1b6cf952 --- /dev/null +++ b/app/imports/ui/properties/forms/AttributesConsumedListForm.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/app/imports/ui/properties/forms/ItemConsumedForm.vue b/app/imports/ui/properties/forms/ItemConsumedForm.vue new file mode 100644 index 00000000..24eb50de --- /dev/null +++ b/app/imports/ui/properties/forms/ItemConsumedForm.vue @@ -0,0 +1,41 @@ + + + diff --git a/app/imports/ui/properties/forms/ItemsConsumedListForm.vue b/app/imports/ui/properties/forms/ItemsConsumedListForm.vue new file mode 100644 index 00000000..79f500f7 --- /dev/null +++ b/app/imports/ui/properties/forms/ItemsConsumedListForm.vue @@ -0,0 +1,48 @@ + + + diff --git a/app/imports/ui/properties/forms/ResourcesForm.vue b/app/imports/ui/properties/forms/ResourcesForm.vue new file mode 100644 index 00000000..7c7b8772 --- /dev/null +++ b/app/imports/ui/properties/forms/ResourcesForm.vue @@ -0,0 +1,110 @@ + + + + +