0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-19 15:21:11 +02:00

Add category scoping field to topics selector

Dieser Commit ist enthalten in:
Angus McLeod 2024-06-24 12:08:51 +02:00
Ursprung f22e515772
Commit 4eb7cbc2c8
10 geänderte Dateien mit 45 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -115,6 +115,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
:preview_template, :preview_template,
:placeholder, :placeholder,
:can_create_tag, :can_create_tag,
:category,
prefill: mapped_params, prefill: mapped_params,
content: mapped_params, content: mapped_params,
condition: mapped_params, condition: mapped_params,

Datei anzeigen

@ -18,6 +18,7 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer
:content, :content,
:tag_groups, :tag_groups,
:can_create_tag, :can_create_tag,
:category,
:validations, :validations,
:max_length, :max_length,
:char_counter, :char_counter,

Datei anzeigen

@ -42,6 +42,13 @@ export default MultiSelectComponent.extend({
searchParams.restrictToArchetype = "regular"; searchParams.restrictToArchetype = "regular";
searchParams.searchForId = true; searchParams.searchForId = true;
if (this.category) {
searchParams.searchContext = {
type: "category",
id: this.category,
};
}
return searchForTerm(filter, searchParams).then((results) => { return searchForTerm(filter, searchParams).then((results) => {
if (results?.posts?.length > 0) { if (results?.posts?.length > 0) {
return results.posts.mapBy("topic"); return results.posts.mapBy("topic");

Datei anzeigen

@ -164,5 +164,9 @@ export default Component.extend(UndoChanges, {
"field.image_upload_id": null, "field.image_upload_id": null,
}); });
}, },
changeCategory(category) {
this.set("field.category", category?.id);
},
}, },
}); });

Datei anzeigen

@ -73,6 +73,7 @@ const field = {
type: null, type: null,
condition: null, condition: null,
tag_groups: null, tag_groups: null,
category: null,
}, },
types: {}, types: {},
mapped: ["prefill", "content", "condition", "index"], mapped: ["prefill", "content", "condition", "index"],

Datei anzeigen

@ -1,5 +1,6 @@
{{custom-wizard-topic-selector {{custom-wizard-topic-selector
topics=topics topics=topics
category=field.category
onChange=(action "setValue") onChange=(action "setValue")
options=(hash maximum=field.limit) options=(hash maximum=field.limit)
}} }}

Datei anzeigen

@ -245,6 +245,25 @@
</div> </div>
{{/if}} {{/if}}
{{#if isTopic}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.field.category.label"}}</label>
</div>
<div class="setting-value">
<CategoryChooser
@value={{this.field.category}}
@onChangeCategory={{action "changeCategory"}}
@options={{hash
none="admin.wizard.field.category.none"
autoInsertNoneItem=true
}}
/>
</div>
</div>
{{/if}}
{{#wizard-subscription-container}} {{#wizard-subscription-container}}
<div class="setting full field-mapper-setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">

Datei anzeigen

@ -282,6 +282,9 @@ en:
content: "Content" content: "Content"
tag_groups: "Tag Groups" tag_groups: "Tag Groups"
can_create_tag: "Can Create Tag" can_create_tag: "Can Create Tag"
category:
label: "Category"
none: "Limit to a category..."
date_time_format: date_time_format:
label: "Format" label: "Format"
instructions: "<a href='https://momentjs.com/docs/#/displaying/format/' target='_blank'>Moment.js format</a>" instructions: "<a href='https://momentjs.com/docs/#/displaying/format/' target='_blank'>Moment.js format</a>"

Datei anzeigen

@ -143,6 +143,10 @@ class CustomWizard::Builder
params[:property] = field_template['property'] params[:property] = field_template['property']
end end
if field_template['type'] === 'topic'
params[:category] = field_template['category']
end
if (content_inputs = field_template['content']).present? if (content_inputs = field_template['content']).present?
content = CustomWizard::Mapper.new( content = CustomWizard::Mapper.new(
inputs: content_inputs, inputs: content_inputs,

Datei anzeigen

@ -22,6 +22,7 @@ class CustomWizard::Field
:property, :property,
:content, :content,
:tag_groups, :tag_groups,
:category,
:can_create_tag, :can_create_tag,
:preview_template, :preview_template,
:placeholder :placeholder
@ -53,6 +54,7 @@ class CustomWizard::Field
@property = attrs[:property] @property = attrs[:property]
@content = attrs[:content] @content = attrs[:content]
@tag_groups = attrs[:tag_groups] @tag_groups = attrs[:tag_groups]
@category = attrs[:category]
@can_create_tag = attrs[:can_create_tag] @can_create_tag = attrs[:can_create_tag]
@preview_template = attrs[:preview_template] @preview_template = attrs[:preview_template]
@placeholder = attrs[:placeholder] @placeholder = attrs[:placeholder]
@ -132,7 +134,8 @@ class CustomWizard::Field
topic: { topic: {
limit: 1, limit: 1,
prefill: nil, prefill: nil,
content: nil content: nil,
category: nil
}, },
group: { group: {
prefill: nil, prefill: nil,