dry_crud 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.rdoc +67 -33
- data/VERSION +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/add.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/delete.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/edit.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/list.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/images/actions/show.png +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/assets/stylesheets/crud.scss +12 -22
- data/{lib/generators/dry_crud/templates/app → app}/assets/stylesheets/sample.scss +157 -106
- data/{lib/generators/dry_crud/templates/app → app}/controllers/crud_controller.rb +15 -16
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/generic_model.rb +7 -7
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/nestable.rb +2 -2
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/rememberable.rb +3 -3
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/render_callbacks.rb +2 -2
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/responder.rb +2 -2
- data/app/controllers/dry_crud/searchable.rb +77 -0
- data/{lib/generators/dry_crud/templates/app/controllers/crud → app/controllers/dry_crud}/sortable.rb +9 -7
- data/{lib/generators/dry_crud/templates/app → app}/controllers/list_controller.rb +11 -9
- data/{lib/generators/dry_crud/templates/app → app}/helpers/actions_helper.rb +2 -2
- data/{lib/generators/dry_crud/templates/app/helpers/crud/form_builder.rb → app/helpers/dry_crud/form/builder.rb} +147 -164
- data/app/helpers/dry_crud/form/control.rb +180 -0
- data/app/helpers/dry_crud/table/actions.rb +88 -0
- data/app/helpers/dry_crud/table/builder.rb +115 -0
- data/app/helpers/dry_crud/table/col.rb +25 -0
- data/app/helpers/dry_crud/table/sorting.rb +61 -0
- data/{lib/generators/dry_crud/templates/app → app}/helpers/form_helper.rb +3 -2
- data/{lib/generators/dry_crud/templates/app → app}/helpers/format_helper.rb +5 -5
- data/{lib/generators/dry_crud/templates/app → app}/helpers/i18n_helper.rb +2 -2
- data/{lib/generators/dry_crud/templates/app → app}/helpers/table_helper.rb +8 -7
- data/{lib/generators/dry_crud/templates/app → app}/helpers/utility_helper.rb +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_edit.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_edit.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_index.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_index.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_show.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_actions_show.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_attrs.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_attrs.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_form.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_form.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_list.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/_list.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/edit.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/edit.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/new.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/new.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/show.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/crud/show.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_flash.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_flash.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_nav.html.erb +2 -2
- data/{lib/generators/dry_crud/templates/app → app}/views/layouts/_nav.html.haml +2 -2
- data/{lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb → app/views/layouts/application.html.erb} +22 -16
- data/{lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml → app/views/layouts/application.html.haml} +17 -11
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_actions_index.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_actions_index.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_list.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/_list.html.haml +0 -0
- data/app/views/list/_search.html.erb +10 -0
- data/app/views/list/_search.html.haml +7 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/index.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/list/index.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_error_messages.html.erb +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_error_messages.html.haml +1 -1
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_labeled.html.erb +0 -0
- data/{lib/generators/dry_crud/templates/app → app}/views/shared/_labeled.html.haml +0 -0
- data/{lib/generators/dry_crud/templates/config → config}/locales/crud.de.yml +0 -0
- data/{lib/generators/dry_crud/templates/config → config}/locales/crud.en.yml +0 -0
- data/lib/dry_crud/engine.rb +18 -0
- data/lib/dry_crud.rb +5 -0
- data/lib/generators/dry_crud/dry_crud_generator.rb +12 -20
- data/lib/generators/dry_crud/dry_crud_generator_base.rb +57 -0
- data/lib/generators/dry_crud/file_generator.rb +41 -0
- data/lib/generators/dry_crud/templates/INSTALL +1 -1
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/helpers/{crud/form_builder_spec.rb → dry_crud/form/builder_spec.rb} +28 -19
- data/lib/generators/dry_crud/templates/spec/helpers/{crud/table_builder_spec.rb → dry_crud/table/builder_spec.rb} +3 -3
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +21 -40
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +36 -26
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +4 -4
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +6 -6
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +0 -1
- data/lib/generators/dry_crud/templates/test/helpers/{crud/form_builder_test.rb → dry_crud/form/builder_test.rb} +38 -25
- data/lib/generators/dry_crud/templates/test/helpers/{crud/table_builder_test.rb → dry_crud/table/builder_test.rb} +4 -4
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +12 -9
- data/lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb +13 -1
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +4 -4
- data/lib/generators/dry_crud/templates/test/support/crud_controller_test_helper.rb +3 -3
- data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +2 -2
- metadata +76 -68
- data/lib/generators/dry_crud/templates/app/controllers/crud/searchable.rb +0 -55
- data/lib/generators/dry_crud/templates/app/helpers/crud/table_builder.rb +0 -280
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.erb +0 -6
- data/lib/generators/dry_crud/templates/app/views/list/_search.html.haml +0 -5
@@ -2,8 +2,8 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
require 'support/crud_test_model'
|
4
4
|
|
5
|
-
# Test
|
6
|
-
class
|
5
|
+
# Test DryCrud::Form::Builder
|
6
|
+
class DryCrud::Form::BuilderTest < ActionView::TestCase
|
7
7
|
|
8
8
|
include FormatHelper
|
9
9
|
include I18nHelper
|
@@ -19,62 +19,75 @@ class Crud::FormBuilderTest < ActionView::TestCase
|
|
19
19
|
|
20
20
|
def create_form
|
21
21
|
@entry = CrudTestModel.first
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
if Rails.version < '4.0'
|
23
|
+
@form = DryCrud::Form::Builder.new(:entry, @entry, self, {},
|
24
|
+
->(form) { form })
|
25
|
+
else
|
26
|
+
@form = DryCrud::Form::Builder.new(:entry, @entry, self, {})
|
27
|
+
end
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'input_field dispatches string attr to string_field' do
|
31
|
-
assert_equal form.
|
31
|
+
assert_equal form.with_addon(
|
32
|
+
form.string_field(:name,
|
33
|
+
class: 'form-control',
|
34
|
+
required: 'required'),
|
35
|
+
'*'),
|
36
|
+
form.input_field(:name)
|
32
37
|
assert form.string_field(:name).html_safe?
|
33
38
|
end
|
34
39
|
|
35
40
|
test 'input_field dispatches password attr to password_field' do
|
36
|
-
assert_equal form.password_field(:password
|
41
|
+
assert_equal form.password_field(:password, class: 'form-control'),
|
42
|
+
form.input_field(:password)
|
37
43
|
assert form.password_field(:name).html_safe?
|
38
44
|
end
|
39
45
|
|
40
46
|
test 'input_field dispatches email attr to email_field' do
|
41
|
-
assert_equal form.email_field(:email
|
47
|
+
assert_equal form.email_field(:email, class: 'form-control'),
|
48
|
+
form.input_field(:email)
|
42
49
|
assert form.email_field(:name).html_safe?
|
43
50
|
end
|
44
51
|
|
45
52
|
test 'input_field dispatches text attr to text_area' do
|
46
|
-
assert_equal form.text_area(:remarks
|
53
|
+
assert_equal form.text_area(:remarks, class: 'form-control'),
|
54
|
+
form.input_field(:remarks)
|
47
55
|
assert form.text_area(:remarks).html_safe?
|
48
56
|
end
|
49
57
|
|
50
58
|
test 'input_field dispatches integer attr to integer_field' do
|
51
|
-
assert_equal form.integer_field(:children
|
59
|
+
assert_equal form.integer_field(:children, class: 'form-control'),
|
60
|
+
form.input_field(:children)
|
52
61
|
assert form.integer_field(:children).html_safe?
|
53
62
|
end
|
54
63
|
|
55
64
|
test 'input_field dispatches boolean attr to boolean_field' do
|
56
|
-
assert_equal form.boolean_field(:human
|
65
|
+
assert_equal form.boolean_field(:human, class: 'form-control'),
|
66
|
+
form.input_field(:human)
|
57
67
|
assert form.boolean_field(:human).html_safe?
|
58
68
|
end
|
59
69
|
|
60
70
|
test 'input_field dispatches date attr to date_field' do
|
61
|
-
assert_equal form.date_field(:birthdate
|
71
|
+
assert_equal form.date_field(:birthdate, class: 'form-control'),
|
72
|
+
form.input_field(:birthdate)
|
62
73
|
assert form.date_field(:birthdate).html_safe?
|
63
74
|
end
|
64
75
|
|
65
76
|
test 'input_field dispatches belongs_to attr to select field' do
|
66
|
-
assert_equal form.belongs_to_field(:companion_id),
|
77
|
+
assert_equal form.belongs_to_field(:companion_id, class: 'form-control'),
|
67
78
|
form.input_field(:companion_id)
|
68
79
|
assert form.belongs_to_field(:companion_id).html_safe?
|
69
80
|
end
|
70
81
|
|
71
82
|
test 'input_field dispatches has_and_belongs_to_many attr to select field' do
|
72
|
-
assert_equal form.has_many_field(:other_ids
|
83
|
+
assert_equal form.has_many_field(:other_ids, class: 'form-control'),
|
84
|
+
form.input_field(:other_ids)
|
73
85
|
assert form.has_many_field(:other_ids).html_safe?
|
74
86
|
end
|
75
87
|
|
76
88
|
test 'input_field dispatches has_many attr to select field' do
|
77
|
-
assert_equal form.has_many_field(:more_ids
|
89
|
+
assert_equal form.has_many_field(:more_ids, class: 'form-control'),
|
90
|
+
form.input_field(:more_ids)
|
78
91
|
assert form.has_many_field(:more_ids).html_safe?
|
79
92
|
end
|
80
93
|
|
@@ -88,15 +101,15 @@ class Crud::FormBuilderTest < ActionView::TestCase
|
|
88
101
|
|
89
102
|
test 'labeld_input_field adds required mark' do
|
90
103
|
result = form.labeled_input_field(:name)
|
91
|
-
assert result.include?(
|
104
|
+
assert result.include?('input-group-addon')
|
92
105
|
result = form.labeled_input_field(:remarks)
|
93
|
-
assert !result.include?(
|
106
|
+
assert !result.include?('input-group-addon')
|
94
107
|
end
|
95
108
|
|
96
109
|
test 'labeld_input_field adds help text' do
|
97
110
|
result = form.labeled_input_field(:name, help: 'Some Help')
|
98
111
|
assert result.include?(form.help_block('Some Help'))
|
99
|
-
assert result.include?(
|
112
|
+
assert result.include?('input-group-addon')
|
100
113
|
end
|
101
114
|
|
102
115
|
test 'belongs_to_field has all options by default' do
|
@@ -211,14 +224,14 @@ class Crud::FormBuilderTest < ActionView::TestCase
|
|
211
224
|
|
212
225
|
test 'labeled field creates label with caption' do
|
213
226
|
result = form.labeled('gugus',
|
214
|
-
'
|
215
|
-
|
227
|
+
"<input type='text' name='gugus' />".html_safe,
|
228
|
+
caption: 'Caption')
|
216
229
|
assert result.html_safe?
|
217
230
|
assert_match /label [^>]*for.+>Caption<\/label>.*<input/m, result
|
218
231
|
end
|
219
232
|
|
220
233
|
test 'labeled field creates label with caption and block' do
|
221
|
-
result = form.labeled('gugus', 'Caption') do
|
234
|
+
result = form.labeled('gugus', caption: 'Caption') do
|
222
235
|
"<input type='text' name='gugus' />".html_safe
|
223
236
|
end
|
224
237
|
assert result.html_safe?
|
@@ -236,4 +249,4 @@ class Crud::FormBuilderTest < ActionView::TestCase
|
|
236
249
|
assert form.respond_to?(:text_field)
|
237
250
|
assert form.respond_to?(:labeled_text_field)
|
238
251
|
end
|
239
|
-
end
|
252
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
|
-
# Test
|
5
|
-
class
|
4
|
+
# Test DryCrud::Table::Builder
|
5
|
+
class DryCrud::Table::BuilderTest < ActionView::TestCase
|
6
6
|
|
7
7
|
# set dummy helper class for ActionView::TestCase
|
8
8
|
self.helper_class = UtilityHelper
|
@@ -13,7 +13,7 @@ class Crud::TableBuilderTest < ActionView::TestCase
|
|
13
13
|
|
14
14
|
def setup
|
15
15
|
@entries = %w(foo bahr)
|
16
|
-
@table =
|
16
|
+
@table = DryCrud::Table::Builder.new(entries, self)
|
17
17
|
end
|
18
18
|
|
19
19
|
def format_size(obj)
|
@@ -122,7 +122,7 @@ class Crud::TableBuilderTest < ActionView::TestCase
|
|
122
122
|
FIN
|
123
123
|
dom.gsub!(/[\n\t]/, '').gsub!(/\s{2,}/, '')
|
124
124
|
|
125
|
-
table =
|
125
|
+
table = DryCrud::Table::Builder.new([], self)
|
126
126
|
table.col('head', class: 'left') { |e| link_to e, '/' }
|
127
127
|
table.attrs :upcase, :size
|
128
128
|
table.col { |e| "Never #{e}" }
|
@@ -54,7 +54,8 @@ class FormHelperTest < ActionView::TestCase
|
|
54
54
|
assert_match /input .*?name="crud_test_model\[name\]"
|
55
55
|
.*?type="text"
|
56
56
|
.*?value="AAAAA"/x, f
|
57
|
-
assert_match /
|
57
|
+
assert_match /input .*?name="crud_test_model\[birthdate\]"
|
58
|
+
.*?type="date"/x, f
|
58
59
|
assert_match /input .*?name="crud_test_model\[children\]"
|
59
60
|
.*?type="number"
|
60
61
|
.*?value=\"9\"/x, f
|
@@ -87,15 +88,12 @@ class FormHelperTest < ActionView::TestCase
|
|
87
88
|
.*?type="hidden"
|
88
89
|
.*?value="(patch|put)"/x, f
|
89
90
|
assert_match /div[^>]* id='error_explanation'/, f
|
90
|
-
assert_match /div\ class="
|
91
|
+
assert_match /div\ class="form-group\ has-error"\>.*?
|
91
92
|
\<input .*?name="crud_test_model\[name\]"
|
92
93
|
.*?type="text"/x, f
|
93
|
-
assert_match /
|
94
|
-
|
95
|
-
|
96
|
-
#{t('date.month_names')[1]}
|
97
|
-
\<\/option\>/x, f
|
98
|
-
assert_match /option selected="selected" value="1">1<\/option>/, f
|
94
|
+
assert_match /input .*?name="crud_test_model\[birthdate\]"
|
95
|
+
.*?type="date"
|
96
|
+
.*?value="1910-01-01"/x, f
|
99
97
|
end
|
100
98
|
|
101
99
|
test 'crud form' do
|
@@ -114,7 +112,12 @@ class FormHelperTest < ActionView::TestCase
|
|
114
112
|
.*?type="number"/x, f
|
115
113
|
assert_match /input .*?name="crud_test_model\[income\]"
|
116
114
|
.*?type="number"/x, f
|
117
|
-
assert_match /
|
115
|
+
assert_match /input .*?name="crud_test_model\[birthdate\]"
|
116
|
+
.*?type="date"/x, f
|
117
|
+
assert_match /input .*?name="crud_test_model\[gets_up_at\]"
|
118
|
+
.*?type="time"/x, f
|
119
|
+
assert_match /input .*?name="crud_test_model\[last_seen\]"
|
120
|
+
.*?type="datetime"/x, f
|
118
121
|
assert_match /input .*?name="crud_test_model\[human\]"
|
119
122
|
.*?type="checkbox"/x, f
|
120
123
|
assert_match /select .*?name="crud_test_model\[companion_id\]"/, f
|
@@ -95,7 +95,7 @@ class FormatHelperTest < ActionView::TestCase
|
|
95
95
|
m = crud_test_models(:AAAAA)
|
96
96
|
assert_equal '9', format_type(m, :children)
|
97
97
|
|
98
|
-
m.children =
|
98
|
+
m.children = 10_000
|
99
99
|
assert_equal '10000', format_type(m, :children)
|
100
100
|
end
|
101
101
|
|
@@ -136,6 +136,18 @@ class FormatHelperTest < ActionView::TestCase
|
|
136
136
|
assert format_type(m, :remarks).html_safe?
|
137
137
|
end
|
138
138
|
|
139
|
+
test 'format boolean false column' do
|
140
|
+
m = crud_test_models(:AAAAA)
|
141
|
+
m.human = false
|
142
|
+
assert_equal 'no', format_type(m, :human)
|
143
|
+
end
|
144
|
+
|
145
|
+
test 'format boolean true column' do
|
146
|
+
m = crud_test_models(:AAAAA)
|
147
|
+
m.human = true
|
148
|
+
assert_equal 'yes', format_type(m, :human)
|
149
|
+
end
|
150
|
+
|
139
151
|
test 'format belongs to column without content' do
|
140
152
|
m = crud_test_models(:AAAAA)
|
141
153
|
assert_equal t('global.associations.no_entry'),
|
@@ -26,7 +26,7 @@ class TableHelperTest < ActionView::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
test 'empty table should render message' do
|
29
|
-
result = plain_table_or_message([]) {
|
29
|
+
result = plain_table_or_message([]) {}
|
30
30
|
assert result.html_safe?
|
31
31
|
assert_match /\<div class=["']table["']\>.*\<\/div\>/, result
|
32
32
|
end
|
@@ -40,9 +40,9 @@ class TableHelperTest < ActionView::TestCase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
test 'table with attrs' do
|
43
|
-
expected =
|
44
|
-
|
45
|
-
|
43
|
+
expected = DryCrud::Table::Builder.table(
|
44
|
+
%w(foo bar), self,
|
45
|
+
class: 'table table-striped table-hover') do |t|
|
46
46
|
t.attrs :size, :upcase
|
47
47
|
end
|
48
48
|
actual = plain_table(%w(foo bar), :size, :upcase)
|
@@ -81,7 +81,7 @@ module CrudControllerTestHelper
|
|
81
81
|
post :create, test_params(model_identifier => new_entry_attrs)
|
82
82
|
end
|
83
83
|
assert_redirected_to_show entry
|
84
|
-
assert !
|
84
|
+
assert !entry.new_record?
|
85
85
|
assert_attrs_equal(new_entry_attrs)
|
86
86
|
end
|
87
87
|
|
@@ -179,12 +179,12 @@ module CrudControllerTestHelper
|
|
179
179
|
|
180
180
|
# Test object used in several tests.
|
181
181
|
def test_entry
|
182
|
-
|
182
|
+
fail 'Implement this method in your test class'
|
183
183
|
end
|
184
184
|
|
185
185
|
# Attribute hash used in several tests.
|
186
186
|
def test_entry_attrs
|
187
|
-
|
187
|
+
fail 'Implement this method in your test class'
|
188
188
|
end
|
189
189
|
|
190
190
|
# Attribute hash used in edit/update tests.
|
@@ -313,7 +313,7 @@ module CrudTestHelper
|
|
313
313
|
gets_up_at: Time.zone.local(2000, 1, 1, index, index),
|
314
314
|
last_seen: "#{2000 + 10 * index}-#{index}-#{index} " +
|
315
315
|
"1#{index}:2#{index}",
|
316
|
-
human: index
|
316
|
+
human: index.even?,
|
317
317
|
remarks: "#{c} #{str(index + 1)} #{str(index + 2)}\n" *
|
318
318
|
(index % 3 + 1))
|
319
319
|
m.companion = companion
|
@@ -330,7 +330,7 @@ module CrudTestHelper
|
|
330
330
|
end
|
331
331
|
|
332
332
|
def str(index)
|
333
|
-
|
333
|
+
(index + 64).chr * 5
|
334
334
|
end
|
335
335
|
|
336
336
|
# A hack to avoid ddl in transaction issues with mysql.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry_crud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Zumkehr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -40,75 +40,83 @@ extra_rdoc_files:
|
|
40
40
|
- README.rdoc
|
41
41
|
- VERSION
|
42
42
|
files:
|
43
|
+
- app/assets/images/actions/add.png
|
44
|
+
- app/assets/images/actions/delete.png
|
45
|
+
- app/assets/images/actions/edit.png
|
46
|
+
- app/assets/images/actions/list.png
|
47
|
+
- app/assets/images/actions/show.png
|
48
|
+
- app/assets/stylesheets/crud.scss
|
49
|
+
- app/assets/stylesheets/sample.scss
|
50
|
+
- app/controllers/crud_controller.rb
|
51
|
+
- app/controllers/dry_crud/generic_model.rb
|
52
|
+
- app/controllers/dry_crud/nestable.rb
|
53
|
+
- app/controllers/dry_crud/rememberable.rb
|
54
|
+
- app/controllers/dry_crud/render_callbacks.rb
|
55
|
+
- app/controllers/dry_crud/responder.rb
|
56
|
+
- app/controllers/dry_crud/searchable.rb
|
57
|
+
- app/controllers/dry_crud/sortable.rb
|
58
|
+
- app/controllers/list_controller.rb
|
59
|
+
- app/helpers/actions_helper.rb
|
60
|
+
- app/helpers/dry_crud/form/builder.rb
|
61
|
+
- app/helpers/dry_crud/form/control.rb
|
62
|
+
- app/helpers/dry_crud/table/actions.rb
|
63
|
+
- app/helpers/dry_crud/table/builder.rb
|
64
|
+
- app/helpers/dry_crud/table/col.rb
|
65
|
+
- app/helpers/dry_crud/table/sorting.rb
|
66
|
+
- app/helpers/form_helper.rb
|
67
|
+
- app/helpers/format_helper.rb
|
68
|
+
- app/helpers/i18n_helper.rb
|
69
|
+
- app/helpers/table_helper.rb
|
70
|
+
- app/helpers/utility_helper.rb
|
71
|
+
- app/views/crud/_actions_edit.html.erb
|
72
|
+
- app/views/crud/_actions_edit.html.haml
|
73
|
+
- app/views/crud/_actions_index.html.erb
|
74
|
+
- app/views/crud/_actions_index.html.haml
|
75
|
+
- app/views/crud/_actions_show.html.erb
|
76
|
+
- app/views/crud/_actions_show.html.haml
|
77
|
+
- app/views/crud/_attrs.html.erb
|
78
|
+
- app/views/crud/_attrs.html.haml
|
79
|
+
- app/views/crud/_form.html.erb
|
80
|
+
- app/views/crud/_form.html.haml
|
81
|
+
- app/views/crud/_list.html.erb
|
82
|
+
- app/views/crud/_list.html.haml
|
83
|
+
- app/views/crud/edit.html.erb
|
84
|
+
- app/views/crud/edit.html.haml
|
85
|
+
- app/views/crud/new.html.erb
|
86
|
+
- app/views/crud/new.html.haml
|
87
|
+
- app/views/crud/show.html.erb
|
88
|
+
- app/views/crud/show.html.haml
|
89
|
+
- app/views/layouts/_flash.html.erb
|
90
|
+
- app/views/layouts/_flash.html.haml
|
91
|
+
- app/views/layouts/_nav.html.erb
|
92
|
+
- app/views/layouts/_nav.html.haml
|
93
|
+
- app/views/layouts/application.html.erb
|
94
|
+
- app/views/layouts/application.html.haml
|
95
|
+
- app/views/list/_actions_index.html.erb
|
96
|
+
- app/views/list/_actions_index.html.haml
|
97
|
+
- app/views/list/_list.html.erb
|
98
|
+
- app/views/list/_list.html.haml
|
99
|
+
- app/views/list/_search.html.erb
|
100
|
+
- app/views/list/_search.html.haml
|
101
|
+
- app/views/list/index.html.erb
|
102
|
+
- app/views/list/index.html.haml
|
103
|
+
- app/views/shared/_error_messages.html.erb
|
104
|
+
- app/views/shared/_error_messages.html.haml
|
105
|
+
- app/views/shared/_labeled.html.erb
|
106
|
+
- app/views/shared/_labeled.html.haml
|
107
|
+
- config/locales/crud.de.yml
|
108
|
+
- config/locales/crud.en.yml
|
109
|
+
- lib/dry_crud.rb
|
110
|
+
- lib/dry_crud/engine.rb
|
43
111
|
- lib/generators/dry_crud/USAGE
|
44
112
|
- lib/generators/dry_crud/dry_crud_generator.rb
|
113
|
+
- lib/generators/dry_crud/dry_crud_generator_base.rb
|
114
|
+
- lib/generators/dry_crud/file_generator.rb
|
45
115
|
- lib/generators/dry_crud/templates/INSTALL
|
46
|
-
- lib/generators/dry_crud/templates/app/assets/images/actions/add.png
|
47
|
-
- lib/generators/dry_crud/templates/app/assets/images/actions/delete.png
|
48
|
-
- lib/generators/dry_crud/templates/app/assets/images/actions/edit.png
|
49
|
-
- lib/generators/dry_crud/templates/app/assets/images/actions/list.png
|
50
|
-
- lib/generators/dry_crud/templates/app/assets/images/actions/show.png
|
51
|
-
- lib/generators/dry_crud/templates/app/assets/stylesheets/crud.scss
|
52
|
-
- lib/generators/dry_crud/templates/app/assets/stylesheets/sample.scss
|
53
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/generic_model.rb
|
54
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/nestable.rb
|
55
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/rememberable.rb
|
56
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/render_callbacks.rb
|
57
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/responder.rb
|
58
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/searchable.rb
|
59
|
-
- lib/generators/dry_crud/templates/app/controllers/crud/sortable.rb
|
60
|
-
- lib/generators/dry_crud/templates/app/controllers/crud_controller.rb
|
61
|
-
- lib/generators/dry_crud/templates/app/controllers/list_controller.rb
|
62
|
-
- lib/generators/dry_crud/templates/app/helpers/actions_helper.rb
|
63
|
-
- lib/generators/dry_crud/templates/app/helpers/crud/form_builder.rb
|
64
|
-
- lib/generators/dry_crud/templates/app/helpers/crud/table_builder.rb
|
65
|
-
- lib/generators/dry_crud/templates/app/helpers/form_helper.rb
|
66
|
-
- lib/generators/dry_crud/templates/app/helpers/format_helper.rb
|
67
|
-
- lib/generators/dry_crud/templates/app/helpers/i18n_helper.rb
|
68
|
-
- lib/generators/dry_crud/templates/app/helpers/table_helper.rb
|
69
|
-
- lib/generators/dry_crud/templates/app/helpers/utility_helper.rb
|
70
|
-
- lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.erb
|
71
|
-
- lib/generators/dry_crud/templates/app/views/crud/_actions_edit.html.haml
|
72
|
-
- lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.erb
|
73
|
-
- lib/generators/dry_crud/templates/app/views/crud/_actions_index.html.haml
|
74
|
-
- lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.erb
|
75
|
-
- lib/generators/dry_crud/templates/app/views/crud/_actions_show.html.haml
|
76
|
-
- lib/generators/dry_crud/templates/app/views/crud/_attrs.html.erb
|
77
|
-
- lib/generators/dry_crud/templates/app/views/crud/_attrs.html.haml
|
78
|
-
- lib/generators/dry_crud/templates/app/views/crud/_form.html.erb
|
79
|
-
- lib/generators/dry_crud/templates/app/views/crud/_form.html.haml
|
80
|
-
- lib/generators/dry_crud/templates/app/views/crud/_list.html.erb
|
81
|
-
- lib/generators/dry_crud/templates/app/views/crud/_list.html.haml
|
82
|
-
- lib/generators/dry_crud/templates/app/views/crud/edit.html.erb
|
83
|
-
- lib/generators/dry_crud/templates/app/views/crud/edit.html.haml
|
84
|
-
- lib/generators/dry_crud/templates/app/views/crud/new.html.erb
|
85
|
-
- lib/generators/dry_crud/templates/app/views/crud/new.html.haml
|
86
|
-
- lib/generators/dry_crud/templates/app/views/crud/show.html.erb
|
87
|
-
- lib/generators/dry_crud/templates/app/views/crud/show.html.haml
|
88
|
-
- lib/generators/dry_crud/templates/app/views/layouts/_flash.html.erb
|
89
|
-
- lib/generators/dry_crud/templates/app/views/layouts/_flash.html.haml
|
90
|
-
- lib/generators/dry_crud/templates/app/views/layouts/_nav.html.erb
|
91
|
-
- lib/generators/dry_crud/templates/app/views/layouts/_nav.html.haml
|
92
|
-
- lib/generators/dry_crud/templates/app/views/layouts/crud.html.erb
|
93
|
-
- lib/generators/dry_crud/templates/app/views/layouts/crud.html.haml
|
94
|
-
- lib/generators/dry_crud/templates/app/views/list/_actions_index.html.erb
|
95
|
-
- lib/generators/dry_crud/templates/app/views/list/_actions_index.html.haml
|
96
|
-
- lib/generators/dry_crud/templates/app/views/list/_list.html.erb
|
97
|
-
- lib/generators/dry_crud/templates/app/views/list/_list.html.haml
|
98
|
-
- lib/generators/dry_crud/templates/app/views/list/_search.html.erb
|
99
|
-
- lib/generators/dry_crud/templates/app/views/list/_search.html.haml
|
100
|
-
- lib/generators/dry_crud/templates/app/views/list/index.html.erb
|
101
|
-
- lib/generators/dry_crud/templates/app/views/list/index.html.haml
|
102
|
-
- lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.erb
|
103
|
-
- lib/generators/dry_crud/templates/app/views/shared/_error_messages.html.haml
|
104
|
-
- lib/generators/dry_crud/templates/app/views/shared/_labeled.html.erb
|
105
|
-
- lib/generators/dry_crud/templates/app/views/shared/_labeled.html.haml
|
106
116
|
- lib/generators/dry_crud/templates/config/initializers/field_error_proc.rb
|
107
|
-
- lib/generators/dry_crud/templates/config/locales/crud.de.yml
|
108
|
-
- lib/generators/dry_crud/templates/config/locales/crud.en.yml
|
109
117
|
- lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb
|
110
|
-
- lib/generators/dry_crud/templates/spec/helpers/
|
111
|
-
- lib/generators/dry_crud/templates/spec/helpers/
|
118
|
+
- lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb
|
119
|
+
- lib/generators/dry_crud/templates/spec/helpers/dry_crud/table/builder_spec.rb
|
112
120
|
- lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb
|
113
121
|
- lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb
|
114
122
|
- lib/generators/dry_crud/templates/spec/helpers/i18n_helper_spec.rb
|
@@ -117,9 +125,9 @@ files:
|
|
117
125
|
- lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb
|
118
126
|
- lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb
|
119
127
|
- lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb
|
120
|
-
- lib/generators/dry_crud/templates/test/helpers/crud/form_builder_test.rb
|
121
|
-
- lib/generators/dry_crud/templates/test/helpers/crud/table_builder_test.rb
|
122
128
|
- lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb
|
129
|
+
- lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb
|
130
|
+
- lib/generators/dry_crud/templates/test/helpers/dry_crud/table/builder_test.rb
|
123
131
|
- lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb
|
124
132
|
- lib/generators/dry_crud/templates/test/helpers/format_helper_test.rb
|
125
133
|
- lib/generators/dry_crud/templates/test/helpers/i18n_helper_test.rb
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Crud
|
4
|
-
# The search functionality for the index table.
|
5
|
-
# Define an array of searchable columns in your subclassing controllers
|
6
|
-
# using the class attribute +search_columns+.
|
7
|
-
module Searchable
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
class_attribute :search_columns
|
12
|
-
self.search_columns = []
|
13
|
-
|
14
|
-
helper_method :search_support?
|
15
|
-
|
16
|
-
alias_method_chain :list_entries, :search
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
# Enhance the list entries with an optional search criteria
|
22
|
-
def list_entries_with_search
|
23
|
-
list_entries_without_search.where(search_condition)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Compose the search condition with a basic SQL OR query.
|
27
|
-
def search_condition
|
28
|
-
if search_support? && params[:q].present?
|
29
|
-
col_clause = search_column_clause
|
30
|
-
terms = params[:q].split(/\s+/).map { |t| "%#{t}%" }
|
31
|
-
term_clause = terms.map { |t| "(#{col_clause})" }.join(' AND ')
|
32
|
-
|
33
|
-
term_params = terms.map { |t| [t] * search_columns.size }.flatten
|
34
|
-
["(#{term_clause})", *term_params]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# SQL where clause with all search colums or'ed.
|
39
|
-
def search_column_clause
|
40
|
-
search_columns.map do |f|
|
41
|
-
if f.to_s.include?('.')
|
42
|
-
"#{f} LIKE ?"
|
43
|
-
else
|
44
|
-
"#{model_class.table_name}.#{f} LIKE ?"
|
45
|
-
end
|
46
|
-
end.join(' OR ')
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns true if this controller has searchable columns.
|
50
|
-
def search_support?
|
51
|
-
search_columns.present?
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|