特定のカテゴリの「新規トピック」ボタンを、ウィザードアンケート(これによりトピックが自動的に作成されます)にリンクさせるように置き換えようとしています。
ボタンの名前を変更する現在のコードは以下の通りです:
<script type="text/discourse-plugin" version="0.8">
const i18nTopicLable = I18n.lookup("topic.create");
api.modifyClass("component:create-topic-button", {
didInsertElement: function() {
var button = $(this),
category = button[0].parentView.get("category"),
label = button[0].label,
newTopicLabel = "topic.create",
buttonText = "";
if (category) {
categoryName = category.name;
if (label != newTopicLabel) {
return;
} else {
switch (categoryName) {
case "Category name": // カテゴリ名
buttonText = "Text"; // ボタンのテキスト
break;
// 上記の行にさらに追加
default:
buttonText = i18nTopicLable;
}
$("#create-topic .d-button-label").text(buttonText);
}
}
}
});
</script>
コンポーザーへのリンクではなく、別の場所へ移動するようにアクションを変更する最良の方法は何でしょうか?
よろしくお願いします!