slash_admin 1.3.5 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/slash_admin/models_controller.rb +6 -2
- data/app/views/slash_admin/base/_translatable_fields.html.erb +4 -4
- 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 +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8f3a52be4da9f7ddc2f3a4888ed7affa7a49aeeeecca3b54b6413d92fad5f5
|
4
|
+
data.tar.gz: 10bda4bc75d87a697aedb1d5f8ee48d0f5203892aeebb9d7d985a2dc8a509897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a057c62b96bc937e332365d5b1277e598f4839af757ca616000e5f06da51a1c043087ab4ed20e18b1071f1881c2639306c0c319a74d8ba5c7a9df2e152e229ff
|
7
|
+
data.tar.gz: 054aee793717a4df3bcb2aeccc26fea5e21286e7a1e2bd25d5a3e97b0be11b1962356f380bfa7e7a7342066f51a7001ba22cc10b54c43a912cc6fcb3e33fd8a7
|
@@ -11,7 +11,7 @@ module SlashAdmin
|
|
11
11
|
before_action :handle_default_params
|
12
12
|
before_action :handle_assocations
|
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,6 +402,10 @@ module SlashAdmin
|
|
402
402
|
params[:filters] ||= []
|
403
403
|
end
|
404
404
|
|
405
|
+
def available_locales
|
406
|
+
SlashAdmin.configuration.available_locales
|
407
|
+
end
|
408
|
+
|
405
409
|
def handle_assocations
|
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)
|
@@ -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 %>
|
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.4'
|
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-06-
|
11
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -398,6 +398,7 @@ files:
|
|
398
398
|
- lib/generators/slash_admin/controllers/controllers_generator.rb
|
399
399
|
- lib/generators/slash_admin/controllers/templates/controllers.erb
|
400
400
|
- lib/generators/slash_admin/install/install_generator.rb
|
401
|
+
- lib/generators/slash_admin/install/templates/initializer.rb
|
401
402
|
- lib/generators/slash_admin/install/templates/install.erb
|
402
403
|
- lib/generators/slash_admin/override_admin/override_admin_generator.rb
|
403
404
|
- lib/generators/slash_admin/override_admin/templates/admin.erb
|
@@ -439,7 +440,7 @@ homepage: https://github.com/nicovak/slash_admin
|
|
439
440
|
licenses:
|
440
441
|
- MIT
|
441
442
|
metadata: {}
|
442
|
-
post_install_message:
|
443
|
+
post_install_message:
|
443
444
|
rdoc_options: []
|
444
445
|
require_paths:
|
445
446
|
- lib
|
@@ -455,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
455
456
|
version: '0'
|
456
457
|
requirements: []
|
457
458
|
rubygems_version: 3.1.2
|
458
|
-
signing_key:
|
459
|
+
signing_key:
|
459
460
|
specification_version: 4
|
460
461
|
summary: A modern and overridable admin gem, just the rails way.
|
461
462
|
test_files: []
|