eac_rails_utils 0.8.0 → 0.11.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 +4 -4
- data/Rakefile +2 -0
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper.rb +8 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder.rb +12 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/association_select_field.rb +5 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/common_text_fields.rb +4 -3
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/currency_field.rb +14 -12
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/date_field.rb +3 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/fields_for.rb +3 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/file_field.rb +2 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/radio_select_field.rb +5 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/searchable_association_field.rb +7 -3
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/select_field.rb +3 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/time_field.rb +2 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/year_month_field.rb +2 -1
- data/app/helpers/eac_rails_utils/data_table_helper.rb +13 -0
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/column.rb +6 -3
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/data_table.rb +13 -11
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/setup.rb +3 -2
- data/app/helpers/eac_rails_utils/formatter_helper.rb +2 -0
- data/app/helpers/eac_rails_utils/links_helper.rb +12 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper.rb +10 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/bootstrap_gui_builder.rb +8 -5
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/data_builder.rb +7 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/gui_builder.rb +6 -3
- data/app/helpers/eac_rails_utils/open_graph_protocol_helper.rb +2 -0
- data/{lib/eac → app/validators/eac_rails_utils}/cpf_validator.rb +8 -4
- data/{lib/eac → app/validators/eac_rails_utils}/no_presence_validator.rb +3 -3
- data/lib/assets/javascripts/jMenu.jquery.min.js +12 -12
- data/lib/eac_rails_utils.rb +3 -41
- data/lib/eac_rails_utils/engine.rb +3 -0
- data/lib/{eac → eac_rails_utils}/htmlbeautifier.rb +3 -1
- data/lib/eac_rails_utils/models.rb +9 -0
- data/lib/eac_rails_utils/models/attribute_required.rb +43 -0
- data/lib/eac_rails_utils/models/fetch_errors.rb +92 -0
- data/lib/eac_rails_utils/models/inequality_queries.rb +39 -0
- data/lib/eac_rails_utils/models/tableless.rb +97 -0
- data/lib/eac_rails_utils/models/test_utils.rb +65 -0
- data/lib/eac_rails_utils/patches.rb +9 -0
- data/lib/eac_rails_utils/patches/action_controller_base.rb +3 -0
- data/lib/eac_rails_utils/version.rb +2 -1
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/models/job.rb +2 -0
- data/test/dummy/app/models/user.rb +6 -0
- data/test/dummy/config.ru +2 -0
- data/test/dummy/config/application.rb +3 -1
- data/test/dummy/config/boot.rb +3 -1
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/test.rb +2 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/db/migrate/20160415125333_create_users.rb +2 -0
- data/test/dummy/db/migrate/20160415143123_create_jobs.rb +2 -0
- data/test/dummy/db/migrate/20160415143229_add_job_to_users.rb +2 -0
- data/test/{lib/eac → helpers/eac_rails_utils}/common_form_helper_test.rb +4 -2
- data/test/{lib/eac/data_table_test_helper.rb → helpers/eac_rails_utils/data_table_test_helper_test.rb} +4 -3
- data/test/{app/helpers → helpers}/eac_rails_utils/formatter_helper_test.rb +1 -0
- data/test/lib/eac_rails_utils/{patches/model_attribute_required_test.rb → models/attribute_required_test.rb} +3 -0
- data/test/lib/eac_rails_utils/models/fetch_errors_test.rb +80 -0
- data/test/lib/eac_rails_utils/models/tableless_test.rb +25 -0
- data/test/test_helper.rb +3 -1
- data/test/{lib/eac → validators}/cpf_validator_test.rb +4 -2
- metadata +91 -98
- data/lib/eac/data_table_helper.rb +0 -12
- data/lib/eac/inequality_queries.rb +0 -36
- data/lib/eac/model.rb +0 -87
- data/lib/eac/parsers/files_test.rb +0 -63
- data/lib/eac/source_target_fixtures.rb +0 -66
- data/lib/eac/test_utils.rb +0 -56
- data/lib/eac_rails_utils/patches/model_attribute_required.rb +0 -31
- data/lib/eac_rails_utils/patches/ofx_parser.rb +0 -42
- data/lib/eac_rails_utils/tableless_model.rb +0 -90
- data/test/lib/eac/model_test.rb +0 -76
- data/test/lib/eac/parsers/files_test_test.rb +0 -27
- data/test/lib/eac/parsers/ok_test_files/a.source.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/a.target.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/b.source.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/b.target.yaml +0 -1
- data/test/lib/eac/source_target_fixtures_test.rb +0 -41
- data/test/lib/eac/source_target_fixtures_test_files/a.source.html +0 -1
- data/test/lib/eac/source_target_fixtures_test_files/a.target.yaml +0 -1
- data/test/lib/eac/source_target_fixtures_test_files/b.source.html +0 -1
- data/test/lib/eac/source_target_fixtures_test_files/c.target.yaml +0 -1
- data/test/lib/eac_rails_utils/tableless_model_test.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fdc60e761e13bcdf41dd921a5501fa3d6e4e372f3d3c2af48eef03a3f7bee723
|
|
4
|
+
data.tar.gz: 6121db8bfd8023c7360fea7d7f40c159a8411462970b37705e3d5c0217e8238f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5171b49a17923a648dc8a94b45d4386f1aec8c9079941da2ff66744347b07bc46ab6f64f42c0a46475fb258fa41fe78e755a8d0d1140497fafd10e19cbbfe902
|
|
7
|
+
data.tar.gz: 486f7961912a84ee2cc74ff6b91c13e9c19364a42b41ee75af835a6cda82fed07c097bf9ba15007f0207eb9f6f986a84fa329c3be87b0b6776dfe147f14a7bb7
|
data/Rakefile
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
|
4
|
+
|
|
5
|
+
module EacRailsUtils
|
|
2
6
|
module CommonFormHelper
|
|
7
|
+
::EacRubyUtils.require_sub __FILE__
|
|
8
|
+
|
|
3
9
|
def common_form(model_instance, options = {}, &block)
|
|
4
10
|
submit_label = options.delete(:submit_label)
|
|
5
11
|
options[:html] ||= {}
|
|
@@ -29,6 +35,7 @@ module Eac
|
|
|
29
35
|
s = ActiveSupport::SafeBuffer.new
|
|
30
36
|
model_instance.errors.each do |k, v|
|
|
31
37
|
next if field_errors_showed.include?(k)
|
|
38
|
+
|
|
32
39
|
s << content_tag(:div, "#{k}: #{v}", class: 'error')
|
|
33
40
|
end
|
|
34
41
|
s
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
|
4
|
+
require 'eac_rails_utils/models/attribute_required'
|
|
5
|
+
|
|
6
|
+
module EacRailsUtils
|
|
3
7
|
module CommonFormHelper
|
|
4
8
|
class FormBuilder
|
|
9
|
+
::EacRubyUtils.require_sub __FILE__
|
|
10
|
+
|
|
5
11
|
include AssociationSelectField
|
|
6
12
|
include CommonTextFields
|
|
7
13
|
include CurrencyField
|
|
@@ -67,6 +73,7 @@ module Eac
|
|
|
67
73
|
|
|
68
74
|
def field_errors_errors(field_name)
|
|
69
75
|
return nil unless model_instance.errors.messages[field_name]
|
|
76
|
+
|
|
70
77
|
s = ActiveSupport::SafeBuffer.new
|
|
71
78
|
model_instance.errors.messages[field_name].each { |error| s << field_error(error) }
|
|
72
79
|
@field_errors_showed.add(field_name)
|
|
@@ -85,7 +92,10 @@ module Eac
|
|
|
85
92
|
end
|
|
86
93
|
|
|
87
94
|
def field_label(field_name, label, required)
|
|
88
|
-
|
|
95
|
+
if required.nil?
|
|
96
|
+
required = ::EacRailsUtils::Models::AttributeRequired
|
|
97
|
+
.required?(model_instance, field_name)
|
|
98
|
+
end
|
|
89
99
|
@form.label(field_name, label, class: required ? 'required' : 'optional')
|
|
90
100
|
end
|
|
91
101
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
2
4
|
module CommonFormHelper
|
|
3
5
|
class FormBuilder
|
|
4
6
|
module AssociationSelectField
|
|
@@ -31,7 +33,8 @@ module Eac
|
|
|
31
33
|
if model_instance.class.respond_to?(:reflect_on_association)
|
|
32
34
|
return model_instance.class.reflect_on_association(field_name).send(method)
|
|
33
35
|
end
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
raise "#{model_instance.class} não possui um método \"reflect_on_association\". " \
|
|
35
38
|
"Defina explicitamente a opção :#{key}"
|
|
36
39
|
end
|
|
37
40
|
end
|
data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/common_text_fields.rb
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
3
4
|
module CommonFormHelper
|
|
4
5
|
class FormBuilder
|
|
5
6
|
module CommonTextFields
|
|
6
|
-
%w
|
|
7
|
+
%w[email password text].each do |t|
|
|
7
8
|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
|
8
9
|
def #{t}_field(field_name, options = {}) # def text_field(field_name, options = {})
|
|
9
10
|
field(field_name, options) do # field(field_name, options) do
|
|
@@ -13,7 +14,7 @@ module Eac
|
|
|
13
14
|
input_options) # class: 'form-control')
|
|
14
15
|
end # end
|
|
15
16
|
end # end
|
|
16
|
-
|
|
17
|
+
RUBY_EVAL
|
|
17
18
|
end
|
|
18
19
|
end
|
|
19
20
|
end
|
data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/currency_field.rb
RENAMED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
2
4
|
module CommonFormHelper
|
|
3
5
|
class FormBuilder
|
|
4
6
|
module CurrencyField
|
|
@@ -7,8 +9,8 @@ module Eac
|
|
|
7
9
|
visible_id = SecureRandom.hex(5)
|
|
8
10
|
cf = field(field_name, options) do
|
|
9
11
|
form.hidden_field(field_name, id: hidden_id) <<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
helper.text_field_tag("#{field_name}_visible", '',
|
|
13
|
+
id: visible_id, class: 'form-control')
|
|
12
14
|
end
|
|
13
15
|
cf << javascript_currency_mask(hidden_id, visible_id)
|
|
14
16
|
end
|
|
@@ -23,15 +25,15 @@ module Eac
|
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def mask_money_options
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
28
|
+
<<~JSON_CODE
|
|
29
|
+
{
|
|
30
|
+
prefix: '#{I18n.t('number.currency.format.unit')} ',
|
|
31
|
+
allowNegative: true,
|
|
32
|
+
thousands: '#{I18n.t('number.currency.format.delimiter')}',
|
|
33
|
+
decimal: '#{I18n.t('number.currency.format.separator')}',
|
|
34
|
+
affixesStay: false
|
|
35
|
+
}
|
|
36
|
+
JSON_CODE
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
end
|
data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/radio_select_field.rb
RENAMED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
2
4
|
module CommonFormHelper
|
|
3
5
|
class FormBuilder
|
|
4
6
|
module RadioSelectField
|
|
@@ -35,7 +37,8 @@ module Eac
|
|
|
35
37
|
if model_instance.class.respond_to?(:reflect_on_association)
|
|
36
38
|
return model_instance.class.reflect_on_association(field_name).send(method)
|
|
37
39
|
end
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
raise "#{model_instance.class} não possui um método \"reflect_on_association\". " \
|
|
39
42
|
"Defina explicitamente a opção :#{key}"
|
|
40
43
|
end
|
|
41
44
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
2
4
|
module CommonFormHelper
|
|
3
5
|
class FormBuilder
|
|
4
6
|
class SearchableAssociationField
|
|
@@ -42,17 +44,19 @@ module Eac
|
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def association_column
|
|
45
|
-
@form_builder.model_instance
|
|
47
|
+
@form_builder.model_instance&.send(@field_name)
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
def initial_id
|
|
49
51
|
return association_column.id if association_column
|
|
52
|
+
|
|
50
53
|
''
|
|
51
54
|
end
|
|
52
55
|
|
|
53
56
|
def initial_label
|
|
54
57
|
return association_column.to_s if association_column
|
|
55
58
|
return params[visible_input_name] if params.key?(visible_input_name)
|
|
59
|
+
|
|
56
60
|
''
|
|
57
61
|
end
|
|
58
62
|
|
|
@@ -66,7 +70,7 @@ module Eac
|
|
|
66
70
|
|
|
67
71
|
def json_options
|
|
68
72
|
r = {}
|
|
69
|
-
[
|
|
73
|
+
%i[hidden_input_id visible_input_id initial_id initial_label url].each do |k|
|
|
70
74
|
r[k] = send(k)
|
|
71
75
|
end
|
|
72
76
|
r.to_json
|
data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/select_field.rb
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
3
4
|
module CommonFormHelper
|
|
4
5
|
class FormBuilder
|
|
5
6
|
module SelectField
|
|
@@ -19,6 +20,7 @@ module Eac
|
|
|
19
20
|
def listable_select_options(field_name)
|
|
20
21
|
return nil unless model_instance.class.respond_to?(:lists)
|
|
21
22
|
return nil unless model_instance.class.lists.respond_to?(field_name)
|
|
23
|
+
|
|
22
24
|
model_instance.class.lists.send(field_name).options
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
|
4
|
+
|
|
5
|
+
module EacRailsUtils
|
|
6
|
+
module DataTableHelper
|
|
7
|
+
::EacRubyUtils.require_sub __FILE__
|
|
8
|
+
|
|
9
|
+
def data_table(dataset, &block)
|
|
10
|
+
::EacRailsUtils::DataTableHelper::DataTable.new(self, dataset, &block).output
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
3
4
|
module DataTableHelper
|
|
4
5
|
class Column
|
|
5
6
|
EMPTY_VALUE = '-'
|
|
@@ -12,8 +13,8 @@ module Eac
|
|
|
12
13
|
@block = block
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def record_value(
|
|
16
|
-
v = Node.new(
|
|
16
|
+
def record_value(record)
|
|
17
|
+
v = Node.new(record, @path).value
|
|
17
18
|
if v.present?
|
|
18
19
|
@block ? @block.call(v) : v
|
|
19
20
|
else
|
|
@@ -35,9 +36,11 @@ module Eac
|
|
|
35
36
|
|
|
36
37
|
def value
|
|
37
38
|
return @node if @node.nil? || @path.empty?
|
|
39
|
+
|
|
38
40
|
subpath = @path.dup
|
|
39
41
|
n = subpath.shift
|
|
40
42
|
return Node.new(@node.send(n), subpath).value if @node.respond_to?(n)
|
|
43
|
+
|
|
41
44
|
raise "Instance of #{@node.class} does not respond to #{n}"
|
|
42
45
|
end
|
|
43
46
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module EacRailsUtils
|
|
4
4
|
module DataTableHelper
|
|
5
5
|
class DataTable
|
|
6
6
|
def initialize(view, dataset)
|
|
7
7
|
@view = view
|
|
8
8
|
@dataset = dataset
|
|
9
|
-
@setup = ::
|
|
9
|
+
@setup = ::EacRailsUtils::DataTableHelper::Setup.new
|
|
10
10
|
yield(@setup)
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -32,20 +32,22 @@ module Eac
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def row(
|
|
35
|
+
def row(record)
|
|
36
36
|
@view.content_tag(:tr) do
|
|
37
|
-
@view.safe_join(
|
|
37
|
+
@view.safe_join(
|
|
38
|
+
@setup.columns.map { |c| @view.content_tag('td', c.record_value(record)) << "\n" }
|
|
39
|
+
)
|
|
38
40
|
end << "\n"
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
def script
|
|
42
|
-
@view.javascript_tag
|
|
43
|
-
$(document).ready(function () {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
@view.javascript_tag <<~JS_CODE
|
|
45
|
+
$(document).ready(function () {
|
|
46
|
+
$('##{id}').DataTable({
|
|
47
|
+
paging: #{@setup.paging ? 'true' : 'false'}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
JS_CODE
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def id
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
module EacRailsUtils
|
|
3
4
|
module DataTableHelper
|
|
4
5
|
class Setup
|
|
5
6
|
attr_reader :columns
|
|
@@ -11,7 +12,7 @@ module Eac
|
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def column(label, path = nil, &block)
|
|
14
|
-
@columns << ::
|
|
15
|
+
@columns << ::EacRailsUtils::DataTableHelper::Column.new(label, path, block)
|
|
15
16
|
end
|
|
16
17
|
end
|
|
17
18
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
module EacRailsUtils
|
|
3
4
|
module FormatterHelper
|
|
4
5
|
extend ::ActiveSupport::Concern
|
|
@@ -10,6 +11,7 @@ module EacRailsUtils
|
|
|
10
11
|
def value_or_sign(value, sign = '-', &block)
|
|
11
12
|
return sign if value.blank?
|
|
12
13
|
return yield(value) if block
|
|
14
|
+
|
|
13
15
|
value
|
|
14
16
|
end
|
|
15
17
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
module EacRailsUtils
|
|
3
4
|
module LinksHelper
|
|
4
5
|
def short_delete_link(object)
|
|
@@ -20,7 +21,8 @@ module EacRailsUtils
|
|
|
20
21
|
def short_goto_link(url)
|
|
21
22
|
value_or_sign(url, '') do |value|
|
|
22
23
|
link_to '', value, class: 'goto_link', target: '_blank',
|
|
23
|
-
title: ::I18n.t('eac_rails_base0.links.goto_url', url: value.to_s)
|
|
24
|
+
title: ::I18n.t('eac_rails_base0.links.goto_url', url: value.to_s),
|
|
25
|
+
rel: 'noopener'
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
|
|
@@ -33,11 +35,12 @@ module EacRailsUtils
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def object_path(object, action = nil)
|
|
36
|
-
current_class = object
|
|
38
|
+
current_class = object_class(object)
|
|
37
39
|
tried_paths = []
|
|
38
40
|
while current_class
|
|
39
41
|
path = object_path_by_class(current_class, action)
|
|
40
42
|
return send(path, object) if respond_to?(path)
|
|
43
|
+
|
|
41
44
|
tried_paths << path
|
|
42
45
|
current_class = current_class.superclass
|
|
43
46
|
end
|
|
@@ -65,5 +68,12 @@ module EacRailsUtils
|
|
|
65
68
|
path = "#{action}_#{path}" if action.present?
|
|
66
69
|
path
|
|
67
70
|
end
|
|
71
|
+
|
|
72
|
+
def object_class(object)
|
|
73
|
+
return object.entity_class if object.respond_to?(:entity_class)
|
|
74
|
+
return object.__getobj__.class if object.respond_to?(:__getobj__)
|
|
75
|
+
|
|
76
|
+
object.class
|
|
77
|
+
end
|
|
68
78
|
end
|
|
69
79
|
end
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
|
4
|
+
|
|
5
|
+
module EacRailsUtils
|
|
2
6
|
module MenusHelper
|
|
7
|
+
::EacRubyUtils.require_sub __FILE__
|
|
8
|
+
|
|
3
9
|
def dropdown_menu(entries)
|
|
4
10
|
entries = DataBuilder.new(self).build(entries)
|
|
5
11
|
return nil unless entries
|
|
12
|
+
|
|
6
13
|
id = SecureRandom.hex(5)
|
|
7
14
|
GuiBuilder.new(self).build(entries, id: id, class: 'jMenu') <<
|
|
8
|
-
|
|
15
|
+
javascript_tag("$(document).ready(function(){$('\##{id}').jMenu();});")
|
|
9
16
|
end
|
|
10
17
|
|
|
11
18
|
def bootstrap_dropdown_menu(entries, options = {})
|
|
12
19
|
entries = DataBuilder.new(self).build(entries)
|
|
13
20
|
return nil unless entries
|
|
21
|
+
|
|
14
22
|
BootstrapGuiBuilder.new(self, options).build(entries)
|
|
15
23
|
end
|
|
16
24
|
end
|