swop 0.1.0 → 1.0.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/README.md +47 -9
- data/app/assets/images/swop/favicon.ico +0 -0
- data/app/assets/stylesheets/rails_admin/application.scss.erb +11 -34
- data/app/assets/stylesheets/{rails_admin/custom/base/base.scss → swop/swop-base/swop-base.scss} +1 -1
- data/app/assets/stylesheets/swop/swop-base/swop-typography.scss +11 -0
- data/app/assets/stylesheets/swop/swop-colors/swop-colors.scss +2 -0
- data/app/assets/stylesheets/swop/swop-core/swop-bootstrap-variables.scss +172 -0
- data/app/assets/stylesheets/{rails_admin/custom/base/mixins.scss → swop/swop-core/swop-mixins.scss} +0 -16
- data/app/assets/stylesheets/swop/swop-core/swop-variables.scss +34 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-base/swop-base.scss +3 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-base/swop-main.scss +25 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-base/swop-typography.scss +4 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-amethyst.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-dark.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-forest.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-light.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-colors/swop-royal.scss +29 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-alerts.scss +12 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-badges.scss +31 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-buttons.scss +133 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-dropdowns.scss +26 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-filters.scss +57 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-forms.scss +158 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-images.scss +31 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-input-groups.scss +18 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-loading.scss +14 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-navbar.scss +15 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-navs.scss +77 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-offcanvas.scss +64 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-pagination.scss +21 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-progress.scss +3 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-sidebars.scss +49 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-tables.scss +82 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-components/swop-tiles.scss +20 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-core/swop-bootstrap-variables.scss +149 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-core/swop-variables.scss +41 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-layouts/swop-containers.scss +24 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-layouts/swop-header.scss +15 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-amethyst.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-base.scss +3 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-components.scss +17 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-dark.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-forest.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-layouts.scss +2 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-light.scss +35 -0
- data/app/assets/stylesheets/swop/swop-themes/swop-simple/swop-simple-royal.scss +35 -0
- data/app/assets/stylesheets/swop/swop.scss +8 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb +7 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb +5 -0
- data/app/views/kaminari/ra-twitter-bootstrap/default/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/default/_prev_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/swop-simple/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/swop-simple/_prev_page.html.erb +9 -0
- data/app/views/layouts/rails_admin/_head.html.erb +5 -0
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.erb +5 -1
- data/app/views/layouts/rails_admin/application.html.erb +5 -24
- data/app/views/layouts/rails_admin/content.html.erb +4 -56
- data/app/views/layouts/rails_admin/default/_application.html.erb +27 -0
- data/app/views/layouts/rails_admin/default/_content.html.erb +22 -0
- data/app/views/layouts/rails_admin/default/_head.html.erb +32 -0
- data/app/views/layouts/rails_admin/default/_sidebar_navigation.html.erb +5 -0
- data/app/views/layouts/rails_admin/swop-simple/_application.html.erb +17 -0
- data/app/views/layouts/rails_admin/swop-simple/_content.html.erb +41 -0
- data/app/views/layouts/rails_admin/swop-simple/_head.html.erb +42 -0
- data/app/views/layouts/rails_admin/swop-simple/_sidebar_navigation.html.erb +12 -0
- data/app/views/rails_admin/main/_delete_notice.html.erb +7 -0
- data/app/views/rails_admin/main/default/_delete.html.erb +21 -0
- data/app/views/rails_admin/main/default/_delete_notice.html.erb +34 -0
- data/app/views/rails_admin/main/default/_edit.html.erb +3 -0
- data/app/views/rails_admin/main/default/_export.html.erb +149 -0
- data/app/views/rails_admin/main/default/_history.html.erb +80 -0
- data/app/views/rails_admin/main/default/_index.html.erb +184 -0
- data/app/views/rails_admin/main/default/_new.html.erb +3 -0
- data/app/views/rails_admin/main/default/_show.html.erb +30 -0
- data/app/views/rails_admin/main/delete.html.erb +5 -19
- data/app/views/rails_admin/main/edit.html.erb +5 -5
- data/app/views/rails_admin/main/export.html.erb +5 -128
- data/app/views/rails_admin/main/history.html.erb +5 -0
- data/app/views/rails_admin/main/index.html.erb +4 -169
- data/app/views/rails_admin/main/new.html.erb +5 -5
- data/app/views/rails_admin/main/show.html.erb +5 -28
- data/app/views/rails_admin/main/swop-simple/_delete.html.erb +11 -0
- data/app/views/rails_admin/main/swop-simple/_delete_notice.html.erb +23 -0
- data/app/views/rails_admin/main/swop-simple/_edit.html.erb +3 -0
- data/app/views/rails_admin/main/swop-simple/_export.html.erb +90 -0
- data/app/views/rails_admin/main/swop-simple/_history.html.erb +80 -0
- data/app/views/rails_admin/main/swop-simple/_index.html.erb +169 -0
- data/app/views/rails_admin/main/swop-simple/_new.html.erb +3 -0
- data/app/views/rails_admin/main/swop-simple/_show.html.erb +18 -0
- data/lib/swop/engine.rb +8 -3
- data/lib/swop/railtie.rb +7 -0
- data/lib/swop/version.rb +1 -1
- data/lib/swop.rb +20 -1
- metadata +101 -84
- data/CHANGELOG.md +0 -5
- data/CODE_OF_CONDUCT.md +0 -132
- data/LICENSE +0 -201
- data/Rakefile +0 -4
- data/app/assets/javascripts/rails_admin/application.js.erb +0 -32
- data/app/assets/javascripts/rails_admin/custom/filtering-select.js +0 -304
- data/app/assets/javascripts/rails_admin/custom/sidescroll.js +0 -20
- data/app/assets/javascripts/rails_admin/custom/ui.js +0 -11
- data/app/assets/stylesheets/rails_admin/custom/base/bootstrap-variables.scss +0 -196
- data/app/assets/stylesheets/rails_admin/custom/base/typography.scss +0 -16
- data/app/assets/stylesheets/rails_admin/custom/base/variables.scss +0 -86
- data/app/assets/stylesheets/rails_admin/custom/components/breadcrumbs.scss +0 -18
- data/app/assets/stylesheets/rails_admin/custom/components/buttons.scss +0 -55
- data/app/assets/stylesheets/rails_admin/custom/components/dropdowns.scss +0 -40
- data/app/assets/stylesheets/rails_admin/custom/components/filtering-select.scss +0 -43
- data/app/assets/stylesheets/rails_admin/custom/components/forms.scss +0 -25
- data/app/assets/stylesheets/rails_admin/custom/components/images.scss +0 -21
- data/app/assets/stylesheets/rails_admin/custom/components/navbar.scss +0 -18
- data/app/assets/stylesheets/rails_admin/custom/components/navs.scss +0 -28
- data/app/assets/stylesheets/rails_admin/custom/components/offcanvas.scss +0 -18
- data/app/assets/stylesheets/rails_admin/custom/components/progress.scss +0 -11
- data/app/assets/stylesheets/rails_admin/custom/components/sidebar.scss +0 -115
- data/app/assets/stylesheets/rails_admin/custom/components/table.scss +0 -59
- data/app/assets/stylesheets/rails_admin/custom/components/tiles.scss +0 -20
- data/app/assets/stylesheets/rails_admin/custom/layouts/body.scss +0 -10
- data/app/assets/stylesheets/rails_admin/custom/layouts/containers.scss +0 -31
- data/app/helpers/rails_admin/application_helper.rb +0 -270
- data/app/views/layouts/rails_admin/custom/_nav.html.erb +0 -10
- data/app/views/rails_admin/main/_submit_buttons.html.erb +0 -25
- data/app/views/rails_admin/main/dashboard.html.erb +0 -70
- data/sig/swop.rbs +0 -4
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RailsAdmin
|
|
4
|
-
module ApplicationHelper
|
|
5
|
-
def authorized?(action_name, abstract_model = nil, object = nil)
|
|
6
|
-
object = nil if object.try :new_record?
|
|
7
|
-
action(action_name, abstract_model, object).try(:authorized?)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def current_action
|
|
11
|
-
params[:action].in?(%w[create new]) ? 'create' : 'update'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def current_action?(action, abstract_model = @abstract_model, object = @object)
|
|
15
|
-
@action.custom_key == action.custom_key &&
|
|
16
|
-
abstract_model.try(:to_param) == @abstract_model.try(:to_param) &&
|
|
17
|
-
(@object.try(:persisted?) ? @object.id == object.try(:id) : !object.try(:persisted?))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def action(key, abstract_model = nil, object = nil)
|
|
21
|
-
RailsAdmin::Config::Actions.find(key, controller: controller, abstract_model: abstract_model, object: object)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def actions(scope = :all, abstract_model = nil, object = nil)
|
|
25
|
-
RailsAdmin::Config::Actions.all(scope, controller: controller, abstract_model: abstract_model, object: object)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def edit_user_link
|
|
29
|
-
return nil unless _current_user.try(:email).present?
|
|
30
|
-
return nil unless (abstract_model = RailsAdmin.config(_current_user.class).abstract_model)
|
|
31
|
-
|
|
32
|
-
edit_action = action(:edit, abstract_model, _current_user)
|
|
33
|
-
authorized = edit_action.try(:authorized?)
|
|
34
|
-
content = edit_user_link_label
|
|
35
|
-
|
|
36
|
-
if authorized
|
|
37
|
-
edit_url = rails_admin.url_for(
|
|
38
|
-
action: edit_action.action_name,
|
|
39
|
-
model_name: abstract_model.to_param,
|
|
40
|
-
controller: 'rails_admin/main',
|
|
41
|
-
id: _current_user.id,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
link_to content, edit_url, class: 'nav-link'
|
|
45
|
-
else
|
|
46
|
-
content_tag :span, content, class: 'nav-link'
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def logout_path
|
|
51
|
-
if defined?(Devise)
|
|
52
|
-
scope = Devise::Mapping.find_scope!(_current_user)
|
|
53
|
-
begin
|
|
54
|
-
main_app.send("destroy_#{scope}_session_path")
|
|
55
|
-
rescue StandardError
|
|
56
|
-
false
|
|
57
|
-
end
|
|
58
|
-
elsif main_app.respond_to?(:logout_path)
|
|
59
|
-
main_app.logout_path
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def logout_method
|
|
64
|
-
return [Devise.sign_out_via].flatten.first if defined?(Devise)
|
|
65
|
-
|
|
66
|
-
:delete
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def wording_for(label, action = @action, abstract_model = @abstract_model, object = @object)
|
|
70
|
-
model_config = abstract_model.try(:config)
|
|
71
|
-
object = nil unless abstract_model && object.is_a?(abstract_model.model)
|
|
72
|
-
action = RailsAdmin::Config::Actions.find(action.to_sym) if action.is_a?(Symbol) || action.is_a?(String)
|
|
73
|
-
|
|
74
|
-
I18n.t(
|
|
75
|
-
"admin.actions.#{action.i18n_key}.#{label}",
|
|
76
|
-
model_label: model_config&.label,
|
|
77
|
-
model_label_plural: model_config&.label_plural,
|
|
78
|
-
object_label: model_config && object.try(model_config.object_label_method),
|
|
79
|
-
)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def main_navigation
|
|
83
|
-
nodes_stack = RailsAdmin::Config.visible_models(controller: controller)
|
|
84
|
-
node_model_names = nodes_stack.collect { |c| c.abstract_model.model_name }
|
|
85
|
-
parent_groups = nodes_stack.group_by { |n| n.parent&.to_s }
|
|
86
|
-
|
|
87
|
-
nodes_stack.group_by(&:navigation_label).collect do |navigation_label, nodes|
|
|
88
|
-
nodes = nodes.select { |n| n.parent.nil? || !n.parent.to_s.in?(node_model_names) }
|
|
89
|
-
li_stack = navigation parent_groups, nodes
|
|
90
|
-
|
|
91
|
-
label = navigation_label || t('admin.misc.navigation')
|
|
92
|
-
|
|
93
|
-
collapsible_stack(label, 'main', li_stack)
|
|
94
|
-
end.join.html_safe
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def root_navigation
|
|
98
|
-
actions(:root).select(&:show_in_sidebar).group_by(&:sidebar_label).collect do |label, nodes|
|
|
99
|
-
li_stack = nodes.map do |node|
|
|
100
|
-
url = rails_admin.url_for(action: node.action_name, controller: 'rails_admin/main')
|
|
101
|
-
nav_icon = node.link_icon ? %(<i class="#{node.link_icon}"></i>).html_safe : ''
|
|
102
|
-
content_tag :li do
|
|
103
|
-
link_to nav_icon + " " + wording_for(:menu, node), url, class: "nav-link"
|
|
104
|
-
end
|
|
105
|
-
end.join.html_safe
|
|
106
|
-
label ||= t('admin.misc.root_navigation')
|
|
107
|
-
|
|
108
|
-
collapsible_stack(label, 'action', li_stack)
|
|
109
|
-
end.join.html_safe
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def static_navigation
|
|
113
|
-
li_stack = RailsAdmin::Config.navigation_static_links.collect do |title, url|
|
|
114
|
-
content_tag(:li, link_to(title.to_s, url, target: '_blank', rel: 'noopener noreferrer', class: 'nav-link'))
|
|
115
|
-
end.join.html_safe
|
|
116
|
-
|
|
117
|
-
label = RailsAdmin::Config.navigation_static_label || t('admin.misc.navigation_static_label')
|
|
118
|
-
collapsible_stack(label, 'static', li_stack) || ''
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def navigation(parent_groups, nodes, level = 0)
|
|
122
|
-
nodes.collect do |node|
|
|
123
|
-
abstract_model = node.abstract_model
|
|
124
|
-
model_param = abstract_model.to_param
|
|
125
|
-
url = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
|
|
126
|
-
nav_icon = node.navigation_icon ? %(<i class="#{node.navigation_icon}"></i>).html_safe : ''
|
|
127
|
-
css_classes = ['nav-link']
|
|
128
|
-
css_classes.push("nav-level-#{level}") if level > 0
|
|
129
|
-
css_classes.push('active') if @action && current_action?(@action, model_param)
|
|
130
|
-
li = content_tag :li, data: {model: model_param} do
|
|
131
|
-
link_to nav_icon + " " + node.label_plural, url, class: css_classes.join(' ')
|
|
132
|
-
end
|
|
133
|
-
child_nodes = parent_groups[abstract_model.model_name]
|
|
134
|
-
child_nodes ? li + navigation(parent_groups, child_nodes, level + 1) : li
|
|
135
|
-
end.join.html_safe
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def breadcrumb(action = @action, _acc = [])
|
|
139
|
-
begin
|
|
140
|
-
(parent_actions ||= []) << action
|
|
141
|
-
end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent)) # rubocop:disable Lint/Loop
|
|
142
|
-
|
|
143
|
-
content_tag(:ol, class: 'breadcrumb') do
|
|
144
|
-
parent_actions.collect do |a|
|
|
145
|
-
am = a.send(:eval, 'bindings[:abstract_model]')
|
|
146
|
-
o = a.send(:eval, 'bindings[:object]')
|
|
147
|
-
content_tag(:li, class: ['breadcrumb-item', current_action?(a, am, o) && 'active']) do
|
|
148
|
-
if current_action?(a, am, o)
|
|
149
|
-
wording_for(:breadcrumb, a, am, o)
|
|
150
|
-
elsif a.http_methods.include?(:get)
|
|
151
|
-
link_to rails_admin.url_for(action: a.action_name, controller: 'rails_admin/main', model_name: am.try(:to_param), id: (o.try(:persisted?) && o.try(:id) || nil)) do
|
|
152
|
-
wording_for(:breadcrumb, a, am, o)
|
|
153
|
-
end
|
|
154
|
-
else
|
|
155
|
-
content_tag(:span, wording_for(:breadcrumb, a, am, o))
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end.reverse.join.html_safe
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
# parent => :root, :collection, :member
|
|
163
|
-
# perf matters here (no action view trickery)
|
|
164
|
-
def menu_for(parent, abstract_model = nil, object = nil, only_icon = false)
|
|
165
|
-
actions = actions(parent, abstract_model, object).select { |a| a.http_methods.include?(:get) && a.show_in_menu }
|
|
166
|
-
|
|
167
|
-
# Filter out list action
|
|
168
|
-
actions.reject! { |action| %i[index].include?(action.key) }
|
|
169
|
-
|
|
170
|
-
# Sort actions
|
|
171
|
-
actions.sort_by! { |action| action.key.to_s }
|
|
172
|
-
|
|
173
|
-
actions.collect do |action|
|
|
174
|
-
wording = wording_for(:menu, action)
|
|
175
|
-
link_class = ["#{action.key}_#{parent}_link"].concat(action.enabled? ? [] : ['disabled'])
|
|
176
|
-
label = content_tag(:i, '', {class: "fa-sm fa-fw #{action.link_icon}"}) + ' ' + content_tag(:span, wording, (only_icon ? {style: 'display:none'} : {}))
|
|
177
|
-
if action.enabled? || !only_icon
|
|
178
|
-
href =
|
|
179
|
-
if action.enabled?
|
|
180
|
-
rails_admin.url_for(action: action.action_name, controller: 'rails_admin/main', model_name: abstract_model.try(:to_param), id: (object.try(:persisted?) && object.try(:id) || nil))
|
|
181
|
-
else
|
|
182
|
-
'javascript:void(0)'
|
|
183
|
-
end
|
|
184
|
-
button_class = action.key == :new ? 'btn btn-primary' : 'btn btn-white'
|
|
185
|
-
content_tag(:div, class: "col-md-auto") do
|
|
186
|
-
content_tag(:a, label, {href: href, target: action.link_target, class: [link_class, button_class, !action.enabled? && 'disabled'].compact}.merge(action.turbo? ? {} : {data: {turbo: 'false'}}))
|
|
187
|
-
end
|
|
188
|
-
else
|
|
189
|
-
content_tag(:span, label)
|
|
190
|
-
end
|
|
191
|
-
end.join(' ').html_safe
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def bulk_menu(abstract_model = @abstract_model)
|
|
195
|
-
actions = actions(:bulkable, abstract_model)
|
|
196
|
-
return '' if actions.empty?
|
|
197
|
-
content_tag(:div, class: "dropdown") do
|
|
198
|
-
content_tag(:button, class: 'btn btn-white dropdown-toggle', data: {'bs-toggle': 'dropdown'}) { t('admin.misc.bulk_menu_title').html_safe + ' ' + '<b class="caret"></b>'.html_safe } +
|
|
199
|
-
content_tag(:ul, class: 'dropdown-menu', style: 'left:auto; right:0;') do
|
|
200
|
-
actions.collect do |action|
|
|
201
|
-
content_tag :li do
|
|
202
|
-
link_to wording_for(:bulk_link, action, abstract_model), '#', class: 'dropdown-item bulk-link', data: {action: action.action_name}
|
|
203
|
-
end
|
|
204
|
-
end.join.html_safe
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def flash_alert_class(flash_key)
|
|
210
|
-
case flash_key.to_s
|
|
211
|
-
when 'error' then 'alert-danger'
|
|
212
|
-
when 'alert' then 'alert-warning'
|
|
213
|
-
when 'notice' then 'alert-info'
|
|
214
|
-
else "alert-#{flash_key}"
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
def handle_asset_dependency_error
|
|
219
|
-
yield
|
|
220
|
-
rescue LoadError => e
|
|
221
|
-
if /sassc/.match?(e.message)
|
|
222
|
-
e = e.exception <<~MSG
|
|
223
|
-
#{e.message}
|
|
224
|
-
RailsAdmin requires the gem sassc-rails, make sure to put `gem 'sassc-rails'` to Gemfile.
|
|
225
|
-
MSG
|
|
226
|
-
end
|
|
227
|
-
raise e
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
# Workaround for https://github.com/rails/rails/issues/31325
|
|
231
|
-
def image_tag(source, options = {})
|
|
232
|
-
if %w[ActiveStorage::Variant ActiveStorage::VariantWithRecord ActiveStorage::Preview].include? source.class.to_s
|
|
233
|
-
super main_app.route_for(ActiveStorage.resolve_model_to_route, source), options
|
|
234
|
-
else
|
|
235
|
-
super
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
private
|
|
240
|
-
|
|
241
|
-
def edit_user_link_label
|
|
242
|
-
[
|
|
243
|
-
RailsAdmin::Config.show_gravatar &&
|
|
244
|
-
image_tag(gravatar_url(_current_user.email), alt: ''),
|
|
245
|
-
|
|
246
|
-
content_tag(:span, _current_user.email),
|
|
247
|
-
].filter(&:present?).join.html_safe
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
def gravatar_url(email)
|
|
251
|
-
"https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest email}?s=30"
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
def collapsible_stack(label, class_prefix, li_stack)
|
|
255
|
-
return nil unless li_stack.present?
|
|
256
|
-
|
|
257
|
-
collapse_classname = "#{class_prefix}-#{Digest::MD5.hexdigest(label)[0..7]}"
|
|
258
|
-
content_tag(:li, class: 'mb-1') do
|
|
259
|
-
content_tag(:button, 'aria-expanded': true, class: 'btn btn-toggle align-items-center rounded', data: {bs_toggle: "collapse", bs_target: ".sidebar .#{collapse_classname}"}) do
|
|
260
|
-
content_tag(:i, '', class: 'fas fa-chevron-down') + html_escape(' ' + label)
|
|
261
|
-
end +
|
|
262
|
-
content_tag(:div, class: "collapse show #{collapse_classname}") do
|
|
263
|
-
content_tag(:ul, class: 'btn-toggle-nav list-unstyled fw-normal pb-1') do
|
|
264
|
-
li_stack
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<ul class="sidebar list-unstyled mb-0">
|
|
2
|
-
<% actions(:root).select(&:show_in_navigation).each do |action| %>
|
|
3
|
-
<li class="nav-item <%= action.action_name %>_root_link">
|
|
4
|
-
<%= link_to "<i class='fas fa-fw fa-sm fa-pie-chart'></i>#{wording_for(:menu, action)}".html_safe, { action: action.action_name, controller: "rails_admin/main" }, {class: ["nav-link #{"active" if current_page?("/")}"]}.merge(action.turbo? ? {} : {data: {turbo: "false"}}) %>
|
|
5
|
-
</li>
|
|
6
|
-
<% end %>
|
|
7
|
-
<%= main_navigation %>
|
|
8
|
-
<%= root_navigation %>
|
|
9
|
-
<%= static_navigation %>
|
|
10
|
-
</ul>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<div class="form-actions row justify-content-end my-3">
|
|
2
|
-
<div class="col-sm-24 d-flex justify-content-end gap-3 flex-column flex-md-row">
|
|
3
|
-
<input name="return_to" type="<%= :hidden %>" value="<%= (params[:return_to].presence || request.referer) %>" />
|
|
4
|
-
<button class="btn btn-primary" data-disable-with="<%= t("admin.form.save") %>" name="_save" type="submit"<%= ' disabled' unless @action.enabled? %>>
|
|
5
|
-
<i class="fas fa-check"></i>
|
|
6
|
-
<%= t("admin.form.save") %>
|
|
7
|
-
</button>
|
|
8
|
-
<span class="extra_buttons d-flex flex-column flex-md-row gap-3">
|
|
9
|
-
<% if @action.enabled? && authorized?(:new, @abstract_model) %>
|
|
10
|
-
<button class="btn btn-white" data-disable-with="<%= t("admin.form.save_and_add_another") %>" name="_add_another" type="submit">
|
|
11
|
-
<%= t("admin.form.save_and_add_another") %>
|
|
12
|
-
</button>
|
|
13
|
-
<% end %>
|
|
14
|
-
<% if @action.enabled? && authorized?(:edit, @abstract_model) %>
|
|
15
|
-
<button class="btn btn-white" data-disable-with="<%= t("admin.form.save_and_edit") %>" name="_add_edit" type="submit"<%= ' disabled' unless @action.enabled? %>>
|
|
16
|
-
<%= t("admin.form.save_and_edit") %>
|
|
17
|
-
</button>
|
|
18
|
-
<% end %>
|
|
19
|
-
<button class="btn btn-light" data-disable-with="<%= t("admin.form.cancel") %>" formnovalidate="<%= true %>" name="_continue" type="submit">
|
|
20
|
-
<i class="fas fa-times"></i>
|
|
21
|
-
<%= t("admin.form.cancel") %>
|
|
22
|
-
</button>
|
|
23
|
-
</span>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<% if @abstract_models %>
|
|
2
|
-
<section class="bg-white p-4 p-md-5 p-lg-6 shadow rounded-3">
|
|
3
|
-
<div class="row align-items-baseline gx-3 gy-0 gx-md-4 gx-lg-5 gx-xl-6">
|
|
4
|
-
<div class="col-11 col-md-6">
|
|
5
|
-
<div class="small text-muted fw-semibold"><%= t "admin.table_headers.model_name" %></div>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="col order-md-last">
|
|
8
|
-
<div class="small text-muted fw-semibold"><%= t "admin.table_headers.records" %></div>
|
|
9
|
-
</div>
|
|
10
|
-
<!-- if md breakpoint -->
|
|
11
|
-
<div class="col col-md-7 d-none d-md-block">
|
|
12
|
-
<div class="small text-muted fw-semibold"><%= t "admin.table_headers.last_created" %></div>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
<% @abstract_models.each do |abstract_model| %>
|
|
16
|
-
<% if authorized? :index, abstract_model %>
|
|
17
|
-
<hr class="my-1">
|
|
18
|
-
<% index_path = index_path(model_name: abstract_model.to_param) %>
|
|
19
|
-
<% last_created = @most_recent_created[abstract_model.model.name] %>
|
|
20
|
-
<% active = last_created.try(:today?) %>
|
|
21
|
-
<div class="row align-items-baseline gx-3 gy-0 gx-md-4 gx-lg-5 gx-xl-6 small">
|
|
22
|
-
<div class="col-11 col-md-6">
|
|
23
|
-
<%= link_to abstract_model.config.label_plural, index_path, class: "fw-bold text-dark" %>
|
|
24
|
-
<% if last_created %>
|
|
25
|
-
<div class="small lh-sm d-md-none">
|
|
26
|
-
<%= t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t("admin.misc.ago")}" if last_created %>
|
|
27
|
-
</div>
|
|
28
|
-
<% end %>
|
|
29
|
-
</div>
|
|
30
|
-
<div class="col order-md-last">
|
|
31
|
-
<% count = @count[abstract_model.model.name] %>
|
|
32
|
-
<% percent = count > 0 ? (@max <= 1 ? count : ((Math.log(count+1) * 100.0) / Math.log(@max+1)).to_i) : -1 %>
|
|
33
|
-
<div class="<%= active ? 'active progress-bar-striped ' : '' %>progress" style="margin-bottom:0px">
|
|
34
|
-
<div class="bg-<%= get_indicator(percent) %> progress-bar animate-width-to" data-animate-length="<%= ([1.0, percent].max.to_i * 20) %>" data-animate-width-to="<%= [2.0, percent].max.to_i %>%" style="width:2%">
|
|
35
|
-
<%= @count[abstract_model.model.name] %>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="col-auto order-md-last">
|
|
40
|
-
<div class="dropdown">
|
|
41
|
-
<button class="btn btn-dropdown btn-sm btn-square" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
42
|
-
<i class="fas fa-ellipsis-vertical"></i>
|
|
43
|
-
</button>
|
|
44
|
-
<ul class="dropdown-menu">
|
|
45
|
-
<%= menu_for :collection, abstract_model, nil, false %>
|
|
46
|
-
</ul>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
<!-- if md breakpoint -->
|
|
50
|
-
<div class="col col-md-7 d-none d-md-block">
|
|
51
|
-
<%= t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t("admin.misc.ago")}" if last_created %>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
<% end %>
|
|
55
|
-
<% end %>
|
|
56
|
-
</section>
|
|
57
|
-
<% end %>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<!-- TO-DO: Review this -->
|
|
61
|
-
<% if @history && authorized?(:history_index) %>
|
|
62
|
-
<div class="block" id="block-tables">
|
|
63
|
-
<div class="content">
|
|
64
|
-
<h2>
|
|
65
|
-
<%= t("admin.actions.history_index.menu") %>
|
|
66
|
-
</h2>
|
|
67
|
-
<%= render partial: 'rails_admin/main/dashboard_history' %>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
<% end %>
|
data/sig/swop.rbs
DELETED