ez-resources 0.1.4 → 0.2.1

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: 1b3e10c0d602e396efdb1f247852079a73a3ff7400f4b8f6e29be00ef09d00a0
4
- data.tar.gz: d2a3b95d310489e308e114fcb7cf254839e98673fdb72431c14eda556f10bca8
3
+ metadata.gz: 4e1bb8408ecf50c3f37c711f2dc794539db2100668807bee71a14497599fbdf8
4
+ data.tar.gz: c0b7daf6075b77cc36bdfad87a2ead85ea077117c7729e9a1bbb905fab206f12
5
5
  SHA512:
6
- metadata.gz: f5352b31aeeb6e3e427dd18a8968c96d8af522c55f5a67240f17131fae7090c25c84fb3b26d5dd2ba0cde8805a1f3f0605cf13671fa196857cadd97279b6709f
7
- data.tar.gz: 1bebc28528126229a4b491a56fa766c8695a279a8780a6118f296ae92242a1aab4596716ed6139dfa8298d5d0a5fd225185591f0fa6aa21308717ca32d59223b
6
+ metadata.gz: fe4c148385baceb68d60985b1a3ed3097a051e57baaf4c7ffc7de1c33e4e0e9d505b612660c008d75d47c8b9faa2bcd39983a73489aa135b50b62038891206e4
7
+ data.tar.gz: a79bd3413544b51fe22762faaccc36c5caae456d7584577743d13e4081f0130737acc44c86d6d2286555d679e73ea0f92addfd052256e090d6267762a9e00250
@@ -25,21 +25,22 @@ module Ez
25
25
  end
26
26
 
27
27
  def record_column_value(record, column)
28
- result = if column.type == :association
28
+ result = case column.type
29
+ when :association
29
30
  column.getter.call(record)
30
- elsif column.type == :boolean
31
+ when :boolean
31
32
  maybe_use_custom_boolean_presenter(record.public_send(column.name))
32
- elsif column.type == :custom
33
+ when :custom
33
34
  column.builder.call(record)
34
- elsif column.type == :image
35
+ when :image
35
36
  url = column.getter.call(record)
36
37
 
37
38
  image_tag url, column.options if url
38
- elsif column.type == :link
39
+ when :link
39
40
  as_a_link(record, column)
40
41
  else
41
42
  record.public_send(column.name)
42
- end
43
+ end
43
44
 
44
45
  result = column.presenter.call(record) if column.presenter
45
46
  result
@@ -47,9 +48,11 @@ module Ez
47
48
 
48
49
  def record_tr(record, &block)
49
50
  if model.actions.include?(:show) && Manager::Hooks.can?(:can_read?, model, record)
50
- content_tag :tr, class: css_for('collection-table-tr'), id: "#{model.model.name.demodulize.pluralize.downcase}-#{record.id}", data: { link: model.path_for(action: :show, id: record.id).to_s }, &block
51
+ content_tag :tr,
52
+ class: css_for('collection-table-tr'), id: "#{model.model.name.demodulize.pluralize.downcase}-#{record.id}", data: { link: model.path_for(action: :show, id: record.id).to_s }, &block
51
53
  else
52
- content_tag :tr, class: css_for('collection-table-tr'), id: "#{model.model.name.demodulize.pluralize.downcase}-#{record.id}", &block
54
+ content_tag :tr,
55
+ class: css_for('collection-table-tr'), id: "#{model.model.name.demodulize.pluralize.downcase}-#{record.id}", &block
53
56
  end
54
57
  end
55
58
 
@@ -64,7 +67,8 @@ module Ez
64
67
  return unless model.actions.include?(:show)
65
68
  return unless Manager::Hooks.can?(:can_read?, model, record)
66
69
 
67
- link_to t('actions.show'), model.path_for(action: :show, id: record.id), class: css_for('collection-table-td-action-item')
70
+ link_to t('actions.show'), model.path_for(action: :show, id: record.id),
71
+ class: css_for('collection-table-td-action-item')
68
72
  end
69
73
 
70
74
  def as_a_link(record, column)
@@ -78,7 +82,8 @@ module Ez
78
82
  return unless model.actions.include?(:edit)
79
83
  return unless Manager::Hooks.can?(:can_read?, model, record)
80
84
 
