FIX: enable_accepted_answers state was not correctly displayed (#82)

This commit is contained in:
Joffrey JAFFEUX 2019-10-23 15:37:37 +02:00 committed by GitHub
parent 17912bdda3
commit e974c35d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 16 deletions

View File

@ -1,11 +1,15 @@
{{#unless siteSettings.allow_solved_on_all_topics}}
<h3>{{i18n 'solved.title'}}</h3>
<section class='field'>
<div class="enable-accepted-answer">
<label class="checkbox-label">
{{input type="checkbox" checked=category.enable_accepted_answers}}
{{i18n 'solved.allow_accepted_answers'}}
</label>
</div>
</section>
<h3>{{i18n 'solved.title'}}</h3>
<section class='field'>
<div class="enable-accepted-answer">
<label class="checkbox-label">
{{input
type="checkbox"
checked=(readonly category.enable_accepted_answers)
change=(action "onChangeSetting" value="target.checked")
}}
{{i18n 'solved.allow_accepted_answers'}}
</label>
</div>
</section>
{{/unless}}

View File

@ -0,0 +1,10 @@
export default {
actions: {
onChangeSetting(value) {
this.set(
"category.custom_fields.enable_accepted_answers",
value ? "true" : "false"
);
}
}
};

View File

@ -10,13 +10,8 @@ export default {
enable_accepted_answers: Ember.computed(
"custom_fields.enable_accepted_answers",
{
get(enableField) {
return enableField === "true";
},
set(value) {
value = value ? "true" : "false";
this.set("custom_fields.enable_accepted_answers", value);
return value;
get(fieldName) {
return Ember.get(this.custom_fields, fieldName) === "true";
}
}
)