Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 11:52:54 +01:00
COMPATIBILITY: The core wizard is now an ember addon
Dieser Commit ist enthalten in:
Ursprung
aea2df9b06
Commit
70329f209a
12 geänderte Dateien mit 137 neuen und 10 gelöschten Zeilen
|
@ -1,8 +1,6 @@
|
|||
//= require_tree_discourse truth-helpers/addon
|
||||
//= require_tree_discourse discourse-common/addon
|
||||
//= require_tree_discourse select-kit/addon
|
||||
//= require_tree_discourse wizard/lib
|
||||
//= require_tree_discourse wizard/mixins
|
||||
//= require_tree_discourse discourse/app/lib
|
||||
//= require_tree_discourse discourse/app/mixins
|
||||
|
||||
|
@ -76,6 +74,7 @@
|
|||
//= require_tree ./wizard/controllers
|
||||
//= require_tree ./wizard/helpers
|
||||
//= require_tree ./wizard/lib
|
||||
//= require_tree ./wizard/mixins
|
||||
//= require_tree ./wizard/models
|
||||
//= require_tree ./wizard/routes
|
||||
//= require_tree ./wizard/templates
|
||||
|
|
47
assets/javascripts/wizard-shims.js
Normale Datei
47
assets/javascripts/wizard-shims.js
Normale Datei
|
@ -0,0 +1,47 @@
|
|||
define("@popperjs/core", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Popper;
|
||||
__exports__.createPopper = window.Popper.createPopper;
|
||||
__exports__.defaultModifiers = window.Popper.defaultModifiers;
|
||||
__exports__.popperGenerator = window.Popper.popperGenerator;
|
||||
});
|
||||
|
||||
define("tippy.js", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.tippy;
|
||||
});
|
||||
|
||||
define("@uppy/core", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.Core;
|
||||
__exports__.BasePlugin = window.Uppy.Core.BasePlugin;
|
||||
});
|
||||
|
||||
define("@uppy/aws-s3", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.AwsS3;
|
||||
});
|
||||
|
||||
define("@uppy/aws-s3-multipart", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.AwsS3Multipart;
|
||||
});
|
||||
|
||||
define("@uppy/xhr-upload", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.XHRUpload;
|
||||
});
|
||||
|
||||
define("@uppy/drop-target", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.DropTarget;
|
||||
});
|
||||
|
||||
define("@uppy/utils/lib/delay", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.Utils.delay;
|
||||
});
|
||||
|
||||
define("@uppy/utils/lib/EventTracker", ["exports"], function (__exports__) {
|
||||
__exports__.default = window.Uppy.Utils.EventTracker;
|
||||
});
|
||||
|
||||
define("@uppy/utils/lib/AbortController", ["exports"], function (__exports__) {
|
||||
__exports__.AbortController =
|
||||
window.Uppy.Utils.AbortControllerLib.AbortController;
|
||||
__exports__.AbortSignal = window.Uppy.Utils.AbortControllerLib.AbortSignal;
|
||||
__exports__.createAbortError =
|
||||
window.Uppy.Utils.AbortControllerLib.createAbortError;
|
||||
});
|
10
assets/javascripts/wizard-vendor.js
Normale Datei
10
assets/javascripts/wizard-vendor.js
Normale Datei
|
@ -0,0 +1,10 @@
|
|||
//= require ember_jquery
|
||||
//= require template_include.js
|
||||
//= require uppy.js
|
||||
//= require bootstrap-modal.js
|
||||
//= require bootbox.js
|
||||
//= require virtual-dom
|
||||
//= require virtual-dom-amd
|
||||
//= require popper.js
|
||||
//= require tippy.umd.js
|
||||
//= require wizard-shims
|
|
@ -1,7 +1,7 @@
|
|||
import Component from "@ember/component";
|
||||
import { equal } from "@ember/object/computed";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { getToken } from "wizard/lib/ajax";
|
||||
import { getToken } from "../lib/ajax";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ["validator"],
|
||||
|
|
33
assets/javascripts/wizard/lib/ajax.js.es6
Normale Datei
33
assets/javascripts/wizard/lib/ajax.js.es6
Normale Datei
|
@ -0,0 +1,33 @@
|
|||
import { Promise } from "rsvp";
|
||||
import getUrl from "discourse-common/lib/get-url";
|
||||
import jQuery from "jquery";
|
||||
import { run } from "@ember/runloop";
|
||||
|
||||
let token;
|
||||
|
||||
export function getToken() {
|
||||
if (!token) {
|
||||
token = document.querySelector('meta[name="csrf-token"]')?.content;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
export function ajax(args) {
|
||||
let url;
|
||||
|
||||
if (arguments.length === 2) {
|
||||
url = arguments[0];
|
||||
args = arguments[1];
|
||||
} else {
|
||||
url = args.url;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
args.headers = { "X-CSRF-Token": getToken() };
|
||||
args.success = (data) => run(null, resolve, data);
|
||||
args.error = (xhr) => run(null, reject, xhr);
|
||||
args.url = getUrl(url);
|
||||
jQuery.ajax(args);
|
||||
});
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
export default {
|
||||
run(app, container) {
|
||||
const getToken = requirejs("wizard/lib/ajax").getToken;
|
||||
const getToken = requirejs(
|
||||
"discourse/plugins/discourse-custom-wizard/wizard/lib/ajax"
|
||||
).getToken;
|
||||
const isTesting = requirejs("discourse-common/config/environment")
|
||||
.isTesting;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ajax } from "wizard/lib/ajax";
|
||||
import { ajax } from "./ajax";
|
||||
import getURL, { getURLWithCDN } from "discourse-common/lib/get-url";
|
||||
import { run } from "@ember/runloop";
|
||||
import { Promise } from "rsvp";
|
||||
|
|
36
assets/javascripts/wizard/mixins/valid-state.js.es6
Normale Datei
36
assets/javascripts/wizard/mixins/valid-state.js.es6
Normale Datei
|
@ -0,0 +1,36 @@
|
|||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export const States = {
|
||||
UNCHECKED: 0,
|
||||
INVALID: 1,
|
||||
VALID: 2,
|
||||
};
|
||||
|
||||
export default {
|
||||
_validState: null,
|
||||
errorDescription: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.set("_validState", States.UNCHECKED);
|
||||
},
|
||||
|
||||
@discourseComputed("_validState")
|
||||
valid: (state) => state === States.VALID,
|
||||
|
||||
@discourseComputed("_validState")
|
||||
invalid: (state) => state === States.INVALID,
|
||||
|
||||
@discourseComputed("_validState")
|
||||
unchecked: (state) => state === States.UNCHECKED,
|
||||
|
||||
setValid(valid, description) {
|
||||
this.set("_validState", valid ? States.VALID : States.INVALID);
|
||||
|
||||
if (!valid && description && description.length) {
|
||||
this.set("errorDescription", description);
|
||||
} else {
|
||||
this.set("errorDescription", null);
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
import EmberObject from "@ember/object";
|
||||
import ValidState from "wizard/mixins/valid-state";
|
||||
import ValidState from "discourse/plugins/discourse-custom-wizard/wizard/mixins/valid-state";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { translatedText } from "discourse/plugins/discourse-custom-wizard/wizard/lib/wizard-i18n";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import EmberObject from "@ember/object";
|
||||
import ValidState from "wizard/mixins/valid-state";
|
||||
import { ajax } from "wizard/lib/ajax";
|
||||
import ValidState from "discourse/plugins/discourse-custom-wizard/wizard/mixins/valid-state";
|
||||
import { ajax } from "../lib/ajax";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { translatedText } from "discourse/plugins/discourse-custom-wizard/wizard/lib/wizard-i18n";
|
||||
import { later } from "@ember/runloop";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { default as computed } from "discourse-common/utils/decorators";
|
||||
import getUrl from "discourse-common/lib/get-url";
|
||||
import Field from "./field";
|
||||
import { ajax } from "wizard/lib/ajax";
|
||||
import { ajax } from "../lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import Step from "./step";
|
||||
import EmberObject from "@ember/object";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
# name: discourse-custom-wizard
|
||||
# about: Create custom wizards
|
||||
# version: 1.19.0
|
||||
# version: 1.20.0
|
||||
# authors: Angus McLeod
|
||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||
# contact emails: angus@thepavilion.io
|
||||
|
|
Laden …
In neuem Issue referenzieren