Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Merge pull request #155 from paviliondev/create_topic_button_override
FEATURE: allow 'New Topic' button to redirect to a wizard
Dieser Commit ist enthalten in:
Commit
1c31097078
5 geänderte Dateien mit 73 neuen und 2 gelöschten Zeilen
|
@ -0,0 +1,16 @@
|
||||||
|
<h3>{{i18n "admin.wizard.category_settings.custom_wizard.title"}}</h3>
|
||||||
|
|
||||||
|
<section class="field new-topic-wizard">
|
||||||
|
<label for="new-topic-wizard">
|
||||||
|
{{i18n "admin.wizard.category_settings.custom_wizard.create_topic_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 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 DiscourseURL from "discourse/lib/url";
|
||||||
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "custom-wizard-edits",
|
name: "custom-wizard-edits",
|
||||||
|
@ -16,5 +18,23 @@ export default {
|
||||||
}
|
}
|
||||||
return existing.apply(this, [path, opts]);
|
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,10 @@ en:
|
||||||
select_type: "Select a type"
|
select_type: "Select a type"
|
||||||
condition: "Condition"
|
condition: "Condition"
|
||||||
index: "Index"
|
index: "Index"
|
||||||
|
category_settings:
|
||||||
|
custom_wizard:
|
||||||
|
title: "Custom Wizard"
|
||||||
|
create_topic_wizard: "Select a wizard to replace the new topic composer in this category."
|
||||||
|
|
||||||
message:
|
message:
|
||||||
wizard:
|
wizard:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Create custom wizards
|
# about: Create custom wizards
|
||||||
# version: 1.15.6
|
# version: 1.16.0
|
||||||
# authors: Angus McLeod
|
# authors: Angus McLeod
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact emails: angus@thepavilion.io
|
# contact emails: angus@thepavilion.io
|
||||||
|
@ -116,6 +116,13 @@ after_initialize do
|
||||||
load File.expand_path(path, __FILE__)
|
load File.expand_path(path, __FILE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# preloaded category custom fields
|
||||||
|
%w[
|
||||||
|
create_topic_wizard
|
||||||
|
].each do |custom_field|
|
||||||
|
Site.preloaded_category_custom_fields << custom_field
|
||||||
|
end
|
||||||
|
|
||||||
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
||||||
|
|
||||||
add_class_method(:wizard, :user_requires_completion?) do |user|
|
add_class_method(:wizard, :user_requires_completion?) do |user|
|
||||||
|
|
Laden …
In neuem Issue referenzieren