Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-24 02:10:29 +01:00
Add category scoping field to topics selector
Dieser Commit ist enthalten in:
Ursprung
f22e515772
Commit
4eb7cbc2c8
10 geänderte Dateien mit 45 neuen und 1 gelöschten Zeilen
|
@ -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,
|
||||
|
|
|
@ -18,6 +18,7 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer
|
|||
:content,
|
||||
:tag_groups,
|
||||
:can_create_tag,
|
||||
:category,
|
||||
:validations,
|
||||
:max_length,
|
||||
:char_counter,
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -164,5 +164,9 @@ export default Component.extend(UndoChanges, {
|
|||
"field.image_upload_id": null,
|
||||
});
|
||||
},
|
||||
|
||||
changeCategory(category) {
|
||||
this.set("field.category", category?.id);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -73,6 +73,7 @@ const field = {
|
|||
type: null,
|
||||
condition: null,
|
||||
tag_groups: null,
|
||||
category: null,
|
||||
},
|
||||
types: {},
|
||||
mapped: ["prefill", "content", "condition", "index"],
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{custom-wizard-topic-selector
|
||||
topics=topics
|
||||
category=field.category
|
||||
onChange=(action "setValue")
|
||||
options=(hash maximum=field.limit)
|
||||
}}
|
|
@ -245,6 +245,25 @@
|
|||
</div>
|
||||
{{/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}}
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
|
|
|
@ -282,6 +282,9 @@ en:
|
|||
content: "Content"
|
||||
tag_groups: "Tag Groups"
|
||||
can_create_tag: "Can Create Tag"
|
||||
category:
|
||||
label: "Category"
|
||||
none: "Limit to a category..."
|
||||
date_time_format:
|
||||
label: "Format"
|
||||
instructions: "<a href='https://momentjs.com/docs/#/displaying/format/' target='_blank'>Moment.js format</a>"
|
||||
|
|
|
@ -143,6 +143,10 @@ class CustomWizard::Builder
|
|||
params[:property] = field_template['property']
|
||||
end
|
||||
|
||||
if field_template['type'] === 'topic'
|
||||
params[:category] = field_template['category']
|
||||
end
|
||||
|
||||
if (content_inputs = field_template['content']).present?
|
||||
content = CustomWizard::Mapper.new(
|
||||
inputs: content_inputs,
|
||||
|
|
|
@ -22,6 +22,7 @@ class CustomWizard::Field
|
|||
:property,
|
||||
:content,
|
||||
:tag_groups,
|
||||
:category,
|
||||
:can_create_tag,
|
||||
:preview_template,
|
||||
:placeholder
|
||||
|
@ -53,6 +54,7 @@ class CustomWizard::Field
|
|||
@property = attrs[:property]
|
||||
@content = attrs[:content]
|
||||
@tag_groups = attrs[:tag_groups]
|
||||
@category = attrs[:category]
|
||||
@can_create_tag = attrs[:can_create_tag]
|
||||
@preview_template = attrs[:preview_template]
|
||||
@placeholder = attrs[:placeholder]
|
||||
|
@ -132,7 +134,8 @@ class CustomWizard::Field
|
|||
topic: {
|
||||
limit: 1,
|
||||
prefill: nil,
|
||||
content: nil
|
||||
content: nil,
|
||||
category: nil
|
||||
},
|
||||
group: {
|
||||
prefill: nil,
|
||||
|
|
Laden …
In neuem Issue referenzieren