super 0.0.11 → 0.0.16
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/.yardopts +0 -9
- data/README.md +42 -54
- data/app/assets/javascripts/super/application.js +5617 -3806
- data/app/assets/stylesheets/super/application.css +114687 -71486
- data/app/controllers/super/application_controller.rb +41 -47
- data/app/controllers/super/substructure_controller.rb +265 -0
- data/app/helpers/super/form_builder_helper.rb +7 -0
- data/app/views/layouts/super/application.html.erb +4 -21
- data/app/views/super/application/_collection_header.html.erb +2 -2
- data/app/views/super/application/{_super_schema_display_actions.html.erb → _display_actions.html.erb} +1 -1
- data/app/views/super/application/{_super_schema_display_index.html.erb → _display_index.html.erb} +5 -5
- data/app/views/super/application/_display_show.html.erb +8 -0
- data/app/views/super/application/_filter_type_select.html.erb +1 -1
- data/app/views/super/application/_filter_type_text.html.erb +1 -1
- data/app/views/super/application/_filter_type_timestamp.html.erb +3 -3
- data/app/views/super/application/{_super_schema_form.html.erb → _form.html.erb} +2 -2
- data/app/views/super/application/_form_field.html.erb +5 -0
- data/app/views/super/application/{_super_layout.html.erb → _layout.html.erb} +8 -8
- data/app/views/super/application/_member_header.html.erb +2 -2
- data/app/views/super/application/{_super_pagination.html.erb → _pagination.html.erb} +1 -1
- data/app/views/super/application/{_super_panel.html.erb → _panel.html.erb} +2 -2
- data/app/views/super/application/_site_footer.html.erb +3 -0
- data/app/views/super/application/_site_header.html.erb +17 -0
- data/app/views/super/feather/README.md +0 -1
- data/frontend/super-frontend/dist/application.css +114687 -71486
- data/frontend/super-frontend/dist/application.js +5617 -3806
- data/lib/generators/super/install/install_generator.rb +16 -23
- data/lib/generators/super/install/templates/base_controller.rb.tt +1 -1
- data/lib/generators/super/install/templates/initializer.rb.tt +9 -2
- data/lib/generators/super/resource/resource_generator.rb +105 -30
- data/lib/generators/super/resource/templates/resources_controller.rb.tt +4 -10
- data/lib/generators/super/webpacker/webpacker_generator.rb +9 -5
- data/lib/super.rb +6 -2
- data/lib/super/action_inquirer.rb +18 -3
- data/lib/super/assets.rb +44 -23
- data/lib/super/badge.rb +60 -0
- data/lib/super/cheat.rb +17 -0
- data/lib/super/compatibility.rb +19 -0
- data/lib/super/configuration.rb +14 -23
- data/lib/super/display.rb +16 -8
- data/lib/super/display/guesser.rb +2 -0
- data/lib/super/display/schema_types.rb +116 -29
- data/lib/super/error.rb +7 -0
- data/lib/super/form.rb +1 -1
- data/lib/super/form/builder.rb +107 -27
- data/lib/super/form/guesser.rb +10 -1
- data/lib/super/form/schema_types.rb +73 -7
- data/lib/super/layout.rb +1 -1
- data/lib/super/link.rb +42 -31
- data/lib/super/link_builder.rb +58 -0
- data/lib/super/navigation.rb +164 -0
- data/lib/super/pagination.rb +3 -45
- data/lib/super/panel.rb +1 -1
- data/lib/super/reset.rb +22 -0
- data/lib/super/useful/builder.rb +25 -0
- data/lib/super/useful/enum.rb +63 -0
- data/lib/super/version.rb +1 -1
- data/lib/tasks/super/cheat.rake +9 -0
- metadata +27 -31
- data/CONTRIBUTING.md +0 -56
- data/Rakefile +0 -36
- data/STABILITY.md +0 -50
- data/app/views/super/application/_form_field_checkbox.html.erb +0 -1
- data/app/views/super/application/_form_field_rich_text_area.html.erb +0 -1
- data/app/views/super/application/_form_field_text.html.erb +0 -1
- data/app/views/super/application/_super_schema_display_show.html.erb +0 -8
- data/app/views/super/feather/_chevron_down.html +0 -1
- data/docs/README.md +0 -8
- data/docs/action_text.md +0 -48
- data/docs/cheat.md +0 -41
- data/docs/faq.md +0 -44
- data/docs/installation.md +0 -21
- data/docs/quick_start.md +0 -30
- data/docs/webpacker.md +0 -25
- data/docs/yard_customizations.rb +0 -43
- data/lib/super/controls.rb +0 -17
- data/lib/super/controls/optional.rb +0 -112
- data/lib/super/controls/required.rb +0 -15
- data/lib/super/controls/steps.rb +0 -106
- data/lib/super/controls/view.rb +0 -55
- data/lib/super/navigation/automatic.rb +0 -73
data/lib/super/badge.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Super
|
4
|
+
class Badge
|
5
|
+
STYLES = {
|
6
|
+
light: "bg-gray-100 text-black",
|
7
|
+
dark: "bg-gray-900 text-white",
|
8
|
+
red: "bg-red-700 text-white",
|
9
|
+
yellow: "bg-yellow-400 text-black",
|
10
|
+
green: "bg-green-700 text-white",
|
11
|
+
blue: "bg-blue-700 text-white",
|
12
|
+
purple: "bg-purple-800 text-white",
|
13
|
+
}
|
14
|
+
|
15
|
+
def initialize(text, styles: nil)
|
16
|
+
@text = text
|
17
|
+
@requested_styles = Array(styles.presence).flatten
|
18
|
+
end
|
19
|
+
|
20
|
+
def styles
|
21
|
+
return @styles if instance_variable_defined?(:@styles)
|
22
|
+
@styles =
|
23
|
+
if requested_styles.delete(:reset)
|
24
|
+
[]
|
25
|
+
else
|
26
|
+
COMMON_STYLES
|
27
|
+
end
|
28
|
+
|
29
|
+
if requested_styles.empty?
|
30
|
+
@styles += [STYLES[:light]]
|
31
|
+
else
|
32
|
+
requested_styles.each do |style|
|
33
|
+
@styles +=
|
34
|
+
if STYLES.key?(style)
|
35
|
+
[STYLES[style]]
|
36
|
+
else
|
37
|
+
[style]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
@styles
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
ActionController::Base.helpers.content_tag(
|
47
|
+
:span,
|
48
|
+
@text,
|
49
|
+
class: styles.join(" ")
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
COMMON_STYLES = %w[rounded px-2 py-1 text-xs leading-none font-bold]
|
56
|
+
private_constant :COMMON_STYLES
|
57
|
+
|
58
|
+
attr_reader :requested_styles
|
59
|
+
end
|
60
|
+
end
|
data/lib/super/cheat.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Super
|
4
|
+
class Cheat
|
5
|
+
def controller
|
6
|
+
paths = %w[../../app/controllers/super/substructure_controller.rb]
|
7
|
+
methods =
|
8
|
+
paths
|
9
|
+
.map { |f| File.read(File.expand_path(f, __dir__)) }
|
10
|
+
.flat_map { |content| content.scan(/^\s+(?:helper_method )?def .*$/) }
|
11
|
+
.map { |method| method.strip.sub(/^(?:helper_method )?def /, "#") }
|
12
|
+
|
13
|
+
puts "== Super::ApplicationController"
|
14
|
+
puts methods.join("\n")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/super/compatibility.rb
CHANGED
@@ -23,5 +23,24 @@ module Super
|
|
23
23
|
ActiveRecord::Base.sanitize_sql_like(query)
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
def polymorphic_path_container
|
28
|
+
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0
|
29
|
+
@polymorphic_path_container ||=
|
30
|
+
begin
|
31
|
+
klass = Class.new do
|
32
|
+
include ActionDispatch::Routing::PolymorphicRoutes
|
33
|
+
|
34
|
+
def method_missing(method_name)
|
35
|
+
Rails.application.routes.url_helpers.public_send(method_name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
klass.new
|
40
|
+
end
|
41
|
+
else
|
42
|
+
Rails.application.routes.url_helpers
|
43
|
+
end
|
44
|
+
end
|
26
45
|
end
|
27
46
|
end
|
data/lib/super/configuration.rb
CHANGED
@@ -21,36 +21,27 @@ module Super
|
|
21
21
|
# end
|
22
22
|
# ```
|
23
23
|
class Configuration
|
24
|
-
|
25
|
-
self.title = "Super Admin"
|
26
|
-
self.index_records_per_page = 20
|
27
|
-
self.controller_namespace = "admin"
|
28
|
-
self.route_namespace = :admin
|
29
|
-
|
30
|
-
controller_plugins.use(prepend: Super::Pagination::ControllerMethods)
|
24
|
+
include ActiveSupport::Configurable
|
31
25
|
|
32
|
-
|
33
|
-
|
26
|
+
config_accessor(:title) { "Super Admin" }
|
27
|
+
config_accessor(:index_records_per_page) { 100 }
|
28
|
+
config_accessor(:javascripts) do
|
29
|
+
[Super::Assets.auto("super/application")]
|
34
30
|
end
|
35
|
-
|
36
|
-
|
37
|
-
attr_accessor :index_records_per_page
|
38
|
-
attr_accessor :controller_namespace
|
39
|
-
attr_writer :route_namespace
|
40
|
-
def route_namespace
|
41
|
-
[@route_namespace].flatten
|
31
|
+
config_accessor(:stylesheets) do
|
32
|
+
[Super::Assets.auto("super/application")]
|
42
33
|
end
|
43
34
|
|
44
|
-
|
45
|
-
|
35
|
+
config_accessor(:path) { "/admin" }
|
36
|
+
config_accessor(:generator_module) { "admin" }
|
37
|
+
config_accessor(:generator_as) { "admin" }
|
46
38
|
|
47
|
-
def
|
48
|
-
|
39
|
+
def initialize
|
40
|
+
controller_plugins.use(prepend: Super::Pagination::ControllerMethods)
|
49
41
|
end
|
50
42
|
|
51
|
-
|
52
|
-
|
53
|
-
route_namespace + parts
|
43
|
+
def controller_plugins
|
44
|
+
Plugin::Registry.controller
|
54
45
|
end
|
55
46
|
end
|
56
47
|
end
|
data/lib/super/display.rb
CHANGED
@@ -45,25 +45,33 @@ module Super
|
|
45
45
|
raise Super::Error::Initalization,
|
46
46
|
"You must call the `#apply` method after instantiating Super::Display"
|
47
47
|
elsif @action_inquirer.index?
|
48
|
-
"
|
48
|
+
"display_index"
|
49
49
|
elsif @action_inquirer.show?
|
50
|
-
"
|
50
|
+
"display_show"
|
51
51
|
else
|
52
|
-
"
|
52
|
+
"display_#{@action_inquirer.action}"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
# @private
|
57
|
-
def
|
57
|
+
def render_attribute(template:, record:, column:)
|
58
58
|
formatter = @fields[column]
|
59
|
+
formatter = formatter.build if formatter.respond_to?(:build)
|
59
60
|
|
60
61
|
formatted =
|
61
|
-
|
62
|
+
SchemaTypes::TYPES
|
63
|
+
.case(formatter.type)
|
64
|
+
.when(:record) do
|
65
|
+
formatter.present(column, record)
|
66
|
+
end
|
67
|
+
.when(:column) do
|
62
68
|
value = record.public_send(column)
|
63
|
-
formatter.present(value)
|
64
|
-
|
65
|
-
|
69
|
+
formatter.present(column, value)
|
70
|
+
end
|
71
|
+
.when(:none) do
|
72
|
+
formatter.present(column)
|
66
73
|
end
|
74
|
+
.result
|
67
75
|
|
68
76
|
if formatted.respond_to?(:to_partial_path)
|
69
77
|
if formatted.respond_to?(:locals)
|
@@ -3,35 +3,102 @@
|
|
3
3
|
module Super
|
4
4
|
class Display
|
5
5
|
class SchemaTypes
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
TYPES = Useful::Enum.new(:column, :record, :none)
|
7
|
+
|
8
|
+
class Builder
|
9
|
+
extend Useful::Builder
|
10
|
+
|
11
|
+
builder_with_block def transform(&block)
|
12
|
+
@transform_block = block
|
13
|
+
end
|
14
|
+
|
15
|
+
builder def real; @real = true; end
|
16
|
+
builder def computed; @real = false; end
|
17
|
+
|
18
|
+
builder def column; @type = :column; end
|
19
|
+
builder def record; @type = :record; end
|
20
|
+
builder def none; @type = :none; end
|
21
|
+
|
22
|
+
builder def ignore_nil; @ignore_nil = true; end
|
23
|
+
|
24
|
+
def build
|
25
|
+
Built.new(
|
26
|
+
real: @real,
|
27
|
+
type: @type,
|
28
|
+
ignore_nil: !!@ignore_nil,
|
29
|
+
&@transform_block
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Built
|
35
|
+
def initialize(real:, type:, ignore_nil:, &transform_block)
|
36
|
+
@real = real
|
37
|
+
@type = type
|
9
38
|
@ignore_nil = ignore_nil
|
39
|
+
@transform_block = transform_block
|
10
40
|
end
|
11
41
|
|
12
|
-
def
|
42
|
+
def real?; @real; end
|
43
|
+
attr_reader :type
|
44
|
+
|
45
|
+
def present(attribute_name, value = nil)
|
46
|
+
if @transform_block.nil?
|
47
|
+
if attribute_name
|
48
|
+
raise Error::ArgumentError, "Transformation block is not set for column: #{attribute_name}"
|
49
|
+
else
|
50
|
+
raise Error::ArgumentError, "Transformation block is not set!"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
13
54
|
return nil if value.nil? && @ignore_nil
|
14
55
|
|
15
|
-
@
|
56
|
+
if @type == :none
|
57
|
+
@transform_block.call
|
58
|
+
else
|
59
|
+
@transform_block.call(value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Badge
|
65
|
+
extend Useful::Builder
|
66
|
+
|
67
|
+
def initialize(builder)
|
68
|
+
@builder = builder
|
69
|
+
@whens = {}
|
70
|
+
format_for_lookup(&:itself)
|
71
|
+
format_for_display(&:itself)
|
16
72
|
end
|
17
73
|
|
18
|
-
def
|
19
|
-
|
74
|
+
builder_with_block def when(*patterns, &block)
|
75
|
+
patterns.each do |pattern|
|
76
|
+
@whens[pattern] = block
|
77
|
+
end
|
20
78
|
end
|
21
|
-
end
|
22
79
|
|
23
|
-
|
24
|
-
|
25
|
-
@partial = partial
|
26
|
-
@real = real
|
80
|
+
builder_with_block def else(&block)
|
81
|
+
@else = block
|
27
82
|
end
|
28
83
|
|
29
|
-
def
|
30
|
-
|
84
|
+
builder_with_block def format_for_lookup(&block)
|
85
|
+
@format_for_lookup = block
|
31
86
|
end
|
32
87
|
|
33
|
-
def
|
34
|
-
@
|
88
|
+
builder_with_block def format_for_display(&block)
|
89
|
+
@format_for_display = block
|
90
|
+
end
|
91
|
+
|
92
|
+
def build
|
93
|
+
@builder.transform do |value|
|
94
|
+
lookup_value = @format_for_lookup.call(value)
|
95
|
+
block = @whens[lookup_value] || @else
|
96
|
+
Super::Badge.new(
|
97
|
+
@format_for_display.call(value),
|
98
|
+
styles: block&.call
|
99
|
+
)
|
100
|
+
end
|
101
|
+
@builder.build
|
35
102
|
end
|
36
103
|
end
|
37
104
|
|
@@ -40,33 +107,53 @@ module Super
|
|
40
107
|
@fields = fields
|
41
108
|
end
|
42
109
|
|
43
|
-
def
|
44
|
-
|
110
|
+
def real(type = :column, &transform_block)
|
111
|
+
TYPES
|
112
|
+
.case(type)
|
113
|
+
.when(:column) { Builder.new.real.ignore_nil.column.transform(&transform_block) }
|
114
|
+
.when(:record) { Builder.new.real.ignore_nil.record.transform(&transform_block) }
|
115
|
+
.when(:none) { Builder.new.real.ignore_nil.none.transform(&transform_block) }
|
116
|
+
.result
|
45
117
|
end
|
46
118
|
|
47
|
-
|
119
|
+
def computed(type = :column, &transform_block)
|
120
|
+
TYPES
|
121
|
+
.case(type)
|
122
|
+
.when(:column) { Builder.new.computed.ignore_nil.column.transform(&transform_block) }
|
123
|
+
.when(:record) { Builder.new.computed.ignore_nil.record.transform(&transform_block) }
|
124
|
+
.when(:none) { Builder.new.computed.ignore_nil.none.transform(&transform_block) }
|
125
|
+
.result
|
126
|
+
end
|
48
127
|
|
49
|
-
def
|
50
|
-
|
128
|
+
def manual(&transform_block)
|
129
|
+
real(:column, &transform_block)
|
51
130
|
end
|
52
131
|
|
132
|
+
def string; real(&:to_s); end
|
133
|
+
alias text string
|
134
|
+
|
135
|
+
def timestamp; real(&:to_s); end
|
136
|
+
def time; real { |value| value.strftime("%H:%M:%S") }; end
|
137
|
+
|
53
138
|
def rich_text
|
54
|
-
|
139
|
+
computed do |value|
|
55
140
|
Partial.new("display_rich_text", locals: { rich_text: value })
|
56
141
|
end
|
57
142
|
end
|
58
143
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
144
|
+
def badge(*builder_methods)
|
145
|
+
builder_methods = %i[real ignore_nil column] if builder_methods.empty?
|
146
|
+
builder = builder_methods.each_with_object(Builder.new) do |builder_method, builder|
|
147
|
+
builder.public_send(builder_method)
|
148
|
+
end
|
149
|
+
Badge.new(builder)
|
65
150
|
end
|
66
151
|
|
67
152
|
def actions
|
68
153
|
@actions_called = true
|
69
|
-
|
154
|
+
Builder.new.computed.none.transform do
|
155
|
+
Partial.new("display_actions")
|
156
|
+
end
|
70
157
|
end
|
71
158
|
|
72
159
|
# @private
|
data/lib/super/error.rb
CHANGED
@@ -27,5 +27,12 @@ module Super
|
|
27
27
|
# Error raised when something wasn't initalized correctly, and if there isn't
|
28
28
|
# a more specific error
|
29
29
|
class Initalization < Error; end
|
30
|
+
class ArgumentError < Error; end
|
31
|
+
|
32
|
+
class Enum < Error
|
33
|
+
class ImpossibleValue < Enum; end
|
34
|
+
class ArgumentError < Enum; end
|
35
|
+
class UndefinedCase < Enum; end
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
data/lib/super/form.rb
CHANGED
data/lib/super/form/builder.rb
CHANGED
@@ -58,6 +58,65 @@ module Super
|
|
58
58
|
@builder.check_box(attribute, options, checked_value, unchecked_value)
|
59
59
|
end
|
60
60
|
|
61
|
+
def date_flatpickr(attribute, options = {})
|
62
|
+
options, defaults = split_defaults(
|
63
|
+
options,
|
64
|
+
class: "super-input w-full",
|
65
|
+
data: {
|
66
|
+
controller: "flatpickr",
|
67
|
+
flatpickr_options_value: {
|
68
|
+
dateFormat: "Y-m-d",
|
69
|
+
}
|
70
|
+
}
|
71
|
+
)
|
72
|
+
options[:class] = join_classes(defaults[:class], options[:class])
|
73
|
+
options[:data] = defaults[:data].deep_merge(options[:data] || {})
|
74
|
+
options[:value] = @builder.object.public_send(attribute).presence&.iso8601
|
75
|
+
|
76
|
+
@builder.text_field(attribute, options)
|
77
|
+
end
|
78
|
+
|
79
|
+
def datetime_flatpickr(attribute, options = {})
|
80
|
+
options, defaults = split_defaults(
|
81
|
+
options,
|
82
|
+
class: "super-input w-full",
|
83
|
+
data: {
|
84
|
+
controller: "flatpickr",
|
85
|
+
flatpickr_options_value: {
|
86
|
+
enableSeconds: true,
|
87
|
+
enableTime: true,
|
88
|
+
dateFormat: "Z",
|
89
|
+
}
|
90
|
+
}
|
91
|
+
)
|
92
|
+
options[:class] = join_classes(defaults[:class], options[:class])
|
93
|
+
options[:data] = defaults[:data].deep_merge(options[:data] || {})
|
94
|
+
options[:value] = @builder.object.public_send(attribute).presence&.iso8601
|
95
|
+
|
96
|
+
@builder.text_field(attribute, options)
|
97
|
+
end
|
98
|
+
|
99
|
+
def time_flatpickr(attribute, options = {})
|
100
|
+
options, defaults = split_defaults(
|
101
|
+
options,
|
102
|
+
class: "super-input w-full",
|
103
|
+
data: {
|
104
|
+
controller: "flatpickr",
|
105
|
+
flatpickr_options_value: {
|
106
|
+
enableSeconds: true,
|
107
|
+
enableTime: true,
|
108
|
+
noCalendar: true,
|
109
|
+
dateFormat: "H:i:S",
|
110
|
+
}
|
111
|
+
}
|
112
|
+
)
|
113
|
+
options[:class] = join_classes(defaults[:class], options[:class])
|
114
|
+
options[:data] = defaults[:data].deep_merge(options[:data] || {})
|
115
|
+
options[:value] = @builder.object.public_send(attribute).presence&.strftime("%H:%M:%S")
|
116
|
+
|
117
|
+
@builder.text_field(attribute, options)
|
118
|
+
end
|
119
|
+
|
61
120
|
def password_field(attribute, options = {})
|
62
121
|
options, defaults = split_defaults(options, class: "super-input w-full")
|
63
122
|
options[:class] = join_classes(defaults[:class], options[:class])
|
@@ -75,25 +134,10 @@ module Super
|
|
75
134
|
def select(attribute, choices, options = {}, html_options = {}, &block)
|
76
135
|
options, defaults = split_defaults(options, include_blank: true)
|
77
136
|
options = defaults.merge(options)
|
78
|
-
html_options, html_defaults = split_defaults(html_options, class: "super-input super-input-select
|
137
|
+
html_options, html_defaults = split_defaults(html_options, class: "super-input super-input-select")
|
79
138
|
html_options[:class] = join_classes(html_defaults[:class], html_options[:class])
|
80
139
|
|
81
|
-
|
82
|
-
%(<div class="super-input-select">).html_safe,
|
83
|
-
@builder.select(attribute, choices, options, html_options, &block),
|
84
|
-
<<~HTML.html_safe,
|
85
|
-
<div class="super-input-select-icon text-blue-700">
|
86
|
-
<span class="h-4 w-4">
|
87
|
-
HTML
|
88
|
-
@template.render("super/feather/chevron_down"),
|
89
|
-
<<~HTML.html_safe,
|
90
|
-
</span>
|
91
|
-
</div>
|
92
|
-
HTML
|
93
|
-
%(</div>).html_safe,
|
94
|
-
]
|
95
|
-
|
96
|
-
@template.safe_join(parts)
|
140
|
+
@builder.select(attribute, choices, options, html_options, &block)
|
97
141
|
end
|
98
142
|
|
99
143
|
def submit(value = nil, options = {})
|
@@ -115,24 +159,60 @@ module Super
|
|
115
159
|
@template.content_tag(:div, class: "super-field-group", &block)
|
116
160
|
end
|
117
161
|
|
118
|
-
def check_box!(attribute, checked_value
|
162
|
+
def check_box!(attribute, checked_value: "1", unchecked_value: "0", label_text: nil, label: {}, field: {}, show_errors: true)
|
119
163
|
label[:super] ||= {}
|
120
164
|
label[:super] = { class: "select-none ml-1" }.merge(label[:super])
|
121
165
|
container do
|
122
166
|
compact_join([
|
123
167
|
"<div>".html_safe,
|
124
168
|
public_send(:check_box, attribute, field, checked_value, unchecked_value),
|
125
|
-
public_send(:label, attribute,
|
169
|
+
public_send(:label, attribute, label_text, label),
|
126
170
|
"</div>".html_safe,
|
127
171
|
show_errors && inline_errors(attribute),
|
128
172
|
])
|
129
173
|
end
|
130
174
|
end
|
131
175
|
|
132
|
-
def
|
176
|
+
def date_flatpickr!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
|
177
|
+
container do
|
178
|
+
compact_join([
|
179
|
+
public_send(:label, attribute, label_text, label),
|
180
|
+
%(<div class="mt-1">).html_safe,
|
181
|
+
public_send(:date_flatpickr, attribute, field),
|
182
|
+
show_errors && inline_errors(attribute),
|
183
|
+
%(</div>).html_safe,
|
184
|
+
])
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def datetime_flatpickr!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
|
189
|
+
container do
|
190
|
+
compact_join([
|
191
|
+
public_send(:label, attribute, label_text, label),
|
192
|
+
%(<div class="mt-1">).html_safe,
|
193
|
+
public_send(:datetime_flatpickr, attribute, field),
|
194
|
+
show_errors && inline_errors(attribute),
|
195
|
+
%(</div>).html_safe,
|
196
|
+
])
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def time_flatpickr!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
|
201
|
+
container do
|
202
|
+
compact_join([
|
203
|
+
public_send(:label, attribute, label_text, label),
|
204
|
+
%(<div class="mt-1">).html_safe,
|
205
|
+
public_send(:time_flatpickr, attribute, field),
|
206
|
+
show_errors && inline_errors(attribute),
|
207
|
+
%(</div>).html_safe,
|
208
|
+
])
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def password_field!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
|
133
213
|
container do
|
134
214
|
compact_join([
|
135
|
-
public_send(:label, attribute, label),
|
215
|
+
public_send(:label, attribute, label_text, label),
|
136
216
|
%(<div class="mt-1">).html_safe,
|
137
217
|
public_send(:password_field, attribute, field),
|
138
218
|
show_errors && inline_errors(attribute),
|
@@ -141,10 +221,10 @@ module Super
|
|
141
221
|
end
|
142
222
|
end
|
143
223
|
|
144
|
-
def rich_text_area!(attribute, label: {}, field: {}, show_errors: true)
|
224
|
+
def rich_text_area!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
|
145
225
|
container do
|
146
226
|
compact_join([
|
147
|
-
public_send(:label, attribute, label),
|
227
|
+
public_send(:label, attribute, label_text, label),
|
148
228
|
%(<div class="mt-1">).html_safe,
|
149
229
|
public_send(:rich_text_area, attribute, field),
|
150
230
|
show_errors && inline_errors(attribute),
|
@@ -153,10 +233,10 @@ module Super
|
|
153
233
|
end
|
154
234
|
end
|
155
235
|
|
156
|
-
def select!(attribute, collection, label: {}, field: {}, show_errors: true)
|
236
|
+
def select!(attribute, collection, label_text: nil, label: {}, field: {}, show_errors: true)
|
157
237
|
container do
|
158
238
|
compact_join([
|
159
|
-
public_send(:label, attribute, label),
|
239
|
+
public_send(:label, attribute, label_text, label),
|
160
240
|
%(<div class="mt-1">).html_safe,
|
161
241
|
public_send(:select, attribute, collection, field),
|
162
242
|
show_errors && inline_errors(attribute),
|
@@ -165,10 +245,10 @@ module Super
|
|
165
245
|
end
|
166
246
|
end
|
167
247
|
|
168
|
-
def text_field!(attribute, label: {}, field: {}, show_errors: true)
|
248
|
+
def text_field!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
|
169
249
|
container do
|
170
250
|
compact_join([
|
171
|
-
public_send(:label, attribute, label),
|
251
|
+
public_send(:label, attribute, label_text, label),
|
172
252
|
%(<div class="mt-1">).html_safe,
|
173
253
|
public_send(:text_field, attribute, field),
|
174
254
|
show_errors && inline_errors(attribute),
|