From e975a2451ae3c5f6eb62bfbfea33be3bb9f2cb14 Mon Sep 17 00:00:00 2001 From: Koza Date: Mon, 11 Jul 2022 10:17:27 +0200 Subject: Add `hideDropDown` alias for `showDropDown` setting, as the latter is confusing to use (because its logic seems inverted). --- lib/axlsx/workbook/worksheet/data_validation.rb | 29 +++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/worksheet/data_validation.rb b/lib/axlsx/workbook/worksheet/data_validation.rb index 835b5b33..71f9bbe6 100644 --- a/lib/axlsx/workbook/worksheet/data_validation.rb +++ b/lib/axlsx/workbook/worksheet/data_validation.rb @@ -13,11 +13,12 @@ module Axlsx # @option options [Boolean] allowBlank - A boolean value indicating whether the data validation allows the use of empty or blank entries. # @option options [String] error - Message text of error alert. # @option options [Symbol] errorStyle - The style of error alert used for this data validation. - # @option options [String] errorTitle - itle bar text of error alert. + # @option options [String] errorTitle - Title bar text of error alert. # @option options [Symbol] operator - The relational operator used with this data validation. # @option options [String] prompt - Message text of input prompt. # @option options [String] promptTitle - Title bar text of input prompt. - # @option options [Boolean] showDropDown - A boolean value indicating whether to display a dropdown combo box for a list type data validation + # @option options [Boolean] showDropDown - A boolean value indicating whether to display a dropdown combo box for a list type data validation. Be careful: It has an inverted logic, false shows the dropdown list! You should use hideDropDown instead. + # @option options [Boolean] hideDropDown - A boolean value indicating whether to hide the dropdown combo box for a list type data validation. Defaults to `false` (meaning the dropdown is visible by default). # @option options [Boolean] showErrorMessage - A boolean value indicating whether to display the error alert message when an invalid value has been entered, according to the criteria specified. # @option options [Boolean] showInputMessage - A boolean value indicating whether to display the input prompt message. # @option options [String] sqref - Range over which data validation is applied, in "A1:B2" format. @@ -121,13 +122,22 @@ module Axlsx # Show drop down # A boolean value indicating whether to display a dropdown combo box for a list type data - # validation. Be careful: false shows the dropdown list! + # validation. Be careful: It has an inverted logic, false shows the dropdown list! # Available for type list # @see type # @return [Boolean] # default false attr_reader :showDropDown + # Hide drop down + # A boolean value indicating whether to hide a dropdown combo box for a list type data + # validation. Defaults to `false` (meaning the dropdown is visible by default). + # Available for type list + # @see type + # @return [Boolean] + # default false + alias :hideDropDown :showDropDown + # Show error message # A boolean value indicating whether to display the error alert message when an invalid # value has been entered, according to the criteria specified. @@ -195,7 +205,18 @@ module Axlsx def promptTitle=(v); Axlsx::validate_string(v); @promptTitle = v end # @see showDropDown - def showDropDown=(v); Axlsx::validate_boolean(v); @showDropDown = v end + def showDropDown=(v) + warn 'The `showDropDown` has an inverted logic, false shows the dropdown list! You should use `hideDropDown` instead.' + Axlsx::validate_boolean(v) + @showDropDown = v + end + + # @see hideDropDown + def hideDropDown=(v) + Axlsx::validate_boolean(v) + # It's just an alias for the showDropDown attribute, hideDropDown should set the value of the original showDropDown. + @showDropDown = v + end # @see showErrorMessage def showErrorMessage=(v); Axlsx::validate_boolean(v); @showErrorMessage = v end -- cgit v1.2.3