mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 19:35:57 +08:00
FIX: Do not destroy $.fileupload element (#9888)
conditional-loading-section component rerendered the <input> element and lost the necessary event handlers for jQuery-File-Upload.
This commit is contained in:
parent
ef3e3077d0
commit
d76ea9fa6b
app/assets/javascripts/discourse/app
config/locales
@ -1,4 +1,4 @@
|
|||||||
import { notEmpty, not } from "@ember/object/computed";
|
import { notEmpty } from "@ember/object/computed";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
@ -11,7 +11,6 @@ export default Component.extend(UploadMixin, {
|
|||||||
uploadUrl: "/admin/customize/emojis",
|
uploadUrl: "/admin/customize/emojis",
|
||||||
hasName: notEmpty("name"),
|
hasName: notEmpty("name"),
|
||||||
hasGroup: notEmpty("group"),
|
hasGroup: notEmpty("group"),
|
||||||
addDisabled: not("hasName"),
|
|
||||||
group: "default",
|
group: "default",
|
||||||
emojiGroups: null,
|
emojiGroups: null,
|
||||||
newEmojiGroups: null,
|
newEmojiGroups: null,
|
||||||
@ -23,6 +22,11 @@ export default Component.extend(UploadMixin, {
|
|||||||
this.set("newEmojiGroups", this.emojiGroups);
|
this.set("newEmojiGroups", this.emojiGroups);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@discourseComputed("hasName", "uploading")
|
||||||
|
addDisabled() {
|
||||||
|
return !this.hasName || this.uploading;
|
||||||
|
},
|
||||||
|
|
||||||
uploadOptions() {
|
uploadOptions() {
|
||||||
return { sequentialUploads: true };
|
return { sequentialUploads: true };
|
||||||
},
|
},
|
||||||
|
@ -39,8 +39,10 @@ export default Mixin.create({
|
|||||||
|
|
||||||
_initialize: on("didInsertElement", function() {
|
_initialize: on("didInsertElement", function() {
|
||||||
const $upload = $(this.element);
|
const $upload = $(this.element);
|
||||||
const reset = () =>
|
const reset = () => {
|
||||||
this.setProperties({ uploading: false, uploadProgress: 0 });
|
this.setProperties({ uploading: false, uploadProgress: 0 });
|
||||||
|
document.getElementsByClassName("hidden-upload-field")[0].value = "";
|
||||||
|
};
|
||||||
const maxFiles = this.getWithDefault(
|
const maxFiles = this.getWithDefault(
|
||||||
"maxFiles",
|
"maxFiles",
|
||||||
this.siteSettings.simultaneous_uploads
|
this.siteSettings.simultaneous_uploads
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
{{#conditional-loading-section isLoading=uploading}}
|
|
||||||
<div class="emoji-uploader">
|
<div class="emoji-uploader">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<span class="label">
|
<span class="label">
|
||||||
@ -34,8 +33,13 @@
|
|||||||
<div class="control">
|
<div class="control">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label class="btn btn-default btn-primary {{if addDisabled "disabled"}}">
|
<label class="btn btn-default btn-primary {{if addDisabled "disabled"}}">
|
||||||
|
{{#if uploading}}
|
||||||
|
{{d-icon "spinner" class="loading-icon"}}
|
||||||
|
<span>{{i18n "admin.emoji.uploading"}}</span>
|
||||||
|
{{else}}
|
||||||
{{d-icon "plus"}}
|
{{d-icon "plus"}}
|
||||||
{{i18n "admin.emoji.add"}}
|
<span>{{i18n "admin.emoji.add"}}</span>
|
||||||
|
{{/if}}
|
||||||
<input
|
<input
|
||||||
class="hidden-upload-field"
|
class="hidden-upload-field"
|
||||||
disabled={{addDisabled}}
|
disabled={{addDisabled}}
|
||||||
@ -45,4 +49,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/conditional-loading-section}}
|
|
||||||
|
@ -4673,6 +4673,7 @@ en:
|
|||||||
title: "Emoji"
|
title: "Emoji"
|
||||||
help: "Add new emoji that will be available to everyone. (PROTIP: drag & drop multiple files at once)"
|
help: "Add new emoji that will be available to everyone. (PROTIP: drag & drop multiple files at once)"
|
||||||
add: "Add New Emoji"
|
add: "Add New Emoji"
|
||||||
|
uploading: "Uploading..."
|
||||||
name: "Name"
|
name: "Name"
|
||||||
group: "Group"
|
group: "Group"
|
||||||
image: "Image"
|
image: "Image"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user