flexi_admin 0.0.5 → 0.0.6
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/README.md +254 -18
- data/lib/flexi_admin/components/helpers/action_helper.rb +21 -0
- data/lib/flexi_admin/components/helpers/frontend_helper.rb +23 -0
- data/lib/flexi_admin/components/helpers/link_helper.rb +35 -2
- data/lib/flexi_admin/components/helpers/resource_helper.rb +79 -14
- data/lib/flexi_admin/components/helpers/url_helper.rb +15 -0
- data/lib/flexi_admin/components/nav/breadcrumbs_component.html.slim +13 -0
- data/lib/flexi_admin/components/nav/breadcrumbs_component.rb +86 -0
- data/lib/flexi_admin/components/resource/autocomplete_component.html.slim +19 -7
- data/lib/flexi_admin/components/resource/autocomplete_component.rb +41 -11
- data/lib/flexi_admin/components/resource/button_select_component.html.slim +2 -2
- data/lib/flexi_admin/components/resource/button_select_component.rb +8 -1
- data/lib/flexi_admin/components/resource/filter_component.html.slim +47 -0
- data/lib/flexi_admin/components/resource/filter_component.rb +51 -0
- data/lib/flexi_admin/components/resource/form_component.rb +16 -1
- data/lib/flexi_admin/components/resource/form_element_component.rb +1 -1
- data/lib/flexi_admin/components/resource/form_mixin.rb +186 -42
- data/lib/flexi_admin/components/resource/link_action_component.html.slim +2 -2
- data/lib/flexi_admin/components/resource/link_action_component.rb +3 -2
- data/lib/flexi_admin/components/resource/view_component.html.slim +14 -4
- data/lib/flexi_admin/components/resource/view_component.rb +11 -2
- data/lib/flexi_admin/components/resources/bulk_action/button_component.rb +8 -1
- data/lib/flexi_admin/components/resources/bulk_action/modal_component.html.slim +21 -15
- data/lib/flexi_admin/components/resources/bulk_action/modal_component.rb +16 -8
- data/lib/flexi_admin/components/resources/bulk_action/row_action_button_component.html.slim +16 -0
- data/lib/flexi_admin/components/resources/bulk_action/row_action_button_component.rb +78 -0
- data/lib/flexi_admin/components/resources/bulk_action/row_actions_dropdown_component.html.slim +15 -0
- data/lib/flexi_admin/components/resources/bulk_action/row_actions_dropdown_component.rb +33 -0
- data/lib/flexi_admin/components/resources/grid_view/card_component.html.slim +4 -1
- data/lib/flexi_admin/components/resources/grid_view/card_component.rb +4 -1
- data/lib/flexi_admin/components/resources/grid_view/grid_component.html.slim +3 -1
- data/lib/flexi_admin/components/resources/grid_view/grid_component.rb +4 -2
- data/lib/flexi_admin/components/resources/grid_view_component.rb +7 -2
- data/lib/flexi_admin/components/resources/index_page_component.html.slim +5 -4
- data/lib/flexi_admin/components/resources/index_page_component.rb +1 -0
- data/lib/flexi_admin/components/resources/list_view/table_component.html.slim +1 -1
- data/lib/flexi_admin/components/resources/list_view_component.rb +2 -1
- data/lib/flexi_admin/components/resources/pagination_component.html.slim +51 -39
- data/lib/flexi_admin/components/resources/pagination_component.rb +52 -47
- data/lib/flexi_admin/components/resources/switch_view_component.html.slim +2 -2
- data/lib/flexi_admin/components/resources/view_component.html.slim +15 -6
- data/lib/flexi_admin/components/shared/medium_component.html.slim +1 -1
- data/lib/flexi_admin/components/shared/table/header_item_component.html.slim +1 -1
- data/lib/flexi_admin/components/shared/table/header_item_component.rb +59 -61
- data/lib/flexi_admin/components/shared/tabs_component.html.slim +26 -0
- data/lib/flexi_admin/components/shared/tabs_component.rb +68 -0
- data/lib/flexi_admin/components.rb +11 -3
- data/lib/flexi_admin/config.rb +21 -3
- data/lib/flexi_admin/controllers/modals_controller.rb +4 -2
- data/lib/flexi_admin/controllers/resources_controller.rb +246 -51
- data/lib/flexi_admin/engine.rb +4 -0
- data/lib/flexi_admin/helpers/application_helper.rb +3 -0
- data/lib/flexi_admin/javascript/controllers/add_row_controller.js +118 -0
- data/lib/flexi_admin/javascript/controllers/autocomplete_controller.js +17 -1
- data/lib/flexi_admin/javascript/controllers/bulk_action_controller.js +192 -33
- data/lib/flexi_admin/javascript/controllers/copy_to_clipboard_controller.js +16 -0
- data/lib/flexi_admin/javascript/controllers/datalist_controller.js +1 -1
- data/lib/flexi_admin/javascript/controllers/delete_controller.js +40 -0
- data/lib/flexi_admin/javascript/controllers/expandable_field_controller.js +15 -0
- data/lib/flexi_admin/javascript/controllers/filter_auto_submit_controller.js +93 -0
- data/lib/flexi_admin/javascript/controllers/index.js +18 -0
- data/lib/flexi_admin/javascript/controllers/pagination_controller.js +8 -0
- data/lib/flexi_admin/javascript/controllers/tabs_controller.js +24 -0
- data/lib/flexi_admin/models/concerns/application_resource.rb +6 -0
- data/lib/flexi_admin/models/concerns/parentable.rb +3 -0
- data/lib/flexi_admin/models/context_params.rb +35 -10
- data/lib/flexi_admin/models/resources/context.rb +4 -0
- data/lib/flexi_admin/routes.rb +7 -1
- data/lib/flexi_admin/services/create_resource.rb +6 -6
- data/lib/flexi_admin/version.rb +1 -1
- data/lib/flexi_admin/views/shared/_reload_frame.slim +19 -0
- data/lib/flexi_admin.rb +0 -3
- metadata +171 -10
|
@@ -1,64 +1,69 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
LIMIT = 10
|
|
3
|
+
class FlexiAdmin::Components::Resources::PaginationComponent < FlexiAdmin::Components::BaseComponent
|
|
4
|
+
MAX_PAGES_TO_SHOW_IN_PAGINATOR = 10
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
include FlexiAdmin::Components::Helpers::ResourceHelper
|
|
7
|
+
include FlexiAdmin::Components::Helpers::UrlHelper
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
attr_reader :context, :per_page, :page, :limited_pagination
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
def initialize(context, per_page:, page:)
|
|
12
|
+
super()
|
|
13
|
+
@context = context
|
|
14
|
+
@resources = context.resources
|
|
15
|
+
@parent = context.parent
|
|
16
|
+
@per_page = per_page
|
|
17
|
+
@page = page&.to_i
|
|
18
|
+
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
def limited_pages
|
|
21
|
+
if paginated_resources.total_pages < MAX_PAGES_TO_SHOW_IN_PAGINATOR
|
|
22
|
+
return (1..paginated_resources.total_pages).to_a
|
|
22
23
|
end
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
return (1..paginated_resources.total_pages).to_a if paginated_resources.total_pages < LIMIT
|
|
26
|
-
|
|
27
|
-
max = paginated_resources.total_pages
|
|
28
|
-
|
|
29
|
-
mid_range_start = if page > (LIMIT / 2) && page < (max - (LIMIT / 2))
|
|
30
|
-
page - (LIMIT / 2)
|
|
31
|
-
elsif page < (LIMIT / 2)
|
|
32
|
-
1
|
|
33
|
-
else
|
|
34
|
-
max - LIMIT
|
|
35
|
-
end
|
|
25
|
+
max = paginated_resources.total_pages
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
page
|
|
39
|
-
elsif page < (
|
|
40
|
-
|
|
27
|
+
mid_range_start = if page > (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2) && page < (max - (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2))
|
|
28
|
+
page - (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2)
|
|
29
|
+
elsif page < (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2)
|
|
30
|
+
1
|
|
41
31
|
else
|
|
42
|
-
max
|
|
32
|
+
max - MAX_PAGES_TO_SHOW_IN_PAGINATOR
|
|
43
33
|
end
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
mid_range_end = if page > (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2) && page < (max - (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2))
|
|
36
|
+
page + (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2)
|
|
37
|
+
elsif page < (MAX_PAGES_TO_SHOW_IN_PAGINATOR / 2)
|
|
38
|
+
MAX_PAGES_TO_SHOW_IN_PAGINATOR
|
|
39
|
+
else
|
|
40
|
+
max
|
|
41
|
+
end
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.merge(page: page_number, per_page:, frame: context.scope)
|
|
51
|
-
.to_params
|
|
43
|
+
[1, (mid_range_start..mid_range_end).to_a, max].flatten.compact.uniq
|
|
44
|
+
end
|
|
52
45
|
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
def page_path(page_number)
|
|
47
|
+
params = context.params
|
|
48
|
+
.merge(page: page_number, per_page: per_page, frame: context.scope_id)
|
|
49
|
+
.to_params
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
end
|
|
51
|
+
resources_path(**params.merge)
|
|
52
|
+
end
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
def per_page_path(new_per_page)
|
|
55
|
+
params = context.params
|
|
56
|
+
.merge(page: 1, per_page: new_per_page, frame: context.scope_id)
|
|
57
|
+
.to_params
|
|
58
|
+
|
|
59
|
+
resources_path(**params.merge)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def paginated_resources
|
|
63
|
+
@resources.paginate(page: page, per_page: per_page)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def total_pages
|
|
67
|
+
(resources.count / per_page.to_f).ceil
|
|
63
68
|
end
|
|
64
|
-
end
|
|
69
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.btn-group role="group"
|
|
2
2
|
- if list_view_available?
|
|
3
|
-
- path = resources_path(**context.params.merge(view: 'list', scope: context.scope, frame: context.
|
|
3
|
+
- path = resources_path(**context.params.merge(view: 'list', scope: context.scope, frame: context.scope_id).to_params)
|
|
4
4
|
.btn.btn-primary.opacity-75 [class="#{list_class}"
|
|
5
5
|
data-controller="switch-view"
|
|
6
6
|
data-action="click->switch-view#switch"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
i.bi.bi-list-ul
|
|
9
9
|
|
|
10
10
|
- if grid_view_available?
|
|
11
|
-
- path = resources_path(**context.params.merge(view: 'grid', scope: context.scope, frame: context.
|
|
11
|
+
- path = resources_path(**context.params.merge(view: 'grid', scope: context.scope, frame: context.scope_id).to_params)
|
|
12
12
|
.btn.btn-primary.opacity-75 [class="#{grid_class}"
|
|
13
13
|
data-controller="switch-view"
|
|
14
14
|
data-action="click->switch-view#switch"
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
turbo-frame [id="#{context.
|
|
1
|
+
turbo-frame [id="#{context.scope_id}"
|
|
2
2
|
data-controller="bulk-action"
|
|
3
|
-
data-bulk-action-scope-value="#{context.
|
|
4
|
-
= helpers.turbo_frame_tag "modalx_#{context.
|
|
3
|
+
data-bulk-action-scope-value="#{context.scope_id}"]
|
|
4
|
+
= helpers.turbo_frame_tag "modalx_#{context.scope_id}", 'data-turbo-temporary': true
|
|
5
5
|
.h2 = title
|
|
6
6
|
.py-2.d-flex.justify-content-between.align-items-center
|
|
7
|
-
.d-flex.gap-
|
|
7
|
+
.d-flex.gap-2
|
|
8
8
|
= actions
|
|
9
|
-
-
|
|
10
|
-
=
|
|
9
|
+
span.text-muted data-bulk-action-target="recordsInfo" data-total-count="#{context.resources&.count || 0}"
|
|
10
|
+
span data-bulk-action-target="defaultText"
|
|
11
|
+
= context.resources&.count || 0
|
|
12
|
+
|< záznamů
|
|
13
|
+
span data-bulk-action-target="selectionText" style="display: none;"
|
|
14
|
+
' vybráno
|
|
15
|
+
span data-bulk-action-target="counter" 0
|
|
16
|
+
| z #{context.resources&.count || 0} záznamů (
|
|
17
|
+
a href="#" data-action="click->bulk-action#clearSelection" zrušit výběr
|
|
18
|
+
| )
|
|
19
|
+
= render FlexiAdmin::Components::Resources::PaginationComponent.new(context, per_page: context.params.per_page, page: context.params.page)
|
|
11
20
|
.py-2
|
|
12
21
|
= views
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
div class="#{merged_classes}" data-controller="sorting" data-sorting-sort-path-value="#{sort_path}"
|
|
3
3
|
- if column.sortable?
|
|
4
4
|
a href="#" class="a text-decoration-none text-secondary" data-action="sorting#sort"
|
|
5
|
-
.d-flex class="#{
|
|
5
|
+
.d-flex class="#{justify.to_sym == :end ? 'justify-content-end' : 'justify-content-start'}"
|
|
6
6
|
= label
|
|
7
7
|
i.bi.text-primary.opacity-75.ms-2 class="#{sort_icon}"
|
|
8
8
|
- else
|
|
@@ -1,78 +1,76 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
attr_reader :column, :attr, :justify, :width, :sort_by
|
|
3
|
+
class FlexiAdmin::Components::Shared::Table::HeaderItemComponent < FlexiAdmin::Components::BaseComponent
|
|
4
|
+
include FlexiAdmin::Components::Helpers::ResourceHelper
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
@column = column
|
|
9
|
-
@justify = column.options[:justify] || :start
|
|
10
|
-
@width = column.options[:width] || ""
|
|
11
|
-
@attr = column.attribute
|
|
12
|
-
@sort_by = column.sort_by
|
|
13
|
-
@label = column.label
|
|
14
|
-
end
|
|
6
|
+
attr_reader :column, :attr, :justify, :width, :sort_by, :context
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
def initialize(column, context:)
|
|
9
|
+
@column = column
|
|
10
|
+
@context = context
|
|
11
|
+
@justify = column.options[:justify] || :start
|
|
12
|
+
@width = column.options[:width] || ""
|
|
13
|
+
@attr = column.attribute
|
|
14
|
+
@sort_by = column.sort_by
|
|
15
|
+
@label = column.label
|
|
16
|
+
end
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
else
|
|
24
|
-
view_context.context.params.merge({ sort: sort_by, order: }).to_path(request.path)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
18
|
+
def label
|
|
19
|
+
@label || attr.to_s.humanize
|
|
20
|
+
end
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
def sort_path
|
|
23
|
+
if order.blank?
|
|
24
|
+
resources_path(**context.params.merge)
|
|
25
|
+
else
|
|
26
|
+
resources_params = context.params
|
|
27
|
+
.merge(sort: sort_by, order: order)
|
|
28
|
+
.to_params
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
width.present? ? "col-#{width}" : "col"
|
|
30
|
+
resources_path(**resources_params.merge)
|
|
34
31
|
end
|
|
32
|
+
end
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"justify-content-start"
|
|
40
|
-
when :end
|
|
41
|
-
"justify-content-end"
|
|
42
|
-
else
|
|
43
|
-
"justify-content-start"
|
|
44
|
-
end
|
|
45
|
-
end
|
|
34
|
+
def merged_classes
|
|
35
|
+
[width_class, justify_class].join(" ")
|
|
36
|
+
end
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
def width_class
|
|
39
|
+
width.present? ? "col-#{width}" : "col"
|
|
40
|
+
end
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
when "desc"
|
|
54
|
-
"bi-arrow-down-square-fill"
|
|
55
|
-
else
|
|
56
|
-
"bi-arrow-up-square"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
42
|
+
def justify_class
|
|
43
|
+
justify.to_sym == :end ? "text-end" : ""
|
|
44
|
+
end
|
|
59
45
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return "asc" if view_context.context.params[:sort].to_s != sort_by.to_s
|
|
46
|
+
def sort_icon
|
|
47
|
+
return "bi-arrow-up-square" if view_context.context.params[:sort].to_s != sort_by.to_s
|
|
63
48
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
end
|
|
49
|
+
case view_context.context.params[:order]
|
|
50
|
+
when "asc"
|
|
51
|
+
"bi-arrow-up-square-fill"
|
|
52
|
+
when "desc"
|
|
53
|
+
"bi-arrow-down-square-fill"
|
|
54
|
+
else
|
|
55
|
+
"bi-arrow-up-square"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
74
58
|
|
|
75
|
-
|
|
59
|
+
def order
|
|
60
|
+
# Sorting by other column, so we need to reset the order
|
|
61
|
+
return "asc" if view_context.context.params[:sort].to_s != sort_by.to_s
|
|
62
|
+
|
|
63
|
+
order = case view_context.context.params[:order]
|
|
64
|
+
when "asc"
|
|
65
|
+
"desc"
|
|
66
|
+
when "desc"
|
|
67
|
+
"default"
|
|
68
|
+
when "default"
|
|
69
|
+
"asc"
|
|
70
|
+
else
|
|
71
|
+
"asc"
|
|
76
72
|
end
|
|
73
|
+
|
|
74
|
+
order
|
|
77
75
|
end
|
|
78
76
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
div.flexi-tabs id=id data-controller=("tabs" if remember?)
|
|
2
|
+
ul.nav.nav-tabs class=nav_class role="tablist"
|
|
3
|
+
- tabs.each do |tab|
|
|
4
|
+
- active = tab.key == active_key
|
|
5
|
+
li.nav-item role="presentation"
|
|
6
|
+
button.nav-link [class=('active' if active)
|
|
7
|
+
id=tab_dom_id(tab)
|
|
8
|
+
type="button"
|
|
9
|
+
role="tab"
|
|
10
|
+
data-bs-toggle="tab"
|
|
11
|
+
data-bs-target="##{pane_dom_id(tab)}"
|
|
12
|
+
data-tabs-key-param=tab.key
|
|
13
|
+
data-action=("shown.bs.tab->tabs#remember" if remember?)
|
|
14
|
+
aria-controls=pane_dom_id(tab)
|
|
15
|
+
aria-selected=active.to_s]
|
|
16
|
+
= tab.label
|
|
17
|
+
- unless tab.count.nil?
|
|
18
|
+
span.badge.rounded-pill.text-bg-light.ms-2 = tab.count
|
|
19
|
+
|
|
20
|
+
.tab-content
|
|
21
|
+
- tabs.each do |tab|
|
|
22
|
+
.tab-pane.fade [class=('show active' if tab.key == active_key)
|
|
23
|
+
id=pane_dom_id(tab)
|
|
24
|
+
role="tabpanel"
|
|
25
|
+
aria-labelledby=tab_dom_id(tab)]
|
|
26
|
+
= tab
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Bootstrap tabs for splitting a long page (typically a show page) into sections.
|
|
4
|
+
#
|
|
5
|
+
# = render FlexiAdmin::Components::Shared::TabsComponent.new(id: 'order') do |tabs|
|
|
6
|
+
# - tabs.with_tab(key: 'prehled', label: 'Přehled')
|
|
7
|
+
# = render EditFormComponent.new(resource)
|
|
8
|
+
# - tabs.with_tab(key: 'kalkulace', label: 'Kalkulace', count: calculations.size)
|
|
9
|
+
# = render CalculationsComponent.new(calculations)
|
|
10
|
+
#
|
|
11
|
+
# Every pane is rendered up front (plain Bootstrap panes, no lazy loading), so content keeps
|
|
12
|
+
# behaving exactly as it did on a single page. The open tab is kept in the URL hash
|
|
13
|
+
# (`#kalkulace`) by the `tabs` Stimulus controller, so a reload or a shared link reopens it;
|
|
14
|
+
# pass `remember: false` to opt out.
|
|
15
|
+
module FlexiAdmin::Components::Shared
|
|
16
|
+
class TabsComponent < FlexiAdmin::Components::BaseComponent
|
|
17
|
+
# One tab and its pane. The slot's block is the pane content.
|
|
18
|
+
class Tab < FlexiAdmin::Components::BaseComponent
|
|
19
|
+
attr_reader :key, :label, :count
|
|
20
|
+
|
|
21
|
+
def initialize(key:, label:, count: nil, active: false)
|
|
22
|
+
@key = key.to_s
|
|
23
|
+
@label = label
|
|
24
|
+
@count = count
|
|
25
|
+
@active = active
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def active?
|
|
29
|
+
@active
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def call
|
|
33
|
+
content
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
renders_many :tabs, Tab
|
|
38
|
+
|
|
39
|
+
attr_reader :id, :nav_class
|
|
40
|
+
|
|
41
|
+
def initialize(id:, remember: true, nav_class: "mb-4")
|
|
42
|
+
@id = id
|
|
43
|
+
@remember = remember
|
|
44
|
+
@nav_class = nav_class
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def remember?
|
|
48
|
+
@remember
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The tab marked active:, or the first one — so the page always opens on a visible pane.
|
|
52
|
+
def active_key
|
|
53
|
+
@active_key ||= (tabs.find(&:active?) || tabs.first)&.key
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def tab_dom_id(tab)
|
|
57
|
+
"#{id}-tab-#{tab.key}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def pane_dom_id(tab)
|
|
61
|
+
"#{id}-pane-#{tab.key}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def render?
|
|
65
|
+
tabs?
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -22,9 +22,6 @@ end
|
|
|
22
22
|
# Base Component
|
|
23
23
|
require_relative "components/base_component"
|
|
24
24
|
|
|
25
|
-
# Nav Components
|
|
26
|
-
require_relative "components/nav/floating_toc_component"
|
|
27
|
-
|
|
28
25
|
# Helpers
|
|
29
26
|
require_relative "components/helpers/action_button_helper"
|
|
30
27
|
require_relative "components/helpers/action_helper"
|
|
@@ -34,9 +31,14 @@ require_relative "components/helpers/url_helper"
|
|
|
34
31
|
require_relative "components/helpers/resource_helper"
|
|
35
32
|
require_relative "components/helpers/selectable"
|
|
36
33
|
require_relative "components/helpers/value_formatter"
|
|
34
|
+
require_relative "components/helpers/frontend_helper"
|
|
37
35
|
|
|
38
36
|
require_relative "components/resource/form_mixin"
|
|
39
37
|
|
|
38
|
+
# Nav Components
|
|
39
|
+
require_relative "components/nav/floating_toc_component"
|
|
40
|
+
require_relative "components/nav/breadcrumbs_component"
|
|
41
|
+
|
|
40
42
|
# Action Components
|
|
41
43
|
require_relative "components/actions/checkbox_component"
|
|
42
44
|
require_relative "components/actions/select_component"
|
|
@@ -49,6 +51,7 @@ require_relative "components/form/text_input_component"
|
|
|
49
51
|
|
|
50
52
|
# Resource Components
|
|
51
53
|
require_relative "components/resource/autocomplete_component"
|
|
54
|
+
require_relative "components/resource/filter_component"
|
|
52
55
|
require_relative "components/resource/button_select_component"
|
|
53
56
|
require_relative "components/resource/form_component"
|
|
54
57
|
require_relative "components/resource/form_element_component"
|
|
@@ -71,6 +74,7 @@ require_relative "components/shared/medium_component"
|
|
|
71
74
|
require_relative "components/shared/table/header_item_component"
|
|
72
75
|
require_relative "components/shared/trix_component"
|
|
73
76
|
require_relative "components/shared/link_component"
|
|
77
|
+
require_relative "components/shared/tabs_component"
|
|
74
78
|
|
|
75
79
|
# Resources List View Components
|
|
76
80
|
require_relative "components/resources/list_view/cell_component"
|
|
@@ -85,3 +89,7 @@ require_relative "components/resources/list_view_component"
|
|
|
85
89
|
# Bulk Action Components
|
|
86
90
|
require_relative "components/resources/bulk_action/modal_component"
|
|
87
91
|
require_relative "components/resources/bulk_action/button_component"
|
|
92
|
+
require_relative "components/resources/bulk_action/row_action_button_component"
|
|
93
|
+
require_relative "components/resources/bulk_action/row_actions_dropdown_component"
|
|
94
|
+
|
|
95
|
+
# Helper Components
|
data/lib/flexi_admin/config.rb
CHANGED
|
@@ -2,11 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
module FlexiAdmin
|
|
4
4
|
class Config
|
|
5
|
+
PAGINATE_PER_OPTIONS = [12, 24, 48, 96].freeze
|
|
6
|
+
PAGINATE_PER_DEFAULT = 12
|
|
7
|
+
# How many rows an autocomplete offers when the field is focused but empty.
|
|
8
|
+
AUTOCOMPLETE_SUGGESTIONS_DEFAULT = 12
|
|
9
|
+
|
|
10
|
+
def self.paginate_per_options
|
|
11
|
+
PAGINATE_PER_OPTIONS
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.paginate_per_default
|
|
15
|
+
PAGINATE_PER_DEFAULT
|
|
16
|
+
end
|
|
17
|
+
|
|
5
18
|
class Store
|
|
6
|
-
attr_accessor :
|
|
7
|
-
|
|
19
|
+
attr_accessor :namespace, :module_namespace, :paginate_per, :paginate_per_options,
|
|
20
|
+
:autocomplete_suggestions
|
|
8
21
|
|
|
9
|
-
|
|
22
|
+
def initialize
|
|
23
|
+
@paginate_per = PAGINATE_PER_DEFAULT
|
|
24
|
+
@paginate_per_options = PAGINATE_PER_OPTIONS
|
|
25
|
+
@autocomplete_suggestions = AUTOCOMPLETE_SUGGESTIONS_DEFAULT
|
|
26
|
+
end
|
|
10
27
|
end
|
|
11
28
|
|
|
12
29
|
class << self
|
|
@@ -18,6 +35,7 @@ module FlexiAdmin
|
|
|
18
35
|
|
|
19
36
|
def configure
|
|
20
37
|
yield(configuration)
|
|
38
|
+
WillPaginate.per_page = configuration.paginate_per
|
|
21
39
|
end
|
|
22
40
|
end
|
|
23
41
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
class FlexiAdmin::Controllers::ModalsController < ActionController::Base
|
|
4
|
+
include FlexiAdmin::Controllers::ResourcesController
|
|
5
|
+
|
|
4
6
|
def show
|
|
5
7
|
component_class = params[:kind].gsub("-", "/").camelize.constantize
|
|
6
8
|
|
|
@@ -8,6 +10,6 @@ module FlexiAdmin::Controllers::ModalsController
|
|
|
8
10
|
|
|
9
11
|
context = FlexiAdmin::Models::Resources::Context.from_params(context_params)
|
|
10
12
|
|
|
11
|
-
render turbo_stream: turbo_stream.update("modalx_#{context.
|
|
13
|
+
render turbo_stream: turbo_stream.update("modalx_#{context.scope_id}", component_class.new(context))
|
|
12
14
|
end
|
|
13
15
|
end
|