mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 16:43:44 +08:00
48193767bf
Automatically generated by `eslint --fix` to satisfy the updated configuration
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
import EmberObject from "@ember/object";
|
|
import { readOnly } from "@ember/object/computed";
|
|
import Evented from "@ember/object/evented";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import Step from "wizard/models/step";
|
|
import WizardField from "wizard/models/wizard-field";
|
|
|
|
const Wizard = EmberObject.extend(Evented, {
|
|
totalSteps: readOnly("steps.length"),
|
|
|
|
getTitle() {
|
|
const titleStep = this.steps.findBy("id", "forum-title");
|
|
if (!titleStep) {
|
|
return;
|
|
}
|
|
return titleStep.get("fieldsById.title.value");
|
|
},
|
|
|
|
getLogoUrl() {
|
|
const logoStep = this.steps.findBy("id", "logos");
|
|
if (!logoStep) {
|
|
return;
|
|
}
|
|
return logoStep.get("fieldsById.logo.value");
|
|
},
|
|
|
|
get currentColors() {
|
|
const colorStep = this.steps.findBy("id", "styling");
|
|
if (!colorStep) {
|
|
return this.current_color_scheme;
|
|
}
|
|
|
|
const themeChoice = colorStep.fieldsById.color_scheme;
|
|
if (!themeChoice) {
|
|
return;
|
|
}
|
|
|
|
return themeChoice.choices?.findBy("id", themeChoice.value)?.data.colors;
|
|
},
|
|
|
|
get font() {
|
|
const fontChoice = this.steps.findBy("id", "styling")?.fieldsById
|
|
?.body_font;
|
|
return fontChoice.choices?.findBy("id", fontChoice.value);
|
|
},
|
|
|
|
get headingFont() {
|
|
const fontChoice = this.steps.findBy("id", "styling")?.fieldsById
|
|
?.heading_font;
|
|
return fontChoice.choices?.findBy("id", fontChoice.value);
|
|
},
|
|
});
|
|
|
|
export function findWizard() {
|
|
return ajax({ url: "/wizard.json" }).then(({ wizard }) => {
|
|
wizard.steps = wizard.steps.map((step) => {
|
|
const stepObj = Step.create(step);
|
|
stepObj.fields = stepObj.fields.map((f) => WizardField.create(f));
|
|
return stepObj;
|
|
});
|
|
|
|
return Wizard.create(wizard);
|
|
});
|
|
}
|