active_scaffold 3.6.20 → 3.7.1

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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +47 -0
  3. data/README.md +29 -16
  4. data/app/assets/javascripts/jquery/active_scaffold.js +106 -68
  5. data/app/assets/javascripts/jquery/active_scaffold_chosen.js +6 -5
  6. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +18 -4
  7. data/app/assets/stylesheets/active_scaffold_layout.css +13 -2
  8. data/app/views/active_scaffold_overrides/_base_form.html.erb +5 -1
  9. data/app/views/active_scaffold_overrides/_field_search.html.erb +1 -0
  10. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +2 -1
  11. data/app/views/active_scaffold_overrides/_render_field.js.erb +24 -13
  12. data/config/locales/de.yml +6 -3
  13. data/config/locales/en.yml +3 -0
  14. data/config/locales/es.yml +3 -0
  15. data/config/locales/fr.yml +9 -6
  16. data/config/locales/hu.yml +20 -17
  17. data/config/locales/ja.yml +83 -80
  18. data/config/locales/ru.yml +17 -14
  19. data/lib/active_scaffold/actions/common_search.rb +2 -2
  20. data/lib/active_scaffold/actions/core.rb +30 -10
  21. data/lib/active_scaffold/actions/field_search.rb +9 -6
  22. data/lib/active_scaffold/actions/nested.rb +7 -7
  23. data/lib/active_scaffold/actions/update.rb +3 -3
  24. data/lib/active_scaffold/attribute_params.rb +22 -70
  25. data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +0 -3
  26. data/lib/active_scaffold/bridges/active_storage/form_ui.rb +6 -6
  27. data/lib/active_scaffold/bridges/active_storage/list_ui.rb +7 -7
  28. data/lib/active_scaffold/bridges/active_storage.rb +3 -0
  29. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +2 -2
  30. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +2 -2
  31. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +12 -14
  32. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +2 -2
  33. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +1 -1
  34. data/lib/active_scaffold/bridges/chosen/helpers.rb +10 -10
  35. data/lib/active_scaffold/bridges/country_select/country_select_bridge_helper.rb +7 -7
  36. data/lib/active_scaffold/bridges/date_picker/ext.rb +20 -9
  37. data/lib/active_scaffold/bridges/date_picker/helper.rb +9 -9
  38. data/lib/active_scaffold/bridges/date_picker.rb +2 -0
  39. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +3 -3
  40. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +5 -5
  41. data/lib/active_scaffold/bridges/file_column/form_ui.rb +1 -1
  42. data/lib/active_scaffold/bridges/file_column/list_ui.rb +3 -3
  43. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +1 -1
  44. data/lib/active_scaffold/bridges/paper_trail/actions.rb +4 -1
  45. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +3 -3
  46. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
  47. data/lib/active_scaffold/bridges/record_select/helpers.rb +17 -17
  48. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +6 -6
  49. data/lib/active_scaffold/bridges/tiny_mce.rb +1 -1
  50. data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +6 -11
  51. data/lib/active_scaffold/bridges.rb +0 -3
  52. data/lib/active_scaffold/config/core.rb +1 -1
  53. data/lib/active_scaffold/config/field_search.rb +9 -1
  54. data/lib/active_scaffold/config/form.rb +9 -1
  55. data/lib/active_scaffold/constraints.rb +22 -7
  56. data/lib/active_scaffold/core.rb +6 -10
  57. data/lib/active_scaffold/data_structures/action_columns.rb +0 -25
  58. data/lib/active_scaffold/data_structures/action_links.rb +1 -1
  59. data/lib/active_scaffold/data_structures/association/abstract.rb +8 -0
  60. data/lib/active_scaffold/data_structures/association/active_mongoid.rb +8 -0
  61. data/lib/active_scaffold/data_structures/association/active_record.rb +1 -13
  62. data/lib/active_scaffold/data_structures/association/mongoid.rb +21 -8
  63. data/lib/active_scaffold/data_structures/column.rb +139 -28
  64. data/lib/active_scaffold/data_structures/columns.rb +12 -12
  65. data/lib/active_scaffold/data_structures/nested_info.rb +12 -0
  66. data/lib/active_scaffold/data_structures/sorting.rb +1 -1
  67. data/lib/active_scaffold/engine.rb +15 -1
  68. data/lib/active_scaffold/extensions/action_view_rendering.rb +13 -5
  69. data/lib/active_scaffold/extensions/cow_proxy.rb +1 -1
  70. data/lib/active_scaffold/extensions/routing_mapper.rb +1 -0
  71. data/lib/active_scaffold/extensions/unsaved_record.rb +9 -3
  72. data/lib/active_scaffold/finder.rb +147 -28
  73. data/lib/active_scaffold/helpers/action_link_helpers.rb +1 -1
  74. data/lib/active_scaffold/helpers/controller_helpers.rb +9 -4
  75. data/lib/active_scaffold/helpers/form_column_helpers.rb +153 -107
  76. data/lib/active_scaffold/helpers/human_condition_helpers.rb +48 -14
  77. data/lib/active_scaffold/helpers/list_column_helpers.rb +37 -20
  78. data/lib/active_scaffold/helpers/search_column_helpers.rb +137 -55
  79. data/lib/active_scaffold/helpers/show_column_helpers.rb +6 -6
  80. data/lib/active_scaffold/helpers/view_helpers.rb +1 -1
  81. data/lib/active_scaffold/orm_checks.rb +21 -1
  82. data/lib/active_scaffold/registry.rb +10 -15
  83. data/lib/active_scaffold/tableless.rb +10 -79
  84. data/lib/active_scaffold/version.rb +2 -2
  85. data/lib/active_scaffold.rb +3 -9
  86. data/lib/generators/active_scaffold/install_generator.rb +2 -2
  87. data/test/bridges/bridge_test.rb +1 -1
  88. data/test/bridges/date_picker_test.rb +3 -2
  89. data/test/bridges/paperclip_test.rb +18 -14
  90. data/test/bridges/tiny_mce_test.rb +5 -3
  91. data/test/config/base_test.rb +1 -1
  92. data/test/config/core_test.rb +1 -1
  93. data/test/config/create_test.rb +1 -1
  94. data/test/config/delete_test.rb +1 -1
  95. data/test/config/field_search_test.rb +1 -1
  96. data/test/config/list_test.rb +1 -1
  97. data/test/config/nested_test.rb +1 -1
  98. data/test/config/search_test.rb +1 -1
  99. data/test/config/show_test.rb +1 -1
  100. data/test/config/subform_test.rb +1 -1
  101. data/test/config/update_test.rb +1 -1
  102. data/test/data_structures/action_columns_test.rb +1 -1
  103. data/test/data_structures/action_link_test.rb +1 -1
  104. data/test/data_structures/action_links_test.rb +1 -1
  105. data/test/data_structures/actions_test.rb +1 -1
  106. data/test/data_structures/association_column_test.rb +1 -1
  107. data/test/data_structures/column_test.rb +1 -1
  108. data/test/data_structures/columns_test.rb +1 -1
  109. data/test/data_structures/set_test.rb +1 -1
  110. data/test/data_structures/sorting_test.rb +1 -1
  111. data/test/data_structures/standard_column_test.rb +1 -1
  112. data/test/data_structures/validation_reflection_test.rb +1 -1
  113. data/test/data_structures/virtual_column_test.rb +1 -1
  114. data/test/extensions/active_record_test.rb +1 -1
  115. data/test/helpers/form_column_helpers_test.rb +7 -5
  116. data/test/helpers/pagination_helpers_test.rb +1 -1
  117. data/test/helpers/search_column_helpers_test.rb +2 -1
  118. data/test/misc/active_record_permissions_test.rb +1 -1
  119. data/test/misc/attribute_params_test.rb +1 -1
  120. data/test/misc/calculation_test.rb +1 -1
  121. data/test/misc/configurable_test.rb +1 -1
  122. data/test/misc/constraints_test.rb +2 -1
  123. data/test/misc/convert_numbers_format_test.rb +1 -1
  124. data/test/misc/finder_test.rb +39 -1
  125. data/test/misc/lang_test.rb +1 -1
  126. data/test/misc/parse_datetime_test.rb +1 -1
  127. data/test/misc/tableless_test.rb +1 -1
  128. data/test/test_helper.rb +4 -4
  129. metadata +5 -17
  130. data/config/brakeman.ignore +0 -26
  131. data/config/brakeman.yml +0 -3
  132. data/config/i18n-tasks.yml +0 -121
  133. data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -221
  134. data/lib/active_scaffold/delayed_setup.rb +0 -41
  135. data/lib/active_scaffold/extensions/left_outer_joins.rb +0 -43
