Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-21 17:00:29 +01:00
Merge branch 'main' into add_discourse_plugin_statistics
Dieser Commit ist enthalten in:
Commit
a848a4612e
18 geänderte Dateien mit 187 neuen und 31 gelöschten Zeilen
|
@ -1,3 +1,4 @@
|
|||
3.2.0.beta2: 1ee2f7d8babafe32912372fbbfa50c89f5b09ba9
|
||||
3.1.999: 1f35b80f85e5fd1efb7f4851f0845700432febdc
|
||||
2.7.99: e07a57e398b6b1676ab42a7e34467556fca5416b
|
||||
2.5.1: bb85b3a0d2c0ab6b59bcb405731c39089ec6731c
|
||||
|
|
14
README.md
14
README.md
|
@ -4,7 +4,7 @@ The Custom Wizard Plugin lets you make forms for your Discourse forum. Better us
|
|||
|
||||
<img src="https://camo.githubusercontent.com/593432f1fc9658ffca104065668cc88fa21dffcd3002cb78ffd50c71f33a2523/68747470733a2f2f706176696c696f6e2d6173736574732e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f706c7567696e732f77697a6172642d7265706f7369746f72792d62616e6e65722e706e67" alt="" data-canonical-src="https://pavilion-assets.nyc3.cdn.digitaloceanspaces.com/plugins/wizard-repository-banner.png" style="max-width: 100%;" width="400">
|
||||
|
||||
👋 Looking to report an issue? We're managing issues for this plugin using our [bug report wizard](https://coop.pavilion.tech/w/bug-report).
|
||||
👋 Looking to report an issue? We're managing issues for this plugin using our [bug report wizard](https://pavilion.tech/products/discourse-custom-wizard-plugin/support/bug-report).
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -12,16 +12,16 @@ If you're not sure how to install a plugin in Discourse, please follow the [plug
|
|||
|
||||
## Documentation
|
||||
|
||||
[Read the full documentation here](https://coop.pavilion.tech/c/82), or go directly to the relevant section
|
||||
[Read the full documentation here](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/), or go directly to the relevant section
|
||||
|
||||
- [Wizard Administration](https://coop.pavilion.tech/t/1602)
|
||||
- [Wizard Settings](https://coop.pavilion.tech/t/1614)
|
||||
- [Step Settings](https://coop.pavilion.tech/t/1735)
|
||||
- [Field Settings](https://coop.pavilion.tech/t/1580)
|
||||
- [Conditional Settings](https://coop.pavilion.tech/t/1673)
|
||||
- [Field Interpolation](https://coop.pavilion.tech/t/1557)
|
||||
- [Step Settings](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/step-settings)
|
||||
- [Field Settings](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/field-settings)
|
||||
- [Conditional Settings](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/conditional-settings)
|
||||
- [Field Interpolation](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/field-interpolation)
|
||||
- [Handling Dates and Times](https://coop.pavilion.tech/t/1708)
|
||||
|
||||
## Support
|
||||
|
||||
- [Report an issue](https://coop.pavilion.tech/w/bug-report)
|
||||
- [Report an issue](https://pavilion.tech/products/discourse-custom-wizard-plugin/support/bug-report)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Component from "@ember/component";
|
||||
import { dasherize } from "@ember/string";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { cookAsync } from "discourse/lib/text";
|
||||
import { cook } from "discourse/lib/text";
|
||||
|
||||
export default Component.extend({
|
||||
classNameBindings: [
|
||||
|
@ -14,7 +14,7 @@ export default Component.extend({
|
|||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
cookAsync(this.field.translatedDescription).then((cookedDescription) => {
|
||||
cook(this.field.translatedDescription).then((cookedDescription) => {
|
||||
this.set("cookedDescription", cookedDescription);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ import I18n from "I18n";
|
|||
import getUrl from "discourse-common/lib/get-url";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { cookAsync } from "discourse/lib/text";
|
||||
import { cook } from "discourse/lib/text";
|
||||
import CustomWizard, {
|
||||
updateCachedWizard,
|
||||
} from "discourse/plugins/discourse-custom-wizard/discourse/models/custom-wizard";
|
||||
|
@ -25,10 +25,10 @@ export default Component.extend({
|
|||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
cookAsync(this.step.translatedTitle).then((cookedTitle) => {
|
||||
cook(this.step.translatedTitle).then((cookedTitle) => {
|
||||
this.set("cookedTitle", cookedTitle);
|
||||
});
|
||||
cookAsync(this.step.translatedDescription).then((cookedDescription) => {
|
||||
cook(this.step.translatedDescription).then((cookedDescription) => {
|
||||
this.set("cookedDescription", cookedDescription);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -41,7 +41,8 @@ export default Component.extend(UndoChanges, {
|
|||
};
|
||||
}),
|
||||
|
||||
messageUrl: "https://discourse.pluginmanager.org/t/action-settings",
|
||||
messageUrl:
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/action-settings",
|
||||
|
||||
@discourseComputed("action.type")
|
||||
messageKey(type) {
|
||||
|
|
|
@ -27,7 +27,8 @@ export default Component.extend(UndoChanges, {
|
|||
isTextType: or("isText", "isTextarea", "isComposer"),
|
||||
isComposerPreview: equal("field.type", "composer_preview"),
|
||||
categoryPropertyTypes: selectKitContent(["id", "slug"]),
|
||||
messageUrl: "https://discourse.pluginmanager.org/t/field-settings",
|
||||
messageUrl:
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/field-settings",
|
||||
|
||||
@discourseComputed("field.type")
|
||||
validations(type) {
|
||||
|
|
|
@ -4,7 +4,8 @@ import CustomWizardCustomField from "../models/custom-wizard-custom-field";
|
|||
export default Controller.extend({
|
||||
messageKey: "create",
|
||||
fieldKeys: ["klass", "type", "name", "serializers"],
|
||||
documentationUrl: "https://discourse.pluginmanager.org/t/custom-fields",
|
||||
documentationUrl:
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/custom-fields",
|
||||
|
||||
actions: {
|
||||
addField() {
|
||||
|
|
|
@ -2,7 +2,8 @@ import Controller from "@ember/controller";
|
|||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Controller.extend({
|
||||
documentationUrl: "https://thepavilion.io/t/2818",
|
||||
documentationUrl:
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/",
|
||||
|
||||
@discourseComputed("wizardId")
|
||||
wizardName(wizardId) {
|
||||
|
|
|
@ -7,7 +7,8 @@ import I18n from "I18n";
|
|||
import { underscore } from "@ember/string";
|
||||
|
||||
export default Controller.extend({
|
||||
messageUrl: "https://discourse.pluginmanager.org/t/wizard-manager",
|
||||
messageUrl:
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/wizard-manager",
|
||||
messageKey: "info",
|
||||
messageIcon: "info-circle",
|
||||
messageClass: "info",
|
||||
|
|
|
@ -2,7 +2,8 @@ import Controller from "@ember/controller";
|
|||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Controller.extend({
|
||||
documentationUrl: "https://thepavilion.io/t/2818",
|
||||
documentationUrl:
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/",
|
||||
|
||||
@discourseComputed("wizardId")
|
||||
wizardName(wizardId) {
|
||||
|
|
|
@ -22,5 +22,5 @@ export default Controller.extend({
|
|||
},
|
||||
|
||||
messageUrl:
|
||||
"https://discourse.pluginmanager.org/c/discourse-custom-wizard/documentation",
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/",
|
||||
});
|
||||
|
|
|
@ -87,10 +87,13 @@ export default {
|
|||
api.modifyClass("component:category-chooser", {
|
||||
categoriesByScope(options = {}) {
|
||||
let categories = this._super(options);
|
||||
|
||||
return categories.filter((category) => {
|
||||
return !category.custom_fields?.create_topic_wizard;
|
||||
});
|
||||
const currentUser = this.currentUser;
|
||||
if (!currentUser?.staff) {
|
||||
categories = categories.filter((category) => {
|
||||
return !category.custom_fields?.create_topic_wizard;
|
||||
});
|
||||
}
|
||||
return categories;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ const PRODUCT_PAGE = "https://custom-wizard.pavilion.tech";
|
|||
const SUPPORT_MESSAGE =
|
||||
"https://coop.pavilion.tech/new-message?username=support&title=Custom%20Wizard%20Support";
|
||||
const MANAGER_CATEGORY =
|
||||
"https://discourse.pluginmanager.org/c/discourse-custom-wizard";
|
||||
"https://pavilion.tech/products/discourse-custom-wizard-plugin/support";
|
||||
|
||||
export default Mixin.create({
|
||||
subscriptionLandingUrl: PRODUCT_PAGE,
|
||||
|
|
|
@ -171,7 +171,7 @@ en:
|
|||
not_subscribed: "You've authorized, but are not currently subscribed to a Custom Wizard plan on %{server}."
|
||||
subscription_expiring: "Your subscription is active, but will expire in the next 48 hours."
|
||||
subscription_active: "Your subscription is active."
|
||||
subscription_inactive: "Your subscription is inactive on this forum. Read more in <a href='https://thepavilion.io/t/3652'>the documentation</a>."
|
||||
subscription_inactive: "Your subscription is inactive on this forum. Read more in <a href='https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/'>the documentation</a>."
|
||||
unauthorized: "You're unauthorized. If you have a subscription, it will become inactive in the next 48 hours."
|
||||
unauthorize_failed: Failed to unauthorize.
|
||||
submissions:
|
||||
|
|
|
@ -131,6 +131,8 @@ class CustomWizard::Submission
|
|||
params[:key] = list_actor_id if list_actor_id
|
||||
|
||||
query = PluginStoreRow.where(params)
|
||||
query = query.order(order_by) if order_by
|
||||
|
||||
result = OpenStruct.new(submissions: [], total: nil)
|
||||
|
||||
query.each do |record|
|
||||
|
|
|
@ -157,7 +157,7 @@ class CustomWizard::Subscription
|
|||
return :none unless subscribed?
|
||||
return :business if business?
|
||||
return :standard if standard?
|
||||
return :community if community?
|
||||
:community if community?
|
||||
end
|
||||
|
||||
def subscribed?
|
||||
|
|
|
@ -40,7 +40,7 @@ describe CustomWizard::SubmissionSerializer do
|
|||
|
||||
it "should return field values, types and labels" do
|
||||
wizard = CustomWizard::Wizard.create(template_json["id"])
|
||||
list = CustomWizard::Submission.list(wizard, page: 0)
|
||||
list = CustomWizard::Submission.list(wizard, page: 0, order_by: 'id')
|
||||
|
||||
json_array = ActiveModel::ArraySerializer.new(
|
||||
list.submissions,
|
||||
|
|
|
@ -3,8 +3,8 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Category Chooser Initializer", function (needs) {
|
||||
needs.user();
|
||||
acceptance("Category Chooser Initializer for regular users", function (needs) {
|
||||
needs.user({ admin: false, moderator: false });
|
||||
needs.settings({
|
||||
allow_uncategorized_topics: false,
|
||||
});
|
||||
|
@ -45,9 +45,8 @@ acceptance("Category Chooser Initializer", function (needs) {
|
|||
],
|
||||
});
|
||||
|
||||
test("does not display category with create_topic_wizard custom field", async function (assert) {
|
||||
test("does not display category with create_topic_wizard for regular users", async function (assert) {
|
||||
const categoryChooser = selectKit(".category-chooser");
|
||||
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
await categoryChooser.expand();
|
||||
|
@ -80,3 +79,148 @@ acceptance("Category Chooser Initializer", function (needs) {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("Category Chooser Initializer for Admins", function (needs) {
|
||||
needs.user({ admin: true });
|
||||
needs.settings({
|
||||
allow_uncategorized_topics: false,
|
||||
});
|
||||
needs.site({
|
||||
can_tag_topics: true,
|
||||
categories: [
|
||||
{
|
||||
id: 1,
|
||||
name: "General",
|
||||
slug: "general",
|
||||
permission: 1,
|
||||
topic_template: null,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Category with custom field",
|
||||
slug: "category-custom-field",
|
||||
permission: 1,
|
||||
topic_template: "",
|
||||
custom_fields: {
|
||||
create_topic_wizard: "21",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Category 1",
|
||||
slug: "category-1",
|
||||
permission: 1,
|
||||
topic_template: "",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Category 2",
|
||||
slug: "category-2",
|
||||
permission: 1,
|
||||
topic_template: "",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
test("displays all categories", async function (assert) {
|
||||
const categoryChooser = selectKit(".category-chooser");
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
await categoryChooser.expand();
|
||||
let categories = Array.from(
|
||||
document.querySelectorAll(".category-chooser .category-row")
|
||||
).filter((category) => category.getAttribute("data-name")); // Filter elements with a data-name attribute
|
||||
assert.equal(
|
||||
categories.length,
|
||||
4,
|
||||
"Correct number of categories are displayed"
|
||||
);
|
||||
const categoryNames = [
|
||||
"General",
|
||||
"Category 1",
|
||||
"Category 2",
|
||||
"Category with custom field",
|
||||
];
|
||||
|
||||
categoryNames.forEach((categoryName) => {
|
||||
assert.ok(
|
||||
categories.some(
|
||||
(category) => category.getAttribute("data-name") === categoryName
|
||||
),
|
||||
`Category '${categoryName}' is displayed`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
acceptance("Category Chooser Initializer for Staff", function (needs) {
|
||||
needs.user({ staff: true });
|
||||
needs.settings({
|
||||
allow_uncategorized_topics: false,
|
||||
});
|
||||
needs.site({
|
||||
can_tag_topics: true,
|
||||
categories: [
|
||||
{
|
||||
id: 1,
|
||||
name: "General",
|
||||
slug: "general",
|
||||
permission: 1,
|
||||
topic_template: null,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Category with custom field",
|
||||
slug: "category-custom-field",
|
||||
permission: 1,
|
||||
topic_template: "",
|
||||
custom_fields: {
|
||||
create_topic_wizard: "21",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Category 1",
|
||||
slug: "category-1",
|
||||
permission: 1,
|
||||
topic_template: "",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Category 2",
|
||||
slug: "category-2",
|
||||
permission: 1,
|
||||
topic_template: "",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
test("displays all categories", async function (assert) {
|
||||
const categoryChooser = selectKit(".category-chooser");
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
await categoryChooser.expand();
|
||||
let categories = Array.from(
|
||||
document.querySelectorAll(".category-chooser .category-row")
|
||||
).filter((category) => category.getAttribute("data-name")); // Filter elements with a data-name attribute
|
||||
assert.equal(
|
||||
categories.length,
|
||||
4,
|
||||
"Correct number of categories are displayed"
|
||||
);
|
||||
const categoryNames = [
|
||||
"General",
|
||||
"Category 1",
|
||||
"Category 2",
|
||||
"Category with custom field",
|
||||
];
|
||||
|
||||
categoryNames.forEach((categoryName) => {
|
||||
assert.ok(
|
||||
categories.some(
|
||||
(category) => category.getAttribute("data-name") === categoryName
|
||||
),
|
||||
`Category '${categoryName}' is displayed`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Laden …
In neuem Issue referenzieren