active_scaffold 3.6.19 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +30 -0
- data/README.md +27 -16
- data/app/assets/javascripts/jquery/active_scaffold.js +38 -6
- data/app/assets/javascripts/jquery/active_scaffold_chosen.js +6 -5
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +18 -4
- data/app/assets/stylesheets/active_scaffold_layout.css +12 -1
- data/app/views/active_scaffold_overrides/_base_form.html.erb +5 -1
- data/app/views/active_scaffold_overrides/_field_search.html.erb +1 -0
- data/app/views/active_scaffold_overrides/_render_field.js.erb +19 -11
- data/config/locales/ja.yml +59 -59
- data/lib/active_scaffold/actions/common_search.rb +2 -2
- data/lib/active_scaffold/actions/core.rb +30 -10
- data/lib/active_scaffold/actions/field_search.rb +9 -6
- data/lib/active_scaffold/actions/nested.rb +7 -7
- data/lib/active_scaffold/attribute_params.rb +19 -57
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +0 -3
- data/lib/active_scaffold/bridges/active_storage/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/active_storage.rb +3 -0
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker/helper.rb +4 -4
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +4 -1
- data/lib/active_scaffold/bridges/record_select/helpers.rb +2 -2
- data/lib/active_scaffold/bridges/tiny_mce.rb +1 -1
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +1 -6
- data/lib/active_scaffold/config/core.rb +1 -1
- data/lib/active_scaffold/config/field_search.rb +9 -1
- data/lib/active_scaffold/config/form.rb +9 -1
- data/lib/active_scaffold/core.rb +2 -8
- data/lib/active_scaffold/data_structures/action_columns.rb +0 -25
- data/lib/active_scaffold/data_structures/action_links.rb +1 -1
- data/lib/active_scaffold/data_structures/association/abstract.rb +8 -0
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +8 -0
- data/lib/active_scaffold/data_structures/association/active_record.rb +1 -13
- data/lib/active_scaffold/data_structures/association/mongoid.rb +21 -8
- data/lib/active_scaffold/data_structures/column.rb +31 -5
- data/lib/active_scaffold/data_structures/columns.rb +12 -12
- data/lib/active_scaffold/data_structures/nested_info.rb +12 -0
- data/lib/active_scaffold/data_structures/sorting.rb +1 -1
- data/lib/active_scaffold/engine.rb +0 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +13 -5
- data/lib/active_scaffold/extensions/cow_proxy.rb +1 -1
- data/lib/active_scaffold/extensions/unsaved_record.rb +9 -3
- data/lib/active_scaffold/finder.rb +6 -2
- data/lib/active_scaffold/helpers/action_link_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/form_column_helpers.rb +48 -22
- data/lib/active_scaffold/helpers/list_column_helpers.rb +3 -2
- data/lib/active_scaffold/helpers/search_column_helpers.rb +8 -2
- data/lib/active_scaffold/helpers/view_helpers.rb +1 -1
- data/lib/active_scaffold/registry.rb +10 -15
- data/lib/active_scaffold/tableless.rb +10 -79
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/active_scaffold.rb +0 -7
- data/lib/generators/active_scaffold/install_generator.rb +2 -2
- data/test/bridges/bridge_test.rb +1 -1
- data/test/bridges/paperclip_test.rb +16 -13
- data/test/bridges/tiny_mce_test.rb +1 -1
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +1 -1
- data/test/config/create_test.rb +1 -1
- data/test/config/delete_test.rb +1 -1
- data/test/config/field_search_test.rb +1 -1
- data/test/config/list_test.rb +1 -1
- data/test/config/nested_test.rb +1 -1
- data/test/config/search_test.rb +1 -1
- data/test/config/show_test.rb +1 -1
- data/test/config/subform_test.rb +1 -1
- data/test/config/update_test.rb +1 -1
- data/test/data_structures/action_columns_test.rb +1 -1
- data/test/data_structures/action_link_test.rb +1 -1
- data/test/data_structures/action_links_test.rb +1 -1
- data/test/data_structures/actions_test.rb +1 -1
- data/test/data_structures/association_column_test.rb +1 -1
- data/test/data_structures/column_test.rb +1 -1
- data/test/data_structures/columns_test.rb +1 -1
- data/test/data_structures/set_test.rb +1 -1
- data/test/data_structures/sorting_test.rb +1 -1
- data/test/data_structures/standard_column_test.rb +1 -1
- data/test/data_structures/validation_reflection_test.rb +1 -1
- data/test/data_structures/virtual_column_test.rb +1 -1
- data/test/extensions/active_record_test.rb +1 -1
- data/test/helpers/pagination_helpers_test.rb +1 -1
- data/test/misc/active_record_permissions_test.rb +1 -1
- data/test/misc/attribute_params_test.rb +1 -1
- data/test/misc/calculation_test.rb +1 -1
- data/test/misc/configurable_test.rb +1 -1
- data/test/misc/constraints_test.rb +1 -1
- data/test/misc/convert_numbers_format_test.rb +1 -1
- data/test/misc/finder_test.rb +1 -1
- data/test/misc/lang_test.rb +1 -1
- data/test/misc/parse_datetime_test.rb +1 -1
- data/test/misc/tableless_test.rb +1 -1
- data/test/test_helper.rb +4 -4
- metadata +6 -14
- data/lib/active_scaffold/delayed_setup.rb +0 -41
- data/lib/active_scaffold/extensions/left_outer_joins.rb +0 -43
@@ -4,24 +4,6 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
4
4
|
def self.scope(association, connection)
|
5
5
|
INSTANCE.scope association, connection
|
6
6
|
end
|
7
|
-
|
8
|
-
if Rails.version < '5.0.0'
|
9
|
-
def column_for(table_name, column_name, alias_tracker = nil)
|
10
|
-
klass = alias_tracker ? alias_tracker.connection.klass : self.klass
|
11
|
-
if table_name == klass.table_name
|
12
|
-
klass.columns_hash[column_name]
|
13
|
-
elsif alias_tracker && (klass = alias_tracker.instance_variable_get(:@assoc_klass))
|
14
|
-
klass.columns_hash[column_name]
|
15
|
-
else # rails < 4.1
|
16
|
-
association.klass.columns_hash[column_name]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_constraints(scope, owner, assoc_klass, refl, tracker)
|
21
|
-
tracker.instance_variable_set(:@assoc_klass, assoc_klass)
|
22
|
-
super
|
23
|
-
end
|
24
|
-
end
|
25
7
|
end
|
26
8
|
|
27
9
|
class Connection < ActiveRecord::ConnectionAdapters::AbstractAdapter
|
@@ -43,33 +25,15 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
43
25
|
end
|
44
26
|
|
45
27
|
class Column < ActiveRecord::ConnectionAdapters::Column
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
super(name, default, metadata, null)
|
50
|
-
end
|
51
|
-
else
|
52
|
-
def initialize(name, default, sql_type = nil, null = true)
|
53
|
-
cast_type = ActiveRecord::Base.connection.send :lookup_cast_type, sql_type
|
54
|
-
super(name, default, cast_type, sql_type, null)
|
55
|
-
end
|
28
|
+
def initialize(name, default, sql_type = nil, null = true, **)
|
29
|
+
metadata = ActiveRecord::Base.connection.send :fetch_type_metadata, sql_type
|
30
|
+
super(name, default, metadata, null)
|
56
31
|
end
|
57
32
|
end
|
58
33
|
|
59
34
|
module Tableless
|
60
|
-
|
61
|
-
|
62
|
-
klass < ActiveScaffold::Tableless ? true : super
|
63
|
-
end
|
64
|
-
|
65
|
-
def association_scope
|
66
|
-
@association_scope ||= AssociationScope.scope(self, klass.connection) if klass < ActiveScaffold::Tableless
|
67
|
-
super
|
68
|
-
end
|
69
|
-
else
|
70
|
-
def skip_statement_cache?(scope)
|
71
|
-
klass < ActiveScaffold::Tableless ? true : super
|
72
|
-
end
|
35
|
+
def skip_statement_cache?(scope)
|
36
|
+
klass < ActiveScaffold::Tableless ? true : super
|
73
37
|
end
|
74
38
|
|
75
39
|
def target_scope
|
@@ -186,18 +150,11 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
186
150
|
private
|
187
151
|
|
188
152
|
def relation
|
189
|
-
|
190
|
-
if Rails.version < '5.2.0'
|
191
|
-
args << arel_table
|
192
|
-
args << predicate_builder if Rails.version >= '5.0.0'
|
193
|
-
end
|
194
|
-
ActiveScaffold::Tableless::Relation.new(*args)
|
153
|
+
ActiveScaffold::Tableless::Relation.new(self)
|
195
154
|
end
|
196
155
|
|
197
|
-
|
198
|
-
|
199
|
-
StatementCache.new(key, self, &block)
|
200
|
-
end
|
156
|
+
def cached_find_by_statement(key, &block)
|
157
|
+
StatementCache.new(key, self, &block)
|
201
158
|
end
|
202
159
|
end
|
203
160
|
|
@@ -207,34 +164,8 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
207
164
|
@model = model
|
208
165
|
end
|
209
166
|
|
210
|
-
|
211
|
-
|
212
|
-
model.where(@key => values)
|
213
|
-
end
|
214
|
-
else
|
215
|
-
def execute(values, connection)
|
216
|
-
@model.where(@key => values)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
if Rails.version < '5.0' # 4.2.x
|
221
|
-
def self.columns_hash
|
222
|
-
if self < ActiveScaffold::Tableless
|
223
|
-
@columns_hash ||= Hash[columns.map { |c| [c.name, c] }]
|
224
|
-
else
|
225
|
-
super
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def self.initialize_find_by_cache
|
230
|
-
self.find_by_statement_cache = Hash.new { |h, k| h[k] = StatementCache.new(k) } # rubocop:disable Rails/DynamicFindBy
|
231
|
-
end
|
232
|
-
elsif Rails.version < '5.2' # 5.0 and 5.1
|
233
|
-
def self.initialize_find_by_cache
|
234
|
-
@find_by_statement_cache = {
|
235
|
-
true => Hash.new { |h, k| h[k] = StatementCache.new(k) },
|
236
|
-
false => Hash.new { |h, k| h[k] = StatementCache.new(k) }
|
237
|
-
}
|
167
|
+
def execute(values, connection)
|
168
|
+
@model.where(@key => values)
|
238
169
|
end
|
239
170
|
end
|
240
171
|
|
data/lib/active_scaffold.rb
CHANGED
@@ -5,7 +5,6 @@ module ActiveScaffold
|
|
5
5
|
autoload :Configurable, 'active_scaffold/configurable'
|
6
6
|
autoload :Constraints, 'active_scaffold/constraints'
|
7
7
|
autoload :Core, 'active_scaffold/core'
|
8
|
-
autoload :DelayedSetup, 'active_scaffold/delayed_setup'
|
9
8
|
autoload :Finder, 'active_scaffold/finder'
|
10
9
|
autoload :MarkedModel, 'active_scaffold/marked_model'
|
11
10
|
autoload :OrmChecks, 'active_scaffold/orm_checks'
|
@@ -45,7 +44,6 @@ module ActiveScaffold
|
|
45
44
|
class ActionNotAllowed < RuntimeError; end
|
46
45
|
class ReverseAssociationRequired < RuntimeError; end
|
47
46
|
|
48
|
-
mattr_accessor :delayed_setup, instance_writer: false
|
49
47
|
mattr_accessor :stylesheets, instance_writer: false
|
50
48
|
self.stylesheets = []
|
51
49
|
mattr_accessor :javascripts, instance_writer: false
|
@@ -84,11 +82,6 @@ module ActiveScaffold
|
|
84
82
|
File.dirname(__FILE__) + '/..'
|
85
83
|
end
|
86
84
|
|
87
|
-
def self.set_defaults(&block) # rubocop:disable Naming/AccessorMethodName
|
88
|
-
ActiveSupport::Deprecation.warn 'use ActiveScaffold.defaults'
|
89
|
-
defaults(&block)
|
90
|
-
end
|
91
|
-
|
92
85
|
def self.defaults(&block)
|
93
86
|
ActiveScaffold::Config::Core.configure(&block)
|
94
87
|
end
|
@@ -37,7 +37,7 @@ module ActiveScaffold
|
|
37
37
|
file = 'app/assets/stylesheets/application.css'
|
38
38
|
return unless File.exist?(file)
|
39
39
|
original_css = File.binread(file)
|
40
|
-
if original_css
|
40
|
+
if original_css.match?(/require active_scaffold$/)
|
41
41
|
say_status('skipped', 'insert into app/assets/stylesheets/application.css', :yellow)
|
42
42
|
else
|
43
43
|
insert_into_file 'app/assets/stylesheets/application.css', before: %r{[ ]*\*/} do
|
@@ -68,7 +68,7 @@ module ActiveScaffold
|
|
68
68
|
say_status('create', file)
|
69
69
|
end
|
70
70
|
insert_into_file 'app/views/layouts/application.html.erb', after: /javascript_pack_tag 'application'.*\n/ do
|
71
|
-
" <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>\n"
|
71
|
+
" <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload', 'data-turbo-track': 'reload' %>\n"
|
72
72
|
end
|
73
73
|
append_to_file 'config/initializers/assets.rb' do
|
74
74
|
"Rails.application.config.assets.precompile += %w( application.js )\n"
|
data/test/bridges/bridge_test.rb
CHANGED
@@ -60,22 +60,25 @@ class PaperclipTest < ActionView::TestCase
|
|
60
60
|
@record = Company.new
|
61
61
|
|
62
62
|
@record.stubs(:logo).returns(stub(:file? => true, :original_filename => 'file', :url => '/system/file', :styles => Company.attachment_definitions[:logo]))
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
'</div></div>'
|
74
|
-
].join
|
75
|
-
assert_dom_equal template, active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo', :object => @record)
|
63
|
+
click_js = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show(); return false;"
|
64
|
+
change_js = "jQuery(this).parents('div.paperclip_controls').find('input.remove_file').val('false'); return false;"
|
65
|
+
@document = Nokogiri::HTML::Document.parse(active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo', :object => @record))
|
66
|
+
assert_select 'div.paperclip_controls input[type=file]' do |match|
|
67
|
+
assert_equal match[0]['onchange'], change_js
|
68
|
+
end
|
69
|
+
assert_select 'div.paperclip_controls a[href="#"][onclick]' do |match|
|
70
|
+
assert_equal match[0]['onclick'], click_js
|
71
|
+
end
|
72
|
+
assert_select 'div.paperclip_controls input.remove_file[type=hidden][value=false]'
|
76
73
|
|
77
74
|
@record.stubs(:logo).returns(stub(:file? => false))
|
78
75
|
assert_dom_equal '<input name="record[logo]" class="text-input" autocomplete="off" type="file" id="record_logo" />', active_scaffold_input_paperclip(config.columns[:logo], :name => 'record[logo]', :id => 'record_logo', :object => @record)
|
79
76
|
end
|
80
77
|
end
|
78
|
+
|
79
|
+
protected
|
80
|
+
|
81
|
+
def document_root_element
|
82
|
+
@document.root
|
83
|
+
end
|
81
84
|
end
|
@@ -28,7 +28,7 @@ class TinyMceTest < ActionView::TestCase
|
|
28
28
|
def test_includes
|
29
29
|
ActiveScaffold::Bridges::TinyMce.expects(:install?).returns(true)
|
30
30
|
with_js_framework :jquery do
|
31
|
-
assert ActiveScaffold::Bridges.all_javascripts.include?('tinymce
|
31
|
+
assert ActiveScaffold::Bridges.all_javascripts.include?('tinymce')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
data/test/config/base_test.rb
CHANGED
data/test/config/core_test.rb
CHANGED
data/test/config/create_test.rb
CHANGED
data/test/config/delete_test.rb
CHANGED
data/test/config/list_test.rb
CHANGED
data/test/config/nested_test.rb
CHANGED
data/test/config/search_test.rb
CHANGED
data/test/config/show_test.rb
CHANGED
data/test/config/subform_test.rb
CHANGED
data/test/config/update_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
# require 'test/model_stub'
|
3
3
|
# require File.join(File.dirname(__FILE__), '../../lib/active_scaffold/data_structures/set.rb')
|
4
4
|
|
5
|
-
class ActionColumnsTest <
|
5
|
+
class ActionColumnsTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@columns = ActiveScaffold::DataStructures::ActionColumns.new(%i[a b])
|
8
8
|
@columns.action = stub(core: stub(model_id: 'model_stub'), user_settings_key: :"model_stub_active_scaffold/config/test")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class SortingTest <
|
3
|
+
class SortingTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
@columns = ActiveScaffold::DataStructures::Columns.new(ModelStub, :a, :b, :c, :d, :id)
|
6
6
|
@sorting = ActiveScaffold::DataStructures::Sorting.new(@columns, ModelStub)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class ValidationReflectionTest <
|
3
|
+
class ValidationReflectionTest < Minitest::Test
|
4
4
|
def test_set_required_for_validates_presence_of
|
5
5
|
column = ActiveScaffold::DataStructures::Column.new(:name, Company)
|
6
6
|
refute column.required?
|
@@ -22,7 +22,7 @@ class NumberModel < ActiveRecord::Base
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
class ConvertNumbersFormatTest <
|
25
|
+
class ConvertNumbersFormatTest < Minitest::Test
|
26
26
|
include ActiveScaffoldConfigMock
|
27
27
|
include ActiveScaffold::AttributeParams
|
28
28
|
include ActiveScaffold::Finder
|
data/test/misc/finder_test.rb
CHANGED
data/test/misc/lang_test.rb
CHANGED
data/test/misc/tableless_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -8,7 +8,7 @@ require 'mocha/minitest'
|
|
8
8
|
require 'cow_proxy'
|
9
9
|
|
10
10
|
require 'minitest/reporters'
|
11
|
-
Minitest::Reporters.use!
|
11
|
+
Minitest::Reporters.use! unless ENV['RM_INFO']
|
12
12
|
|
13
13
|
def load_schema
|
14
14
|
stdout = $stdout
|
@@ -32,10 +32,10 @@ I18n.backend.store_translations :en, YAML.load_file(File.expand_path('../config/
|
|
32
32
|
|
33
33
|
# rails 4.0
|
34
34
|
unless defined? Minitest::Test
|
35
|
-
class Minitest::Test <
|
35
|
+
class Minitest::Test < Minitest::Unit::TestCase
|
36
36
|
end
|
37
37
|
|
38
|
-
class
|
38
|
+
class Minitest::Unit::TestCase
|
39
39
|
def with_js_framework(framework)
|
40
40
|
framework, ActiveScaffold.js_framework = ActiveScaffold.js_framework, framework
|
41
41
|
yield
|
@@ -44,7 +44,7 @@ unless defined? Minitest::Test
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
class
|
47
|
+
class Minitest::Test
|
48
48
|
protected
|
49
49
|
|
50
50
|
def with_js_framework(framework)
|