From 57ca3ecb01c5140474998bca659e776c10fe3d12 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 16 May 2023 20:20:39 +0200 Subject: [PATCH] Form overhaul: Class Form --- .../client/ui/properties/forms/ClassForm.vue | 106 +++--------------- .../properties/forms/shared/TagTargeting.vue | 48 +++++--- 2 files changed, 51 insertions(+), 103 deletions(-) diff --git a/app/imports/client/ui/properties/forms/ClassForm.vue b/app/imports/client/ui/properties/forms/ClassForm.vue index bb715706..c75a871b 100644 --- a/app/imports/client/ui/properties/forms/ClassForm.vue +++ b/app/imports/client/ui/properties/forms/ClassForm.vue @@ -3,19 +3,6 @@ - - - - - - - - - + - - - - mdi-plus - - - - - -
- - - - mdi-delete - -
-
+
@@ -130,10 +56,12 @@ import propertyFormMixin from '/imports/client/ui/properties/forms/shared/proper import FormSection from '/imports/client/ui/properties/forms/shared/FormSection.vue'; import PROPERTIES from '/imports/constants/PROPERTIES.js'; import { SlotSchema } from '/imports/api/properties/Slots.js'; +import TagTargeting from '/imports/client/ui/properties/forms/shared/TagTargeting.vue'; export default { components: { FormSection, + TagTargeting, }, mixins: [propertyFormMixin], inject: { diff --git a/app/imports/client/ui/properties/forms/shared/TagTargeting.vue b/app/imports/client/ui/properties/forms/shared/TagTargeting.vue index 31b48b0b..fb9663a0 100644 --- a/app/imports/client/ui/properties/forms/shared/TagTargeting.vue +++ b/app/imports/client/ui/properties/forms/shared/TagTargeting.vue @@ -17,22 +17,22 @@
@@ -41,24 +41,24 @@ style="width: 90px; flex-grow: 0;" :items="['OR', 'NOT']" :value="extras.operation" - :error-messages="errors.extraTags && errors.extraTags[i]" - @change="change(['extraTags', i, 'operation'], ...arguments)" + :error-messages="errors[extraTagsField] && errors[extraTagsField][i]" + @change="change([extraTagsField, i, 'operation'], ...arguments)" /> mdi-delete @@ -80,6 +80,26 @@ export default { type: Object, required: true, }, + tagField: { + type: String, + default: 'targetTags', + }, + extraTagsField: { + type: String, + default: 'extraTags', + }, + tagHint: { + type: String, + default: 'Applied to properties that have all the listed tags', + }, + orHint: { + type: String, + default: 'Also applied to properties that have all of these tags', + }, + notHint: { + type: String, + default: 'Ignore properties that have any of these tags', + }, }, data() { return { @@ -90,18 +110,18 @@ export default { maxTags() { if (!this.model?.type) return 0; const schema = propertySchemasIndex[this.model.type]; - return schema.get('extraTags', 'maxCount'); + return schema.get(this.extraTagsField, 'maxCount'); }, extraTagsFull() { - if (!this.model.extraTags) return false; - return this.model.extraTags.length >= this.maxTags; + if (!this.model[this.extraTagsField]) return false; + return this.model[this.extraTagsField].length >= this.maxTags; }, }, methods: { addExtraTags() { this.addExtraTagsLoading = true; this.$emit('push', { - path: ['extraTags'], + path: [this.extraTagsField], value: { _id: Random.id(), operation: 'OR',