0
0
Fork 1
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:
Angus McLeod 2024-05-15 13:46:56 +02:00
Ursprung 0d0fb83bd1
Commit 7eb7b7eba6
3 geänderte Dateien mit 32 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -18,6 +18,9 @@ import { inject as service } from "@ember/service";
const IMAGE_MARKDOWN_REGEX =
/!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g;
export const wizardComposerEdtiorEventPrefix = "wizard-editor";
export default ComposerEditor.extend({
modal: service(),
@ -33,7 +36,7 @@ export default ComposerEditor.extend({
draftStatus: "null",
replyPlaceholder: alias("field.translatedPlaceholder"),
wizardEventFieldId: null,
composerEventPrefix: "wizard-editor",
composerEventPrefix: wizardComposerEdtiorEventPrefix,
@on("didInsertElement")
_composerEditorInit() {

Datei anzeigen

@ -7,8 +7,21 @@ import { cook } from "discourse/lib/text";
import CustomWizard, {
updateCachedWizard,
} 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 { 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({
classNameBindings: [":wizard-step", "step.id"],
@ -28,6 +41,17 @@ export default Component.extend({
cook(this.step.translatedDescription).then((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() {
@ -40,6 +64,7 @@ export default Component.extend({
showNextButton: not("step.final"),
showDoneButton: alias("step.final"),
btnsDisabled: or("saving", "uploading"),
@discourseComputed(
"step.index",

Datei anzeigen

@ -60,7 +60,7 @@
type="button"
class="wizard-btn next primary"
{{action "nextStep"}}
disabled={{saving}}
disabled={{btnsDisabled}}
tabindex={{primaryButtonIndex}}
>
{{i18n "wizard.next"}}
@ -73,7 +73,7 @@
type="button"
class="wizard-btn done"
{{action "done"}}
disabled={{saving}}
disabled={{btnsDisabled}}
tabindex={{primaryButtonIndex}}
>
{{i18n "wizard.done_custom"}}