ez-resources 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/ez/resources/collection_cell.rb +19 -13
- data/lib/ez/resources/manager/config.rb +5 -3
- data/lib/ez/resources/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e1bb8408ecf50c3f37c711f2dc794539db2100668807bee71a14497599fbdf8
|
4
|
+
data.tar.gz: c0b7daf6075b77cc36bdfad87a2ead85ea077117c7729e9a1bbb905fab206f12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
28
|
+
result = case column.type
|
29
|
+
when :association
|
29
30
|
column.getter.call(record)
|
30
|
-
|
31
|
+
when :boolean
|
31
32
|
maybe_use_custom_boolean_presenter(record.public_send(column.name))
|
32
|
-
|
33
|
+
when :custom
|
33
34
|
column.builder.call(record)
|
34
|
-
|
35
|
+
when :image
|
35
36
|
url = column.getter.call(record)
|
36
37
|
|
37
38
|
image_tag url, column.options if url
|
38
|
-
|
39
|
+
when :link
|
39
40
|
as_a_link(record, column)
|
40
41
|
else
|
41
42
|
record.public_send(column.name)
|
42
|
-
|
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,
|
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,
|
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),
|
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),
|
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
|
-
|
90
|
-
|
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:
|
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
|
@@ -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
|
-
|
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,
|
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,
|
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
|
data/lib/ez/resources/version.rb
CHANGED
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.2.
|
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:
|
11
|
+
date: 2023-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cells-rails
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: ransack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '2.3'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.3'
|
97
97
|
- !ruby/object:Gem::Dependency
|