ez-resources 0.2.0 → 0.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d29f29e01ad1b5f219ff7ab58bb7f6394179367b106726d7add1615fb7d25d
|
4
|
+
data.tar.gz: 766c145a98f669b4b4210be7a4e054137d5056de10da89dc2d87328020b46e4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ecfcbf112bc353e6b20ff08e6b5041db933b007f3c97d04c7ce8730698d35ca980cb631a5c9ba62d3ecac10c2f18ae7c42a511b3a9014ca7e6e49e26d21f99e
|
7
|
+
data.tar.gz: 322224c6d06813aa0b16207ced31fdb81b885d5c1ecc1a16cc9a9c25bff4e7d3c918dcdc04ee479cae97656183624032075d9a0803cd324acdb4835d1a10290d
|
@@ -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
|
@@ -20,6 +20,7 @@ module Ez
|
|
20
20
|
:searchable,
|
21
21
|
:sortable,
|
22
22
|
:search_suffix,
|
23
|
+
:search_label,
|
23
24
|
:options
|
24
25
|
|
25
26
|
def initialize(options = {})
|
@@ -38,6 +39,7 @@ module Ez
|
|
38
39
|
@searchable = options.delete(:searchable) != false
|
39
40
|
@sortable = options.delete(:sortable) || false
|
40
41
|
@search_suffix = options.delete(:search_suffix) || :cont
|
42
|
+
@search_label = options.delete(:search_label)
|
41
43
|
@options = options # use for all other custom options
|
42
44
|
end
|
43
45
|
|
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.2
|
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-04-08 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
|