trestle 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +4 -0
- data/app/assets/bundle/trestle/admin.css +3 -3
- data/app/assets/bundle/trestle/admin.js +13 -13
- data/app/assets/bundle/trestle/photoswipe-2d522a3abaa59f8a8f73.digested.js +6 -0
- data/app/helpers/trestle/avatar_helper.rb +20 -14
- data/app/helpers/trestle/card_helper.rb +27 -9
- data/app/helpers/trestle/container_helper.rb +37 -6
- data/app/helpers/trestle/display_helper.rb +11 -0
- data/app/helpers/trestle/flash_helper.rb +1 -10
- data/app/helpers/trestle/form_helper.rb +32 -18
- data/app/helpers/trestle/format_helper.rb +47 -17
- data/app/helpers/trestle/gravatar_helper.rb +48 -0
- data/app/helpers/trestle/grid_helper.rb +12 -14
- data/app/helpers/trestle/headings_helper.rb +2 -23
- data/app/helpers/trestle/i18n_helper.rb +1 -0
- data/app/helpers/trestle/icon_helper.rb +16 -3
- data/app/helpers/trestle/layout_helper.rb +1 -0
- data/app/helpers/trestle/modal_helper.rb +21 -2
- data/app/helpers/trestle/navigation_helper.rb +1 -0
- data/app/helpers/trestle/pagination_helper.rb +1 -0
- data/app/helpers/trestle/params_helper.rb +32 -0
- data/app/helpers/trestle/sort_helper.rb +38 -7
- data/app/helpers/trestle/status_helper.rb +19 -3
- data/app/helpers/trestle/tab_helper.rb +42 -7
- data/app/helpers/trestle/table_helper.rb +23 -23
- data/app/helpers/trestle/timestamp_helper.rb +18 -25
- data/app/helpers/trestle/title_helper.rb +2 -0
- data/app/helpers/trestle/toolbars_helper.rb +2 -1
- data/app/helpers/trestle/turbo/frame_helper.rb +25 -14
- data/app/helpers/trestle/url_helper.rb +124 -54
- data/app/views/kaminari/trestle/_first_page.html.erb +1 -2
- data/app/views/kaminari/trestle/_gap.html.erb +0 -1
- data/app/views/kaminari/trestle/_last_page.html.erb +1 -2
- data/app/views/kaminari/trestle/_page.html.erb +1 -2
- data/app/views/kaminari/trestle/_paginator.html.erb +0 -1
- data/app/views/layouts/trestle/admin.html.erb +3 -3
- data/app/views/layouts/trestle/modal.html.erb +2 -2
- data/app/views/trestle/application/_layout.html.erb +22 -18
- data/app/views/trestle/application/_tabs.html.erb +1 -1
- data/app/views/trestle/flash/_alert.html.erb +3 -1
- data/app/views/trestle/flash/_flash.html.erb +7 -4
- data/app/views/trestle/resource/_scopes.html.erb +3 -3
- data/app/views/trestle/resource/create.turbo_stream.erb +1 -0
- data/app/views/trestle/resource/destroy.turbo_stream.erb +2 -0
- data/app/views/trestle/resource/index.html.erb +10 -12
- data/app/views/trestle/resource/update.turbo_stream.erb +1 -0
- data/app/views/trestle/shared/_sidebar.html.erb +8 -8
- data/app/views/trestle/table/_table.html.erb +2 -2
- data/config/locales/pt-BR.yml +13 -13
- data/frontend/css/components/_scopes.scss +6 -7
- data/frontend/css/core/_theme.scss +3 -3
- data/frontend/css/layout/_sidebar.scss +2 -0
- data/frontend/js/controllers/flatpickr_controller.js +2 -2
- data/frontend/js/controllers/lightbox_controller.js +3 -3
- data/frontend/js/controllers/modal_trigger_controller.js +2 -2
- data/frontend/js/controllers/sidebar_controller.js +13 -3
- data/frontend/js/controllers/tab_errors_controller.js +2 -2
- data/frontend/js/core/backdrop.js +30 -28
- data/frontend/js/core/error_modal.js +7 -9
- data/frontend/js/core/fetch.js +2 -0
- data/lib/trestle/admin.rb +9 -2
- data/lib/trestle/configuration.rb +3 -0
- data/lib/trestle/engine.rb +1 -1
- data/lib/trestle/evaluation_context.rb +2 -4
- data/lib/trestle/form/automatic.rb +1 -1
- data/lib/trestle/form/field.rb +1 -1
- data/lib/trestle/form/fields/check_box.rb +1 -1
- data/lib/trestle/form/fields/collection_check_boxes.rb +1 -1
- data/lib/trestle/form/fields/collection_radio_buttons.rb +1 -1
- data/lib/trestle/form/fields/date_select.rb +1 -1
- data/lib/trestle/form/fields/datetime_select.rb +1 -1
- data/lib/trestle/form/fields/form_control.rb +2 -2
- data/lib/trestle/form/fields/form_group.rb +4 -4
- data/lib/trestle/form/fields/radio_button.rb +1 -1
- data/lib/trestle/form/fields/static_field.rb +1 -1
- data/lib/trestle/form/fields/time_select.rb +1 -1
- data/lib/trestle/form/renderer.rb +2 -4
- data/lib/trestle/hook/helpers.rb +21 -0
- data/lib/trestle/navigation/block.rb +8 -15
- data/lib/trestle/navigation/group.rb +2 -2
- data/lib/trestle/navigation/item.rb +21 -4
- data/lib/trestle/registry.rb +14 -11
- data/lib/trestle/resource/builder.rb +9 -6
- data/lib/trestle/resource/toolbar.rb +4 -4
- data/lib/trestle/resource.rb +7 -5
- data/lib/trestle/scopes/block.rb +8 -12
- data/lib/trestle/scopes/definition.rb +6 -2
- data/lib/trestle/scopes/scope.rb +13 -10
- data/lib/trestle/tab.rb +2 -2
- data/lib/trestle/table/column.rb +4 -3
- data/lib/trestle/table/row.rb +1 -1
- data/lib/trestle/toolbar/builder.rb +6 -6
- data/lib/trestle/toolbar/context.rb +2 -4
- data/lib/trestle/toolbar/item.rb +10 -19
- data/lib/trestle/toolbar/menu.rb +9 -9
- data/lib/trestle/version.rb +1 -1
- data/lib/trestle.rb +2 -2
- data/package.json +7 -7
- data/yarn.lock +517 -564
- metadata +5 -5
- data/app/assets/bundle/trestle/photoswipe-063ce7be40e10b3e6848.digested.js +0 -6
- data/app/views/layouts/trestle/admin.turbo_stream.erb +0 -4
data/lib/trestle/registry.rb
CHANGED
@@ -15,27 +15,24 @@ module Trestle
|
|
15
15
|
|
16
16
|
def reset!
|
17
17
|
@admins = {}
|
18
|
-
@models =
|
18
|
+
@models = nil
|
19
19
|
end
|
20
20
|
|
21
21
|
def empty?
|
22
22
|
none?
|
23
23
|
end
|
24
24
|
|
25
|
-
def register(admin
|
25
|
+
def register(admin)
|
26
26
|
@admins[admin.admin_name] = admin
|
27
|
-
|
28
|
-
if register_model && register_admin_for_model_loookup?(admin)
|
29
|
-
@models[admin.model.name] ||= admin
|
30
|
-
end
|
31
|
-
|
32
|
-
admin
|
33
27
|
end
|
34
28
|
|
35
29
|
def lookup_admin(admin)
|
36
30
|
# Given object is already an admin class
|
37
31
|
return admin if admin.is_a?(Class) && admin < Trestle::Admin
|
38
32
|
|
33
|
+
# Given object is already an admin instance
|
34
|
+
return admin if admin.is_a?(Trestle::Admin)
|
35
|
+
|
39
36
|
@admins[admin.to_s]
|
40
37
|
end
|
41
38
|
alias lookup lookup_admin
|
@@ -43,7 +40,7 @@ module Trestle
|
|
43
40
|
def lookup_model(model)
|
44
41
|
# Lookup each class in the model's ancestor chain
|
45
42
|
while model
|
46
|
-
admin =
|
43
|
+
admin = models[model.name]
|
47
44
|
return admin if admin
|
48
45
|
|
49
46
|
model = model.superclass
|
@@ -54,8 +51,14 @@ module Trestle
|
|
54
51
|
end
|
55
52
|
|
56
53
|
private
|
57
|
-
def
|
58
|
-
|
54
|
+
def models
|
55
|
+
@models ||= @admins.values.inject({}) { |result, admin|
|
56
|
+
if admin.respond_to?(:register_model?) && admin.register_model?
|
57
|
+
result[admin.model.name] ||= admin
|
58
|
+
end
|
59
|
+
|
60
|
+
result
|
61
|
+
}
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|
@@ -43,9 +43,10 @@ module Trestle
|
|
43
43
|
admin.define_adapter_method(:to_param, &block)
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def permitted_params(&block)
|
47
47
|
admin.define_adapter_method(:permitted_params, &block)
|
48
48
|
end
|
49
|
+
alias params permitted_params
|
49
50
|
|
50
51
|
def decorator(decorator)
|
51
52
|
admin.decorator = decorator
|
@@ -76,14 +77,16 @@ module Trestle
|
|
76
77
|
admin.define_adapter_method(:count, &block)
|
77
78
|
end
|
78
79
|
|
79
|
-
def scopes(
|
80
|
-
|
81
|
-
|
80
|
+
def scopes(defaults: {}, **options, &block)
|
81
|
+
defaults = defaults.merge(options.slice(:count))
|
82
|
+
|
83
|
+
admin.scopes.apply_options!(options)
|
84
|
+
admin.scopes.append(**defaults, &block) if block_given?
|
82
85
|
end
|
83
86
|
|
84
|
-
def scope(name, scope=nil, options
|
87
|
+
def scope(name, scope=nil, **options, &block)
|
85
88
|
scopes do
|
86
|
-
scope(name, scope, options, &block)
|
89
|
+
scope(name, scope, **options, &block)
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
@@ -9,26 +9,26 @@ module Trestle
|
|
9
9
|
return unless action?(:new)
|
10
10
|
|
11
11
|
defaults = { action: :new, style: :light, icon: "fa fa-plus", class: "btn-new-resource" }
|
12
|
-
link(label, defaults.merge(attrs))
|
12
|
+
link(label, **defaults.merge(attrs))
|
13
13
|
end
|
14
14
|
|
15
15
|
def save(label: t("buttons.save", default: "Save %{model_name}"), **attrs)
|
16
16
|
defaults = { style: :success }
|
17
|
-
button(label, defaults.merge(attrs))
|
17
|
+
button(label, **defaults.merge(attrs))
|
18
18
|
end
|
19
19
|
|
20
20
|
def delete(label: t("buttons.delete", default: "Delete %{model_name}"), **attrs)
|
21
21
|
return unless action?(:destroy)
|
22
22
|
|
23
23
|
defaults = Trestle::Options.new(action: :destroy, style: :danger, icon: "fa fa-trash", data: { turbo_method: "delete", turbo_frame: "_top", controller: "confirm-delete", confirm_delete_placement_value: "bottom" })
|
24
|
-
link(label, instance, defaults.merge(attrs))
|
24
|
+
link(label, instance, **defaults.merge(attrs))
|
25
25
|
end
|
26
26
|
|
27
27
|
def dismiss(label: t("buttons.ok", default: "OK"), **attrs)
|
28
28
|
return unless @template.modal_request?
|
29
29
|
|
30
30
|
defaults = Trestle::Options.new(type: :button, style: :light, data: { bs_dismiss: "modal" })
|
31
|
-
button(label, defaults.merge(attrs))
|
31
|
+
button(label, **defaults.merge(attrs))
|
32
32
|
end
|
33
33
|
alias ok dismiss
|
34
34
|
|
data/lib/trestle/resource.rb
CHANGED
@@ -104,6 +104,10 @@ module Trestle
|
|
104
104
|
options[:singular]
|
105
105
|
end
|
106
106
|
|
107
|
+
def register_model?
|
108
|
+
options[:register_model] != false && !singular?
|
109
|
+
end
|
110
|
+
|
107
111
|
def translate(key, options={})
|
108
112
|
super(key, options.merge({
|
109
113
|
model_name: model_name.titleize,
|
@@ -113,10 +117,8 @@ module Trestle
|
|
113
117
|
end
|
114
118
|
alias t translate
|
115
119
|
|
116
|
-
def instance_path(instance, options
|
117
|
-
|
118
|
-
options = options.merge(id: to_param(instance)) unless singular?
|
119
|
-
|
120
|
+
def instance_path(instance, action: :show, **options)
|
121
|
+
options.merge!(id: to_param(instance)) unless singular?
|
120
122
|
path(action, options)
|
121
123
|
end
|
122
124
|
|
@@ -133,7 +135,7 @@ module Trestle
|
|
133
135
|
}
|
134
136
|
|
135
137
|
Proc.new do
|
136
|
-
public_send(resource_method, resource_name, resource_options) do
|
138
|
+
public_send(resource_method, resource_name, **resource_options) do
|
137
139
|
admin.additional_routes.each do |block|
|
138
140
|
instance_exec(&block)
|
139
141
|
end
|
data/lib/trestle/scopes/block.rb
CHANGED
@@ -1,37 +1,33 @@
|
|
1
1
|
module Trestle
|
2
2
|
class Scopes
|
3
3
|
class Block
|
4
|
-
attr_reader :block, :
|
4
|
+
attr_reader :block, :defaults
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(**defaults, &block)
|
7
|
+
@defaults, @block = defaults, block
|
8
8
|
end
|
9
9
|
|
10
10
|
# Evaluates the scope block within the given admin context
|
11
11
|
# and returns an array of the scopes that were defined.
|
12
12
|
def scopes(context)
|
13
|
-
context = Evaluator.new(context,
|
13
|
+
context = Evaluator.new(context, **defaults)
|
14
14
|
context.instance_exec(context, &block)
|
15
15
|
context.scopes
|
16
16
|
end
|
17
17
|
|
18
|
+
protected
|
18
19
|
class Evaluator
|
19
20
|
include EvaluationContext
|
20
21
|
|
21
22
|
attr_reader :scopes
|
22
23
|
|
23
|
-
def initialize(context=nil, defaults
|
24
|
+
def initialize(context=nil, **defaults)
|
24
25
|
@context, @defaults = context, defaults
|
25
26
|
@scopes = []
|
26
27
|
end
|
27
28
|
|
28
|
-
def scope(name, scope=nil, options
|
29
|
-
|
30
|
-
options = scope
|
31
|
-
scope = nil
|
32
|
-
end
|
33
|
-
|
34
|
-
scopes << Scope.new(@context, name, @defaults.merge(options), &(scope || block))
|
29
|
+
def scope(name, scope=nil, **options, &block)
|
30
|
+
scopes << Scope.new(@context, name, **@defaults.merge(options), &(scope || block))
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
@@ -8,8 +8,12 @@ module Trestle
|
|
8
8
|
@options = {}
|
9
9
|
end
|
10
10
|
|
11
|
-
def append(
|
12
|
-
@blocks << Block.new(
|
11
|
+
def append(**defaults, &block)
|
12
|
+
@blocks << Block.new(**defaults, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def apply_options!(options)
|
16
|
+
@options.merge!(options)
|
13
17
|
end
|
14
18
|
|
15
19
|
# Evaluates each of the scope blocks within the given admin context
|
data/lib/trestle/scopes/scope.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Trestle
|
2
2
|
class Scopes
|
3
3
|
class Scope
|
4
|
-
attr_reader :name, :
|
4
|
+
attr_reader :name, :group, :block
|
5
5
|
|
6
|
-
def initialize(admin, name,
|
7
|
-
@admin, @name, @
|
6
|
+
def initialize(admin, name, label: nil, group: nil, default: false, count: true, &block)
|
7
|
+
@admin, @name, @block = admin, name, block
|
8
|
+
@label, @group, @default, @count = label, group, default, count
|
8
9
|
end
|
9
10
|
|
10
11
|
def to_param
|
@@ -12,19 +13,15 @@ module Trestle
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def label
|
15
|
-
@
|
16
|
-
end
|
17
|
-
|
18
|
-
def group
|
19
|
-
@options[:group]
|
16
|
+
@label || default_label
|
20
17
|
end
|
21
18
|
|
22
19
|
def default?
|
23
|
-
@
|
20
|
+
@default
|
24
21
|
end
|
25
22
|
|
26
23
|
def count?
|
27
|
-
@
|
24
|
+
@count
|
28
25
|
end
|
29
26
|
|
30
27
|
def apply(collection)
|
@@ -40,6 +37,7 @@ module Trestle
|
|
40
37
|
end
|
41
38
|
|
42
39
|
def count(collection)
|
40
|
+
return unless count?
|
43
41
|
@admin.count(@admin.merge_scopes(collection, apply(collection)))
|
44
42
|
end
|
45
43
|
|
@@ -52,6 +50,11 @@ module Trestle
|
|
52
50
|
default?
|
53
51
|
end
|
54
52
|
end
|
53
|
+
|
54
|
+
protected
|
55
|
+
def default_label
|
56
|
+
@admin.t("scopes.#{name}", default: name.to_s.humanize.titleize)
|
57
|
+
end
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
data/lib/trestle/tab.rb
CHANGED
@@ -6,7 +6,7 @@ module Trestle
|
|
6
6
|
|
7
7
|
attr_reader :name, :options
|
8
8
|
|
9
|
-
def initialize(name, options
|
9
|
+
def initialize(name, **options)
|
10
10
|
@name, @options = name, options
|
11
11
|
end
|
12
12
|
|
@@ -19,7 +19,7 @@ module Trestle
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def badge
|
22
|
-
|
22
|
+
tag.span(options[:badge], class: "badge") if options[:badge]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/trestle/table/column.rb
CHANGED
@@ -36,7 +36,7 @@ module Trestle
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def render(instance)
|
39
|
-
@template.
|
39
|
+
@template.tag.td(content(instance), class: classes, data: data)
|
40
40
|
end
|
41
41
|
|
42
42
|
def render?
|
@@ -61,7 +61,8 @@ module Trestle
|
|
61
61
|
return if options.key?(:header) && options[:header].in?([nil, false])
|
62
62
|
|
63
63
|
if @table.sortable? && @column.sortable?
|
64
|
-
|
64
|
+
link_options = @column.sort_options.slice(:default, :default_order)
|
65
|
+
@template.sort_link(header_text, @column.sort_field, **link_options)
|
65
66
|
else
|
66
67
|
header_text
|
67
68
|
end
|
@@ -69,7 +70,7 @@ module Trestle
|
|
69
70
|
|
70
71
|
def content(instance)
|
71
72
|
value = column_value(instance)
|
72
|
-
content = @template.format_value(value, options)
|
73
|
+
content = @template.format_value(value, **options)
|
73
74
|
|
74
75
|
if value.respond_to?(:id) && options[:link] != false
|
75
76
|
# Column value was a model instance (e.g. from an association).
|
data/lib/trestle/table/row.rb
CHANGED
@@ -5,16 +5,16 @@ module Trestle
|
|
5
5
|
@template = template
|
6
6
|
end
|
7
7
|
|
8
|
-
def button(label, options
|
9
|
-
Button.new(@template, label, options, &block)
|
8
|
+
def button(label, **options, &block)
|
9
|
+
Button.new(@template, label, **options, &block)
|
10
10
|
end
|
11
11
|
|
12
|
-
def link(label, instance_or_url=
|
13
|
-
Link.new(@template, label, instance_or_url, options, &block)
|
12
|
+
def link(label, instance_or_url=nil, **options, &block)
|
13
|
+
Link.new(@template, label, instance_or_url, **options, &block)
|
14
14
|
end
|
15
15
|
|
16
|
-
def dropdown(label=nil, options
|
17
|
-
Dropdown.new(@template, label, options, &block)
|
16
|
+
def dropdown(label=nil, **options, &block)
|
17
|
+
Dropdown.new(@template, label, **options, &block)
|
18
18
|
end
|
19
19
|
|
20
20
|
# Only methods explicitly tagged as builder methods will be automatically
|
@@ -21,10 +21,7 @@ module Trestle
|
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
|
-
def
|
25
|
-
end unless respond_to?(:ruby2_keywords, true)
|
26
|
-
|
27
|
-
ruby2_keywords def method_missing(name, *args, &block)
|
24
|
+
def method_missing(name, *args, &block)
|
28
25
|
result = builder.send(name, *args, &block)
|
29
26
|
|
30
27
|
if builder.builder_methods.include?(name)
|
@@ -33,6 +30,7 @@ module Trestle
|
|
33
30
|
result
|
34
31
|
end
|
35
32
|
end
|
33
|
+
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
36
34
|
|
37
35
|
def respond_to_missing?(name, include_all=false)
|
38
36
|
builder.respond_to?(name) || super
|
data/lib/trestle/toolbar/item.rb
CHANGED
@@ -3,17 +3,16 @@ module Trestle
|
|
3
3
|
class Item
|
4
4
|
attr_reader :label, :menu
|
5
5
|
|
6
|
-
delegate :admin_link_to, :button_tag, :
|
6
|
+
delegate :admin_link_to, :button_tag, :tag, :safe_join, :icon, to: :@template
|
7
7
|
|
8
|
-
def initialize(template, label, options
|
8
|
+
def initialize(template, label, icon: nil, style: nil, **options, &block)
|
9
9
|
@template = template
|
10
10
|
@label, @options, @block = label, options
|
11
11
|
|
12
12
|
@menu = Menu.new(template)
|
13
13
|
@menu.build(&block) if block_given?
|
14
14
|
|
15
|
-
@icon =
|
16
|
-
@style = options.delete(:style)
|
15
|
+
@icon, @style = icon, style
|
17
16
|
end
|
18
17
|
|
19
18
|
def ==(other)
|
@@ -22,7 +21,7 @@ module Trestle
|
|
22
21
|
|
23
22
|
def to_s
|
24
23
|
if menu.items.any?
|
25
|
-
|
24
|
+
tag.div(class: "btn-group", role: "group") do
|
26
25
|
safe_join([render, render_menu], "\n")
|
27
26
|
end
|
28
27
|
else
|
@@ -54,7 +53,7 @@ module Trestle
|
|
54
53
|
|
55
54
|
def button_label(content, options)
|
56
55
|
icon = icon(@icon) if @icon
|
57
|
-
label =
|
56
|
+
label = tag.span(content, class: "btn-label")
|
58
57
|
|
59
58
|
safe_join([icon, label].compact, " ")
|
60
59
|
end
|
@@ -77,21 +76,13 @@ module Trestle
|
|
77
76
|
class Link < Item
|
78
77
|
attr_reader :instance_or_url
|
79
78
|
|
80
|
-
def initialize(template, label, instance_or_url=
|
81
|
-
|
82
|
-
|
83
|
-
else
|
84
|
-
super(template, label, options, &block)
|
85
|
-
@instance_or_url = instance_or_url
|
86
|
-
end
|
79
|
+
def initialize(template, label, instance_or_url=nil, **options, &block)
|
80
|
+
super(template, label, **options, &block)
|
81
|
+
@instance_or_url = instance_or_url
|
87
82
|
end
|
88
83
|
|
89
84
|
def render
|
90
|
-
|
91
|
-
admin_link_to(button_label(label, options), instance_or_url, options)
|
92
|
-
else
|
93
|
-
admin_link_to(button_label(label, options), options)
|
94
|
-
end
|
85
|
+
admin_link_to(button_label(label, options), instance_or_url, **options)
|
95
86
|
end
|
96
87
|
end
|
97
88
|
|
@@ -102,7 +93,7 @@ module Trestle
|
|
102
93
|
|
103
94
|
def label
|
104
95
|
safe_join([
|
105
|
-
super,
|
96
|
+
super, tag.span("", class: "caret")
|
106
97
|
], " ")
|
107
98
|
end
|
108
99
|
|
data/lib/trestle/toolbar/menu.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Trestle
|
2
2
|
class Toolbar
|
3
3
|
class Menu
|
4
|
-
delegate :
|
4
|
+
delegate :tag, :safe_join, to: :@template
|
5
5
|
|
6
6
|
attr_reader :items
|
7
7
|
|
@@ -18,17 +18,17 @@ module Trestle
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def render_toggle(options={})
|
21
|
-
|
22
|
-
|
21
|
+
tag.button(type: "button", class: Array(options[:class]) + ["dropdown-toggle dropdown-toggle-split"], data: { bs_toggle: "dropdown" }, aria: { expanded: false }) do
|
22
|
+
tag.span(I18n.t("trestle.ui.toggle_dropdown", default: "Toggle dropdown"), class: "visually-hidden")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def render_items
|
27
|
-
|
27
|
+
tag.ul(safe_join(items, "\n"), class: "dropdown-menu dropdown-menu-end", role: "menu")
|
28
28
|
end
|
29
29
|
|
30
30
|
class Builder
|
31
|
-
delegate :admin_link_to, :
|
31
|
+
delegate :admin_link_to, :tag, to: :@template
|
32
32
|
|
33
33
|
def initialize(menu, template)
|
34
34
|
@menu, @template = menu, template
|
@@ -42,19 +42,19 @@ module Trestle
|
|
42
42
|
options[:class] = Array(options[:class])
|
43
43
|
options[:class] << "dropdown-item"
|
44
44
|
|
45
|
-
item { admin_link_to(content, instance_or_url, options, &block) }
|
45
|
+
item { admin_link_to(content, instance_or_url, **options, &block) }
|
46
46
|
end
|
47
47
|
|
48
48
|
def header(text)
|
49
|
-
item {
|
49
|
+
item { tag.h6(text, class: "dropdown-header") }
|
50
50
|
end
|
51
51
|
|
52
52
|
def divider
|
53
|
-
item { tag(
|
53
|
+
item { tag.hr(class: "dropdown-divider") }
|
54
54
|
end
|
55
55
|
|
56
56
|
def item(options={}, &block)
|
57
|
-
item = block_given? ?
|
57
|
+
item = block_given? ? tag.li(**options, &block) : tag.li("", **options)
|
58
58
|
|
59
59
|
@menu.items << item
|
60
60
|
|
data/lib/trestle/version.rb
CHANGED
data/lib/trestle.rb
CHANGED
@@ -44,8 +44,8 @@ module Trestle
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# Builds and registers a new admin resource
|
47
|
-
def self.resource(name,
|
48
|
-
register(Resource::Builder.create(name, options, &block)
|
47
|
+
def self.resource(name, **options, &block)
|
48
|
+
register(Resource::Builder.create(name, options, &block))
|
49
49
|
end
|
50
50
|
|
51
51
|
# Configuration methods
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "trestle",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.1",
|
4
4
|
"description": "A modern, responsive admin framework for Ruby on Rails",
|
5
5
|
"homepage": "https://trestle.io",
|
6
6
|
"repository": "https://github.com/TrestleAdmin/trestle.git",
|
@@ -18,15 +18,15 @@
|
|
18
18
|
"@babel/preset-env": "^7.20.2",
|
19
19
|
"autoprefixer": "^10.4.13",
|
20
20
|
"babel-loader": "^9.1.2",
|
21
|
-
"copy-webpack-plugin": "^
|
22
|
-
"css-loader": "^
|
23
|
-
"css-minimizer-webpack-plugin": "^
|
24
|
-
"expose-loader": "^
|
21
|
+
"copy-webpack-plugin": "^12.0.2",
|
22
|
+
"css-loader": "^7.1.2",
|
23
|
+
"css-minimizer-webpack-plugin": "^7.0.0",
|
24
|
+
"expose-loader": "^5.0.0",
|
25
25
|
"mini-css-extract-plugin": "^2.7.2",
|
26
26
|
"postcss": "^8.4.21",
|
27
|
-
"postcss-loader": "^
|
27
|
+
"postcss-loader": "^8.1.1",
|
28
28
|
"sass": "^1.57.1",
|
29
|
-
"sass-loader": "^
|
29
|
+
"sass-loader": "^16.0.2",
|
30
30
|
"webpack": "^5.75.0",
|
31
31
|
"webpack-bundle-analyzer": "^4.7.0",
|
32
32
|
"webpack-cli": "^5.0.1"
|