dry_crud 5.0.0 → 5.2.0
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 +5 -5
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/sample.scss +8 -11
- data/app/controllers/crud_controller.rb +63 -45
- data/app/controllers/dry_crud/generic_model.rb +0 -2
- data/app/controllers/dry_crud/nestable.rb +0 -2
- data/app/controllers/dry_crud/rememberable.rb +1 -3
- data/app/controllers/dry_crud/render_callbacks.rb +0 -2
- data/app/controllers/dry_crud/searchable.rb +0 -2
- data/app/controllers/dry_crud/sortable.rb +1 -3
- data/app/controllers/list_controller.rb +0 -2
- data/app/helpers/actions_helper.rb +1 -3
- data/app/helpers/dry_crud/form/builder.rb +7 -8
- data/app/helpers/dry_crud/form/control.rb +3 -5
- data/app/helpers/dry_crud/table/actions.rb +10 -12
- data/app/helpers/dry_crud/table/builder.rb +4 -6
- data/app/helpers/dry_crud/table/col.rb +0 -2
- data/app/helpers/dry_crud/table/sorting.rb +4 -6
- data/app/helpers/form_helper.rb +1 -3
- data/app/helpers/format_helper.rb +4 -5
- data/app/helpers/i18n_helper.rb +0 -2
- data/app/helpers/table_helper.rb +0 -2
- data/app/helpers/utility_helper.rb +1 -2
- data/app/views/layouts/_nav.html.erb +4 -4
- data/app/views/layouts/_nav.html.haml +4 -4
- data/app/views/layouts/application.html.erb +3 -23
- data/app/views/layouts/application.html.haml +3 -21
- data/app/views/list/_search.html.erb +4 -4
- data/app/views/list/_search.html.haml +2 -2
- data/config/locales/crud.it.yml +64 -0
- data/lib/dry_crud.rb +1 -0
- data/lib/dry_crud/engine.rb +9 -3
- data/lib/generators/dry_crud/dry_crud_generator.rb +3 -5
- data/lib/generators/dry_crud/dry_crud_generator_base.rb +5 -4
- data/lib/generators/dry_crud/file_generator.rb +11 -5
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +48 -23
- data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb +6 -8
- data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/table/builder_spec.rb +1 -2
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +0 -1
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +23 -7
- data/lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb +43 -11
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +8 -6
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +8 -8
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +32 -35
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +1 -3
- data/lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb +38 -17
- data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +0 -1
- data/lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb +6 -6
- data/lib/generators/dry_crud/templates/test/helpers/dry_crud/table/builder_test.rb +1 -2
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +1 -2
- data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +13 -3
- data/lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb +28 -11
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +5 -5
- data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +11 -18
- data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +5 -7
- data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +17 -16
- data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +4 -4
- data/lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb +11 -6
- data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +1 -3
- metadata +14 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3fa4767cf781b94a5ed47a5833f76a96494c450967e9f3599806226aafcf4a74
|
|
4
|
+
data.tar.gz: bd4c40f8493eef40c6618ead701877f8ec8d39b552db5787ae184273be0fc8d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8fef4d2ed06521eafd92c4fa87a36d07fdeee79a1a0f0d3a0e6098e2ac98b6c92d7c5cd2e87046b4cf37a3fa2e90f2d1cda382d645e828b3aeba2b5cd26e0903
|
|
7
|
+
data.tar.gz: 41b31166a4f5c82374587e49fe76580d32487ccff0fa52b6f0e72f131b2eb9a7d296d6ff53d8cc3de470fe1671dbdfb2749a4bdba685ce2bf110ea163abea225
|
data/README.rdoc
CHANGED
|
@@ -70,7 +70,7 @@ Say you want to manage a +Person+ model. Overwrite the +to_s+ method of your mod
|
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
Then create the following controller. The +permitted_attrs+ define the attribute parameters allowed when creating or updating a model entry (see {Strong
|
|
73
|
+
Then create the following controller. The +permitted_attrs+ define the attribute parameters allowed when creating or updating a model entry (see {Strong Parameters}[http://api.rubyonrails.org/classes/ActionController/StrongParameters.html]).
|
|
74
74
|
|
|
75
75
|
<tt>app/controllers/people_controller.rb</tt>:
|
|
76
76
|
class PeopleController < CrudController
|
|
@@ -86,7 +86,7 @@ Well, maybe there are certain attributes you do not want to display in the peopl
|
|
|
86
86
|
|
|
87
87
|
<%= crud_table :lastname, :firstname, :city, :sex %>
|
|
88
88
|
|
|
89
|
-
This only displays these
|
|
89
|
+
This only displays these four attributes in the table. All other templates, as well as the main index view, fallback to the ones in <tt>app/views/crud</tt>.
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
==== Adapt general behavior
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.
|
|
1
|
+
5.2.0
|
|
@@ -51,20 +51,20 @@ a.navbar-brand:hover {
|
|
|
51
51
|
color: #ddd;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
.nav {
|
|
54
|
+
.navbar-nav {
|
|
55
55
|
list-style: none;
|
|
56
56
|
margin: 0;
|
|
57
57
|
float: left;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.nav li {
|
|
60
|
+
.navbar-nav li.nav-item {
|
|
61
61
|
float: left;
|
|
62
62
|
font-size: 110%;
|
|
63
63
|
margin: 0;
|
|
64
64
|
padding: 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.nav a {
|
|
67
|
+
.navbar-nav a.nav-link {
|
|
68
68
|
color: #ddd !important;
|
|
69
69
|
display: block;
|
|
70
70
|
float: left;
|
|
@@ -74,7 +74,7 @@ a.navbar-brand:hover {
|
|
|
74
74
|
height: 19px;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
.nav a:hover {
|
|
77
|
+
.navbar-nav a.nav-link:hover {
|
|
78
78
|
background: $theme_color bottom center no-repeat;
|
|
79
79
|
color: #fff !important;
|
|
80
80
|
text-decoration: none;
|
|
@@ -261,10 +261,11 @@ textarea, select[multiple] {
|
|
|
261
261
|
border-color: #D88;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
.input-group-
|
|
264
|
+
.input-group-append {
|
|
265
265
|
font-size: 80%;
|
|
266
266
|
vertical-align: top;
|
|
267
267
|
margin-left: 4px;
|
|
268
|
+
display: inline-block;
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
.help-block {
|
|
@@ -291,11 +292,11 @@ textarea, select[multiple] {
|
|
|
291
292
|
float: right;
|
|
292
293
|
}
|
|
293
294
|
|
|
294
|
-
.
|
|
295
|
+
.float-right {
|
|
295
296
|
float: right;
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
.
|
|
299
|
+
.float-left {
|
|
299
300
|
float: left;
|
|
300
301
|
}
|
|
301
302
|
|
|
@@ -306,10 +307,6 @@ footer {
|
|
|
306
307
|
min-width: $container_width - 200px;
|
|
307
308
|
}
|
|
308
309
|
|
|
309
|
-
footer * {
|
|
310
|
-
font-size: 80%;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
310
|
.col-md-offset-2 {
|
|
314
311
|
margin-left: 130px;
|
|
315
312
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
# Abstract controller providing basic CRUD actions.
|
|
4
2
|
#
|
|
5
3
|
# Some enhancements were made to ease extensibility.
|
|
@@ -22,7 +20,7 @@ class CrudController < ListController
|
|
|
22
20
|
# further down.
|
|
23
21
|
define_render_callbacks :show, :new, :edit
|
|
24
22
|
|
|
25
|
-
before_action :entry, only: [
|
|
23
|
+
before_action :entry, only: %i[show new edit update destroy]
|
|
26
24
|
|
|
27
25
|
helper_method :entry, :full_entry_label
|
|
28
26
|
|
|
@@ -32,8 +30,7 @@ class CrudController < ListController
|
|
|
32
30
|
# GET /entries/1.json
|
|
33
31
|
#
|
|
34
32
|
# Show one entry of this model.
|
|
35
|
-
def show
|
|
36
|
-
end
|
|
33
|
+
def show; end
|
|
37
34
|
|
|
38
35
|
# GET /entries/new
|
|
39
36
|
# GET /entries/new.json
|
|
@@ -55,27 +52,21 @@ class CrudController < ListController
|
|
|
55
52
|
# in the given block will take precedence over the one defined here.
|
|
56
53
|
#
|
|
57
54
|
# Specify a :location option if you wish to do a custom redirect.
|
|
58
|
-
def create(options = {}, &
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
format.json { render :show, status: :created, location: show_path }
|
|
67
|
-
else
|
|
68
|
-
format.html { render :new }
|
|
69
|
-
format.json { render json: entry.errors, status: :unprocessable_entity }
|
|
70
|
-
end
|
|
55
|
+
def create(options = {}, &block)
|
|
56
|
+
model_class.transaction do
|
|
57
|
+
assign_attributes
|
|
58
|
+
created = with_callbacks(:create, :save) { entry.save }
|
|
59
|
+
respond(created,
|
|
60
|
+
options.merge(status: :created, render_on_failure: :new),
|
|
61
|
+
&block)
|
|
62
|
+
raise ActiveRecord::Rollback unless created
|
|
71
63
|
end
|
|
72
64
|
end
|
|
73
65
|
|
|
74
66
|
# GET /entries/1/edit
|
|
75
67
|
#
|
|
76
68
|
# Display a form to edit an exisiting entry of this model.
|
|
77
|
-
def edit
|
|
78
|
-
end
|
|
69
|
+
def edit; end
|
|
79
70
|
|
|
80
71
|
# PUT /entries/1
|
|
81
72
|
# PUT /entries/1.json
|
|
@@ -89,19 +80,14 @@ class CrudController < ListController
|
|
|
89
80
|
# in the given block will take precedence over the one defined here.
|
|
90
81
|
#
|
|
91
82
|
# Specify a :location option if you wish to do a custom redirect.
|
|
92
|
-
def update(options = {}, &
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
format.json { render :show, status: :ok, location: show_path }
|
|
101
|
-
else
|
|
102
|
-
format.html { render :edit }
|
|
103
|
-
format.json { render json: entry.errors, status: :unprocessable_entity }
|
|
104
|
-
end
|
|
83
|
+
def update(options = {}, &block)
|
|
84
|
+
model_class.transaction do
|
|
85
|
+
assign_attributes
|
|
86
|
+
updated = with_callbacks(:update, :save) { entry.save }
|
|
87
|
+
respond(updated,
|
|
88
|
+
options.merge(status: :ok, render_on_failure: :edit),
|
|
89
|
+
&block)
|
|
90
|
+
raise ActiveRecord::Rollback unless updated
|
|
105
91
|
end
|
|
106
92
|
end
|
|
107
93
|
|
|
@@ -117,18 +103,13 @@ class CrudController < ListController
|
|
|
117
103
|
# in the given block will take precedence over the one defined here.
|
|
118
104
|
#
|
|
119
105
|
# Specify a :location option if you wish to do a custom redirect.
|
|
120
|
-
def destroy(options = {}, &
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
format.json { head :no_content }
|
|
128
|
-
else
|
|
129
|
-
format.html { redirect_on_failure(options) }
|
|
130
|
-
format.json { render json: entry.errors, status: :unprocessable_entity }
|
|
131
|
-
end
|
|
106
|
+
def destroy(options = {}, &block)
|
|
107
|
+
model_class.transaction do
|
|
108
|
+
destroyed = run_callbacks(:destroy) { entry.destroy }
|
|
109
|
+
respond(destroyed,
|
|
110
|
+
options.merge(status: :no_content),
|
|
111
|
+
&block)
|
|
112
|
+
raise ActiveRecord::Rollback unless destroyed
|
|
132
113
|
end
|
|
133
114
|
end
|
|
134
115
|
|
|
@@ -171,6 +152,29 @@ class CrudController < ListController
|
|
|
171
152
|
path_args(entry)
|
|
172
153
|
end
|
|
173
154
|
|
|
155
|
+
def respond(success, options)
|
|
156
|
+
respond_to do |format|
|
|
157
|
+
yield(format, success) if block_given?
|
|
158
|
+
if success
|
|
159
|
+
format.html { redirect_on_success(options) }
|
|
160
|
+
format.json { render_success_json(options[:status]) }
|
|
161
|
+
else
|
|
162
|
+
format.html { render_or_redirect_on_failure(options) }
|
|
163
|
+
format.json { render_failure_json }
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# If the option :render_on_failure is given, render the corresponding
|
|
169
|
+
# template, otherwise redirect.
|
|
170
|
+
def render_or_redirect_on_failure(options)
|
|
171
|
+
if options[:render_on_failure]
|
|
172
|
+
render options[:render_on_failure]
|
|
173
|
+
else
|
|
174
|
+
redirect_on_failure(options)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
174
178
|
# Perform a redirect after a successfull operation and set a flash notice.
|
|
175
179
|
def redirect_on_success(options = {})
|
|
176
180
|
location = options[:location] ||
|
|
@@ -188,6 +192,20 @@ class CrudController < ListController
|
|
|
188
192
|
redirect_to location
|
|
189
193
|
end
|
|
190
194
|
|
|
195
|
+
# Render the show json with the given status or :no_content
|
|
196
|
+
def render_success_json(status)
|
|
197
|
+
if status == :no_content
|
|
198
|
+
head :no_content
|
|
199
|
+
else
|
|
200
|
+
render :show, status: status, location: show_path
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Render a json with the errors.
|
|
205
|
+
def render_failure_json
|
|
206
|
+
render json: entry.errors, status: :unprocessable_entity
|
|
207
|
+
end
|
|
208
|
+
|
|
191
209
|
# Get an I18n flash message.
|
|
192
210
|
# Uses the key {controller_name}.{action_name}.flash.{state}
|
|
193
211
|
# or crud.{action_name}.flash.{state} as fallback.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
module DryCrud
|
|
4
2
|
|
|
5
3
|
# Remembers certain params of the index action in order to return
|
|
@@ -18,7 +16,7 @@ module DryCrud
|
|
|
18
16
|
|
|
19
17
|
included do
|
|
20
18
|
class_attribute :remember_params
|
|
21
|
-
self.remember_params = %w
|
|
19
|
+
self.remember_params = %w[q sort sort_dir page]
|
|
22
20
|
|
|
23
21
|
before_action :handle_remember_params, only: [:index]
|
|
24
22
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
module DryCrud
|
|
4
2
|
|
|
5
3
|
# Sort functionality for the index table.
|
|
@@ -44,7 +42,7 @@ module DryCrud
|
|
|
44
42
|
sortable = sortable?(params[:sort])
|
|
45
43
|
if sortable || default_sort
|
|
46
44
|
clause = [sortable ? sort_expression : nil, default_sort]
|
|
47
|
-
super.reorder(clause.compact.join(', '))
|
|
45
|
+
super.reorder(Arel.sql(clause.compact.join(', ')))
|
|
48
46
|
else
|
|
49
47
|
super
|
|
50
48
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
# Helpers to create action links. This default implementation supports
|
|
4
2
|
# regular links with an icon and a label. To change the general style
|
|
5
3
|
# of action links, change the method #action_link, e.g. to generate a button.
|
|
@@ -9,7 +7,7 @@ module ActionsHelper
|
|
|
9
7
|
# A generic helper method to create action links.
|
|
10
8
|
# These link could be styled to look like buttons, for example.
|
|
11
9
|
def action_link(label, icon = nil, url = {}, html_options = {})
|
|
12
|
-
add_css_class html_options, 'action btn btn-
|
|
10
|
+
add_css_class html_options, 'action btn btn-light'
|
|
13
11
|
link_to(icon ? action_icon(icon, label) : label,
|
|
14
12
|
url, html_options)
|
|
15
13
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
module DryCrud
|
|
4
2
|
module Form
|
|
5
3
|
|
|
@@ -84,8 +82,8 @@ module DryCrud
|
|
|
84
82
|
end
|
|
85
83
|
|
|
86
84
|
# Add form-control class to all input fields.
|
|
87
|
-
%w
|
|
88
|
-
number_field date_field time_field datetime_field
|
|
85
|
+
%w[text_field password_field email_field
|
|
86
|
+
number_field date_field time_field datetime_field].each do |method|
|
|
89
87
|
define_method(method) do |attr, html_options = {}|
|
|
90
88
|
add_css_class(html_options, 'form-control')
|
|
91
89
|
super(attr, html_options)
|
|
@@ -150,7 +148,8 @@ module DryCrud
|
|
|
150
148
|
# Renders the given content with an addon.
|
|
151
149
|
def with_addon(content, addon)
|
|
152
150
|
content_tag(:div, class: 'input-group') do
|
|
153
|
-
|
|
151
|
+
html = content_tag(:span, addon, class: 'input-group-text')
|
|
152
|
+
content + content_tag(:div, html, class: 'input-group-append')
|
|
154
153
|
end
|
|
155
154
|
end
|
|
156
155
|
|
|
@@ -244,13 +243,13 @@ module DryCrud
|
|
|
244
243
|
if field_method
|
|
245
244
|
build_labeled_field(field_method, *args)
|
|
246
245
|
else
|
|
247
|
-
super
|
|
246
|
+
super
|
|
248
247
|
end
|
|
249
248
|
end
|
|
250
249
|
|
|
251
250
|
# Overriden to fullfill contract with method_missing 'labeled_' methods.
|
|
252
|
-
def
|
|
253
|
-
labeled_field_method?(name).present? || super
|
|
251
|
+
def respond_to_missing?(name, include_private = false)
|
|
252
|
+
labeled_field_method?(name).present? || super
|
|
254
253
|
end
|
|
255
254
|
|
|
256
255
|
private
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
module DryCrud
|
|
4
2
|
module Form
|
|
5
3
|
|
|
@@ -8,7 +6,7 @@ module DryCrud
|
|
|
8
6
|
# required mark.
|
|
9
7
|
class Control
|
|
10
8
|
|
|
11
|
-
attr_reader :builder, :attr, :args, :options, :
|
|
9
|
+
attr_reader :builder, :attr, :args, :options, :addon, :help
|
|
12
10
|
|
|
13
11
|
delegate :content_tag, :object,
|
|
14
12
|
to: :builder
|
|
@@ -32,8 +30,8 @@ module DryCrud
|
|
|
32
30
|
# This includes an options hash as the last argument, that
|
|
33
31
|
# may contain the following special options:
|
|
34
32
|
#
|
|
35
|
-
# * <tt>:addon</tt> - Addon content
|
|
36
|
-
# * <tt>:help</tt> - A help text
|
|
33
|
+
# * <tt>:addon</tt> - Addon content displayed just after the input field.
|
|
34
|
+
# * <tt>:help</tt> - A help text displayed below the input field.
|
|
37
35
|
# * <tt>:span</tt> - Number of columns the input field should span.
|
|
38
36
|
# * <tt>:caption</tt> - Different caption for the label.
|
|
39
37
|
# * <tt>:field_method</tt> - Different method to create the input field.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
1
|
module DryCrud
|
|
4
2
|
module Table
|
|
5
3
|
|
|
@@ -20,8 +18,8 @@ module DryCrud
|
|
|
20
18
|
# the current entry.
|
|
21
19
|
# A block may be given to define the link path for the row entry.
|
|
22
20
|
def attr_with_show_link(attr, &block)
|
|
23
|
-
sortable_attr(attr) do |
|
|
24
|
-
link_to(format_attr(
|
|
21
|
+
sortable_attr(attr) do |entry|
|
|
22
|
+
link_to(format_attr(entry, attr), action_path(entry, &block))
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
|
|
@@ -29,8 +27,8 @@ module DryCrud
|
|
|
29
27
|
# A block may be given to define the link path for the row entry.
|
|
30
28
|
# If the block returns nil, no link is rendered.
|
|
31
29
|
def show_action_col(html_options = {}, &block)
|
|
32
|
-
action_col do |
|
|
33
|
-
path = action_path(
|
|
30
|
+
action_col do |entry|
|
|
31
|
+
path = action_path(entry, &block)
|
|
34
32
|
if path
|
|
35
33
|
table_action_link('zoom-in',
|
|
36
34
|
path,
|
|
@@ -43,8 +41,8 @@ module DryCrud
|
|
|
43
41
|
# A block may be given to define the link path for the row entry.
|
|
44
42
|
# If the block returns nil, no link is rendered.
|
|
45
43
|
def edit_action_col(html_options = {}, &block)
|
|
46
|
-
action_col do |
|
|
47
|
-
path = action_path(
|
|
44
|
+
action_col do |entry|
|
|
45
|
+
path = action_path(entry, &block)
|
|
48
46
|
if path
|
|
49
47
|
path = path.is_a?(String) ? path : edit_polymorphic_path(path)
|
|
50
48
|
table_action_link('pencil', path, html_options.clone)
|
|
@@ -56,8 +54,8 @@ module DryCrud
|
|
|
56
54
|
# A block may be given to define the link path for the row entry.
|
|
57
55
|
# If the block returns nil, no link is rendered.
|
|
58
56
|
def destroy_action_col(html_options = {}, &block)
|
|
59
|
-
action_col do |
|
|
60
|
-
path = action_path(
|
|
57
|
+
action_col do |entry|
|
|
58
|
+
path = action_path(entry, &block)
|
|
61
59
|
if path
|
|
62
60
|
table_action_link('remove',
|
|
63
61
|
path,
|
|
@@ -85,8 +83,8 @@ module DryCrud
|
|
|
85
83
|
|
|
86
84
|
# If a block is given, call it to get the path for the current row entry.
|
|
87
85
|
# Otherwise, return the standard path args.
|
|
88
|
-
def action_path(
|
|
89
|
-
block_given? ? yield(
|
|
86
|
+
def action_path(entry)
|
|
87
|
+
block_given? ? yield(entry) : path_args(entry)
|
|
90
88
|
end
|
|
91
89
|
|
|
92
90
|
end
|