Skip to content

DEV: Update custom category settings to Glimmer component #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<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">
<ComboBox
@value={{this.wizardListVal}}
@content={{this.wizardList}}
@onChange={{this.changeWizard}}
@options={{hash none="admin.wizard.select"}}
/>
</div>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { popupAjaxError } from "discourse/lib/ajax-error";
import CustomWizardAdmin from "../models/custom-wizard-admin";

export default class CustomWizardCategorySettings extends Component {
@tracked wizardList = [];
@tracked
wizardListVal = this.args?.category?.custom_fields?.create_topic_wizard;

constructor() {
super(...arguments);

CustomWizardAdmin.all()
.then((result) => {
this.wizardList = result;
})
.catch(popupAjaxError);
}

@action
changeWizard(wizard) {
this.wizardListVal = wizard;
this.args.category.custom_fields.create_topic_wizard = wizard;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
<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=this.wizardListVal
content=this.wizardList
onChange=(action "changeWizard")
options=(hash none="admin.wizard.select")
}}
</div>
</section>
<CustomWizardCategorySettings @category={{this.category}} />

This file was deleted.

31 changes: 17 additions & 14 deletions assets/javascripts/discourse/initializers/custom-wizard-edits.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { withPluginApi } from "discourse/lib/plugin-api";
Expand All @@ -23,21 +24,23 @@ export default {
};

withPluginApi("0.8.36", (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();
api.modifyClass(
"component:d-navigation",
(Superclass) =>
class extends Superclass {
@action
clickCreateTopicButton() {
let createTopicWizard = this.get(
"category.custom_fields.create_topic_wizard"
);
if (createTopicWizard) {
window.location.href = getUrl(`/w/${createTopicWizard}`);
} else {
super.clickCreateTopicButton();
}
}
},
},
});
}
);

api.modifyClass("component:d-editor", {
pluginId: "custom-wizard",
Expand Down
4 changes: 2 additions & 2 deletions plugin.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.11.3
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
# version: 2.11.4
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Marcos Gutierrez
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: [email protected]
# subscription_url: https://coop.pavilion.tech
Expand Down
Loading