@@ -22,7 +22,7 @@ class NumberModel < ActiveRecord::Base
22
22
  end
23
23
  end
24
24
 
25
- class ConvertNumbersFormatTest < MiniTest::Test
25
+ class ConvertNumbersFormatTest < Minitest::Test
26
26
  include ActiveScaffoldConfigMock
27
27
  include ActiveScaffold::AttributeParams
28
28
  include ActiveScaffold::Finder
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
  require 'class_with_finder'
3
3
 
4
- class FinderTest < MiniTest::Test
4
+ class FinderTest < Minitest::Test
5
5
  def setup
6
6
  @klass = ClassWithFinder.new
7
7
  @klass.active_scaffold_config.stubs(model: ModelStub)
@@ -78,6 +78,44 @@ class FinderTest < MiniTest::Test
78
78
  assert_equal ['"people"."adult" = ?', false], ClassWithFinder.condition_for_column(column, '0')
79
79
  end
80
80
 
81
+ def test_condition_for_polymorphic_column
82
+ column = ActiveScaffold::DataStructures::Column.new('addressable', Address)
83
+ column.search_sql = [{subquery: [Building, 'name']}]
84
+ condition = ClassWithFinder.condition_for_column(column, 'test search')
85
+ assert_equal Building.where(['name LIKE ?', '%test search%']).select(:id).to_sql, condition[1].to_sql
86
+ assert_equal '"addresses"."addressable_id" IN (?) AND "addresses"."addressable_type" = ?', condition[0]
87
+ assert_equal ['Building'], condition[2..-1]
88
+ end
89
+
90
+ def test_condition_for_polymorphic_column_with_relation
91
+ column = ActiveScaffold::DataStructures::Column.new('contactable', Contact)
92
+ column.search_sql = [{subquery: [Person.joins(:buildings), 'first_name', 'last_name']}]
93
+ condition = ClassWithFinder.condition_for_column(column, 'test search')
94
+ assert_equal Person.joins(:buildings).where(['first_name LIKE ? OR last_name LIKE ?', '%test search%', '%test search%']).select(:id).to_sql, condition[1].to_sql
95
+ assert_equal '"contacts"."contactable_id" IN (?) AND "contacts"."contactable_type" = ?', condition[0]
96
+ assert_equal ['Person'], condition[2..-1]
97
+ end
98
+
99
+ def test_subquery_condition_for_association_with_condition
100
+ column = ActiveScaffold::DataStructures::Column.new('owner', Building)
101
+ column.search_sql = [{subquery: [Person, 'first_name', 'last_name'], conditions: ['floor_count > 0']}]
102
+ column.search_ui = :text
103
+ condition = ClassWithFinder.condition_for_column(column, 'test search')
104
+ assert_equal Person.where(['first_name LIKE ? OR last_name LIKE ?', '%test search%', '%test search%']).select(:id).to_sql, condition[1].to_sql
105
+ assert_equal '"buildings"."owner_id" IN (?) AND floor_count > 0', condition[0]
106
+ assert_equal [], condition[2..-1]
107
+ end
108
+
109
+ def test_subquery_condition_for_association_with_conditions
110
+ column = ActiveScaffold::DataStructures::Column.new('owner', Building)
111
+ column.search_sql = [{subquery: [Person, 'first_name', 'last_name'], conditions: ['floor_count > 0 AND name != ?', '']}]
112
+ column.search_ui = :text
113
+ condition = ClassWithFinder.condition_for_column(column, 'test search')
114
+ assert_equal Person.where(['first_name LIKE ? OR last_name LIKE ?', '%test search%', '%test search%']).select(:id).to_sql, condition[1].to_sql
115
+ assert_equal '"buildings"."owner_id" IN (?) AND floor_count > 0 AND name != ?', condition[0]
116
+ assert_equal [''], condition[2..-1]
117
+ end
118
+
81
119
  private
