trestle 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,6 @@
2
2
  <%= render "trestle/flash/alert", html_class: "alert-success", icon: icon("alert-icon far fa-check-circle"), alert: normalize_flash_alert(flash[:message]) %>
3
3
  <% elsif flash[:error] -%>
4
4
  <%= render layout: "trestle/flash/alert", locals: { html_class: "alert-danger", icon: icon("alert-icon far fa-times-circle"), alert: normalize_flash_alert(flash[:error]) } do %>
5
- <%= render "trestle/flash/debug", errors: instance.errors if debug_form_errors? %>
5
+ <%= render "trestle/flash/debug", errors: Trestle::DebugErrors.new(instance.errors) if debug_form_errors? %>
6
6
  <% end %>
7
7
  <% end -%>
@@ -14,6 +14,7 @@
14
14
 
15
15
  ul.invalid-feedback {
16
16
  list-style: none;
17
+ margin-bottom: 0;
17
18
  padding-left: 0;
18
19
  }
19
20
 
@@ -6,7 +6,7 @@ import { init } from '../core/events'
6
6
 
7
7
  const TAB_SELECTOR = 'a[data-toggle="tab"]'
8
8
  const TAB_PANE_SELECTOR = '.tab-pane'
9
- const ERROR_SELECTOR = '.is-invalid:not([type="hidden"])'
9
+ const ERROR_SELECTOR = '.has-error'
10
10
 
11
11
  // Save active tab to URL hash
12
12
  init(function (root) {
@@ -10,8 +10,12 @@ module Trestle
10
10
  end
11
11
 
12
12
  def create_assets
13
- template "_theme.scss", "app/assets/stylesheets/trestle/_theme.scss"
14
- template "_custom.scss", "app/assets/stylesheets/trestle/_custom.scss"
13
+ if defined?(Sass) || defined?(SassC)
14
+ template "_custom.scss", "app/assets/stylesheets/trestle/_custom.scss"
15
+ template "_theme.scss", "app/assets/stylesheets/trestle/_theme.scss"
16
+ else
17
+ template "_custom.css", "app/assets/stylesheets/trestle/_custom.css"
18
+ end
15
19
 
16
20
  template "custom.js", "app/assets/javascripts/trestle/custom.js"
17
21
  end
@@ -0,0 +1,8 @@
1
+ /* This file may be used for providing additional customizations to the Trestle
2
+ * admin. It will be automatically included within all admin pages.
3
+ *
4
+ * For organizational purposes, you may wish to define your customizations
5
+ * within individual partials in this folder and they'll be required below.
6
+ *
7
+ *= require_tree .
8
+ */
@@ -0,0 +1,24 @@
1
+ module Trestle
2
+ class DebugErrors
3
+ def initialize(errors)
4
+ @errors = errors
5
+ end
6
+
7
+ def any?
8
+ @errors.any?
9
+ end
10
+
11
+ def each
12
+ if defined?(ActiveModel::Error)
13
+ # Rails 6.1 introduces a unified Error class
14
+ @errors.each do |error|
15
+ yield error.attribute, error.message
16
+ end
17
+ else
18
+ @errors.each do |error, message|
19
+ yield error, message
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -4,8 +4,7 @@ module Trestle
4
4
  attr_reader :name, :options
5
5
 
6
6
  def initialize(name, options={})
7
- @name = name
8
- @options = options
7
+ @name, @options = name.to_s, options
9
8
  end
10
9
 
11
10
  def ==(other)
@@ -4,7 +4,7 @@ module Trestle
4
4
  attr_reader :name, :path, :options
5
5
 
6
6
  def initialize(name, path=nil, options={})
7
- @name, @path, @options = name, path, options
7
+ @name, @path, @options = name.to_s, path, options
8
8
  end
9
9
 
10
10
  def ==(other)
@@ -40,7 +40,7 @@ module Trestle
40
40
  end
41
41
 
42
42
  def label
43
- options[:label] || I18n.t("admin.navigation.items.#{name}", default: name.to_s.titlecase)
43
+ options[:label] || I18n.t("admin.navigation.items.#{name}", default: name.titlecase)
44
44
  end
45
45
 
46
46
  def icon
@@ -1,3 +1,3 @@
1
1
  module Trestle
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.8"
3
3
  end
data/lib/trestle.rb CHANGED
@@ -11,6 +11,7 @@ module Trestle
11
11
  require_relative "trestle/adapters"
12
12
  require_relative "trestle/attribute"
13
13
  require_relative "trestle/breadcrumb"
14
+ require_relative "trestle/debug_errors"
14
15
  require_relative "trestle/lazy"
15
16
  require_relative "trestle/configurable"
16
17
  require_relative "trestle/configuration"