mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 17:48:30 +08:00
The previous `createPreviewComponent` implementation was problematic for template colocation. We can achieve the same result using normal component class inheritance.
64 lines
1.7 KiB
JavaScript
Vendored
64 lines
1.7 KiB
JavaScript
Vendored
export default function (helpers) {
|
|
const { parsePostData, response } = helpers;
|
|
|
|
this.get("/wizard.json", () => {
|
|
return response({
|
|
wizard: {
|
|
start: "hello-world",
|
|
completed: true,
|
|
steps: [
|
|
{
|
|
id: "hello-world",
|
|
title: "hello there",
|
|
index: 0,
|
|
description: "hello!",
|
|
fields: [
|
|
{
|
|
id: "full_name",
|
|
type: "text",
|
|
required: true,
|
|
description: "Your name",
|
|
},
|
|
],
|
|
next: "styling",
|
|
},
|
|
{
|
|
id: "styling",
|
|
title: "Second step",
|
|
index: 1,
|
|
fields: [{ id: "some_title", type: "text" }],
|
|
previous: "hello-world",
|
|
next: "corporate",
|
|
},
|
|
{
|
|
id: "corporate",
|
|
index: 2,
|
|
fields: [
|
|
{ id: "company_name", type: "text", required: true },
|
|
{ id: "styling_preview", type: "component" },
|
|
],
|
|
previous: "styling",
|
|
},
|
|
],
|
|
},
|
|
});
|
|
});
|
|
|
|
this.put("/wizard/steps/:id", (request) => {
|
|
const body = parsePostData(request.requestBody);
|
|
|
|
if (body.fields.full_name === "Server Fail") {
|
|
return response(422, {
|
|
errors: [{ field: "full_name", description: "Invalid name" }],
|
|
});
|
|
} else if (body.fields.company_name === "Server Fail") {
|
|
return response(422, {
|
|
errors: [
|
|
{ field: "company_name", description: "Invalid company name" },
|
|
],
|
|
});
|
|
} else {
|
|
return response(200, { success: true });
|
|
}
|
|
});
|
|
}
|