From ed17d9e2d2683b398e0ce72a1c56dabf87f5689a Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 15 Oct 2020 14:54:58 +0200 Subject: [PATCH] Added slotfiller property type to increase control over slot filling --- app/imports/api/properties/SlotFillers.js | 38 ++++++++ .../computedPropertySchemasIndex.js | 4 +- .../api/properties/propertySchemasIndex.js | 4 +- app/imports/constants/PROPERTIES.js | 4 + .../server/publications/slotFillers.js | 11 ++- .../ui/creature/slots/SlotFillDialog.vue | 48 ++++++++-- app/imports/ui/creature/slots/Slots.vue | 26 ++++-- .../ui/properties/forms/SlotFillerForm.vue | 88 +++++++++++++++++++ app/imports/ui/properties/forms/SlotForm.vue | 3 +- .../forms/shared/propertyFormIndex.js | 4 +- 10 files changed, 214 insertions(+), 16 deletions(-) create mode 100644 app/imports/api/properties/SlotFillers.js create mode 100644 app/imports/ui/properties/forms/SlotFillerForm.vue diff --git a/app/imports/api/properties/SlotFillers.js b/app/imports/api/properties/SlotFillers.js new file mode 100644 index 00000000..338d360d --- /dev/null +++ b/app/imports/api/properties/SlotFillers.js @@ -0,0 +1,38 @@ +// SlotFiller fillers specifically fill a slot with a bit more control than +// other properties + +import SimpleSchema from 'simpl-schema'; + +let SlotFillerSchema = new SimpleSchema({ + name: { + type: String, + optional: true, + }, + picture: { + type: String, + optional: true, + }, + description: { + type: String, + optional: true, + }, + // Overrides the type when searching for properties + slotFillerType: { + type: String, + optional: true, + }, + // Fill more than one quantity in a slot, like feats and ability score + // improvements, filtered out of UI if there isn't space in quantityExpected + slotQuantityFilled: { + type: SimpleSchema.Integer, + defaultValue: 1, + min: 0, + }, + // Filters out of UI if condition isn't met, but isn't otherwise enforced + slotFillerCondition: { + type: String, + optional: true, + }, +}); + +export { SlotFillerSchema }; diff --git a/app/imports/api/properties/computedPropertySchemasIndex.js b/app/imports/api/properties/computedPropertySchemasIndex.js index d171a995..b5156b8e 100644 --- a/app/imports/api/properties/computedPropertySchemasIndex.js +++ b/app/imports/api/properties/computedPropertySchemasIndex.js @@ -18,6 +18,7 @@ import { RollSchema } from '/imports/api/properties/Rolls.js'; import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; import { ComputedSkillSchema } from '/imports/api/properties/Skills.js'; import { ComputedSlotSchema } from '/imports/api/properties/Slots.js'; +import { SlotFillerSchema } from '/imports/api/properties/SlotFillers.js'; import { ComputedSpellSchema } from '/imports/api/properties/Spells.js'; import { ComputedSpellListSchema } from '/imports/api/properties/SpellLists.js'; import { ToggleSchema } from '/imports/api/properties/Toggles.js'; @@ -36,10 +37,11 @@ const propertySchemasIndex = { folder: FolderSchema, note: NoteSchema, proficiency: ProficiencySchema, + propertySlot: ComputedSlotSchema, roll: RollSchema, savingThrow: ComputedSavingThrowSchema, skill: ComputedSkillSchema, - propertySlot: ComputedSlotSchema, + slotFiller: SlotFillerSchema, spellList: ComputedSpellListSchema, spell: ComputedSpellSchema, toggle: ToggleSchema, diff --git a/app/imports/api/properties/propertySchemasIndex.js b/app/imports/api/properties/propertySchemasIndex.js index af7b31e3..cc88f2ba 100644 --- a/app/imports/api/properties/propertySchemasIndex.js +++ b/app/imports/api/properties/propertySchemasIndex.js @@ -16,6 +16,7 @@ import { RollSchema } from '/imports/api/properties/Rolls.js'; import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; import { SkillSchema } from '/imports/api/properties/Skills.js'; import { SlotSchema } from '/imports/api/properties/Slots.js'; +import { SlotFillerSchema } from '/imports/api/properties/SlotFillers.js'; import { SpellListSchema } from '/imports/api/properties/SpellLists.js'; import { SpellSchema } from '/imports/api/properties/Spells.js'; import { ToggleSchema } from '/imports/api/properties/Toggles.js'; @@ -36,10 +37,11 @@ const propertySchemasIndex = { folder: FolderSchema, note: NoteSchema, proficiency: ProficiencySchema, + propertySlot: SlotSchema, roll: RollSchema, savingThrow: SavingThrowSchema, skill: SkillSchema, - propertySlot: SlotSchema, + slotFiller: SlotFillerSchema, spellList: SpellListSchema, spell: SpellSchema, toggle: ToggleSchema, diff --git a/app/imports/constants/PROPERTIES.js b/app/imports/constants/PROPERTIES.js index 78828b06..18646ac7 100644 --- a/app/imports/constants/PROPERTIES.js +++ b/app/imports/constants/PROPERTIES.js @@ -75,6 +75,10 @@ const PROPERTIES = Object.freeze({ icon: 'tab_unselected', name: 'Slot' }, + slotFiller: { + icon: 'picture_in_picture', + name: 'Slot filler' + }, spellList: { icon: '$vuetify.icons.spell_list', name: 'Spell list' diff --git a/app/imports/server/publications/slotFillers.js b/app/imports/server/publications/slotFillers.js index cd3804d5..21c80a3a 100644 --- a/app/imports/server/publications/slotFillers.js +++ b/app/imports/server/publications/slotFillers.js @@ -33,10 +33,17 @@ Meteor.publish('slotFillers', function(slotId){ // Build a filter for nodes in those libraries that match the slot let filter = { 'ancestors.id': {$in: libraryIds}, - 'tags': {$all: slot.slotTags}, }; + if (slot.tags.length){ + filter.tags = {$all: slot.slotTags}; + } if (slot.slotType){ - filter.type = slot.slotType; + filter.$or = [{ + type: slot.slotType + },{ + type: 'slotFiller', + slotFillerType: slot.slotType, + }]; } return LibraryNodes.find(filter); }); diff --git a/app/imports/ui/creature/slots/SlotFillDialog.vue b/app/imports/ui/creature/slots/SlotFillDialog.vue index 5475ea94..95b937a5 100644 --- a/app/imports/ui/creature/slots/SlotFillDialog.vue +++ b/app/imports/ui/creature/slots/SlotFillDialog.vue @@ -73,11 +73,14 @@ diff --git a/app/imports/ui/properties/forms/SlotForm.vue b/app/imports/ui/properties/forms/SlotForm.vue index 85f5e112..938678e3 100644 --- a/app/imports/ui/properties/forms/SlotForm.vue +++ b/app/imports/ui/properties/forms/SlotForm.vue @@ -1,5 +1,5 @@