82
120
 
83
121
  def relation_class
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class LocalizationTest < MiniTest::Test
3
+ class LocalizationTest < Minitest::Test
4
4
  def test_localization
5
5
  assert_equal 'Dutch', as_(:dutch)
6
6
  assert_equal 'dutch', as_('dutch')
@@ -22,7 +22,7 @@ class DateTimeModel < ActiveRecord::Base
22
22
  end
23
23
  end
24
24
 
25
- class ParseDatetimeTest < MiniTest::Test
25
+ class ParseDatetimeTest < Minitest::Test
26
26
  include ActiveScaffoldConfigMock
27
27
  include ActiveScaffold::AttributeParams
28
28
  include ActiveScaffold::Finder
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class TablelessTest < MiniTest::Test
3
+ class TablelessTest < Minitest::Test
4
4
  def test_find_all
5
5
  assert FileModel.all.to_a.empty?
6
6
  end
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 < MiniTest::Unit::TestCase
35
+ class Minitest::Test < Minitest::Unit::TestCase
36
36
  end
37
37
 
38
- class MiniTest::Unit::TestCase
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 MiniTest::Test
47
+ class Minitest::Test
48
48
  protected
49
49
 
50
50
  def with_js_framework(framework)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.20
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
11
+ date: 2024-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6.2'
19
+ version: 5.2.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 4.2.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6.2'
26
+ version: 5.2.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: cow_proxy
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -195,9 +189,6 @@ files:
195
189
  - app/views/active_scaffold_overrides/update.html.erb
