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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccb3baa1e350b7dd50df3668174273bc00d7e1aa343181b1f79f8212281488cb
4
- data.tar.gz: 2157f07a84cd25f6fa9bd3420d4ac6b0b540082afc07ea69d706517f6740672c
3
+ metadata.gz: aa8f3a52be4da9f7ddc2f3a4888ed7affa7a49aeeeecca3b54b6413d92fad5f5
4
+ data.tar.gz: 10bda4bc75d87a697aedb1d5f8ee48d0f5203892aeebb9d7d985a2dc8a509897
5
5
  SHA512:
6
- metadata.gz: 9af1af8597797ddb789f091c9d722c1edb6f3d9ebcdb28ec50b7e3051c170095bda6964f2970c080930a39c13f454642f2cf4ae79848c4f6d0decd7da9a6e0fb
7
- data.tar.gz: 6ca2267f25300ba5d2a5323c160d23e17d184adbfabc0819264dfd44a4a9c3a08df051f22993b59bb78215a24a75fec02d2fcaeb42a4a8e644dd89d6e0a17595
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
- I18n.available_locales.reject { |key| key == :root }.each do |locale|
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
- <% I18n.available_locales.each do |locale| %>
5
- <a class="nav-item nav-link <%= I18n.available_locales.first == locale ? 'active' : '' %>" id="nav-language-<%= locale %>" data-toggle="tab" href="#language-<%= locale %>" role="tab" aria-controls="language-<%= locale %>">
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
- <% I18n.available_locales.each do |locale| %>
12
- <div class="tab-pane fade <%= I18n.available_locales.first == locale ? 'show active' : '' %>" id="language-<%= locale %>" role="tabpanel" aria-labelledby="language-<%= locale %>-tab">
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 %>
@@ -8,6 +8,8 @@ module SlashAdmin
8
8
  def install
9
9
  template "install.erb",
10
10
  "app/helpers/slash_admin/menu_helper.rb"
11
+ template "initializer.erb",
12
+ "config/initializers/slash_admin.rb"
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ SlashAdmin.configure do |config|
4
+ # Do some config
5
+ # config.available_locales = I18n.available_locales
6
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SlashAdmin
2
- VERSION = "1.3.5"
2
+ VERSION = "1.4"
3
3
  end
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.3.5
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-08 00:00:00.000000000 Z
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: []