slash_admin 1.3.5 → 1.5.2

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: dd6fca0261e85e32892848c0fc3b5ea84e76c839c410a6e0f37d05474cc41b1a
4
+ data.tar.gz: ee1e603f3e4acb9e0ea876f1aba28495ae7686eae58ea7be36dadb95ef68b644
5
5
  SHA512:
6
- metadata.gz: 9af1af8597797ddb789f091c9d722c1edb6f3d9ebcdb28ec50b7e3051c170095bda6964f2970c080930a39c13f454642f2cf4ae79848c4f6d0decd7da9a6e0fb
7
- data.tar.gz: 6ca2267f25300ba5d2a5323c160d23e17d184adbfabc0819264dfd44a4a9c3a08df051f22993b59bb78215a24a75fec02d2fcaeb42a4a8e644dd89d6e0a17595
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 administrate/application.css
90
- //= link administrate/application.js
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 :handle_assocations
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
- 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,7 +402,11 @@ module SlashAdmin
402
402
  params[:filters] ||= []
403
403
  end
404
404
 
405
- def handle_assocations
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 %>"><%= render attr.keys.first.to_s, model: m %></td>
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>&nbsp;</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>&nbsp;</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
- <% 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 %>
@@ -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
- 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
- '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', required: required?(f.object, a).present? %>
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
- 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] },
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', required: required?(f.object, a).present? %>
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
- <a class="nav-link">
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">
@@ -13,6 +13,7 @@ en:
13
13
  error: Impossible to create '%{model_name}'
14
14
  success: Operation successed.
15
15
  view:
16
+ edit_account: Edit my Account
16
17
  fill_login_and_password: "Please enter your credentials to proceed."
17
18
  administration: Administration
18
19
  home: Home
@@ -13,6 +13,7 @@ fr:
13
13
  error: Impossible de trier '%{model_name}'
14
14
  success: Opération réussi.
15
15
  view:
16
+ edit_account: Modifier mon Compte
16
17
  fill_login_and_password: "Merci d'entrer votre identifiant et mot de passe."
17
18
  administration: Administration
18
19
  home: Accueil
@@ -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.rb",
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.5.2"
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.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-06-08 00:00:00.000000000 Z
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.2
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: []