mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 20:45:51 +00:00
UX: Trash icon displaying when there is no upload.
This commit is contained in:
parent
575d6855ea
commit
10c6211cdf
@ -9,9 +9,15 @@ export default Em.Component.extend(UploadMixin, {
|
|||||||
if (Em.isNone(imageUrl)) {
|
if (Em.isNone(imageUrl)) {
|
||||||
return "".htmlSafe();
|
return "".htmlSafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
return `background-image: url(${imageUrl})`.htmlSafe();
|
return `background-image: url(${imageUrl})`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed("backgroundStyle")
|
||||||
|
hasBackgroundStyle(backgroundStyle) {
|
||||||
|
Ember.isEmpty(backgroundStyle);
|
||||||
|
},
|
||||||
|
|
||||||
validateUploadedFilesOptions() {
|
validateUploadedFilesOptions() {
|
||||||
return { imagesOnly: true };
|
return { imagesOnly: true };
|
||||||
},
|
},
|
||||||
|
@ -18,9 +18,8 @@ export default Em.Mixin.create({
|
|||||||
|
|
||||||
calculateUploadUrl() {
|
calculateUploadUrl() {
|
||||||
return (
|
return (
|
||||||
getUrl(this.getWithDefault("uploadUrl", "/uploads")) +
|
+".json?client_id=" +
|
||||||
".json?client_id=" +
|
(this.messageBus && this.messageBus.clientId) +
|
||||||
this.messageBus.clientId +
|
|
||||||
"&authenticity_token=" +
|
"&authenticity_token=" +
|
||||||
encodeURIComponent(Discourse.Session.currentProp("csrfToken"))
|
encodeURIComponent(Discourse.Session.currentProp("csrfToken"))
|
||||||
);
|
);
|
||||||
@ -99,7 +98,9 @@ export default Em.Mixin.create({
|
|||||||
}.on("didInsertElement"),
|
}.on("didInsertElement"),
|
||||||
|
|
||||||
_destroy: function() {
|
_destroy: function() {
|
||||||
this.messageBus.unsubscribe("/uploads/" + this.get("type"));
|
this.messageBus &&
|
||||||
|
this.messageBus.unsubscribe("/uploads/" + this.get("type"));
|
||||||
|
|
||||||
const $upload = this.$();
|
const $upload = this.$();
|
||||||
try {
|
try {
|
||||||
$upload.fileupload("destroy");
|
$upload.fileupload("destroy");
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{d-icon "picture-o"}}
|
{{d-icon "picture-o"}}
|
||||||
<input class="hidden-upload-field" disabled={{uploading}} type="file" accept="image/*" />
|
<input class="hidden-upload-field" disabled={{uploading}} type="file" accept="image/*" />
|
||||||
</label>
|
</label>
|
||||||
{{#if backgroundStyle}}
|
{{#if hasBackgroundStyle}}
|
||||||
<button {{action "trash"}} class="btn btn-danger pad-left no-text">{{d-icon "trash-o"}}</button>
|
<button {{action "trash"}} class="btn btn-danger pad-left no-text">{{d-icon "trash-o"}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span class="btn {{unless uploading 'hidden'}}">{{i18n 'upload_selector.uploading'}} {{uploadProgress}}%</span>
|
<span class="btn {{unless uploading 'hidden'}}">{{i18n 'upload_selector.uploading'}} {{uploadProgress}}%</span>
|
||||||
|
14
test/javascripts/components/image-uploader-test.js.es6
Normal file
14
test/javascripts/components/image-uploader-test.js.es6
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import componentTest from "helpers/component-test";
|
||||||
|
moduleForComponent("image-uploader", { integration: true });
|
||||||
|
|
||||||
|
componentTest("without image", {
|
||||||
|
template: "{{image-uploader}}",
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.equal(
|
||||||
|
this.$(".d-icon-trash-o").length,
|
||||||
|
0,
|
||||||
|
"it does not display trash icon"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user