1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6

53 Zeilen
1,5 KiB
Text

import DiscourseURL from "discourse/lib/url";
import { withPluginApi } from "discourse/lib/plugin-api";
import getUrl from "discourse-common/lib/get-url";
import { observes } from "discourse-common/utils/decorators";
2017-11-22 10:34:21 +01:00
export default {
name: "custom-wizard-edits",
initialize(container) {
const siteSettings = container.lookup("site-settings:main");
2021-04-12 08:12:20 +02:00
if (!siteSettings.custom_wizard_enabled) {
return;
}
const existing = DiscourseURL.routeTo;
DiscourseURL.routeTo = function (path, opts) {
if (path && path.indexOf("/w/") > -1) {
return (window.location = path);
}
return existing.apply(this, [path, opts]);
};
withPluginApi("0.8.7", (api) => {
api.modifyClass("component:d-navigation", {
2021-11-11 13:08:53 +01:00
pluginId: "custom-wizard",
actions: {
2021-11-11 13:08:53 +01:00
clickCreateTopicButton() {
let createTopicWizard = this.get(
"category.custom_fields.create_topic_wizard"
);
if (createTopicWizard) {
window.location.href = getUrl(`/w/${createTopicWizard}`);
} else {
this._super();
}
2021-11-11 13:08:53 +01:00
},
},
});
api.modifyClass("component:uppy-image-uploader", {
2022-07-27 12:47:50 +02:00
pluginId: "custom-wizard",
// Needed to ensure appEvents get registered when navigating between steps
@observes("id")
initOnStepChange() {
if (/wizard-field|wizard-step/.test(this.id)) {
this._initialize();
}
},
});
});
},
2017-11-22 10:34:21 +01:00
};