diff --git a/app/controllers/custom_wizard/admin/wizard.rb b/app/controllers/custom_wizard/admin/wizard.rb index 08e7b6d0..955deb3f 100644 --- a/app/controllers/custom_wizard/admin/wizard.rb +++ b/app/controllers/custom_wizard/admin/wizard.rb @@ -115,6 +115,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController :preview_template, :placeholder, :can_create_tag, + :category, prefill: mapped_params, content: mapped_params, condition: mapped_params, diff --git a/app/serializers/custom_wizard/wizard_field_serializer.rb b/app/serializers/custom_wizard/wizard_field_serializer.rb index 56e86cc8..af4514ae 100644 --- a/app/serializers/custom_wizard/wizard_field_serializer.rb +++ b/app/serializers/custom_wizard/wizard_field_serializer.rb @@ -18,6 +18,7 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer :content, :tag_groups, :can_create_tag, + :category, :validations, :max_length, :char_counter, diff --git a/assets/javascripts/discourse/components/custom-wizard-topic-selector.js.es6 b/assets/javascripts/discourse/components/custom-wizard-topic-selector.js.es6 index 8f3ac98f..b3d9cc57 100644 --- a/assets/javascripts/discourse/components/custom-wizard-topic-selector.js.es6 +++ b/assets/javascripts/discourse/components/custom-wizard-topic-selector.js.es6 @@ -42,6 +42,13 @@ export default MultiSelectComponent.extend({ searchParams.restrictToArchetype = "regular"; searchParams.searchForId = true; + if (this.category) { + searchParams.searchContext = { + type: "category", + id: this.category, + }; + } + return searchForTerm(filter, searchParams).then((results) => { if (results?.posts?.length > 0) { return results.posts.mapBy("topic"); diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 6990cf9f..5aff7f6e 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -164,5 +164,9 @@ export default Component.extend(UndoChanges, { "field.image_upload_id": null, }); }, + + changeCategory(category) { + this.set("field.category", category?.id); + }, }, }); diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index f3c59785..710a3594 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -73,6 +73,7 @@ const field = { type: null, condition: null, tag_groups: null, + category: null, }, types: {}, mapped: ["prefill", "content", "condition", "index"], diff --git a/assets/javascripts/discourse/templates/components/custom-wizard-field-topic.hbs b/assets/javascripts/discourse/templates/components/custom-wizard-field-topic.hbs index e19eb48d..fbaf016b 100644 --- a/assets/javascripts/discourse/templates/components/custom-wizard-field-topic.hbs +++ b/assets/javascripts/discourse/templates/components/custom-wizard-field-topic.hbs @@ -1,5 +1,6 @@ {{custom-wizard-topic-selector topics=topics + category=field.category onChange=(action "setValue") options=(hash maximum=field.limit) }} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs index c4d297ff..33a4400d 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs @@ -245,6 +245,25 @@ {{/if}} +{{#if isTopic}} +