Merge pull request #93 from paviliondev/es-lint
Apply es-lint to javascripts/discourse
Dieser Commit ist enthalten in:
Commit
c02ae44a82
27 geänderte Dateien mit 82 neuen und 101 gelöschten Zeilen
|
@ -1,6 +1,7 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
import { or, alias } from "@ember/object/computed";
|
import { alias, or } from "@ember/object/computed";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
const generateContent = function (array, type) {
|
const generateContent = function (array, type) {
|
||||||
return array.map((key) => ({
|
return array.map((key) => ({
|
||||||
|
@ -34,7 +35,7 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("field.klass")
|
@discourseComputed("field.klass")
|
||||||
serializerContent(klass, p2) {
|
serializerContent(klass) {
|
||||||
const serializers = this.get(`${klass}Serializers`);
|
const serializers = this.get(`${klass}Serializers`);
|
||||||
|
|
||||||
if (serializers) {
|
if (serializers) {
|
||||||
|
@ -66,21 +67,21 @@ export default Component.extend({
|
||||||
"field.serializers"
|
"field.serializers"
|
||||||
)
|
)
|
||||||
saveDisabled(saving) {
|
saveDisabled(saving) {
|
||||||
if (saving) return true;
|
if (saving) {return true;}
|
||||||
|
|
||||||
const originalField = this.originalField;
|
const originalField = this.originalField;
|
||||||
if (!originalField) return false;
|
if (!originalField) {return false;}
|
||||||
|
|
||||||
return ["name", "klass", "type", "serializers"].every((attr) => {
|
return ["name", "klass", "type", "serializers"].every((attr) => {
|
||||||
let current = this.get(attr);
|
let current = this.get(attr);
|
||||||
let original = originalField[attr];
|
let original = originalField[attr];
|
||||||
|
|
||||||
if (!current) return false;
|
if (!current) {return false;}
|
||||||
|
|
||||||
if (attr == "serializers") {
|
if (attr === "serializers") {
|
||||||
return this.compareArrays(current, original);
|
return this.compareArrays(current, original);
|
||||||
} else {
|
} else {
|
||||||
return current == original;
|
return current === original;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default Component.extend({
|
||||||
@discourseComputed("showAdvanced")
|
@discourseComputed("showAdvanced")
|
||||||
toggleClass(showAdvanced) {
|
toggleClass(showAdvanced) {
|
||||||
let classes = "btn";
|
let classes = "btn";
|
||||||
if (showAdvanced) classes += " btn-primary";
|
if (showAdvanced) {classes += " btn-primary";}
|
||||||
return classes;
|
return classes;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
import { equal, empty, or, and } from "@ember/object/computed";
|
import { and, empty, equal, or } from "@ember/object/computed";
|
||||||
import { generateName, selectKitContent } from "../lib/wizard";
|
import { notificationLevels, selectKitContent } from "../lib/wizard";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import wizardSchema from "../lib/wizard-schema";
|
import wizardSchema from "../lib/wizard-schema";
|
||||||
import UndoChanges from "../mixins/undo-changes";
|
import UndoChanges from "../mixins/undo-changes";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { notificationLevels } from "../lib/wizard";
|
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Component.extend(UndoChanges, {
|
export default Component.extend(UndoChanges, {
|
||||||
|
@ -43,7 +42,7 @@ export default Component.extend(UndoChanges, {
|
||||||
name: I18n.t(`admin.wizard.action.${type}.label`),
|
name: I18n.t(`admin.wizard.action.${type}.label`),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
availableNotificationLevels: notificationLevels.map((type, index) => {
|
availableNotificationLevels: notificationLevels.map((type) => {
|
||||||
return {
|
return {
|
||||||
id: type,
|
id: type,
|
||||||
name: I18n.t(
|
name: I18n.t(
|
||||||
|
@ -92,7 +91,7 @@ export default Component.extend(UndoChanges, {
|
||||||
|
|
||||||
@discourseComputed("apis", "action.api")
|
@discourseComputed("apis", "action.api")
|
||||||
availableEndpoints(apis, api) {
|
availableEndpoints(apis, api) {
|
||||||
if (!api) return [];
|
if (!api) {return [];}
|
||||||
return apis.find((a) => a.name === api).endpoints;
|
return apis.find((a) => a.name === api).endpoints;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
import { equal, or, alias } from "@ember/object/computed";
|
import { alias, equal, or } from "@ember/object/computed";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import { selectKitContent } from "../lib/wizard";
|
import { selectKitContent } from "../lib/wizard";
|
||||||
import UndoChanges from "../mixins/undo-changes";
|
import UndoChanges from "../mixins/undo-changes";
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: "wizard-custom-step",
|
classNames: "wizard-custom-step",
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import {
|
import {
|
||||||
default as discourseComputed,
|
default as discourseComputed,
|
||||||
on,
|
|
||||||
observes,
|
observes,
|
||||||
|
on,
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { generateName } from "../lib/wizard";
|
import { generateName } from "../lib/wizard";
|
||||||
import {
|
import {
|
||||||
default as wizardSchema,
|
|
||||||
setWizardDefaults,
|
setWizardDefaults,
|
||||||
|
default as wizardSchema,
|
||||||
} from "../lib/wizard-schema";
|
} from "../lib/wizard-schema";
|
||||||
import { notEmpty } from "@ember/object/computed";
|
import { notEmpty } from "@ember/object/computed";
|
||||||
import { scheduleOnce, bind } from "@ember/runloop";
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
|
@ -53,7 +53,7 @@ export default Component.extend({
|
||||||
"items.@each.title"
|
"items.@each.title"
|
||||||
)
|
)
|
||||||
links(current, items) {
|
links(current, items) {
|
||||||
if (!items) return;
|
if (!items) {return;}
|
||||||
|
|
||||||
return items.map((item) => {
|
return items.map((item) => {
|
||||||
if (item) {
|
if (item) {
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gt } from "@ember/object/computed";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import { defaultConnector } from "../lib/wizard-mapper";
|
import { defaultConnector } from "../lib/wizard-mapper";
|
||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { computed, set } from "@ember/object";
|
import { computed, set } from "@ember/object";
|
||||||
import { alias, equal, or, not } from "@ember/object/computed";
|
import { alias, equal, not, or } from "@ember/object/computed";
|
||||||
import {
|
import {
|
||||||
newPair,
|
|
||||||
connectorContent,
|
connectorContent,
|
||||||
inputTypesContent,
|
|
||||||
defaultSelectionType,
|
|
||||||
defaultConnector,
|
defaultConnector,
|
||||||
|
defaultSelectionType,
|
||||||
|
inputTypesContent,
|
||||||
|
newPair,
|
||||||
} from "../lib/wizard-mapper";
|
} from "../lib/wizard-mapper";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connectorContent } from "../lib/wizard-mapper";
|
import { connectorContent } from "../lib/wizard-mapper";
|
||||||
import { gt, or, alias } from "@ember/object/computed";
|
import { alias, gt } from "@ember/object/computed";
|
||||||
import { computed, observes } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import { alias, or, gt } from "@ember/object/computed";
|
import { alias, gt, or } from "@ember/object/computed";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import {
|
import {
|
||||||
default as discourseComputed,
|
default as discourseComputed,
|
||||||
observes,
|
observes
|
||||||
on,
|
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
import { defaultSelectionType, selectionTypes } from "../lib/wizard-mapper";
|
import { defaultSelectionType, selectionTypes } from "../lib/wizard-mapper";
|
||||||
import { snakeCase, generateName, userProperties } from "../lib/wizard";
|
import { generateName, snakeCase, userProperties } from "../lib/wizard";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { bind, later } from "@ember/runloop";
|
import { bind, later } from "@ember/runloop";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
@ -135,7 +134,7 @@ 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.parents(".type-selector").length && this.showTypes) {
|
if (!$target.parents(".type-selector").length && this.showTypes) {
|
||||||
|
@ -249,7 +248,7 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("activeType", "inputType")
|
@discourseComputed("activeType", "inputType")
|
||||||
placeholderKey(activeType, inputType) {
|
placeholderKey(activeType) {
|
||||||
if (
|
if (
|
||||||
activeType === "text" &&
|
activeType === "text" &&
|
||||||
this.options[`${this.selectorType}Placeholder`]
|
this.options[`${this.selectorType}Placeholder`]
|
||||||
|
@ -275,14 +274,14 @@ export default Component.extend({
|
||||||
|
|
||||||
optionEnabled(type) {
|
optionEnabled(type) {
|
||||||
const options = this.options;
|
const options = this.options;
|
||||||
if (!options) return false;
|
if (!options) {return false;}
|
||||||
|
|
||||||
const option = options[type];
|
const option = options[type];
|
||||||
if (option === true) return true;
|
if (option === true) {return true;}
|
||||||
if (typeof option !== "string") return false;
|
if (typeof option !== "string") {return false;}
|
||||||
|
|
||||||
return option.split(",").filter((option) => {
|
return option.split(",").filter((o) => {
|
||||||
return [this.selectorType, this.inputType].indexOf(option) !== -1;
|
return [this.selectorType, this.inputType].indexOf(o) !== -1;
|
||||||
}).length;
|
}).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
|
||||||
import { newInput, selectionTypes } from "../lib/wizard-mapper";
|
import { newInput, selectionTypes } from "../lib/wizard-mapper";
|
||||||
import {
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
default as discourseComputed,
|
|
||||||
observes,
|
|
||||||
on,
|
|
||||||
} from "discourse-common/utils/decorators";
|
|
||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default Component.extend({
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
if (!this.validations) return;
|
if (!this.validations) {return;}
|
||||||
|
|
||||||
if (!this.field.validations) {
|
if (!this.field.validations) {
|
||||||
const validations = {};
|
const validations = {};
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
default as discourseComputed,
|
|
||||||
on,
|
|
||||||
} from "discourse-common/utils/decorators";
|
|
||||||
import { notEmpty } from "@ember/object/computed";
|
import { notEmpty } from "@ember/object/computed";
|
||||||
import { userProperties } from "../lib/wizard";
|
import { userProperties } from "../lib/wizard";
|
||||||
import { scheduleOnce } from "@ember/runloop";
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import CustomWizardApi from "../models/custom-wizard-api";
|
import CustomWizardApi from "../models/custom-wizard-api";
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
import { not, and, equal } from "@ember/object/computed";
|
import { and, equal, not } from "@ember/object/computed";
|
||||||
import { selectKitContent } from "../lib/wizard";
|
import { selectKitContent } from "../lib/wizard";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
@ -64,8 +64,8 @@ export default Controller.extend({
|
||||||
threeLeggedOauth
|
threeLeggedOauth
|
||||||
) {
|
) {
|
||||||
if (saveDisabled || !authType || !tokenUrl || !clientId || !clientSecret)
|
if (saveDisabled || !authType || !tokenUrl || !clientId || !clientSecret)
|
||||||
return true;
|
{return true;}
|
||||||
if (threeLeggedOauth) return !authUrl;
|
if (threeLeggedOauth) {return !authUrl;}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -146,16 +146,16 @@ export default Controller.extend({
|
||||||
const api = this.get("api");
|
const api = this.get("api");
|
||||||
const name = api.name;
|
const name = api.name;
|
||||||
const authType = api.authType;
|
const authType = api.authType;
|
||||||
let refreshList = false;
|
let refreshList = false; // eslint-disable-line
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
if (!name || !authType) return;
|
if (!name || !authType) {return;}
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
auth_type: authType,
|
auth_type: authType,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (api.title) data["title"] = api.title;
|
if (api.title) {data["title"] = api.title;}
|
||||||
|
|
||||||
const originalTitle = this.get("api.originalTitle");
|
const originalTitle = this.get("api.originalTitle");
|
||||||
if (api.get("isNew") || (originalTitle && api.title !== originalTitle)) {
|
if (api.get("isNew") || (originalTitle && api.title !== originalTitle)) {
|
||||||
|
@ -232,7 +232,7 @@ export default Controller.extend({
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
const name = this.get("api.name");
|
const name = this.get("api.name");
|
||||||
if (!name) return;
|
if (!name) {return;}
|
||||||
|
|
||||||
this.set("updating", true);
|
this.set("updating", true);
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ export default Controller.extend({
|
||||||
|
|
||||||
clearLogs() {
|
clearLogs() {
|
||||||
const name = this.get("api.name");
|
const name = this.get("api.name");
|
||||||
if (!name) return;
|
if (!name) {return;}
|
||||||
|
|
||||||
ajax(`/admin/wizards/api/${name.underscore()}/logs`, {
|
ajax(`/admin/wizards/api/${name.underscore()}/logs`, {
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import EmberObject from "@ember/object";
|
|
||||||
import { ajax } from "discourse/lib/ajax";
|
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
||||||
import CustomWizardCustomField from "../models/custom-wizard-custom-field";
|
import CustomWizardCustomField from "../models/custom-wizard-custom-field";
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
messageKey: "create",
|
messageKey: "create",
|
||||||
|
@ -49,7 +45,7 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
removeField(field) {
|
removeField(field) {
|
||||||
return CustomWizardCustomField.destroyField(field).then((result) => {
|
return CustomWizardCustomField.destroyField(field).then(() => {
|
||||||
this.get("customFields").removeObject(field);
|
this.get("customFields").removeObject(field);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { default as computed } from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
||||||
import { ajax } from "discourse/lib/ajax";
|
|
||||||
import { notEmpty } from "@ember/object/computed";
|
import { notEmpty } from "@ember/object/computed";
|
||||||
import CustomWizardLogs from "../models/custom-wizard-logs";
|
import CustomWizardLogs from "../models/custom-wizard-logs";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
|
@ -13,7 +11,7 @@ export default Controller.extend({
|
||||||
logs: [],
|
logs: [],
|
||||||
|
|
||||||
loadLogs() {
|
loadLogs() {
|
||||||
if (!this.canLoadMore) return;
|
if (!this.canLoadMore) {return;}
|
||||||
|
|
||||||
this.set("refreshing", true);
|
this.set("refreshing", true);
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ export default Controller.extend({
|
||||||
.finally(() => this.set("refreshing", false));
|
.finally(() => this.set("refreshing", false));
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("hasLogs", "refreshing")
|
@discourseComputed("hasLogs", "refreshing")
|
||||||
noResults(hasLogs, refreshing) {
|
noResults(hasLogs, refreshing) {
|
||||||
return !hasLogs && !refreshing;
|
return !hasLogs && !refreshing;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import {
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
default as discourseComputed,
|
|
||||||
observes,
|
|
||||||
} from "discourse-common/utils/decorators";
|
|
||||||
import { empty } from "@ember/object/computed";
|
import { empty } from "@ember/object/computed";
|
||||||
import CustomWizardManager from "../models/custom-wizard-manager";
|
import CustomWizardManager from "../models/custom-wizard-manager";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
|
@ -196,7 +193,7 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
const destroyWizards = this.get("destroyWizards");
|
let destroyWizards = this.get("destroyWizards");
|
||||||
|
|
||||||
if (!destroyWizards.length) {
|
if (!destroyWizards.length) {
|
||||||
this.setMessage("error", "none_selected");
|
this.setMessage("error", "none_selected");
|
||||||
|
@ -227,7 +224,7 @@ export default Controller.extend({
|
||||||
|
|
||||||
if (result.destroyed.length) {
|
if (result.destroyed.length) {
|
||||||
const destroyedIds = result.destroyed.map((d) => d.id);
|
const destroyedIds = result.destroyed.map((d) => d.id);
|
||||||
const destroyWizards = this.get("destroyWizards");
|
destroyWizards = this.get("destroyWizards");
|
||||||
const wizards = this.get("wizards");
|
const wizards = this.get("wizards");
|
||||||
|
|
||||||
wizards.removeObjects(
|
wizards.removeObjects(
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
import {
|
import {
|
||||||
default as discourseComputed,
|
default as discourseComputed,
|
||||||
observes,
|
observes
|
||||||
on,
|
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { notEmpty, alias } from "@ember/object/computed";
|
import { notEmpty } from "@ember/object/computed";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
import { generateId, wizardFieldList } from "../lib/wizard";
|
import { generateId, wizardFieldList } from "../lib/wizard";
|
||||||
import { buildProperties } from "../lib/wizard-json";
|
|
||||||
import { dasherize } from "@ember/string";
|
import { dasherize } from "@ember/string";
|
||||||
import EmberObject from "@ember/object";
|
import { later, scheduleOnce } from "@ember/runloop";
|
||||||
import { scheduleOnce, later } from "@ember/runloop";
|
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import copyText from "discourse/lib/copy-text";
|
import copyText from "discourse/lib/copy-text";
|
||||||
import CustomWizard from "../models/custom-wizard";
|
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -6,7 +5,7 @@ export default {
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const siteSettings = container.lookup("site-settings:main");
|
const siteSettings = container.lookup("site-settings:main");
|
||||||
|
|
||||||
if (!siteSettings.custom_wizard_enabled) return;
|
if (!siteSettings.custom_wizard_enabled) {return;}
|
||||||
|
|
||||||
const existing = DiscourseURL.routeTo;
|
const existing = DiscourseURL.routeTo;
|
||||||
DiscourseURL.routeTo = function (path, opts) {
|
DiscourseURL.routeTo = function (path, opts) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default {
|
||||||
const messageBus = container.lookup("message-bus:main");
|
const messageBus = container.lookup("message-bus:main");
|
||||||
const siteSettings = container.lookup("site-settings:main");
|
const siteSettings = container.lookup("site-settings:main");
|
||||||
|
|
||||||
if (!siteSettings.custom_wizard_enabled || !messageBus) return;
|
if (!siteSettings.custom_wizard_enabled || !messageBus) {return;}
|
||||||
|
|
||||||
messageBus.subscribe("/redirect_to_wizard", function (wizardId) {
|
messageBus.subscribe("/redirect_to_wizard", function (wizardId) {
|
||||||
const wizardUrl = window.location.origin + "/w/" + wizardId;
|
const wizardUrl = window.location.origin + "/w/" + wizardId;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { listProperties, camelCase, snakeCase } from "../lib/wizard";
|
import { camelCase, listProperties } from "../lib/wizard";
|
||||||
import wizardSchema from "../lib/wizard-schema";
|
import wizardSchema from "../lib/wizard-schema";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
|
|
|
@ -4,6 +4,13 @@ import I18n from "I18n";
|
||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
|
|
||||||
|
const selectableInputTypes = [
|
||||||
|
'conditional',
|
||||||
|
'assignment',
|
||||||
|
'association',
|
||||||
|
'validation'
|
||||||
|
];
|
||||||
|
|
||||||
function defaultInputType(options = {}) {
|
function defaultInputType(options = {}) {
|
||||||
return options.inputTypes.split(",")[0];
|
return options.inputTypes.split(",")[0];
|
||||||
}
|
}
|
||||||
|
@ -43,13 +50,13 @@ function defaultConnector(connectorType, inputType, options = {}) {
|
||||||
return defaultInputType(options);
|
return defaultInputType(options);
|
||||||
}
|
}
|
||||||
if (connectorType === "pair") {
|
if (connectorType === "pair") {
|
||||||
if (inputType === "conditional") return "equal";
|
if (inputType === "conditional") {return "equal";}
|
||||||
if (inputType === "association") return "association";
|
if (inputType === "association") {return "association";}
|
||||||
if (inputType === "validation") return "equal";
|
if (inputType === "validation") {return "equal";}
|
||||||
}
|
}
|
||||||
if (connectorType === "output") {
|
if (connectorType === "output") {
|
||||||
if (inputType === "conditional") return "then";
|
if (inputType === "conditional") {return "then";}
|
||||||
if (inputType === "assignment") return "set";
|
if (inputType === "assignment") {return "set";}
|
||||||
}
|
}
|
||||||
return "equal";
|
return "equal";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { set, get } from "@ember/object";
|
import { get, set } from "@ember/object";
|
||||||
|
|
||||||
const wizard = {
|
const wizard = {
|
||||||
basic: {
|
basic: {
|
||||||
|
@ -225,7 +225,7 @@ if (Discourse.SiteSettings.wizard_apis_enabled) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setWizardDefaults(obj, itemType, opts = {}) {
|
export function setWizardDefaults(obj, itemType) {
|
||||||
const objSchema = wizardSchema[itemType];
|
const objSchema = wizardSchema[itemType];
|
||||||
const basicDefaults = objSchema.basic;
|
const basicDefaults = objSchema.basic;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ function generateName(id) {
|
||||||
return id ? sentenceCase(id) : "";
|
return id ? sentenceCase(id) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateId(name, opts = {}) {
|
function generateId(name) {
|
||||||
return name ? snakeCase(name) : "";
|
return name ? snakeCase(name) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ const notificationLevels = [
|
||||||
"muted",
|
"muted",
|
||||||
];
|
];
|
||||||
|
|
||||||
function listProperties(type, opts = {}) {
|
function listProperties(itemType, opts = {}) {
|
||||||
let properties = Object.keys(wizardSchema[type].basic);
|
let properties = Object.keys(wizardSchema[itemType].basic);
|
||||||
|
|
||||||
const types = wizardSchema[type].types;
|
const types = wizardSchema[itemType].types;
|
||||||
|
|
||||||
if (types) {
|
if (types) {
|
||||||
let typeProperties = [];
|
let typeProperties = [];
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { listProperties } from "../lib/wizard";
|
import { listProperties } from "../lib/wizard";
|
||||||
import { default as wizardSchema } from "../lib/wizard-schema";
|
import { default as wizardSchema } from "../lib/wizard-schema";
|
||||||
import { set, get } from "@ember/object";
|
import { get, set } from "@ember/object";
|
||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
|
||||||
import { deepEqual } from "discourse-common/lib/object";
|
import { deepEqual } from "discourse-common/lib/object";
|
||||||
|
|
||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
|
@ -97,7 +96,6 @@ export default Mixin.create({
|
||||||
actions: {
|
actions: {
|
||||||
undoChanges() {
|
undoChanges() {
|
||||||
const componentType = this.componentType;
|
const componentType = this.componentType;
|
||||||
const original = this.get("originalObject");
|
|
||||||
const obj = this.get(componentType);
|
const obj = this.get(componentType);
|
||||||
|
|
||||||
this.removeObservers(obj.type);
|
this.removeObservers(obj.type);
|
||||||
|
@ -118,6 +116,7 @@ export default Mixin.create({
|
||||||
this.setupObservers(type);
|
this.setupObservers(type);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
mappedFieldUpdated(property, mappedComponent, type) {
|
mappedFieldUpdated(property, mappedComponent, type) {
|
||||||
const obj = this.get(this.componentType);
|
const obj = this.get(this.componentType);
|
||||||
obj.notifyPropertyChange(property);
|
obj.notifyPropertyChange(property);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { buildProperties, present, mapped } from "../lib/wizard-json";
|
import { buildProperties, mapped, present } from "../lib/wizard-json";
|
||||||
import { listProperties, camelCase, snakeCase } from "../lib/wizard";
|
import { listProperties, snakeCase } from "../lib/wizard";
|
||||||
import wizardSchema from "../lib/wizard-schema";
|
import wizardSchema from "../lib/wizard-schema";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
@ -132,7 +132,7 @@ const CustomWizard = EmberObject.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
buildMappedJson(inputs) {
|
buildMappedJson(inputs) {
|
||||||
if (!inputs || !inputs.length) return false;
|
if (!inputs || !inputs.length) {return false;}
|
||||||
|
|
||||||
let result = [];
|
let result = [];
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default DiscourseRoute.extend({
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
const showParams = this.paramsFor("adminWizardsApiShow");
|
const showParams = this.paramsFor("adminWizardsApiShow");
|
||||||
const apiName = showParams.name == "create" ? null : showParams.name;
|
const apiName = showParams.name === "create" ? null : showParams.name;
|
||||||
const apiList = (model || []).map((api) => {
|
const apiList = (model || []).map((api) => {
|
||||||
return {
|
return {
|
||||||
id: api.name,
|
id: api.name,
|
||||||
|
|
Laden …
In neuem Issue referenzieren