FIX: Was modifying Category after it was instantiated

This commit is contained in:
Robin Ward 2015-09-17 12:21:41 -04:00
parent 1e1b7d7327
commit de39f46279
2 changed files with 25 additions and 18 deletions

View File

@ -11,25 +11,7 @@ export default {
name: 'extend-for-solved-button', name: 'extend-for-solved-button',
initialize: function() { initialize: function() {
Discourse.Category.reopen({
@computed("custom_fields")
enable_accepted_answers: {
get() {
const fields = this.get("custom_fields");
return fields && fields.enable_accepted_answers === "true";
},
set(value) {
value = value ? "true" : "false";
this.set("custom_fields.enable_accepted_answers", value);
return value;
}
}
});
Topic.reopen({ Topic.reopen({
// keeping this here cause there is complex localization // keeping this here cause there is complex localization
acceptedAnswerHtml: function(){ acceptedAnswerHtml: function(){
const username = this.get('accepted_answer.username'); const username = this.get('accepted_answer.username');

View File

@ -0,0 +1,25 @@
import property from 'ember-addons/ember-computed-decorators';
import Category from 'discourse/models/category';
export default {
name: 'extend-category-for-solved',
before: 'inject-discourse-objects',
initialize() {
Category.reopen({
@property('custom_fields.enable_accepted_answers')
enable_accepted_answers: {
get(enableField) {
return enableField === "true";
},
set(value) {
value = value ? "true" : "false";
this.set("custom_fields.enable_accepted_answers", value);
return value;
}
}
});
}
};