UX: Introduce automatic 'categories topics' setting (#8804)

When 'categories topics' setting is set to 0, the system will
automatically try to find a value to keep the two columns (categories
and topics) symmetrical.

The value is computed as 1.5x the number of top level categories and at
least 5 topics will always be returned.
This commit is contained in:
Dan Ungureanu
2020-01-29 20:30:48 +02:00
committed by GitHub
parent d24d47b2ee
commit 09e8be3209
5 changed files with 72 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
# frozen_string_literal: true
class CategoriesTopicsValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(val)
num = val.to_i
return false if num.to_s != val.to_s
return false if num != 0 && num < CategoriesController::MIN_CATEGORIES_TOPICS
true
end
def error_message
I18n.t('site_settings.errors.invalid_integer_min', min: 5)
end
end