diff --git a/app/assets/javascripts/discourse/components/edit-category-images.js.es6 b/app/assets/javascripts/discourse/components/edit-category-images.js.es6 index 885ee5835b2..2aae9d52fff 100644 --- a/app/assets/javascripts/discourse/components/edit-category-images.js.es6 +++ b/app/assets/javascripts/discourse/components/edit-category-images.js.es6 @@ -1,2 +1,40 @@ import { buildCategoryPanel } from 'discourse/components/edit-category-panel'; -export default buildCategoryPanel('images'); +import { default as computed, observes } from 'ember-addons/ember-computed-decorators'; + +export default buildCategoryPanel('images').extend({ + @computed('category.uploaded_background.url') + backgroundImageUrl(uploadedBackgroundUrl) { + return uploadedBackgroundUrl || ''; + }, + + @computed('category.uploaded_background.id') + backgroundImageId(uploadedBackgroundId) { + return uploadedBackgroundId || null; + }, + + @computed('category.uploaded_logo.url') + logoImageUrl(uploadedLogoUrl) { + return uploadedLogoUrl || ''; + }, + + @computed('category.uploaded_logo.id') + logoImageId(uploadedLogoId) { + return uploadedLogoId || null; + }, + + @observes("backgroundImageUrl", "backgroundImageId") + _setBackgroundUpload() { + this.set("category.uploaded_background", Ember.Object.create({ + id: this.get('backgroundImageId'), + url: this.get('backgroundImageUrl') + })); + }, + + @observes("logoImageUrl", "logoImageId") + _setLogoUpload() { + this.set("category.uploaded_logo", Ember.Object.create({ + id: this.get('logoImageId'), + url: this.get('logoImageUrl') + })); + } +}); diff --git a/app/assets/javascripts/discourse/components/image-uploader.js.es6 b/app/assets/javascripts/discourse/components/image-uploader.js.es6 index 8e7d0420c61..afa00fcfb30 100644 --- a/app/assets/javascripts/discourse/components/image-uploader.js.es6 +++ b/app/assets/javascripts/discourse/components/image-uploader.js.es6 @@ -12,11 +12,13 @@ export default Em.Component.extend(UploadMixin, { uploadDone(upload) { this.set("imageUrl", upload.url); + this.set("imageId", upload.id); }, actions: { trash() { this.set("imageUrl", null); + this.set("imageId", null); } } }); diff --git a/app/assets/javascripts/discourse/models/category.js.es6 b/app/assets/javascripts/discourse/models/category.js.es6 index fc56790194d..a8657ad16ab 100644 --- a/app/assets/javascripts/discourse/models/category.js.es6 +++ b/app/assets/javascripts/discourse/models/category.js.es6 @@ -91,8 +91,8 @@ const Category = RestModel.extend({ email_in: this.get('email_in'), email_in_allow_strangers: this.get('email_in_allow_strangers'), parent_category_id: this.get('parent_category_id'), - logo_url: this.get('logo_url'), - background_url: this.get('background_url'), + uploaded_logo_id: this.get('uploaded_logo.id'), + uploaded_background_id: this.get('uploaded_background.id'), allow_badges: this.get('allow_badges'), custom_fields: this.get('custom_fields'), topic_template: this.get('topic_template'), diff --git a/app/assets/javascripts/discourse/templates/components/categories-only.hbs b/app/assets/javascripts/discourse/templates/components/categories-only.hbs index 6f6a674c51d..f2db6778627 100644 --- a/app/assets/javascripts/discourse/templates/components/categories-only.hbs +++ b/app/assets/javascripts/discourse/templates/components/categories-only.hbs @@ -11,7 +11,7 @@
{{#each categories as |c|}} -