slash_admin 1.3.5 → 1.5.2
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 +2 -2
- data/app/assets/stylesheets/slash_admin/application.scss +15 -17
- data/app/controllers/slash_admin/models_controller.rb +8 -4
- data/app/views/slash_admin/base/_data_list.html.erb +3 -1
- data/app/views/slash_admin/base/_filters.html.erb +7 -0
- data/app/views/slash_admin/base/_translatable_fields.html.erb +4 -4
- data/app/views/slash_admin/base/_wysiwyg.html.erb +1 -0
- data/app/views/slash_admin/fields/_belongs_to.html.erb +13 -8
- data/app/views/slash_admin/fields/_has_one.html.erb +10 -8
- data/app/views/slash_admin/shared/_header.html.erb +13 -2
- data/config/locales/en.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/lib/generators/slash_admin/install/install_generator.rb +2 -0
- data/lib/generators/slash_admin/install/templates/initializer.rb +6 -0
- data/lib/slash_admin.rb +16 -0
- data/lib/slash_admin/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6fca0261e85e32892848c0fc3b5ea84e76c839c410a6e0f37d05474cc41b1a
|
4
|
+
data.tar.gz: ee1e603f3e4acb9e0ea876f1aba28495ae7686eae58ea7be36dadb95ef68b644
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d797a173c872decb0062ba27623a110870ecf13039953f0c37d7cdad0dedcbe32a3d4b4028ce802e563c7023e25e9bee086f6b4774cd255de095e6a8f26f54
|
7
|
+
data.tar.gz: 2df908377331a6a5ed064c6b4a38784bad47d6f07b30d9cb0c7743ffd41918f30b345d53bedeac6db8acf35dd7233511dac88c3699ec0d76860b7177b625d368
|
data/README.md
CHANGED
@@ -86,8 +86,8 @@ If your apps uses Sprockets 4+, you'll need to add SlashAdmin assets to your `ma
|
|
86
86
|
`app/assets/config/manifest.js`
|
87
87
|
|
88
88
|
```
|
89
|
-
//= link
|
90
|
-
//= link
|
89
|
+
//= link slash_admin/application.css
|
90
|
+
//= link slash_admin/application.js
|
91
91
|
```
|
92
92
|
|
93
93
|
`config/routes.rb`
|
@@ -91,7 +91,7 @@ p[data-f-id="pbf"] {
|
|
91
91
|
margin: 0;
|
92
92
|
|
93
93
|
label.form-control-label {
|
94
|
-
display: block;
|
94
|
+
display: inline-block;
|
95
95
|
font-weight: 600;
|
96
96
|
}
|
97
97
|
|
@@ -266,20 +266,6 @@ p[data-f-id="pbf"] {
|
|
266
266
|
}
|
267
267
|
}
|
268
268
|
|
269
|
-
.field_with_errors {
|
270
|
-
label {
|
271
|
-
color: $red;
|
272
|
-
}
|
273
|
-
|
274
|
-
input {
|
275
|
-
border-color: $red !important;
|
276
|
-
}
|
277
|
-
|
278
|
-
& + .form-control-feedback {
|
279
|
-
color: $red;
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
269
|
.block-language {
|
284
270
|
display: block;
|
285
271
|
margin: 15px 0;
|
@@ -436,6 +422,16 @@ p[data-f-id="pbf"] {
|
|
436
422
|
color: $primary;
|
437
423
|
}
|
438
424
|
|
425
|
+
.has-danger {
|
426
|
+
.form-control, input, select, textarea {
|
427
|
+
border-color: $error !important;
|
428
|
+
}
|
429
|
+
|
430
|
+
label, .form-control-feedback {
|
431
|
+
color: $error !important;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
439
435
|
.scroll-to-top {
|
440
436
|
text-align: center;
|
441
437
|
position: fixed;
|
@@ -484,11 +480,9 @@ p[data-f-id="pbf"] {
|
|
484
480
|
|
485
481
|
.badge {
|
486
482
|
font-size: 11px;
|
487
|
-
font-weight: 300;
|
488
483
|
height: 18px;
|
489
484
|
color: #fff;
|
490
485
|
padding: 3px 6px;
|
491
|
-
border-radius: 12px;
|
492
486
|
text-shadow: none;
|
493
487
|
text-align: center;
|
494
488
|
vertical-align: middle;
|
@@ -571,6 +565,10 @@ p[data-f-id="pbf"] {
|
|
571
565
|
padding-left: 8px;
|
572
566
|
}
|
573
567
|
|
568
|
+
.dropdown .dropdown-menu a.dropdown-item {
|
569
|
+
color: #7f96ac;
|
570
|
+
}
|
571
|
+
|
574
572
|
.nav-item {
|
575
573
|
margin: 0;
|
576
574
|
padding: 0;
|
@@ -9,9 +9,9 @@ module SlashAdmin
|
|
9
9
|
before_action :handle_default
|
10
10
|
before_action :nestable_config
|
11
11
|
before_action :handle_default_params
|
12
|
-
before_action :
|
12
|
+
before_action :handle_associations
|
13
13
|
|
14
|
-
helper_method :list_params, :export_params, :create_params, :update_params, :show_params, :nested_params, :should_add_translatable?, :translatable_params, :tooltips
|
14
|
+
helper_method :list_params, :export_params, :create_params, :update_params, :show_params, :nested_params, :should_add_translatable?, :translatable_params, :available_locales, :tooltips
|
15
15
|
|
16
16
|
def index
|
17
17
|
authorize! :index, @model_class
|
@@ -386,7 +386,7 @@ module SlashAdmin
|
|
386
386
|
end
|
387
387
|
|
388
388
|
def handle_default_translations
|
389
|
-
|
389
|
+
available_locales.reject { |key| key == :root }.each do |locale|
|
390
390
|
translation = @model.translations.find_by_locale locale.to_s
|
391
391
|
if translation.nil?
|
392
392
|
@model.translations.build locale: locale
|
@@ -402,7 +402,11 @@ module SlashAdmin
|
|
402
402
|
params[:filters] ||= []
|
403
403
|
end
|
404
404
|
|
405
|
-
def
|
405
|
+
def available_locales
|
406
|
+
SlashAdmin.configuration.available_locales
|
407
|
+
end
|
408
|
+
|
409
|
+
def handle_associations
|
406
410
|
@belongs_to_fields = @model_class.reflect_on_all_associations(:belongs_to).map(&:name)
|
407
411
|
@has_many_fields = @model_class.reflect_on_all_associations(:has_many).map(&:name)
|
408
412
|
@has_one_fields = @model_class.reflect_on_all_associations(:has_one).map(&:name)
|
@@ -75,7 +75,9 @@
|
|
75
75
|
<% end %>
|
76
76
|
</td>
|
77
77
|
<% else %>
|
78
|
-
<td class="<%= attr.to_s.parameterize.underscore.downcase %>"
|
78
|
+
<td class="<%= attr.to_s.parameterize.underscore.downcase %>">
|
79
|
+
<%= render attr[attr.keys.first][:type].to_s, model: m, attr: attr.keys.first %>
|
80
|
+
</td>
|
79
81
|
<% end %>
|
80
82
|
<% else %>
|
81
83
|
<% if m.send(attr).is_a?(TrueClass) || m.send(attr).is_a?(FalseClass) %>
|
@@ -60,6 +60,13 @@
|
|
60
60
|
<% else %>
|
61
61
|
<td> </td>
|
62
62
|
<% end %>
|
63
|
+
<% elsif attr.is_a?(Hash) && attr[:filter].present? %>
|
64
|
+
<td>
|
65
|
+
<% case attr[:filter] %>
|
66
|
+
<% when :text, :string %>
|
67
|
+
<input type="text" name="filters[<%= attr.keys.first %>]" value="<%= params[:filters][attr.keys.first] rescue nil %>" class="form-control form-control-sm"/>
|
68
|
+
<% end %>
|
69
|
+
</td>
|
63
70
|
<% else %>
|
64
71
|
<td> </td>
|
65
72
|
<% end %>
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<% if should_add_translatable? %>
|
2
2
|
<h3 class="translations"><%= t('slash_admin.view.translations') %></h3>
|
3
3
|
<nav class="nav nav-tabs" id="language-tabs" role="tablist">
|
4
|
-
<%
|
5
|
-
<a class="nav-item nav-link <%=
|
4
|
+
<% available_locales.each do |locale| %>
|
5
|
+
<a class="nav-item nav-link <%= available_locales.first == locale ? 'active' : '' %>" id="nav-language-<%= locale %>" data-toggle="tab" href="#language-<%= locale %>" role="tab" aria-controls="language-<%= locale %>">
|
6
6
|
<img src='<%= image_path("slash_admin/#{locale.to_s}.png") %>' style="margin-right: 5px; max-width: 25px;">
|
7
7
|
</a>
|
8
8
|
<% end %>
|
9
9
|
</nav>
|
10
10
|
<div class="tab-content">
|
11
|
-
<%
|
12
|
-
<div class="tab-pane fade <%=
|
11
|
+
<% available_locales.each do |locale| %>
|
12
|
+
<div class="tab-pane fade <%= available_locales.first == locale ? 'show active' : '' %>" id="language-<%= locale %>" role="tabpanel" aria-labelledby="language-<%= locale %>-tab">
|
13
13
|
<%= f.globalize_fields_for locale do |g| %>
|
14
14
|
<% translatable_params.each do |a| %>
|
15
15
|
<%= render 'slash_admin/fields/form_group', f: g, a: a %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= truncate(strip_tags(model.send(attr)), length: 50) %>
|
@@ -1,11 +1,16 @@
|
|
1
1
|
<%= f.label a, class: "form-control-label #{required?(f.object, a).present? ? 'required' : ''}" %>
|
2
2
|
<%= render 'slash_admin/shared/tooltip', a: a %>
|
3
3
|
<%= f.collection_select a.to_s + '_id',
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
class_name_from_association(f.object, a).constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20), :id, object_label(class_name_from_association(f.object, a)),
|
5
|
+
{
|
6
|
+
include_blank: true,
|
7
|
+
},
|
8
|
+
{
|
9
|
+
'data-placeholder': t('slash_admin.view.select_model', model_name: class_name_from_association(f.object, a).constantize.model_name.human.downcase),
|
10
|
+
'data-model': class_name_from_association(f.object, a).constantize.model_name.to_s.underscore,
|
11
|
+
'data-fields': "SlashAdmin::Models::#{class_name_from_association(f.object, a).classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
|
12
|
+
class: 'form-control select2-model-single',
|
13
|
+
required: required?(f.object, a).present?,
|
14
|
+
selected: f.object.send(a).present? ? f.object.send(a).try(:id) : nil,
|
15
|
+
}
|
16
|
+
%>
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<%= f.label a, class: "form-control-label #{required?(f.object, a).present? ? 'required' : ''}" %>
|
2
2
|
<%= render 'slash_admin/shared/tooltip', a: a %>
|
3
3
|
<%= f.select a.to_s,
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
options_for_select(class_name_from_association(f.object, a).constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20).collect { |assoc| [assoc.send(object_label(class_name_from_association(f.object, a))), assoc.id] }, f.object.send(a).present? ? f.object.send(a).try(:id) : nil),
|
5
|
+
{
|
6
|
+
include_blank: true,
|
7
|
+
},
|
8
|
+
'data-placeholder': t('slash_admin.view.select_model', model_name: class_name_from_association(f.object, a).constantize.model_name.human.downcase),
|
9
|
+
'data-model': class_name_from_association(f.object, a).constantize.model_name.to_s.underscore,
|
10
|
+
'data-fields': "SlashAdmin::Models::#{class_name_from_association(f.object, a).classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
|
11
|
+
class: 'form-control select2-model-single',
|
12
|
+
required: required?(f.object, a).present?
|
13
|
+
%>
|
@@ -10,8 +10,12 @@
|
|
10
10
|
<div class="navbar-nav mr-auto mt-2 mt-lg-0">
|
11
11
|
</div>
|
12
12
|
<ul class="nav right-nav-fix">
|
13
|
-
<li class="nav-item">
|
14
|
-
|
13
|
+
<li class="nav-item <%= can?(:update, current_admin) ? 'dropdown' : '' %>">
|
14
|
+
<% if can?(:update, current_admin) %>
|
15
|
+
<a class= "nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown">
|
16
|
+
<% else %>
|
17
|
+
<a class="nav-link">
|
18
|
+
<% end %>
|
15
19
|
<% if current_admin.avatar.present? %>
|
16
20
|
<img src="<%= current_admin.avatar.url %>" class="rounded-circle"/>
|
17
21
|
<% else %>
|
@@ -19,6 +23,13 @@
|
|
19
23
|
<% end %>
|
20
24
|
<span class=""><%= current_admin.login %></span>
|
21
25
|
</a>
|
26
|
+
<% if can?(:update, current_admin) %>
|
27
|
+
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
28
|
+
<a href="<%= edit_slash_admin_admin_path current_admin %>" class="dropdown-item">
|
29
|
+
<i class="fas fa-user-circle"></i> <%= t('slash_admin.view.edit_account') %>
|
30
|
+
</a>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
22
33
|
</li>
|
23
34
|
|
24
35
|
<li class="nav-item">
|
data/config/locales/en.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/lib/slash_admin.rb
CHANGED
@@ -23,4 +23,20 @@ require "http_accept_language"
|
|
23
23
|
require "batch_translation"
|
24
24
|
|
25
25
|
module SlashAdmin
|
26
|
+
class << self
|
27
|
+
attr_accessor :configuration
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure
|
31
|
+
self.configuration ||= Configuration.new
|
32
|
+
yield(configuration)
|
33
|
+
end
|
34
|
+
|
35
|
+
class Configuration
|
36
|
+
attr_accessor :available_locales
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
@available_locales = I18n.available_locales
|
40
|
+
end
|
41
|
+
end
|
26
42
|
end
|
data/lib/slash_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slash_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOVACS Nicolas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -342,6 +342,7 @@ files:
|
|
342
342
|
- app/views/slash_admin/base/_data_show.html.erb
|
343
343
|
- app/views/slash_admin/base/_filters.html.erb
|
344
344
|
- app/views/slash_admin/base/_translatable_fields.html.erb
|
345
|
+
- app/views/slash_admin/base/_wysiwyg.html.erb
|
345
346
|
- app/views/slash_admin/base/edit.html.erb
|
346
347
|
- app/views/slash_admin/base/index.html.erb
|
347
348
|
- app/views/slash_admin/base/index.xls.erb
|
@@ -398,6 +399,7 @@ files:
|
|
398
399
|
- lib/generators/slash_admin/controllers/controllers_generator.rb
|
399
400
|
- lib/generators/slash_admin/controllers/templates/controllers.erb
|
400
401
|
- lib/generators/slash_admin/install/install_generator.rb
|
402
|
+
- lib/generators/slash_admin/install/templates/initializer.rb
|
401
403
|
- lib/generators/slash_admin/install/templates/install.erb
|
402
404
|
- lib/generators/slash_admin/override_admin/override_admin_generator.rb
|
403
405
|
- lib/generators/slash_admin/override_admin/templates/admin.erb
|
@@ -439,7 +441,7 @@ homepage: https://github.com/nicovak/slash_admin
|
|
439
441
|
licenses:
|
440
442
|
- MIT
|
441
443
|
metadata: {}
|
442
|
-
post_install_message:
|
444
|
+
post_install_message:
|
443
445
|
rdoc_options: []
|
444
446
|
require_paths:
|
445
447
|
- lib
|
@@ -454,8 +456,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
454
456
|
- !ruby/object:Gem::Version
|
455
457
|
version: '0'
|
456
458
|
requirements: []
|
457
|
-
rubygems_version: 3.1.
|
458
|
-
signing_key:
|
459
|
+
rubygems_version: 3.1.4
|
460
|
+
signing_key:
|
459
461
|
specification_version: 4
|
460
462
|
summary: A modern and overridable admin gem, just the rails way.
|
461
463
|
test_files: []
|