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

43 Zeilen
1,2 KiB
Text

import DiscourseURL from "discourse/lib/url";
2021-09-24 11:58:42 +02:00
import { withPluginApi } from "discourse/lib/plugin-api";
2021-11-01 14:52:29 +01:00
import { isPresent } from "@ember/utils";
2021-09-24 11:58:42 +02:00
import { A } from "@ember/array";
import getUrl from "discourse-common/lib/get-url";
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]);
};
2021-09-24 11:58:42 +02:00
withPluginApi("0.8.36", (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
},
2021-11-17 13:48:11 +01:00
},
2021-09-24 11:58:42 +02:00
});
});
},
2017-11-22 10:34:21 +01:00
};