Skip to content

Commit 809c097

Browse files
authored
Merge pull request #300 from paviliondev/glimmer-category-settings
DEV: Update custom category settings to Glimmer component
2 parents 0e06722 + 25c8595 commit 809c097

File tree

6 files changed

+61
-55
lines changed

6 files changed

+61
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h3>{{i18n "admin.wizard.category_settings.custom_wizard.title"}}</h3>
2+
<section class="field new-topic-wizard">
3+
<label for="new-topic-wizard">
4+
{{i18n "admin.wizard.category_settings.custom_wizard.create_topic_wizard"}}
5+
</label>
6+
<div class="controls">
7+
<ComboBox
8+
@value={{this.wizardListVal}}
9+
@content={{this.wizardList}}
10+
@onChange={{this.changeWizard}}
11+
@options={{hash none="admin.wizard.select"}}
12+
/>
13+
</div>
14+
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Component from "@glimmer/component";
2+
import { tracked } from "@glimmer/tracking";
3+
import { action } from "@ember/object";
4+
import { popupAjaxError } from "discourse/lib/ajax-error";
5+
import CustomWizardAdmin from "../models/custom-wizard-admin";
6+
7+
export default class CustomWizardCategorySettings extends Component {
8+
@tracked wizardList = [];
9+
@tracked
10+
wizardListVal = this.args?.category?.custom_fields?.create_topic_wizard;
11+
12+
constructor() {
13+
super(...arguments);
14+
15+
CustomWizardAdmin.all()
16+
.then((result) => {
17+
this.wizardList = result;
18+
})
19+
.catch(popupAjaxError);
20+
}
21+
22+
@action
23+
changeWizard(wizard) {
24+
this.wizardListVal = wizard;
25+
this.args.category.custom_fields.create_topic_wizard = wizard;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
<h3>{{i18n "admin.wizard.category_settings.custom_wizard.title"}}</h3>
2-
3-
<section class="field new-topic-wizard">
4-
<label for="new-topic-wizard">
5-
{{i18n "admin.wizard.category_settings.custom_wizard.create_topic_wizard"}}
6-
</label>
7-
<div class="controls">
8-
{{combo-box
9-
value=this.wizardListVal
10-
content=this.wizardList
11-
onChange=(action "changeWizard")
12-
options=(hash none="admin.wizard.select")
13-
}}
14-
</div>
15-
</section>
1+
<CustomWizardCategorySettings @category={{this.category}} />

assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.js

-24
This file was deleted.

assets/javascripts/discourse/initializers/custom-wizard-edits.js

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { action } from "@ember/object";
12
import { ajax } from "discourse/lib/ajax";
23
import { popupAjaxError } from "discourse/lib/ajax-error";
34
import { withPluginApi } from "discourse/lib/plugin-api";
@@ -23,21 +24,23 @@ export default {
2324
};
2425

2526
withPluginApi("0.8.36", (api) => {
26-
api.modifyClass("component:d-navigation", {
27-
pluginId: "custom-wizard",
28-
actions: {
29-
clickCreateTopicButton() {
30-
let createTopicWizard = this.get(
31-
"category.custom_fields.create_topic_wizard"
32-
);
33-
if (createTopicWizard) {
34-
window.location.href = getUrl(`/w/${createTopicWizard}`);
35-
} else {
36-
this._super();
27+
api.modifyClass(
28+
"component:d-navigation",
29+
(Superclass) =>
30+
class extends Superclass {
31+
@action
32+
clickCreateTopicButton() {
33+
let createTopicWizard = this.get(
34+
"category.custom_fields.create_topic_wizard"
35+
);
36+
if (createTopicWizard) {
37+
window.location.href = getUrl(`/w/${createTopicWizard}`);
38+
} else {
39+
super.clickCreateTopicButton();
40+
}
3741
}
38-
},
39-
},
40-
});
42+
}
43+
);
4144

4245
api.modifyClass("component:d-editor", {
4346
pluginId: "custom-wizard",

plugin.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22
# name: discourse-custom-wizard
33
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
4-
# version: 2.11.3
5-
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
4+
# version: 2.11.4
5+
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Marcos Gutierrez
66
# url: https://github.com/paviliondev/discourse-custom-wizard
77
# contact_emails: [email protected]
88
# subscription_url: https://coop.pavilion.tech

0 commit comments

Comments
 (0)