From cb13152a43a409d5629e8cdd6e67660129832b7e Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 8 Jun 2020 15:16:42 +0200 Subject: [PATCH] FIX: ensures edit-category-setting is correctly casting boolean (#9999) --- .../app/components/edit-category-settings.js | 11 +++++++++-- .../components/edit-category-settings.hbs | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/edit-category-settings.js b/app/assets/javascripts/discourse/app/components/edit-category-settings.js index c811ce2db6e..5dc44ee02b9 100644 --- a/app/assets/javascripts/discourse/app/components/edit-category-settings.js +++ b/app/assets/javascripts/discourse/app/components/edit-category-settings.js @@ -108,11 +108,18 @@ export default buildCategoryPanel("settings", { .sort((a, b) => a.name.localeCompare(b.name)); }, + @discourseComputed("category.sort_ascending") + sortAscendingOption(sortAscending) { + if (sortAscending === "false") return false; + if (sortAscending === "true") return true; + return sortAscending; + }, + @discourseComputed sortAscendingOptions() { return [ - { name: I18n.t("category.sort_ascending"), value: "true" }, - { name: I18n.t("category.sort_descending"), value: "false" } + { name: I18n.t("category.sort_ascending"), value: true }, + { name: I18n.t("category.sort_descending"), value: false } ]; } }); diff --git a/app/assets/javascripts/discourse/app/templates/components/edit-category-settings.hbs b/app/assets/javascripts/discourse/app/templates/components/edit-category-settings.hbs index a569876fd8c..5520c045a70 100644 --- a/app/assets/javascripts/discourse/app/templates/components/edit-category-settings.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/edit-category-settings.hbs @@ -181,17 +181,25 @@ {{i18n "category.sort_order"}}
- {{combo-box valueProperty="value" content=availableSorts value=category.sort_order none="category.sort_options.default"}} + {{combo-box + valueProperty="value" + content=availableSorts + value=category.sort_order + options=(hash + none="category.sort_options.default" + ) + onChange=(action (mut category.sort_order)) + }} {{#unless isDefaultSortOrder}} {{combo-box - castBoolean=true valueProperty="value" content=sortAscendingOptions - value=category.sort_ascending - none="category.sort_options.default" + value=sortAscendingOption options=(hash + none="category.sort_options.default" placementStrategy="absolute" ) + onChange=(action (mut category.sort_ascending)) }} {{/unless}}