ez-resources 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faeed954e2b59068bceac5d87b8d94029e8ee5c75ee32831c1daf539a8c8ef5f
4
- data.tar.gz: 9341e3858d0273d8afae03827f7b541462c47668eeb7fba2a572087b2774d2db
3
+ metadata.gz: 1b3e10c0d602e396efdb1f247852079a73a3ff7400f4b8f6e29be00ef09d00a0
4
+ data.tar.gz: d2a3b95d310489e308e114fcb7cf254839e98673fdb72431c14eda556f10bca8
5
5
  SHA512:
6
- metadata.gz: 77ee0e92778121182d86b24788a37d6572b5ebe1511f0e137298f1556ad6a9e4979dd25045fb9ce401da04388b8a8de1c55a79e62e72e88a89b20e7b9de32b13
7
- data.tar.gz: 36a4a91698f181fae7e04141c15a08a13adcd746f1eb29005a75aa55e765adcd418e5c6f79ccd9f4ff795e0cd3c14bba04100950cd01b5ee4dc55335456f52ab
6
+ metadata.gz: f5352b31aeeb6e3e427dd18a8968c96d8af522c55f5a67240f17131fae7090c25c84fb3b26d5dd2ba0cde8805a1f3f0605cf13671fa196857cadd97279b6709f
7
+ data.tar.gz: 1bebc28528126229a4b491a56fa766c8695a279a8780a6118f296ae92242a1aab4596716ed6139dfa8298d5d0a5fd225185591f0fa6aa21308717ca32d59223b
data/README.md CHANGED
@@ -43,7 +43,7 @@ class UsersController < ApplicationController
43
43
  config.collection_columns do
44
44
  column :email
45
45
  column :active, type: :boolean
46
- column :name, type: :link, presenter: -> (user) { user.name.humanize }
46
+ column :name, type: :link, presenter: -> (user) { user.name.humanize }, sortable: true
47
47
  column :age
48
48
  column :avatar, type: :image, getter: ->(user) { "/avatars/#{user.id}.jpg" }, class: "t-image-tag"
49
49
  column :custom, type: :custom, builder: ->(user) { "custom #{user.email}" }
@@ -17,7 +17,7 @@
17
17
  thead class=(css_for 'collection-table-thead')
18
18
  tr class=(css_for 'collection-table-thead-tr')
19
19
  - collection_columns.each do |column|
20
- th class=(css_for 'collection-table-thead-th') id=("ez-t-#{column.name}") = column.title
20
+ th class=(css_for 'collection-table-thead-th') id=("ez-t-#{column.name}") = column_title(column)
21
21
  th class=(css_for 'collection-table-thead-th') colspan="2" style="width: 1%"
22
22
  tbody class=(css_for 'collection-table-tbody')
23
23
  - collection.each do |record|
@@ -4,6 +4,7 @@ module Ez
4
4
  module Resources
5
5
  class CollectionCell < ApplicationCell
6
6
  include Pagy::Frontend
7
+ include Ransack::Helpers::FormHelper
7
8
 
8
9
  delegate :resources_name, :collection_columns, :paginator, to: :model
9
10
 
@@ -108,6 +109,10 @@ module Ez
108
109
  end
109
110
  end
110
111
 
112
+ def column_title(column)
113
+ column.sortable ? sort_link(search, column.name, column.title) : column.title
114
+ end
115
+
111
116
  private
112
117
 
113
118
  def maybe_use_custom_boolean_presenter(bool)
@@ -115,6 +120,10 @@ module Ez
115
120
 
116
121
  instance_exec bool, &Ez::Resources.config.ui_custom_boolean_presenter
117
122
  end
123
+
124
+ def search
125
+ @search ||= model.model.ransack(model.params[:q])
126
+ end
118
127
  end
119
128
  end
120
129
  end
@@ -18,6 +18,7 @@ module Ez
18
18
  :presenter,
19
19
  :builder,
20
20
  :searchable,
21
+ :sortable,
21
22
  :search_suffix,
22
23
  :options
23
24
 
@@ -35,6 +36,7 @@ module Ez
35
36
  @getter = options.delete(:getter)
36
37
  @presenter = options.delete(:presenter)
37
38
  @searchable = options.delete(:searchable) != false
39
+ @sortable = options.delete(:sortable) || false
38
40
  @search_suffix = options.delete(:search_suffix) || :cont
39
41
  @options = options # use for all other custom options
40
42
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ez
4
4
  module Resources
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ez-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cells-rails
@@ -198,6 +198,20 @@ dependencies:
198
198
  - - ">="
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
+ - !ruby/object:Gem::Dependency
202
+ name: orderly
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
201
215
  - !ruby/object:Gem::Dependency
202
216
  name: pry-rails
203
217
  requirement: !ruby/object:Gem::Requirement