Skip to content

Commit

Permalink
option Wice::Defaults::HIDE_ALL_LINK_FROM is a limit which hides the …
Browse files Browse the repository at this point in the history
…“Show All” link

versions 3.4.13
  • Loading branch information
leikind committed Mar 1, 2015
1 parent 9b6f448 commit 6e49833
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
7 changes: 6 additions & 1 deletion lib/generators/wice_grid/templates/wice_grid_config.rb
Expand Up @@ -92,13 +92,18 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Showing All Queries #

# Enable or disable showing all queries (non-paginated table)
# Enable or disable showing all records (non-paginated table)
Wice::Defaults::ALLOW_SHOWING_ALL_QUERIES = true

# If number of all queries is more than this value, the user will be given a warning message
Wice::Defaults::START_SHOWING_WARNING_FROM = 100


# Hide the "show all" link if the number of all records is more than...
# set to nil to shows it always
Wice::Defaults::HIDE_ALL_LINK_FROM = 500


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Saving Queries #

Expand Down
12 changes: 9 additions & 3 deletions lib/wice/helpers/wice_grid_view_helpers.rb
Expand Up @@ -700,12 +700,18 @@ def total_pages
else
parameters << ["#{grid.name}[pp]", collection_total_entries]

show_all_records_link = allow_showing_all_records && collection_total_entries > collection.length

if show_all_records_link && limit = Wice::ConfigurationProvider.value_for(:HIDE_ALL_LINK_FROM, strict: false)
show_all_records_link = limit > collection_total_entries
end

"#{first}-#{last} / #{collection_total_entries} " +
if (! allow_showing_all_records) || collection_total_entries <= collection.length
''
else
if show_all_records_link
res, js = show_all_link(collection_total_entries, parameters, grid.name)
res
else
''
end
end +
if grid.all_record_mode?
Expand Down
12 changes: 7 additions & 5 deletions lib/wice/wice_grid_misc.rb
Expand Up @@ -95,14 +95,16 @@ def [](key) #:nodoc:
module ConfigurationProvider #:nodoc:
class << self

def value_for(key) #:nodoc:
def value_for(key, strict: true) #:nodoc:
if Wice::Defaults.const_defined?(key)
Wice::Defaults.const_get(key)
else
raise WiceGridMissingConfigurationConstantException.new("Could not find constant #{key} in the configuration file!" +
" It is possible that the version of WiceGrid you are using is newer than the installed configuration file in config/initializers. " +
"Constant Wice::Defaults::#{key} is missing and you need to add it manually to wice_grid_config.rb or run the generator task=:\n" +
" rails g wice_grid:install")
if strict
raise WiceGridMissingConfigurationConstantException.new("Could not find constant #{key} in the configuration file!" +
" It is possible that the version of WiceGrid you are using is newer than the installed configuration file in config/initializers. " +
"Constant Wice::Defaults::#{key} is missing and you need to add it manually to wice_grid_config.rb or run the generator task=:\n" +
" rails g wice_grid:install")
end # else nil
end
end

Expand Down
4 changes: 2 additions & 2 deletions wice_grid.gemspec
@@ -1,8 +1,8 @@
Gem::Specification.new do |s|
s.name = 'wice_grid'
s.version = '3.4.12'
s.version = '3.4.13'
s.homepage = 'https://github.com/leikind/wice_grid'
s.date = '2014-12-31'
s.date = '2015-03-01'
s.summary = 'A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters.'
s.description = 'A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters.' +
'One of the goals of this plugin was to allow the programmer to define the contents of the cell by himself, ' +
Expand Down

0 comments on commit 6e49833

Please sign in to comment.