mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Associate category logo and background to uploads record.
This commit is contained in:
@@ -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')
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each categories as |c|}}
|
||||
<tr data-category-id={{c.id}} class="{{if c.description_excerpt 'has-description' 'no-description'}} {{if c.logo_url 'has-logo' 'no-logo'}}">
|
||||
<tr data-category-id={{c.id}} class="{{if c.description_excerpt 'has-description' 'no-description'}} {{if c.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<td class="category" style={{border-color c.color}}>
|
||||
<div>
|
||||
{{category-title-link category=c}}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<span class="category-name">{{category.name}}</span>
|
||||
|
||||
{{#if category.logo_url}}
|
||||
<div>{{cdn-img src=category.logo_url class="category-logo"}}</div>
|
||||
{{#if category.uploaded_logo.url}}
|
||||
<div>{{cdn-img src=category.uploaded_logo.url class="category-logo"}}</div>
|
||||
{{/if}}
|
||||
</a>
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
<section class='field'>
|
||||
<label>{{i18n 'category.logo'}}</label>
|
||||
{{image-uploader imageUrl=category.logo_url type="category_logo" class="no-repeat"}}
|
||||
{{image-uploader
|
||||
imageId=logoImageId
|
||||
imageUrl=logoImageUrl
|
||||
type="category_logo"
|
||||
class="no-repeat"}}
|
||||
</section>
|
||||
|
||||
<section class='field'>
|
||||
<label>{{i18n 'category.background_image'}}</label>
|
||||
{{image-uploader imageUrl=category.background_url type="category_background"}}
|
||||
{{image-uploader
|
||||
imageId=backgroundImageId
|
||||
imageUrl=backgroundImageUrl
|
||||
type="category_background"}}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user