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

Apply prettier to recent changes

Dieser Commit ist enthalten in:
angusmcleod 2021-04-12 16:12:20 +10:00
Ursprung c02ae44a82
Commit 54c00f1784
13 geänderte Dateien mit 84 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -67,16 +67,22 @@ 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);

Datei anzeigen

@ -7,7 +7,9 @@ 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;
}, },

Datei anzeigen

@ -91,7 +91,9 @@ 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;
}, },
}); });

Datei anzeigen

@ -53,7 +53,9 @@ 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) {

Datei anzeigen

@ -2,7 +2,7 @@ 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,
} 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";
@ -134,7 +134,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.parents(".type-selector").length && this.showTypes) { if (!$target.parents(".type-selector").length && this.showTypes) {
@ -274,11 +276,17 @@ 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) {
if (typeof option !== "string") {return false;} return true;
}
if (typeof option !== "string") {
return false;
}
return option.split(",").filter((o) => { return option.split(",").filter((o) => {
return [this.selectorType, this.inputType].indexOf(o) !== -1; return [this.selectorType, this.inputType].indexOf(o) !== -1;

Datei anzeigen

@ -19,7 +19,9 @@ 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 = {};

Datei anzeigen

@ -63,9 +63,12 @@ export default Controller.extend({
clientSecret, clientSecret,
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;
}, },
@ -149,13 +152,17 @@ export default Controller.extend({
let refreshList = false; // eslint-disable-line 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 +239,9 @@ 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 +259,9 @@ 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",

Datei anzeigen

@ -11,7 +11,9 @@ export default Controller.extend({
logs: [], logs: [],
loadLogs() { loadLogs() {
if (!this.canLoadMore) {return;} if (!this.canLoadMore) {
return;
}
this.set("refreshing", true); this.set("refreshing", true);

Datei anzeigen

@ -1,6 +1,6 @@
import { import {
default as discourseComputed, default as discourseComputed,
observes observes,
} from "discourse-common/utils/decorators"; } from "discourse-common/utils/decorators";
import { notEmpty } from "@ember/object/computed"; import { notEmpty } from "@ember/object/computed";
import showModal from "discourse/lib/show-modal"; import showModal from "discourse/lib/show-modal";

Datei anzeigen

@ -5,7 +5,9 @@ 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) {

Datei anzeigen

@ -8,7 +8,9 @@ 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;

Datei anzeigen

@ -5,10 +5,10 @@ import I18n from "I18n";
// Inputs // Inputs
const selectableInputTypes = [ const selectableInputTypes = [
'conditional', "conditional",
'assignment', "assignment",
'association', "association",
'validation' "validation",
]; ];
function defaultInputType(options = {}) { function defaultInputType(options = {}) {
@ -50,13 +50,23 @@ 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") {
if (inputType === "association") {return "association";} return "equal";
if (inputType === "validation") {return "equal";} }
if (inputType === "association") {
return "association";
}
if (inputType === "validation") {
return "equal";
}
} }
if (connectorType === "output") { if (connectorType === "output") {
if (inputType === "conditional") {return "then";} if (inputType === "conditional") {
if (inputType === "assignment") {return "set";} return "then";
}
if (inputType === "assignment") {
return "set";
}
} }
return "equal"; return "equal";
} }

Datei anzeigen

@ -132,7 +132,9 @@ const CustomWizard = EmberObject.extend({
}, },
buildMappedJson(inputs) { buildMappedJson(inputs) {
if (!inputs || !inputs.length) {return false;} if (!inputs || !inputs.length) {
return false;
}
let result = []; let result = [];