FEATURE: Can upload images to categories
This commit is contained in:
@@ -13,7 +13,19 @@ export default Em.Component.extend(UploadMixin, {
|
||||
this.set('imageUrl', data.result.url);
|
||||
},
|
||||
|
||||
deleteDone: function() {
|
||||
this.set('imageUrl', null);
|
||||
actions: {
|
||||
trash: function() {
|
||||
this.set('imageUrl', null);
|
||||
|
||||
// Do we want to signal the delete to the server right away?
|
||||
if (this.get('instantDelete')) {
|
||||
Discourse.ajax(this.get('uploadUrl'), {
|
||||
type: 'DELETE',
|
||||
data: { image_type: this.get('type') }
|
||||
}).then(null, function() {
|
||||
bootbox.alert(I18n.t('generic_error'));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
**/
|
||||
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
foregroundColors: ['FFFFFF', '000000'],
|
||||
categoryUploadUrl: '/category/uploads',
|
||||
|
||||
parentCategories: function() {
|
||||
return Discourse.Category.list().filter(function (c) {
|
||||
|
||||
@@ -53,18 +53,6 @@ export default Em.Mixin.create({
|
||||
actions: {
|
||||
selectFile: function() {
|
||||
this.$('input[type=file]').click();
|
||||
},
|
||||
|
||||
trash: function() {
|
||||
var self = this;
|
||||
Discourse.ajax(this.get('uploadUrl'), {
|
||||
type: 'DELETE',
|
||||
data: { image_type: this.get('type') }
|
||||
}).then(function() {
|
||||
self.deleteDone();
|
||||
}).catch(function() {
|
||||
bootbox.alert(I18n.t('generic_error'));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -68,7 +68,9 @@ Discourse.Category = Discourse.Model.extend({
|
||||
position: this.get('position'),
|
||||
email_in: this.get('email_in'),
|
||||
email_in_allow_strangers: this.get('email_in_allow_strangers'),
|
||||
parent_category_id: this.get('parent_category_id')
|
||||
parent_category_id: this.get('parent_category_id'),
|
||||
logo_url: this.get('logo_url'),
|
||||
background_url: this.get('background_url')
|
||||
},
|
||||
type: this.get('id') ? 'PUT' : 'POST'
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<section class='field'>
|
||||
<label>{{i18n category.logo}}</label>
|
||||
{{image-uploader uploadUrl=categoryUploadUrl imageUrl=logo_url type="logo"}}
|
||||
</section>
|
||||
|
||||
<section class='field'>
|
||||
<label>{{i18n category.background_image}}</label>
|
||||
{{image-uploader uploadUrl=categoryUploadUrl imageUrl=background_url type="background"}}
|
||||
</section>
|
||||
@@ -94,6 +94,7 @@
|
||||
<div class="controls">
|
||||
{{image-uploader uploadUrl=imageUploadUrl
|
||||
imageUrl=profile_background
|
||||
instantDelete="true"
|
||||
type="profile_background"}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user