slash_admin 1.3.4 → 1.5.1
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 +12 -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/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 +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a370ada076f5e75847c03295de614ad55fe75a3cc21aea02bb3643dae2112325
|
4
|
+
data.tar.gz: 263f0df3accd2d6d316bcde3b11c476facd7e724a1c75980ef7ca7d1f358b37f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2418b0341f04bf62b210034f09ad73cee0b02e306f2b52ffe8f32327b2f4a607bbd8c356d4b5940cef4f5c3a28bd495c24cb43fe2a9c3d0162c37aec69d9573
|
7
|
+
data.tar.gz: c002bf47c5741ce20fbba8a3d9260708794f4e16a7fb35ca56a847650ccc496254c8fe2440737bf6522c26c8385fca45845461f4d09015a83ce78327530b571e
|
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`
|
@@ -10,6 +10,7 @@
|
|
10
10
|
@import "jquery.minicolors";
|
11
11
|
@import "slash_admin/colors";
|
12
12
|
@import "slash_admin/alert";
|
13
|
+
@import "slash_admin/custom";
|
13
14
|
@import "codemirror/codemirror";
|
14
15
|
@import "codemirror/theme/relax-seti";
|
15
16
|
@import "codemirror/lint/lint";
|
@@ -90,7 +91,7 @@ p[data-f-id="pbf"] {
|
|
90
91
|
margin: 0;
|
91
92
|
|
92
93
|
label.form-control-label {
|
93
|
-
display: block;
|
94
|
+
display: inline-block;
|
94
95
|
font-weight: 600;
|
95
96
|
}
|
96
97
|
|
@@ -265,20 +266,6 @@ p[data-f-id="pbf"] {
|
|
265
266
|
}
|
266
267
|
}
|
267
268
|
|
268
|
-
.field_with_errors {
|
269
|
-
label {
|
270
|
-
color: $red;
|
271
|
-
}
|
272
|
-
|
273
|
-
input {
|
274
|
-
border-color: $red !important;
|
275
|
-
}
|
276
|
-
|
277
|
-
& + .form-control-feedback {
|
278
|
-
color: $red;
|
279
|
-
}
|
280
|
-
}
|
281
|
-
|
282
269
|
.block-language {
|
283
270
|
display: block;
|
284
271
|
margin: 15px 0;
|
@@ -435,6 +422,16 @@ p[data-f-id="pbf"] {
|
|
435
422
|
color: $primary;
|
436
423
|
}
|
437
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
|
+
|
438
435
|
.scroll-to-top {
|
439
436
|
text-align: center;
|
440
437
|
position: fixed;
|
@@ -483,11 +480,9 @@ p[data-f-id="pbf"] {
|
|
483
480
|
|
484
481
|
.badge {
|
485
482
|
font-size: 11px;
|
486
|
-
font-weight: 300;
|
487
483
|
height: 18px;
|
488
484
|
color: #fff;
|
489
485
|
padding: 3px 6px;
|
490
|
-
border-radius: 12px;
|
491
486
|
text-shadow: none;
|
492
487
|
text-align: center;
|
493
488
|
vertical-align: middle;
|
@@ -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
|
+
%>
|
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.1
|
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-07-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
|
@@ -455,7 +457,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
455
457
|
version: '0'
|
456
458
|
requirements: []
|
457
459
|
rubygems_version: 3.1.2
|
458
|
-
signing_key:
|
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: []
|