196
190
  - app/views/active_scaffold_overrides/update_column.js.erb
197
191
  - app/views/active_scaffold_overrides/update_row.js.erb
198
- - config/brakeman.ignore
199
- - config/brakeman.yml
200
- - config/i18n-tasks.yml
201
192
  - config/locales/de.yml
202
193
  - config/locales/en.yml
203
194
  - config/locales/es.yml
@@ -273,7 +264,6 @@ files:
273
264
  - lib/active_scaffold/bridges/record_select/helpers.rb
274
265
  - lib/active_scaffold/bridges/semantic_attributes.rb
275
266
  - lib/active_scaffold/bridges/semantic_attributes/column.rb
276
- - lib/active_scaffold/bridges/shared/date_bridge.rb
277
267
  - lib/active_scaffold/bridges/tiny_mce.rb
278
268
  - lib/active_scaffold/bridges/tiny_mce/helpers.rb
279
269
  - lib/active_scaffold/bridges/usa_state_select.rb
@@ -309,7 +299,6 @@ files:
309
299
  - lib/active_scaffold/data_structures/nested_info.rb
310
300
  - lib/active_scaffold/data_structures/set.rb
311
301
  - lib/active_scaffold/data_structures/sorting.rb
312
- - lib/active_scaffold/delayed_setup.rb
313
302
  - lib/active_scaffold/engine.rb
314
303
  - lib/active_scaffold/extensions/action_controller_rendering.rb
315
304
  - lib/active_scaffold/extensions/action_controller_rescueing.rb
@@ -317,7 +306,6 @@ files:
317
306
  - lib/active_scaffold/extensions/connection_adapter.rb
318
307
  - lib/active_scaffold/extensions/cow_proxy.rb
319
308
  - lib/active_scaffold/extensions/ice_nine.rb
320
- - lib/active_scaffold/extensions/left_outer_joins.rb
321
309
  - lib/active_scaffold/extensions/localize.rb
322
310
  - lib/active_scaffold/extensions/name_option_for_datetime.rb
323
311
  - lib/active_scaffold/extensions/paginator_extensions.rb
@@ -470,7 +458,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
470
458
  requirements:
471
459
  - - ">="
472
460
  - !ruby/object:Gem::Version
473
- version: '2.3'
461
+ version: '2.5'
474
462
  required_rubygems_version: !ruby/object:Gem::Requirement
475
463
  requirements:
476
464
  - - ">="
