FEATURE: allow 'New Topic' button to redirect to a wizard
Dieser Commit ist enthalten in:
Ursprung
51dbf7ac40
Commit
564985e46e
5 geänderte Dateien mit 62 neuen und 0 gelöschten Zeilen
|
@ -0,0 +1,16 @@
|
|||
<h3>{{i18n "admin.wizard.category_settings.create_topic_wizard"}}</h3>
|
||||
|
||||
<section class="field new-topic-wizard">
|
||||
<label for="new-topic-wizard">
|
||||
{{i18n "admin.wizard.category_settings.select_wizard"}}
|
||||
</label>
|
||||
<div class="controls">
|
||||
{{combo-box
|
||||
value=wizardListVal
|
||||
content=wizardList
|
||||
onChange=(action "changeWizard")
|
||||
options=(hash
|
||||
none="admin.wizard.select"
|
||||
)}}
|
||||
</div>
|
||||
</section>
|
|
@ -0,0 +1,24 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
import CustomWizard from "../../models/custom-wizard";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default {
|
||||
setupComponent(attrs, component) {
|
||||
CustomWizard.all()
|
||||
.then(result => {
|
||||
component.set('wizardList', result);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
component.set(
|
||||
'wizardListVal',
|
||||
attrs.category.custom_fields.create_topic_wizard
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
changeWizard(wizard){
|
||||
this.set('wizardListVal', wizard);
|
||||
this.set('category.custom_fields.create_topic_wizard', wizard);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
import DiscourseURL from "discourse/lib/url";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import getUrl from "discourse-common/lib/get-url";
|
||||
|
||||
export default {
|
||||
name: "custom-wizard-edits",
|
||||
|
@ -16,5 +18,21 @@ export default {
|
|||
}
|
||||
return existing.apply(this, [path, opts]);
|
||||
};
|
||||
|
||||
withPluginApi("0.8.7", (api) => {
|
||||
api.modifyClass("component:d-navigation", {
|
||||
pluginId: 'custom-wizard',
|
||||
actions: {
|
||||
clickCreateTopicButton(){
|
||||
let createTopicWizard = this.get('category.custom_fields.create_topic_wizard');
|
||||
if (createTopicWizard) {
|
||||
window.location.href = getUrl(`/w/${createTopicWizard}`);
|
||||
} else {
|
||||
this._super();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -60,6 +60,9 @@ en:
|
|||
select_type: "Select a type"
|
||||
condition: "Condition"
|
||||
index: "Index"
|
||||
category_settings:
|
||||
create_topic_wizard: "Create Topic Wizard"
|
||||
select_wizard: "Select a wizard you want to use for creating topics in this category"
|
||||
|
||||
message:
|
||||
wizard:
|
||||
|
|
|
@ -117,6 +117,7 @@ after_initialize do
|
|||
end
|
||||
|
||||
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
||||
Site.preloaded_category_custom_fields << "create_topic_wizard"
|
||||
|
||||
add_class_method(:wizard, :user_requires_completion?) do |user|
|
||||
wizard_result = self.new(user).requires_completion?
|
||||
|
|
Laden …
In neuem Issue referenzieren