smart_table 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9580e5cd19fa52e7a9ee8644c0c01317ee3da2e1dd3fe36f8ea49e947859791
4
- data.tar.gz: e407570cff3a6f620b302babd89ecfa14b67c3a5863b2f6884a2f908a9bd521f
3
+ metadata.gz: 1db263f81ea99ecb98bdd3d489e5d26c78185de5a898580a9e7ef01df14094a0
4
+ data.tar.gz: ad0f2d48342d05fdad85fef5e7439f397507b024dcd3c9253824d0bd1b8ad8e4
5
5
  SHA512:
6
- metadata.gz: e04715bee3e791045aa175039b1a4da8986c1f071766bd80a44ba6aa2c10f0492b7b4bae07172663cc88671c68464089b572b1364d4c8dae0742606f438664e7
7
- data.tar.gz: 1ccaefb74058377dacf9c8ab970dafdc81df29c2cec42e7f897212b1e97e75cf4221b01853f7b5bec1ed8c572d3d307463ec426b7a54190dbbfd389ea04ad523
6
+ metadata.gz: 7ccf44e9d7d0c7f409d27987917386e2facaa4f5d599ab41c5016e2be818f975105e11315c9d62d8420baa2c625f13adaf08bc29d590ba486d6625d3bd84fdeb
7
+ data.tar.gz: 68d32cd3588d43aaba371a40184cd5af7cf438160175ac03b3035eccf02091ceb7526a37ff80b183861da5fd4161925668d6994d1f75d3f46436ccaa17af4472
data/README.md CHANGED
@@ -133,3 +133,12 @@ The following snippet shows how to use different input types to make custom filt
133
133
  <%= radio_button_tag("category", "java", params["category"] == 'java') %>
134
134
  <% end %>
135
135
  ```
136
+
137
+ ### Setting Up Defaults
138
+ ```ruby
139
+ smart_table_params = smart_table_params(
140
+ initial_page_size: 20,
141
+ initial_sort_attribute: :name,
142
+ initial_sort_order: :desc
143
+ )
144
+ ```
@@ -6,7 +6,7 @@ ul.pagination {
6
6
  border-radius: 4px;
7
7
 
8
8
  // Pagination buttons
9
- &>a {
9
+ &>a, &>span.gap {
10
10
  position: relative;
11
11
  float: left;
12
12
  line-height: 1.428571429;
@@ -26,11 +26,16 @@ module SmartTable
26
26
  end
27
27
  end
28
28
 
29
- def smart_table_params(initial_page_size: 25)
29
+ def smart_table_params(initial_page_size: 25, initial_sort_attribute: nil, initial_sort_order: :asc)
30
30
  return @st_params if @st_params
31
31
 
32
32
  @st_params = Params.new
33
+
33
34
  @st_params.sort = params[SORT_PARAM]
35
+ if @st_params.sort.nil? && initial_sort_attribute
36
+ @st_params.sort = "#{initial_sort_attribute} #{initial_sort_order}"
37
+ end
38
+
34
39
  @st_params.search = params[SEARCH_PARAM]
35
40
  @st_params.page_size = params[PAGE_SIZE_PARAM] || initial_page_size
36
41
  if @st_params.page_size == SHOW_ALL
@@ -23,7 +23,7 @@ module SmartTable
23
23
  raise 'smart_table_params must be called on the controller, before using smart_table_paginate helper' unless get_cached_smart_table_params
24
24
 
25
25
  paginatable_array = Kaminari.
26
- paginate_array(records, total_count: total_records_count).
26
+ paginate_array(records.to_a, total_count: total_records_count).
27
27
  page(get_cached_smart_table_params.page_number).
28
28
  per(get_cached_smart_table_params.page_size)
29
29
 
@@ -126,7 +126,7 @@ module SmartTable
126
126
  page_size.to_s
127
127
  else
128
128
  human_page_size = (page_size == SHOW_ALL ? I18n.t('smart_table.show_all') : page_size.to_s)
129
- link_to human_page_size, current_request_url_with_merged_query_params(PAGE_SIZE_PARAM => page_size)
129
+ link_to human_page_size, current_request_url_with_merged_query_params(PAGE_SIZE_PARAM => page_size, PAGE_PARAM => 1)
130
130
  end
131
131
  end.join(' ')
132
132
  ).html_safe
@@ -1,3 +1,3 @@
1
1
  module SmartTable
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Gubert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -186,11 +186,6 @@ files:
186
186
  - "./lib/smart_table/config.rb"
187
187
  - "./lib/smart_table/engine.rb"
188
188
  - "./lib/smart_table/version.rb"
189
- - "./smart_table-0.0.1.gem"
190
- - "./smart_table-0.0.2.gem"
191
- - "./smart_table-0.0.3.gem"
192
- - "./smart_table-0.0.4.gem"
193
- - "./smart_table-0.0.5.gem"
194
189
  - "./smart_table.gemspec"
195
190
  - "./spec/dummy_app/Rakefile"
196
191
  - "./spec/dummy_app/app/assets/config/manifest.js"
Binary file
Binary file
Binary file
Binary file
Binary file