81
- link_to t('actions.edit'), model.path_for(action: :edit, id: record.id), class: css_for('collection-table-td-action-item')
85
+ link_to t('actions.edit'), model.path_for(action: :edit, id: record.id),
86
+ class: css_for('collection-table-td-action-item')
82
87
  end
83
88
 
84
89
  def remove_link(record)
@@ -86,8 +91,8 @@ module Ez
86
91
  return unless Manager::Hooks.can?(:can_destroy?, model, record)
87
92
 
88
93
  link_to t('actions.remove'), model.path_for(action: :destroy, id: record.id),
89
- method: :delete,
90
- class: css_for('collection-table-td-action-item')
94
+ method: :delete,
95
+ class: css_for('collection-table-td-action-item')
91
96
  end
92
97
 
93
98
  def pagination
@@ -104,7 +109,8 @@ module Ez
104
109
  params = model.params.to_unsafe_hash.slice(:q, :page, :s).symbolize_keys.merge(view: view_name)
105
110
  selected = css_for('collection-view-selected-link') if model.params[:view] == view_name.to_s
106
111
 
107
- link_to model.path_for(action: :index, params: params), id: "ez-view-#{view_name}", class: css_for("collection-view-link-#{view_name}", selected) do
112
+ link_to model.path_for(action: :index, params: params), id: "ez-view-#{view_name}",
113
+ class: css_for("collection-view-link-#{view_name}", selected) do
108
114
  content_tag :i, nil, class: css_for("collection-view-link-#{view_name}-icon")
109
115
  end
110
116
  end
@@ -7,7 +7,7 @@
7
7
  - model.collection_columns.each do |field|
8
8
  - if field.searchable && SEARCHABLE_FIELDS.include?(field.type)
9
9
  = div_for 'collection-search-panel-field'
10
- = f.input field_name(field),
10
+ = f.input field_input_name(field),
11
11
  label: field_label(field),
12
12
  required: false,
13
13
  as: cast_field_type(field.type),
@@ -17,7 +17,7 @@ module Ez
17
17
  end
18
18
  end
19
19
 
20
- def field_name(field)
20
+ def field_input_name(field)
21
21
  if association?(field)
22
22
  search_key(field.name, field.search_suffix, field.options.fetch(:association))
23
23
  else
@@ -26,7 +26,7 @@ module Ez
26
26
  when 'destroy' then resource
27
27
  else
28
28
  raise ConfigurationError, "Invalid action #{controller.action_name}"
29
- end
29
+ end
30
30
  end
31
31
 
32
32
  def total_count
@@ -36,7 +36,8 @@ module Ez
36
36
  def model
37
37
  @model ||= dsl_config.model || controller_name.classify.constantize
38
38
  rescue NameError
39
- raise GuessingError, "Ez::Resources tried to guess model name as #{controller_name.classify} but constant is missing. You can define model class explicitly with :model options"
39
+ raise GuessingError,
40
+ "Ez::Resources tried to guess model name as #{controller_name.classify} but constant is missing. You can define model class explicitly with :model options"
40
41
  end
41
42
 
42
43
  def actions
@@ -125,7 +126,8 @@ module Ez
125
126
  @search = model.ransack(params[:q])
126
127
 
127
128
  @paginated_collection ||= if dsl_config.collection_query
128
- pagy, paginated_collection = pagy dsl_config.collection_query.call(search.result, controller)
129
+ pagy, paginated_collection = pagy dsl_config.collection_query.call(search.result,
130
+ controller)
129
131
  else
130
132
  pagy, paginated_collection = pagy search.result.includes(dsl_config.includes)
131
133
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ez
4
4
  module Resources
5
- VERSION = '0.1.4'
5
+ VERSION = '0.2.1'
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.4
4
+ version: 0.2.1
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-27 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cells-rails
@@ -73,9 +73,6 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '5.2'
76
- - - "<="
77
- - !ruby/object:Gem::Version
78
- version: '7.0'
79
76
  type: :runtime
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,21 +80,18 @@ dependencies:
83
80
  - - ">="
84
81
  - !ruby/object:Gem::Version
85
82
  version: '5.2'
86
- - - "<="
87
- - !ruby/object:Gem::Version
88
- version: '7.0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: ransack
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
87
+ - - ">="
94
88
  - !ruby/object:Gem::Version
95
89
  version: '2.3'
96
90
  type: :runtime
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - "~>"
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
96
  version: '2.3'
103
97
  - !ruby/object:Gem::Dependency