From e974c35d38053e1ad21310d83c68770555e1c5f7 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 23 Oct 2019 15:37:37 +0200 Subject: [PATCH] FIX: enable_accepted_answers state was not correctly displayed (#82) --- .../solved-settings.hbs | 22 +++++++++++-------- .../solved-settings.js.es6 | 10 +++++++++ .../extend-category-for-solved.js.es6 | 9 ++------ 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.js.es6 diff --git a/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.hbs b/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.hbs index de81877..51bcda7 100644 --- a/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.hbs +++ b/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.hbs @@ -1,11 +1,15 @@ {{#unless siteSettings.allow_solved_on_all_topics}} -

{{i18n 'solved.title'}}

-
-
- -
-
+

{{i18n 'solved.title'}}

+
+
+ +
+
{{/unless}} diff --git a/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.js.es6 b/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.js.es6 new file mode 100644 index 0000000..41697d3 --- /dev/null +++ b/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.js.es6 @@ -0,0 +1,10 @@ +export default { + actions: { + onChangeSetting(value) { + this.set( + "category.custom_fields.enable_accepted_answers", + value ? "true" : "false" + ); + } + } +}; diff --git a/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 b/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 index 2a36f6d..d45af81 100644 --- a/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 +++ b/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 @@ -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"; } } )