mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
37 lines
800 B
JavaScript
37 lines
800 B
JavaScript
import computed from "ember-addons/ember-computed-decorators";
|
|
import UploadMixin from "discourse/mixins/upload";
|
|
|
|
export default Em.Component.extend(UploadMixin, {
|
|
classNames: ["image-uploader"],
|
|
|
|
@computed("imageUrl")
|
|
backgroundStyle(imageUrl) {
|
|
if (Em.isEmpty(imageUrl)) {
|
|
return "".htmlSafe();
|
|
}
|
|
|
|
return `background-image: url(${imageUrl})`.htmlSafe();
|
|
},
|
|
|
|
@computed("backgroundStyle")
|
|
hasBackgroundStyle(backgroundStyle) {
|
|
return !Ember.isEmpty(backgroundStyle.string);
|
|
},
|
|
|
|
validateUploadedFilesOptions() {
|
|
return { imagesOnly: true };
|
|
},
|
|
|
|
uploadDone(upload) {
|
|
this.set("imageUrl", upload.url);
|
|
this.set("imageId", upload.id);
|
|
},
|
|
|
|
actions: {
|
|
trash() {
|
|
this.set("imageUrl", null);
|
|
this.set("imageId", null);
|
|
}
|
|
}
|
|
});
|