eac_rails_utils 0.10.1 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper.rb +5 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder.rb +10 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/association_select_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/common_text_fields.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/currency_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/date_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/fields_for.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/file_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/radio_select_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/searchable_association_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/select_field.rb +3 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/time_field.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/year_month_field.rb +1 -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 +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/data_table.rb +2 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/setup.rb +2 -2
- data/app/helpers/eac_rails_utils/links_helper.rb +5 -5
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper.rb +5 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/bootstrap_gui_builder.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/data_builder.rb +1 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/gui_builder.rb +1 -1
- data/{lib/eac → app/validators/eac_rails_utils}/cpf_validator.rb +1 -1
- data/{lib/eac → app/validators/eac_rails_utils}/no_presence_validator.rb +1 -1
- data/config/locales/en.yml +8 -0
- data/config/locales/pt-BR.yml +8 -0
- data/lib/eac_rails_utils.rb +2 -39
- data/lib/eac_rails_utils/engine.rb +2 -0
- data/lib/{eac → eac_rails_utils}/htmlbeautifier.rb +1 -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 +2 -0
- data/lib/eac_rails_utils/patches/active_model_associations.rb +40 -0
- data/lib/eac_rails_utils/version.rb +1 -1
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/models/user.rb +4 -0
- data/test/dummy/config/application.rb +1 -1
- data/test/{lib/eac → helpers/eac_rails_utils}/common_form_helper_test.rb +2 -2
- data/test/{lib/eac → helpers/eac_rails_utils}/data_table_test_helper_test.rb +2 -2
- data/test/{app/helpers → helpers}/eac_rails_utils/formatter_helper_test.rb +0 -0
- data/test/lib/eac_rails_utils/{patches/model_attribute_required_test.rb → models/attribute_required_test.rb} +1 -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/{lib/eac → validators}/cpf_validator_test.rb +2 -2
- metadata +69 -66
- data/lib/eac/data_table_helper.rb +0 -13
- data/lib/eac/inequality_queries.rb +0 -37
- data/lib/eac/model.rb +0 -90
- data/lib/eac/test_utils.rb +0 -61
- data/lib/eac_rails_utils/patches/model_attribute_required.rb +0 -34
- data/lib/eac_rails_utils/patches/ofx_parser.rb +0 -43
- data/lib/eac_rails_utils/tableless_model.rb +0 -92
- data/test/lib/eac/model_test.rb +0 -78
- 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: 07d2a7ca43c5129fbcb1bc6e6e1359583dfde2e49fd98ee7e13e643121e19638
|
4
|
+
data.tar.gz: 3157833b02da72112a981c2cd526a7d102fff2fb55c6b567fbae4645365bd523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c6dd756b2569913fafee714f74c77b51d6d2f7e7814a234c9c60aec4b53d5c2a720a5844677a1012e8765a3d5b8e769e946088766a99a75a2cccf3c21884ad
|
7
|
+
data.tar.gz: 6ed6ec289d5c4bb3b9c01d732323ad4d0c9901e97c59904f552b1a052ddec63593c3be60c78374c44c4e94251e37e91c7212979369c09560981afd1e73730355
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
5
|
+
module EacRailsUtils
|
4
6
|
module CommonFormHelper
|
7
|
+
::EacRubyUtils.require_sub __FILE__
|
8
|
+
|
5
9
|
def common_form(model_instance, options = {}, &block)
|
6
10
|
submit_label = options.delete(:submit_label)
|
7
11
|
options[:html] ||= {}
|
@@ -1,8 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
require 'eac_rails_utils/models/attribute_required'
|
5
|
+
|
6
|
+
module EacRailsUtils
|
4
7
|
module CommonFormHelper
|
5
8
|
class FormBuilder
|
9
|
+
::EacRubyUtils.require_sub __FILE__
|
10
|
+
|
6
11
|
include AssociationSelectField
|
7
12
|
include CommonTextFields
|
8
13
|
include CurrencyField
|
@@ -87,7 +92,10 @@ module Eac
|
|
87
92
|
end
|
88
93
|
|
89
94
|
def field_label(field_name, label, required)
|
90
|
-
|
95
|
+
if required.nil?
|
96
|
+
required = ::EacRailsUtils::Models::AttributeRequired
|
97
|
+
.required?(model_instance, field_name)
|
98
|
+
end
|
91
99
|
@form.label(field_name, label, class: required ? 'required' : 'optional')
|
92
100
|
end
|
93
101
|
end
|
data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/select_field.rb
RENAMED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module EacRailsUtils
|
4
4
|
module CommonFormHelper
|
5
5
|
class FormBuilder
|
6
6
|
module SelectField
|
7
7
|
def select_field(field_name, options = {})
|
8
8
|
options = options.dup
|
9
9
|
field(field_name, options) do
|
10
|
-
form.select(field_name, select_options(field_name, options)
|
10
|
+
form.select(field_name, select_options(field_name, options),
|
11
|
+
options, options[:html] || {})
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -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,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
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module EacRailsUtils
|
4
4
|
module DataTableHelper
|
5
5
|
class Setup
|
6
6
|
attr_reader :columns
|
@@ -12,7 +12,7 @@ module Eac
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def column(label, path = nil, &block)
|
15
|
-
@columns << ::
|
15
|
+
@columns << ::EacRailsUtils::DataTableHelper::Column.new(label, path, block)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -4,24 +4,24 @@ module EacRailsUtils
|
|
4
4
|
module LinksHelper
|
5
5
|
def short_delete_link(object)
|
6
6
|
short_object_link object, '', class: 'delete_link', method: :delete, target: '_blank',
|
7
|
-
title: ::I18n.t('
|
7
|
+
title: ::I18n.t('eac_rails_utils.links.delete_object',
|
8
8
|
label: object.to_s),
|
9
9
|
data: {
|
10
|
-
confirm: ::I18n.t('
|
10
|
+
confirm: ::I18n.t('eac_rails_utils.links.delete_confirm',
|
11
11
|
label: object.to_s)
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
15
|
def short_edit_link(object)
|
16
16
|
short_object_link object, 'edit', class: 'edit_link', target: '_blank',
|
17
|
-
title: ::I18n.t('
|
17
|
+
title: ::I18n.t('eac_rails_utils.links.edit_object',
|
18
18
|
label: object.to_s)
|
19
19
|
end
|
20
20
|
|
21
21
|
def short_goto_link(url)
|
22
22
|
value_or_sign(url, '') do |value|
|
23
23
|
link_to '', value, class: 'goto_link', target: '_blank',
|
24
|
-
title: ::I18n.t('
|
24
|
+
title: ::I18n.t('eac_rails_utils.links.goto_url', url: value.to_s),
|
25
25
|
rel: 'noopener'
|
26
26
|
end
|
27
27
|
end
|
@@ -54,7 +54,7 @@ module EacRailsUtils
|
|
54
54
|
short_object_link object,
|
55
55
|
detail ? 'detail' : nil,
|
56
56
|
class: 'show_link', target: '_blank',
|
57
|
-
title: ::I18n.t('
|
57
|
+
title: ::I18n.t('eac_rails_utils.links.show_object', label: object.to_s)
|
58
58
|
end
|
59
59
|
|
60
60
|
def short_object_link(object, action = nil, options = {})
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
5
|
+
module EacRailsUtils
|
4
6
|
module MenusHelper
|
7
|
+
::EacRubyUtils.require_sub __FILE__
|
8
|
+
|
5
9
|
def dropdown_menu(entries)
|
6
10
|
entries = DataBuilder.new(self).build(entries)
|
7
11
|
return nil unless entries
|
data/lib/eac_rails_utils.rb
CHANGED
@@ -1,44 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
4
|
|
5
5
|
module EacRailsUtils
|
6
|
-
|
7
|
-
require 'nested_form_fields'
|
8
|
-
require 'ofx-parser'
|
9
|
-
require 'virtus'
|
10
|
-
|
11
|
-
require 'eac_rails_utils/patches/action_controller_base'
|
12
|
-
require 'eac_rails_utils/patches/model_attribute_required'
|
13
|
-
require 'eac_rails_utils/patches/ofx_parser'
|
14
|
-
require 'eac_rails_utils/engine'
|
15
|
-
require 'eac_rails_utils/tableless_model'
|
16
|
-
require 'eac/cpf_validator'
|
17
|
-
require 'eac/common_form_helper/form_builder/association_select_field'
|
18
|
-
require 'eac/common_form_helper/form_builder/common_text_fields'
|
19
|
-
require 'eac/common_form_helper/form_builder/currency_field'
|
20
|
-
require 'eac/common_form_helper/form_builder/date_field'
|
21
|
-
require 'eac/common_form_helper/form_builder/fields_for'
|
22
|
-
require 'eac/common_form_helper/form_builder/file_field'
|
23
|
-
require 'eac/common_form_helper/form_builder/radio_select_field'
|
24
|
-
require 'eac/common_form_helper/form_builder/searchable_association_field'
|
25
|
-
require 'eac/common_form_helper/form_builder/select_field'
|
26
|
-
require 'eac/common_form_helper/form_builder/time_field'
|
27
|
-
require 'eac/common_form_helper/form_builder/year_month_field'
|
28
|
-
require 'eac/common_form_helper/form_builder'
|
29
|
-
require 'eac/common_form_helper'
|
30
|
-
require 'eac/data_table_helper'
|
31
|
-
require 'eac/htmlbeautifier'
|
32
|
-
require 'eac/inequality_queries'
|
33
|
-
require 'eac/menus_helper'
|
34
|
-
require 'eac/menus_helper/bootstrap_gui_builder'
|
35
|
-
require 'eac/menus_helper/data_builder'
|
36
|
-
require 'eac/menus_helper/gui_builder'
|
37
|
-
require 'eac/model'
|
38
|
-
require 'eac/no_presence_validator'
|
39
|
-
require 'eac/test_utils'
|
40
|
-
|
41
|
-
ActionView::Base.include Eac::CommonFormHelper
|
42
|
-
ActionView::Base.include Eac::DataTableHelper
|
43
|
-
ActionView::Base.include Eac::MenusHelper
|
6
|
+
::EacRubyUtils.require_sub __FILE__
|
44
7
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
|
5
|
+
module EacRailsUtils
|
6
|
+
module Models
|
7
|
+
module AttributeRequired
|
8
|
+
extend ::ActiveSupport::Concern
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def required?(model_class_or_record, attribute)
|
12
|
+
model = model_class_or_record_to_model(model_class_or_record)
|
13
|
+
record = model.new
|
14
|
+
record.validate
|
15
|
+
record.errors.key?(attribute.to_sym)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def model_class_or_record_to_model(model_class_or_record)
|
21
|
+
model_class_or_record.is_a?(::Class) ? model_class_or_record : model_class_or_record.class
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
included do
|
26
|
+
extend ClassMethods
|
27
|
+
include InstanceMethods
|
28
|
+
end
|
29
|
+
|
30
|
+
module ClassMethods
|
31
|
+
def column_required?(column)
|
32
|
+
::EacRailsUtils::Models::AttributeRequired.required?(self, column)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module InstanceMethods
|
37
|
+
def attribute_required?(column)
|
38
|
+
self.class.column_required?(column)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|