Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 01:10:28 +01:00
Disable step controls when uploading
Dieser Commit ist enthalten in:
Ursprung
0d0fb83bd1
Commit
7eb7b7eba6
3 geänderte Dateien mit 32 neuen und 4 gelöschten Zeilen
|
@ -18,6 +18,9 @@ import { inject as service } from "@ember/service";
|
||||||
const IMAGE_MARKDOWN_REGEX =
|
const IMAGE_MARKDOWN_REGEX =
|
||||||
/!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g;
|
/!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g;
|
||||||
|
|
||||||
|
|
||||||
|
export const wizardComposerEdtiorEventPrefix = "wizard-editor";
|
||||||
|
|
||||||
export default ComposerEditor.extend({
|
export default ComposerEditor.extend({
|
||||||
modal: service(),
|
modal: service(),
|
||||||
|
|
||||||
|
@ -33,7 +36,7 @@ export default ComposerEditor.extend({
|
||||||
draftStatus: "null",
|
draftStatus: "null",
|
||||||
replyPlaceholder: alias("field.translatedPlaceholder"),
|
replyPlaceholder: alias("field.translatedPlaceholder"),
|
||||||
wizardEventFieldId: null,
|
wizardEventFieldId: null,
|
||||||
composerEventPrefix: "wizard-editor",
|
composerEventPrefix: wizardComposerEdtiorEventPrefix,
|
||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
_composerEditorInit() {
|
_composerEditorInit() {
|
||||||
|
|
|
@ -7,8 +7,21 @@ import { cook } from "discourse/lib/text";
|
||||||
import CustomWizard, {
|
import CustomWizard, {
|
||||||
updateCachedWizard,
|
updateCachedWizard,
|
||||||
} from "discourse/plugins/discourse-custom-wizard/discourse/models/custom-wizard";
|
} from "discourse/plugins/discourse-custom-wizard/discourse/models/custom-wizard";
|
||||||
import { alias, not } from "@ember/object/computed";
|
import { alias, not, or } from "@ember/object/computed";
|
||||||
import discourseLater from "discourse-common/lib/later";
|
import discourseLater from "discourse-common/lib/later";
|
||||||
|
import { wizardComposerEdtiorEventPrefix } from "./custom-wizard-composer-editor";
|
||||||
|
|
||||||
|
const uploadStartedEventKeys = [
|
||||||
|
"upload-started"
|
||||||
|
];
|
||||||
|
const uploadEndedEventKeys = [
|
||||||
|
"upload-success",
|
||||||
|
"upload-error",
|
||||||
|
"upload-cancelled",
|
||||||
|
"uploads-cancelled",
|
||||||
|
"uploads-aborted",
|
||||||
|
"all-uploads-complete"
|
||||||
|
];
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNameBindings: [":wizard-step", "step.id"],
|
classNameBindings: [":wizard-step", "step.id"],
|
||||||
|
@ -28,6 +41,17 @@ export default Component.extend({
|
||||||
cook(this.step.translatedDescription).then((cookedDescription) => {
|
cook(this.step.translatedDescription).then((cookedDescription) => {
|
||||||
this.set("cookedDescription", cookedDescription);
|
this.set("cookedDescription", cookedDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
uploadStartedEventKeys.forEach(key => {
|
||||||
|
this.appEvents.on(`${wizardComposerEdtiorEventPrefix}:${key}`, () => {
|
||||||
|
this.set("uploading", true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
uploadEndedEventKeys.forEach(key => {
|
||||||
|
this.appEvents.on(`${wizardComposerEdtiorEventPrefix}:${key}`, () => {
|
||||||
|
this.set("uploading", false);
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
@ -40,6 +64,7 @@ export default Component.extend({
|
||||||
|
|
||||||
showNextButton: not("step.final"),
|
showNextButton: not("step.final"),
|
||||||
showDoneButton: alias("step.final"),
|
showDoneButton: alias("step.final"),
|
||||||
|
btnsDisabled: or("saving", "uploading"),
|
||||||
|
|
||||||
@discourseComputed(
|
@discourseComputed(
|
||||||
"step.index",
|
"step.index",
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="wizard-btn next primary"
|
class="wizard-btn next primary"
|
||||||
{{action "nextStep"}}
|
{{action "nextStep"}}
|
||||||
disabled={{saving}}
|
disabled={{btnsDisabled}}
|
||||||
tabindex={{primaryButtonIndex}}
|
tabindex={{primaryButtonIndex}}
|
||||||
>
|
>
|
||||||
{{i18n "wizard.next"}}
|
{{i18n "wizard.next"}}
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="wizard-btn done"
|
class="wizard-btn done"
|
||||||
{{action "done"}}
|
{{action "done"}}
|
||||||
disabled={{saving}}
|
disabled={{btnsDisabled}}
|
||||||
tabindex={{primaryButtonIndex}}
|
tabindex={{primaryButtonIndex}}
|
||||||
>
|
>
|
||||||
{{i18n "wizard.done_custom"}}
|
{{i18n "wizard.done_custom"}}
|
||||||
|
|
Laden …
In neuem Issue referenzieren