0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00

fixed linting issues for javascripts/wizard folder (#94)

* ran eslint and fixes linting issues for javascripts/wizard folder

* ran prettier
Dieser Commit ist enthalten in:
Faizaan Gagan 2021-04-12 11:56:22 +05:30 committet von GitHub
Ursprung 54c00f1784
Commit 0205d8ccb5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
25 geänderte Dateien mit 108 neuen und 71 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
window.Discourse = {} /* eslint no-undef: 0*/
window.Discourse = {};
window.Wizard = {}; window.Wizard = {};
Wizard.SiteSettings = {}; Wizard.SiteSettings = {};
Discourse.__widget_helpers = {}; Discourse.__widget_helpers = {};

Datei anzeigen

@ -1,4 +1,4 @@
(function () { (function () {
document.cookie = 'destination_url=' + window.location.href + ';path=/'; document.cookie = 'destination_url=' + window.location.href + ';path=/';
window.location.href = '/login' window.location.href = '/login';
})() })();

Datei anzeigen

@ -1,4 +1,4 @@
(function() { (function() {
var wizard = require('discourse/plugins/discourse-custom-wizard/wizard/custom-wizard').default.create(); let wizard = require('discourse/plugins/discourse-custom-wizard/wizard/custom-wizard').default.create();
wizard.start(); wizard.start();
})(); })();

Datei anzeigen

@ -5,6 +5,8 @@ import {
import { renderAvatar } from "discourse/helpers/user-avatar"; import { renderAvatar } from "discourse/helpers/user-avatar";
import userSearch from "../lib/user-search"; import userSearch from "../lib/user-search";
import WizardI18n from "../lib/wizard-i18n"; import WizardI18n from "../lib/wizard-i18n";
import Handlebars from "handlebars";
import { isEmpty } from "@ember/utils";
const template = function (params) { const template = function (params) {
const options = params.options; const options = params.options;
@ -43,13 +45,14 @@ export default Ember.TextField.extend({
@observes("usernames") @observes("usernames")
_update() { _update() {
if (this.get("canReceiveUpdates") === "true") if (this.get("canReceiveUpdates") === "true") {
this.didInsertElement({ updateData: true }); this.didInsertElement({ updateData: true });
}
}, },
didInsertElement(opts) { didInsertElement(opts) {
this._super(); this._super();
var self = this, let self = this,
selected = [], selected = [],
groups = [], groups = [],
currentUser = this.currentUser, currentUser = this.currentUser,
@ -82,7 +85,7 @@ export default Ember.TextField.extend({
dataSource(term) { dataSource(term) {
const termRegex = /[^a-zA-Z0-9_\-\.@\+]/; const termRegex = /[^a-zA-Z0-9_\-\.@\+]/;
var results = userSearch({ let results = userSearch({
term: term.replace(termRegex, ""), term: term.replace(termRegex, ""),
topicId: self.get("topicId"), topicId: self.get("topicId"),
exclude: excludedUsernames(), exclude: excludedUsernames(),
@ -102,7 +105,7 @@ export default Ember.TextField.extend({
} }
return v.username || v.name; return v.username || v.name;
} else { } else {
var excludes = excludedUsernames(); let excludes = excludedUsernames();
return v.usernames.filter(function (item) { return v.usernames.filter(function (item) {
return excludes.indexOf(item) === -1; return excludes.indexOf(item) === -1;
}); });
@ -110,7 +113,7 @@ export default Ember.TextField.extend({
}, },
onChangeItems(items) { onChangeItems(items) {
var hasGroups = false; let hasGroups = false;
items = items.map(function (i) { items = items.map(function (i) {
if (groups.indexOf(i) > -1) { if (groups.indexOf(i) > -1) {
hasGroups = true; hasGroups = true;
@ -121,7 +124,9 @@ export default Ember.TextField.extend({
self.set("hasGroups", hasGroups); self.set("hasGroups", hasGroups);
selected = items; selected = items;
if (self.get("onChangeCallback")) self.sendAction("onChangeCallback"); if (self.get("onChangeCallback")) {
self.sendAction("onChangeCallback");
}
}, },
reverseTransform(i) { reverseTransform(i) {
@ -139,7 +144,7 @@ export default Ember.TextField.extend({
@observes("usernames") @observes("usernames")
_clearInput: function () { _clearInput: function () {
if (arguments.length > 1) { if (arguments.length > 1) {
if (Em.isEmpty(this.get("usernames"))) { if (isEmpty(this.get("usernames"))) {
$(this.element).parent().find("a").click(); $(this.element).parent().find("a").click();
} }
} }

Datei anzeigen

@ -1,5 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { observes } from "discourse-common/utils/decorators";
export default Component.extend({ export default Component.extend({
actions: { actions: {
perform() { perform() {

Datei anzeigen

@ -1,11 +1,10 @@
import WizardFieldValidator from "../../wizard/components/validator"; import WizardFieldValidator from "../../wizard/components/validator";
import { deepMerge } from "discourse-common/lib/object"; import { deepMerge } from "discourse-common/lib/object";
import { observes } from "discourse-common/utils/decorators"; import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { cancel, later } from "@ember/runloop"; import { cancel, later } from "@ember/runloop";
import { A } from "@ember/array"; import { A } from "@ember/array";
import EmberObject, { computed } from "@ember/object"; import EmberObject, { computed } from "@ember/object";
import { notEmpty, and, equal, empty } from "@ember/object/computed"; import { and, equal, notEmpty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
import { categoryBadgeHTML } from "discourse/helpers/category-link"; import { categoryBadgeHTML } from "discourse/helpers/category-link";
import { dasherize } from "@ember/string"; import { dasherize } from "@ember/string";
@ -16,7 +15,7 @@ export default WizardFieldValidator.extend({
hasSimilarTopics: notEmpty("similarTopics"), hasSimilarTopics: notEmpty("similarTopics"),
hasNotSearched: equal("similarTopics", null), hasNotSearched: equal("similarTopics", null),
noSimilarTopics: computed("similarTopics", function () { noSimilarTopics: computed("similarTopics", function () {
return this.similarTopics !== null && this.similarTopics.length == 0; return this.similarTopics !== null && this.similarTopics.length === 0;
}), }),
showSimilarTopics: computed("typing", "hasSimilarTopics", function () { showSimilarTopics: computed("typing", "hasSimilarTopics", function () {
return this.hasSimilarTopics && !this.typing; return this.hasSimilarTopics && !this.typing;
@ -35,8 +34,9 @@ export default WizardFieldValidator.extend({
@discourseComputed("validation.categories") @discourseComputed("validation.categories")
validationCategories(categoryIds) { validationCategories(categoryIds) {
if (categoryIds) if (categoryIds) {
return categoryIds.map((id) => this.site.categoriesById[id]); return categoryIds.map((id) => this.site.categoriesById[id]);
}
return A(); return A();
}, },
@ -78,15 +78,18 @@ export default WizardFieldValidator.extend({
@discourseComputed("currentState") @discourseComputed("currentState")
currentStateClass(currentState) { currentStateClass(currentState) {
if (currentState) return `similar-topics-${dasherize(currentState)}`; if (currentState) {
return `similar-topics-${dasherize(currentState)}`;
}
return "similar-topics"; return "similar-topics";
}, },
@discourseComputed("currentState") @discourseComputed("currentState")
currentStateKey(currentState) { currentStateKey(currentState) {
if (currentState) if (currentState) {
return `realtime_validations.similar_topics.${currentState}`; return `realtime_validations.similar_topics.${currentState}`;
}
return false; return false;
}, },

Datei anzeigen

@ -4,22 +4,18 @@ import {
on, on,
} from "discourse-common/utils/decorators"; } from "discourse-common/utils/decorators";
import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { findRawTemplate } from "discourse-common/lib/raw-templates";
import { throttle } from "@ember/runloop"; import { next, scheduleOnce, throttle } from "@ember/runloop";
import { scheduleOnce, next } from "@ember/runloop"; import { caretPosition, inCodeBlock } from "discourse/lib/utilities";
import {
safariHacksDisabled,
caretPosition,
inCodeBlock,
} from "discourse/lib/utilities";
import highlightSyntax from "discourse/lib/highlight-syntax"; import highlightSyntax from "discourse/lib/highlight-syntax";
import { getToken } from "wizard/lib/ajax"; import { getToken } from "wizard/lib/ajax";
import { import {
validateUploadedFiles, displayErrorForUpload,
getUploadMarkdown, getUploadMarkdown,
uploadIcon,
validateUploadedFiles,
} from "discourse/lib/uploads"; } from "discourse/lib/uploads";
import { cacheShortUploadUrl } from "pretty-text/upload-short-url"; import { cacheShortUploadUrl } from "pretty-text/upload-short-url";
import { alias } from "@ember/object/computed"; import { alias } from "@ember/object/computed";
import { uploadIcon } from "discourse/lib/uploads";
import WizardI18n from "../lib/wizard-i18n"; import WizardI18n from "../lib/wizard-i18n";
const uploadMarkdownResolvers = []; const uploadMarkdownResolvers = [];
@ -78,8 +74,8 @@ export default ComposerEditor.extend({
.join(","); .join(",");
}, },
@discourseComputed("currentUser") @discourseComputed()
uploadIcon(currentUser) { uploadIcon() {
return uploadIcon(false, this.siteSettings); return uploadIcon(false, this.siteSettings);
}, },
@ -295,7 +291,7 @@ export default ComposerEditor.extend({
shortcut: "K", shortcut: "K",
trimLeading: true, trimLeading: true,
unshift: true, unshift: true,
sendAction: (event) => component.set("showHyperlinkBox", true), sendAction: () => component.set("showHyperlinkBox", true),
}); });
}, },

Datei anzeigen

@ -12,7 +12,9 @@ export default Ember.Component.extend({
[...value].reduce((result, v) => { [...value].reduce((result, v) => {
let val = let val =
property === "id" ? Category.findById(v) : Category.findBySlug(v); property === "id" ? Category.findById(v) : Category.findBySlug(v);
if (val) result.push(val); if (val) {
result.push(val);
}
return result; return result;
}, []) }, [])
); );

Datei anzeigen

@ -2,6 +2,7 @@ import CustomWizard from "../models/custom";
export default Ember.Component.extend({ export default Ember.Component.extend({
siteName: function () { siteName: function () {
/*eslint no-undef:0*/
return Wizard.SiteSettings.title; return Wizard.SiteSettings.title;
}.property(), }.property(),

Datei anzeigen

@ -15,7 +15,9 @@ export default Component.extend({
}, },
documentClick(e) { documentClick(e) {
if (this._state == "destroying") return; if (this._state === "destroying") {
return;
}
let $target = $(e.target); let $target = $(e.target);
if (!$target.hasClass("show-topics")) { if (!$target.hasClass("show-topics")) {

Datei anzeigen

@ -1,7 +1,7 @@
/* eslint no-undef: 0 */ /* eslint no-undef: 0*/
import computed from "discourse-common/utils/decorators"; import computed from "discourse-common/utils/decorators";
import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction"; import { isLTR, isRTL, siteDir } from "discourse/lib/text-direction";
import WizardI18n from "../lib/wizard-i18n"; import WizardI18n from "../lib/wizard-i18n";
export default Ember.TextField.extend({ export default Ember.TextField.extend({

Datei anzeigen

@ -1,5 +1,6 @@
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n"; import I18n from "I18n";
import Handlebars from "handlebars";
export default registerUnbound("char-counter", function (body, maxLength) { export default registerUnbound("char-counter", function (body, maxLength) {
let bodyLength = body ? body.length : 0; let bodyLength = body ? body.length : 0;
@ -9,11 +10,11 @@ export default registerUnbound("char-counter", function (body, maxLength) {
let isOverMax = bodyLength > maxLength ? "true" : "false"; let isOverMax = bodyLength > maxLength ? "true" : "false";
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t( finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
"wizard.x_characters", "wizard.x_characters",
{ count: parseInt(maxLength) } { count: parseInt(maxLength, 10) }
)}</div>`; )}</div>`;
} else { } else {
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", { finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
count: parseInt(bodyLength), count: parseInt(bodyLength, 10),
})}</div>`; })}</div>`;
} }

Datei anzeigen

@ -1,5 +1,6 @@
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
import { longDate, number, relativeAge } from "discourse/lib/formatter"; import { longDate, relativeAge } from "discourse/lib/formatter";
import Handlebars from "handlebars";
export default registerUnbound("date-node", function (dt) { export default registerUnbound("date-node", function (dt) {
if (typeof dt === "string") { if (typeof dt === "string") {

Datei anzeigen

@ -1,4 +1,5 @@
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
import Handlebars from "handlebars";
export default registerUnbound("dir-span", function (str) { export default registerUnbound("dir-span", function (str) {
return new Handlebars.SafeString(str); return new Handlebars.SafeString(str);

Datei anzeigen

@ -1,15 +1,17 @@
import { htmlHelper } from 'discourse-common/lib/helpers'; import { htmlHelper } from "discourse-common/lib/helpers";
function renderSpinner(cssClass) { function renderSpinner(cssClass) {
var html = "<div class='spinner"; var html = "<div class='spinner";
if (cssClass) { html += ' ' + cssClass; } if (cssClass) {
html += " " + cssClass;
}
return html + "'></div>"; return html + "'></div>";
} }
var spinnerHTML = renderSpinner(); var spinnerHTML = renderSpinner();
export default htmlHelper(params => { export default htmlHelper((params) => {
const hash = params.hash; const hash = params.hash;
return renderSpinner((hash && hash.size) ? hash.size : undefined); return renderSpinner(hash && hash.size ? hash.size : undefined);
}); });
export { spinnerHTML, renderSpinner }; export { spinnerHTML, renderSpinner };

Datei anzeigen

@ -1,5 +1,6 @@
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound } from "discourse-common/lib/helpers";
import Handlebars from "handlebars";
export default registerUnbound("plugin-outlet", function (attrs) { export default registerUnbound("plugin-outlet", function () {
return new Handlebars.SafeString(""); return new Handlebars.SafeString("");
}); });

Datei anzeigen

@ -3,8 +3,10 @@ import discourseComputed from "discourse-common/utils/decorators";
export default { export default {
name: "custom-wizard-field", name: "custom-wizard-field",
initialize(app) { initialize() {
if (window.location.pathname.indexOf("/w/") < 0) return; if (window.location.pathname.indexOf("/w/") < 0) {
return;
}
const FieldComponent = requirejs("wizard/components/wizard-field").default; const FieldComponent = requirejs("wizard/components/wizard-field").default;
const FieldModel = requirejs("wizard/models/wizard-field").default; const FieldModel = requirejs("wizard/models/wizard-field").default;
@ -30,7 +32,9 @@ export default {
inputComponentName: function () { inputComponentName: function () {
const type = this.get("field.type"); const type = this.get("field.type");
const id = this.get("field.id"); const id = this.get("field.id");
if (["text_only"].includes(type)) return false; if (["text_only"].includes(type)) {
return false;
}
return dasherize(type === "component" ? id : `wizard-field-${type}`); return dasherize(type === "component" ? id : `wizard-field-${type}`);
}.property("field.type", "field.id"), }.property("field.type", "field.id"),
}); });

Datei anzeigen

@ -1,7 +1,9 @@
export default { export default {
name: "custom-wizard-step", name: "custom-wizard-step",
initialize(app) { initialize() {
if (window.location.pathname.indexOf("/w/") < 0) return; if (window.location.pathname.indexOf("/w/") < 0) {
return;
}
const CustomWizard = requirejs( const CustomWizard = requirejs(
"discourse/plugins/discourse-custom-wizard/wizard/models/custom" "discourse/plugins/discourse-custom-wizard/wizard/models/custom"
@ -132,7 +134,9 @@ export default {
bannerImage: function () { bannerImage: function () {
const src = this.get("step.banner"); const src = this.get("step.banner");
if (!src) return; if (!src) {
return;
}
return getUrl(src); return getUrl(src);
}.property("step.banner"), }.property("step.banner"),
@ -166,7 +170,7 @@ export default {
.finally(() => this.set("saving", false)); .finally(() => this.set("saving", false));
}, },
keyPress(key) {}, keyPress() {},
actions: { actions: {
quit() { quit() {

Datei anzeigen

@ -1,14 +1,13 @@
export default { export default {
name: "custom-routes", name: "custom-routes",
initialize(app) { initialize(app) {
if (window.location.pathname.indexOf("/w/") < 0) return; if (window.location.pathname.indexOf("/w/") < 0) {
return;
}
const EmberObject = requirejs("@ember/object").default; const EmberObject = requirejs("@ember/object").default;
const Router = requirejs("wizard/router").default; const Router = requirejs("wizard/router").default;
const ApplicationRoute = requirejs("wizard/routes/application").default; const ApplicationRoute = requirejs("wizard/routes/application").default;
const CustomWizard = requirejs(
"discourse/plugins/discourse-custom-wizard/wizard/models/custom"
).default;
const getUrl = requirejs("discourse-common/lib/get-url").default; const getUrl = requirejs("discourse-common/lib/get-url").default;
const Store = requirejs("discourse/models/store").default; const Store = requirejs("discourse/models/store").default;
const registerRawHelpers = requirejs( const registerRawHelpers = requirejs(
@ -18,6 +17,7 @@ export default {
.createHelperContext; .createHelperContext;
const RawHandlebars = requirejs("discourse-common/lib/raw-handlebars") const RawHandlebars = requirejs("discourse-common/lib/raw-handlebars")
.default; .default;
const Handlebars = requirejs("handlebars").default;
const Site = requirejs( const Site = requirejs(
"discourse/plugins/discourse-custom-wizard/wizard/models/site" "discourse/plugins/discourse-custom-wizard/wizard/models/site"
).default; ).default;
@ -36,10 +36,12 @@ export default {
// IE11 Polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill // IE11 Polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill
if (!Object.entries) { if (!Object.entries) {
Object.entries = function (obj) { Object.entries = function (obj) {
var ownProps = Object.keys(obj), let ownProps = Object.keys(obj),
i = ownProps.length, i = ownProps.length,
resArray = new Array(i); // preallocate the Array resArray = new Array(i); // preallocate the Array
while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]]; while (i--) {
resArray[i] = [ownProps[i], obj[ownProps[i]]];
}
return resArray; return resArray;
}; };
@ -53,7 +55,7 @@ export default {
}); });
const targets = ["controller", "component", "route", "model", "adapter"]; const targets = ["controller", "component", "route", "model", "adapter"];
/*eslint no-undef: 0*/
const siteSettings = Wizard.SiteSettings; const siteSettings = Wizard.SiteSettings;
app.register("site-settings:main", siteSettings, { instantiate: false }); app.register("site-settings:main", siteSettings, { instantiate: false });
createHelperContext({ siteSettings }); createHelperContext({ siteSettings });

Datei anzeigen

@ -1,5 +1,6 @@
import loadScript from "./load-script"; import loadScript from "./load-script";
import { default as PrettyText } from "pretty-text/pretty-text"; import { default as PrettyText } from "pretty-text/pretty-text";
import Handlebars from "handlebars";
export function cook(text, options) { export function cook(text, options) {
return new Handlebars.SafeString(new PrettyText(options).cook(text)); return new Handlebars.SafeString(new PrettyText(options).cook(text));

Datei anzeigen

@ -2,7 +2,7 @@ import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
import { debounce } from "@ember/runloop"; import { debounce } from "@ember/runloop";
import getUrl from "discourse-common/lib/get-url"; import getUrl from "discourse-common/lib/get-url";
var cache = {}, let cache = {},
cacheTopicId, cacheTopicId,
cacheTime, cacheTime,
currentTerm, currentTerm,
@ -18,7 +18,7 @@ function performSearch(
group, group,
resultsFn resultsFn
) { ) {
var cached = cache[term]; let cached = cache[term];
if (cached) { if (cached) {
resultsFn(cached); resultsFn(cached);
return; return;
@ -37,7 +37,7 @@ function performSearch(
}, },
}); });
var returnVal = CANCELLED_STATUS; let returnVal = CANCELLED_STATUS;
oldSearch oldSearch
.then(function (r) { .then(function (r) {
@ -59,7 +59,7 @@ function organizeResults(r, options) {
return r; return r;
} }
var exclude = options.exclude || [], let exclude = options.exclude || [],
limit = options.limit || 5, limit = options.limit || 5,
users = [], users = [],
emails = [], emails = [],
@ -87,8 +87,9 @@ function organizeResults(r, options) {
if ( if (
results.length > limit && results.length > limit &&
options.term.toLowerCase() !== g.name.toLowerCase() options.term.toLowerCase() !== g.name.toLowerCase()
) ) {
return false; return false;
}
if (exclude.indexOf(g.name) === -1) { if (exclude.indexOf(g.name) === -1) {
groups.push(g); groups.push(g);
results.push(g); results.push(g);
@ -104,7 +105,7 @@ function organizeResults(r, options) {
} }
export default function userSearch(options) { export default function userSearch(options) {
var term = options.term || "", let term = options.term || "",
includeGroups = options.includeGroups, includeGroups = options.includeGroups,
includeMentionableGroups = options.includeMentionableGroups, includeMentionableGroups = options.includeMentionableGroups,
includeMessageableGroups = options.includeMessageableGroups, includeMessageableGroups = options.includeMessageableGroups,
@ -131,7 +132,7 @@ export default function userSearch(options) {
cacheTopicId = topicId; cacheTopicId = topicId;
var clearPromise = setTimeout(function () { let clearPromise = setTimeout(function () {
resolve(CANCELLED_STATUS); resolve(CANCELLED_STATUS);
}, 5000); }, 5000);

Datei anzeigen

@ -19,7 +19,9 @@ const translationExists = (key) => {
const WizardI18n = (key, params = {}) => { const WizardI18n = (key, params = {}) => {
const themeId = getThemeId(); const themeId = getThemeId();
if (!themeId) return I18n.t(key, params); if (!themeId) {
return I18n.t(key, params);
}
const themeKey = `theme_translations.${themeId}.${key}`; const themeKey = `theme_translations.${themeId}.${key}`;

Datei anzeigen

@ -10,7 +10,9 @@ const CustomWizard = EmberObject.extend({
totalSteps: (length) => length, totalSteps: (length) => length,
skip() { skip() {
if (this.required && !this.completed && this.permitted) return; if (this.required && !this.completed && this.permitted) {
return;
}
CustomWizard.skip(this.id); CustomWizard.skip(this.id);
}, },
}); });
@ -35,7 +37,9 @@ export function findCustomWizard(wizardId, params = {}) {
let url = `/w/${wizardId}`; let url = `/w/${wizardId}`;
let paramKeys = Object.keys(params).filter((k) => { let paramKeys = Object.keys(params).filter((k) => {
if (k === "wizard_id") return false; if (k === "wizard_id") {
return false;
}
return !!params[k]; return !!params[k];
}); });
@ -51,7 +55,9 @@ export function findCustomWizard(wizardId, params = {}) {
return ajax({ url, cache: false, dataType: "json" }).then((result) => { return ajax({ url, cache: false, dataType: "json" }).then((result) => {
const wizard = result; const wizard = result;
if (!wizard) return null; if (!wizard) {
return null;
}
if (!wizard.completed) { if (!wizard.completed) {
wizard.steps = wizard.steps.map((step) => { wizard.steps = wizard.steps.map((step) => {
@ -62,7 +68,7 @@ export function findCustomWizard(wizardId, params = {}) {
}); });
let tabindex = 1; let tabindex = 1;
stepObj.fields.forEach((f, i) => { stepObj.fields.forEach((f) => {
f.tabindex = tabindex; f.tabindex = tabindex;
if (["date_time"].includes(f.type)) { if (["date_time"].includes(f.type)) {

Datei anzeigen

@ -13,7 +13,9 @@ export default Ember.Route.extend({
}, },
afterModel(model) { afterModel(model) {
if (model.completed) return this.transitionTo("index"); if (model.completed) {
return this.transitionTo("index");
}
return model.set("wizardId", this.modelFor("custom").id); return model.set("wizardId", this.modelFor("custom").id);
}, },

Datei anzeigen

@ -1,4 +1,4 @@
/* eslint no-undef: 0 */ /* eslint no-undef: 0*/
import { findCustomWizard } from "../models/custom"; import { findCustomWizard } from "../models/custom";
import { ajax } from "wizard/lib/ajax"; import { ajax } from "wizard/lib/ajax";