@@ -1,26 +0,0 @@
1
- {
2
- "ignored_warnings": [
3
- {
4
- "warning_type": "Weak Hash",
5
- "warning_code": 90,
6
- "fingerprint": "bca53a490b010fea618ad3791c37086988592b4706fc569f244bca2a3a471bef",
7
- "check_name": "WeakHash",
8
- "message": "Weak hashing algorithm (MD5) used",
9
- "file": "lib/active_scaffold/extensions/action_view_rendering.rb",
10
- "line": 99,
11
- "link": "http://brakemanscanner.org/docs/warning_types/weak_hash/",
12
- "code": "Digest::MD5.hexdigest((params[:controller] + options.to_s))",
13
- "render_path": null,
14
- "location": {
15
- "type": "method",
16
- "class": "ActiveScaffold::RenderingHelper",
17
- "method": "render_embedded"
18
- },
19
- "user_input": "params",
20
- "confidence": "High",
21
- "note": "Hash used for uniquely identify different embedded scaffolds with fixed length id"
22
- }
23
- ],
24
- "updated": "2017-10-18 08:35:45 +0200",
25
- "brakeman_version": "4.0.1"
26
- }
data/config/brakeman.yml DELETED
@@ -1,3 +0,0 @@
1
- ---
2
- :run_all_checks: true
3
- :quiet: true
@@ -1,121 +0,0 @@
1
- # i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
2
-
3
- # The "main" locale.
4
- base_locale: en
5
- ## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
6
- #locales: [en]
7
- ## Reporting locale, default: en. Available: en, ru.
8
- # internal_locale: en
9
-
10
- # Read and write translations.
11
- data:
12
- ## Translations are read from the file system. Supported format: YAML, JSON.
13
- ## Provide a custom adapter:
14
- # adapter: I18n::Tasks::Data::FileSystem
15
-
16
- # Locale files or `File.find` patterns where translations are read from:
17
- read:
18
- ## Default:
19
- - config/locales/%{locale}.yml
20
- ## More files:
21
- # - config/locales/**/*.%{locale}.yml
22
- ## Another gem (replace %#= with %=):
23
- # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
24
-
25
- # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
26
- # `i18n-tasks normalize -p` will force move the keys according to these rules
27
- write:
28
- ## For example, write devise and simple form keys to their respective files:
29
- # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
30
- ## Catch-all default:
31
- # - config/locales/%{locale}.yml
32
-
33
- ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
34
- # router: convervative_router
35
-
36
- yaml:
37
- write:
38
- # do not wrap lines at 80 characters
39
- line_width: -1
40
-
41
- ## Pretty-print JSON:
42
- # json:
43
- # write:
44
- # indent: ' '
45
- # space: ' '
46
- # object_nl: "\n"
47
- # array_nl: "\n"
48
-
49
- # Find translate calls
50
- search:
51
- ## Paths or `File.find` patterns to search in:
52
- paths:
53
- - app/
54
- - lib/
55
-
56
- ## Root directories for relative keys resolution.
57
- # relative_roots:
58
- # - app/controllers
59
- # - app/helpers
60
- # - app/mailers
61
- # - app/presenters
62
- # - app/views
63
-
64
- ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
65
- ## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
66
- exclude:
67
- - app/assets/images
68
- - lib/generators/templates
69
-
70
- ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
71
- ## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
72
- # only: ["*.rb", "*.html.slim"]
73
-
74
- ## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
75
- # strict: true
76
-
77
- ## Multiple scanners can be used. Their results are merged.
78
- ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
79
- ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
80
-
81
- ## Google Translate
82
- # translation:
83
- # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
84
- # api_key: "AbC-dEf5"
85
-
86
- ## Do not consider these keys missing:
87
- ignore_missing:
88
- # translations from rails i18n are used
89
- - date.formats.default
90
- - number.currency.format
91
- - number.format
92
- - number.human.format
93
- - number.percentage.format
94
-
95
- ## Consider these keys used:
96
- ignore_unused:
97
- - 'active_scaffold.*' # used indirectly by the ActiveScaffold
98
-
99
- ## Exclude these keys from the `i18n-tasks eq-base' report:
100
- # ignore_eq_base:
101
- # all:
102
- # - common.ok
103
- # fr,es:
104
- # - common.brand
105
-
106
- ## Ignore these keys completely:
107
- # ignore:
108
- # - kaminari.*
109
-
110
- ## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
111
- ## e.g. in case of a relative key defined in a helper method.
112
- ## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
113
- #
114
- # <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
115
- # only: %w(*.html.haml *.html.slim),
116
- # patterns: [['= title\b', '.page_title']] %>
117
- #
118
- # The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
119
- #
120
- # <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
121
- # patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
@@ -1,221 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- module Shared
4
- module DateBridge
5
- module SearchColumnHelpers
6
- def active_scaffold_search_date_bridge(column, options)
7
- current_search = {'from' => nil, 'to' => nil, 'opt' => 'BETWEEN',
8
- 'number' => 1, 'unit' => 'DAYS', 'range' => nil}
9
- current_search.merge!(options[:value]) unless options[:value].nil?
10
- tags = []
11
- tags << active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
12
- tags << active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
13
- tags << active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
14
- tags << active_scaffold_search_date_bridge_range_tag(column, options, current_search)
15
- safe_join tags, '&nbsp;'.html_safe # rubocop:disable Rails/OutputSafety
16
- end
17
-
18
- def active_scaffold_search_date_bridge_comparator_options(column)
19
- select_options = ActiveScaffold::Finder::DATE_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] }
20
- select_options + ActiveScaffold::Finder::NUMERIC_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] }
21
- end
22
-
23
- def active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
24
- choices = options_for_select(active_scaffold_search_date_bridge_comparator_options(column), current_search['opt'])
25
- select_tag("#{options[:name]}[opt]", choices, :id => "#{options[:id]}_opt", :class => 'as_search_range_option as_search_date_time_option')
26
- end
27
-
28
- def active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
29
- numeric_controls = [
30
- active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from'),
31
- content_tag(:span, safe_join([' - ', active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')]),
32
- :id => "#{options[:id]}_between", :class => 'as_search_range_between',
33
- :style => current_search['opt'] == 'BETWEEN' ? nil : 'display: none')
34
- ]
35
- content_tag('span', safe_join(numeric_controls),
36
- :id => "#{options[:id]}_numeric", :class => 'search-date-numeric',
37
- :style => ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(current_search['opt']) ? nil : 'display: none')
38
- end
39
-
40
- def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
41
- active_scaffold_date_bridge_trend_tag(column, options,
42
- :number_value => current_search['number'],
43
- :unit_value => current_search['unit'],
44
- :show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE'))
45
- end
46
-
47
- def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
48
- trend_controls = [
49
- text_field_tag("#{options[:name]}[number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off'),
50
- select_tag("#{options[:name]}[unit]",
51
- options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
52
- :class => 'text-input')
53
- ]
54
- content_tag('span', safe_join(trend_controls, ' '),
55
- :id => "#{options[:id]}_trend", :class => 'search-date-trend',
56
- :style => trend_options[:show] ? nil : 'display: none')
57
- end
58
-
59
- def active_scaffold_search_date_bridge_trend_units(column)
60
- options = ActiveScaffold::Finder::DATE_UNITS.collect { |unit| [as_(unit.downcase.to_sym), unit] }
61
- options = ActiveScaffold::Finder::TIME_UNITS.collect { |unit| [as_(unit.downcase.to_sym), unit] } + options if column_datetime?(column)
62
- options
63
- end
64
-
65
- def active_scaffold_search_date_bridge_range_tag(column, options, current_search)
66
- values = ActiveScaffold::Finder::DATE_RANGES.collect { |range| [as_(range.downcase.to_sym), range] }
67
- range_controls = select_tag("#{options[:name]}[range]",
68
- options_for_select(values, current_search['range']),
69
- :class => 'text-input', :id => nil)
70
- content_tag('span', range_controls,
71
- :id => "#{options[:id]}_range", :class => 'search-date-range',
72
- :style => ('display: none' unless current_search['opt'] == 'RANGE'))
73
- end
74
-
75
- def column_datetime?(column)
76
- (!column.column.nil? && %i[datetime time].include?(column.column.type))
77
- end
78
- end
79
-
80
- module HumanConditionHelpers
81
- def active_scaffold_human_condition_date_bridge(column, value)
82
- case value['opt']
83
- when 'RANGE'
84
- range_type, range = value['range'].downcase.split('_')
85
- format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
86
- from, = controller.class.date_bridge_from_to(column, value)
87
- "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value['range'].downcase).downcase} (#{I18n.l(from, :format => format)})"
88
- when 'PAST', 'FUTURE'
89
- from, to = controller.class.date_bridge_from_to(column, value)
90
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
91
- else
92
- from, to = controller.class.date_bridge_from_to(column, value)
93
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value['opt'].downcase).downcase} #{I18n.l(from)} #{value['opt'] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
94
- end
95
- end
96
-
97
- def active_scaffold_human_condition_date_bridge_range_format(range_type, range)
98
- case range
99
- when 'week'
100
- first_day_of_week = I18n.translate 'active_scaffold.date_picker_options.firstDay'
101
- if first_day_of_week == 1
102
- '%W %Y'
103
- else
104
- '%U %Y'
105
- end
106
- when 'month'
107
- '%b %Y'
108
- when 'year'
109
- '%Y'
110
- else
111
- I18n.translate 'date.formats.default'
112
- end
113
- end
114
- end
115
-
116
- module Finder
117
- module ClassMethods
118
- def condition_for_date_bridge_type(column, value, like_pattern)
119
- operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value['opt']) && value['opt'] != 'BETWEEN' ? value['opt'] : nil
120
- from_value, to_value = date_bridge_from_to(column, value)
121
-
122
- if column.search_sql.is_a? Proc
123
- column.search_sql.call(from_value, to_value, operator)
124
- elsif operator.nil?
125
- ['%<search_sql>s BETWEEN ? AND ?', from_value, to_value] unless from_value.nil? || to_value.nil?
126
- else
127
- ["%<search_sql>s #{value['opt']} ?", from_value] unless from_value.nil?
128
- end
129
- end
130
-
131
- def date_bridge_from_to(column, value)
132
- conversion = datetime_conversion_for_condition(column)
133
- case value['opt']
134
- when 'RANGE'
135
- values = date_bridge_from_to_for_range(column, value)
136
- # Avoid calling to_time, not needed and broken on rails >= 4, because return local time instead of UTC
137
- values.collect!(&conversion) if conversion != :to_time
138
- values
139
- when 'PAST', 'FUTURE'
140
- values = date_bridge_from_to_for_trend(column, value)
141
- # Avoid calling to_time, not needed and broken on rails >= 4, because return local time instead of UTC
142
- values.collect!(&conversion) if conversion != :to_time
143
- values
144
- else
145
- %w[from to].collect { |field| condition_value_for_datetime(column, value[field], conversion) }
146
- end
147
- end
148
-
149
- def date_bridge_now
150
- Time.zone.now
151
- end
152
-
153
- def date_bridge_from_to_for_trend(column, value)
154
- case value['opt']
155
- when 'PAST'
156
- trend_number = [value['number'].to_i, 1].max
157
- now = date_bridge_now
158
- if date_bridge_column_date?(column)
159
- from = now.beginning_of_day.ago(trend_number.send(value['unit'].downcase.singularize.to_sym))
160
- to = now.end_of_day
161
- else
162
- from = now.ago(trend_number.send(value['unit'].downcase.singularize.to_sym))
163
- to = now
164
- end
165
- [from, to]
166
- when 'FUTURE'
167
- trend_number = [value['number'].to_i, 1].max
168
- now = date_bridge_now
169
- if date_bridge_column_date?(column)
170
- from = now.beginning_of_day
171
- to = now.end_of_day.in(trend_number.send(value['unit'].downcase.singularize.to_sym))
172
- else
173
- from = now
174
- to = now.in(trend_number.send(value['unit'].downcase.singularize.to_sym))
175
- end
176
- [from, to]
177
- end
178
- end
179
-
180
- def date_bridge_from_to_for_range(column, value)
181
- case value['range']
182
- when 'TODAY'
183
- [date_bridge_now.beginning_of_day, date_bridge_now.end_of_day]
184
- when 'YESTERDAY'
185
- [date_bridge_now.ago(1.day).beginning_of_day, date_bridge_now.ago(1.day).end_of_day]
186
- when 'TOMORROW'
187
- [date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day]
188
- else
189
- range_type, range = value['range'].downcase.split('_')
190
- raise ArgumentError unless %w[week month year].include?(range)
191
- case range_type
192
- when 'this'
193
- return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
194
- when 'prev'
195
- return date_bridge_now.ago(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.ago(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
196
- when 'next'
197
- return date_bridge_now.in(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.in(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
198
- else
199
- return nil, nil
200
- end
201
- end
202
- end
203
-
204
- def date_bridge_column_date?(column)
205
- if %i[date_picker datetime_picker].include? column.form_ui
206
- column.form_ui == :date_picker
207
- else
208
- (!column.column.nil? && [:date].include?(column.column.type))
209
- end
210
- end
211
- end
212
- end
213
- end
214
- end
215
- end
216
- end
217
-
218
- ActiveScaffold::Finder.const_set('DATE_COMPARATORS', %w[PAST FUTURE RANGE])
219
- ActiveScaffold::Finder.const_set('DATE_UNITS', %w[DAYS WEEKS MONTHS YEARS])
220
- ActiveScaffold::Finder.const_set('TIME_UNITS', %w[SECONDS MINUTES HOURS])
221
- ActiveScaffold::Finder.const_set('DATE_RANGES', %w[TODAY YESTERDAY TOMORROW THIS_WEEK PREV_WEEK NEXT_WEEK THIS_MONTH PREV_MONTH NEXT_MONTH THIS_YEAR PREV_YEAR NEXT_YEAR])
@@ -1,41 +0,0 @@
1
- module ActiveScaffold
2
- module DelayedSetup
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- def process(*)
8
- self.class.config_active_scaffold_delayed
9
- super
10
- end
11
-
12
- module ClassMethods
13
- def active_scaffold(model_id = nil, &block)
14
- @delayed_monitor ||= Monitor.new
15
- @active_scaffold_delayed = proc do
16
- begin
17
- @_prefixes = nil # clean prefixes in case is already cached, so our local_prefixes override is picked up
18
- super(model_id, &block)
19
- @active_scaffold_delayed = @delayed_monitor = nil # after configuring, no need to keep proc or monitor
20
- rescue StandardError
21
- # clear config variable if failed, so next request tries again
22
- @active_scaffold_config = nil
23
- raise
24
- end
25
- end
26
- end
27
-
28
- def config_active_scaffold_delayed
29
- @delayed_monitor&.synchronize do
30
- # if called in same thread while running config, do nothing
31
- @active_scaffold_delayed&.call unless @active_scaffold_config
32
- end
33
- end
34
-
35
- def active_scaffold_config
36
- config_active_scaffold_delayed
37
- super
38
- end
39
- end
40
- end
41
- end
@@ -1,43 +0,0 @@
1
- if Rails.version < '5.0.0'
2
- module ActiveScaffold
3
- module OuterJoins
4
- extend ActiveSupport::Concern
5
-
6
- def left_outer_joins_values
7
- @values[:left_outer_joins] || []
8
- end
9
-
10
- def left_outer_joins_values=(values)
11
- raise ImmutableRelation if @loaded
12
- @values[:left_outer_joins] = values
13
- end
14
-
15
- def left_outer_joins(*args)
16
- check_if_method_has_arguments!('left_outer_joins', args)
17
- spawn.left_outer_joins!(*args.compact.flatten)
18
- end
19
- alias left_joins left_outer_joins
20
-
21
- def left_outer_joins!(*args)
22
- self.joins_values += [''] # HACK: for using left_outer_joins in update_all/delete_all
23
- self.left_outer_joins_values += args
24
- self
25
- end
26
- alias left_joins! left_outer_joins!
27
-
28
- def build_arel
29
- if left_outer_joins_values.empty?
30
- super
31
- else
32
- relation = except(:left_outer_joins)
33
- relation.joins! ActiveRecord::Associations::JoinDependency.new(@klass, left_outer_joins_values, [])
34
- relation.build_arel
35
- end
36
- end
37
- end
38
- end
39
- ActiveRecord::Relation.send :include, ActiveScaffold::OuterJoins
40
- module ActiveRecord::Querying
41
- delegate :left_outer_joins, :left_joins, :to => :all
42
- end
43
- end