From da5143693f4f82665f599e1203ba5eec662665a5 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 21 Jun 2022 11:08:45 +0200 Subject: [PATCH] Iterated on class UI --- app/imports/api/properties/Classes.js | 93 ++++++-- app/imports/ui/properties/forms/ClassForm.vue | 222 ++++++++++++++++++ .../forms/shared/propertyFormIndex.js | 3 +- .../ui/properties/viewers/ClassViewer.vue | 91 +++++++ .../ui/properties/viewers/SlotViewer.vue | 15 +- .../viewers/shared/propertyViewerIndex.js | 3 +- 6 files changed, 405 insertions(+), 22 deletions(-) create mode 100644 app/imports/ui/properties/forms/ClassForm.vue create mode 100644 app/imports/ui/properties/viewers/ClassViewer.vue diff --git a/app/imports/api/properties/Classes.js b/app/imports/api/properties/Classes.js index ee631246..e6e6471f 100644 --- a/app/imports/api/properties/Classes.js +++ b/app/imports/api/properties/Classes.js @@ -1,34 +1,95 @@ import SimpleSchema from 'simpl-schema'; import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js'; import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js'; -import { SlotSchema, ComputedOnlySlotSchema } from './Slots.js'; // Classes are like slots, except they only take class levels and enforce that // lower levels are taken before higher levels let ClassSchema = createPropertySchema({ + name: { + type: String, + optional: true, + max: STORAGE_LIMITS.name, + }, + description: { + type: 'inlineCalculationFieldToCompute', + optional: true, + }, // Only `classLevel`s with the same variable name can fill the class variableName: { type: String, optional: true, max: STORAGE_LIMITS.variableName, }, -}).extend(SlotSchema); + slotTags: { + type: Array, + defaultValue: [], + maxCount: STORAGE_LIMITS.tagCount, + }, + 'slotTags.$': { + type: String, + max: STORAGE_LIMITS.tagLength, + }, + extraTags: { + type: Array, + defaultValue: [], + maxCount: STORAGE_LIMITS.extraTagsCount, + }, + 'extraTags.$': { + type: Object, + }, + 'extraTags.$._id': { + type: String, + regEx: SimpleSchema.RegEx.Id, + autoValue(){ + if (!this.isSet) return Random.id(); + } + }, + 'extraTags.$.operation': { + type: String, + allowedValues: ['OR', 'NOT'], + defaultValue: 'OR', + }, + 'extraTags.$.tags': { + type: Array, + defaultValue: [], + maxCount: STORAGE_LIMITS.tagCount, + }, + 'extraTags.$.tags.$': { + type: String, + max: STORAGE_LIMITS.tagLength, + }, + slotCondition: { + type: 'fieldToCompute', + optional: true, + }, +}); const ComputedOnlyClassSchema = createPropertySchema({ - level: { - type: SimpleSchema.Integer, - optional: true, - removeBeforeCompute: true, - }, - missingLevels: { - type: Array, - optional: true, - removeBeforeCompute: true, - }, - 'missingLevels.$': { - type: SimpleSchema.Integer, - }, - }).extend(ComputedOnlySlotSchema); + // Computed fields + description: { + type: 'computedOnlyInlineCalculationField', + optional: true, + }, + slotCondition: { + type: 'computedOnlyField', + optional: true, + }, + + // Denormalised fields + level: { + type: SimpleSchema.Integer, + optional: true, + removeBeforeCompute: true, + }, + missingLevels: { + type: Array, + optional: true, + removeBeforeCompute: true, + }, + 'missingLevels.$': { + type: SimpleSchema.Integer, + }, +}); const ComputedClassSchema = new SimpleSchema() .extend(ClassSchema) diff --git a/app/imports/ui/properties/forms/ClassForm.vue b/app/imports/ui/properties/forms/ClassForm.vue new file mode 100644 index 00000000..50003919 --- /dev/null +++ b/app/imports/ui/properties/forms/ClassForm.vue @@ -0,0 +1,222 @@ + + + diff --git a/app/imports/ui/properties/forms/shared/propertyFormIndex.js b/app/imports/ui/properties/forms/shared/propertyFormIndex.js index 09627057..1687a2cb 100644 --- a/app/imports/ui/properties/forms/shared/propertyFormIndex.js +++ b/app/imports/ui/properties/forms/shared/propertyFormIndex.js @@ -3,6 +3,7 @@ const AdjustmentForm = () => import('/imports/ui/properties/forms/AdjustmentForm const AttributeForm = () => import('/imports/ui/properties/forms/AttributeForm.vue'); const BuffForm = () => import('/imports/ui/properties/forms/BuffForm.vue'); const BranchForm = () => import('/imports/ui/properties/forms/BranchForm.vue'); +const ClassForm = () => import('/imports/ui/properties/forms/ClassForm.vue'); const ClassLevelForm = () => import('/imports/ui/properties/forms/ClassLevelForm.vue'); const ConstantForm = () => import('/imports/ui/properties/forms/ConstantForm.vue'); const ContainerForm = () => import('/imports/ui/properties/forms/ContainerForm.vue'); @@ -32,8 +33,8 @@ export default { branch: BranchForm, constant: ConstantForm, container: ContainerForm, + class: ClassForm, classLevel: ClassLevelForm, - class: SlotForm, damage: DamageForm, damageMultiplier: DamageMultiplierForm, effect: EffectForm, diff --git a/app/imports/ui/properties/viewers/ClassViewer.vue b/app/imports/ui/properties/viewers/ClassViewer.vue new file mode 100644 index 00000000..26e4ffbd --- /dev/null +++ b/app/imports/ui/properties/viewers/ClassViewer.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/app/imports/ui/properties/viewers/SlotViewer.vue b/app/imports/ui/properties/viewers/SlotViewer.vue index 2c5bb3f6..36e432f1 100644 --- a/app/imports/ui/properties/viewers/SlotViewer.vue +++ b/app/imports/ui/properties/viewers/SlotViewer.vue @@ -16,7 +16,7 @@ /> - mdi-plus + + mdi-plus + Fill Slot @@ -68,9 +70,14 @@ } export default { - mixins: [propertyViewerMixin], components: { FillSlotButton, + }, + mixins: [propertyViewerMixin], + inject: { + context: { + default: {}, + }, }, computed: { slotTypeName(){ diff --git a/app/imports/ui/properties/viewers/shared/propertyViewerIndex.js b/app/imports/ui/properties/viewers/shared/propertyViewerIndex.js index 8845fac6..1df889ee 100644 --- a/app/imports/ui/properties/viewers/shared/propertyViewerIndex.js +++ b/app/imports/ui/properties/viewers/shared/propertyViewerIndex.js @@ -4,6 +4,7 @@ const AttributeViewer = () => import ('/imports/ui/properties/viewers/AttributeV const BuffViewer = () => import ('/imports/ui/properties/viewers/BuffViewer.vue'); const BranchViewer = () => import ('/imports/ui/properties/viewers/BranchViewer.vue'); const ContainerViewer = () => import ('/imports/ui/properties/viewers/ContainerViewer.vue'); +const ClassViewer = () => import ('/imports/ui/properties/viewers/ClassViewer.vue'); const ClassLevelViewer = () => import ('/imports/ui/properties/viewers/ClassLevelViewer.vue'); const ConstantViewer = () => import ('/imports/ui/properties/viewers/ConstantViewer.vue'); const DamageViewer = () => import ('/imports/ui/properties/viewers/DamageViewer.vue'); @@ -31,7 +32,7 @@ export default { buff: BuffViewer, branch: BranchViewer, container: ContainerViewer, - class: SlotViewer, + class: ClassViewer, classLevel: ClassLevelViewer, constant: ConstantViewer, damage: DamageViewer,