neuron 0.0.3 → 0.0.4

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.
@@ -23,7 +23,8 @@ module Neuron
23
23
  end
24
24
 
25
25
  def page_title(title = nil, options = {})
26
- options = {default: navigation_title}.merge(default_options).merge(options)
26
+ options = default_options.merge(options)
27
+ options = options.merge(default: navigation_title(title, options))
27
28
  @page_title ||= title || view.t('.title', options)
28
29
  end
29
30
 
@@ -49,7 +50,7 @@ module Neuron
49
50
  # @param [String, nil] title title to set
50
51
  # @param [Hash] options options to {I18n#translate} if building default title
51
52
  def page_title(title = nil, options = {})
52
- neuron_title.page_title(title, options)
53
+ neuron_title.page_title(title, options).html_safe
53
54
  end
54
55
 
55
56
  def navigation_title(title = nil, options = {})
@@ -43,34 +43,33 @@ module Neuron
43
43
  # @param [Hash] html_options html options hash
44
44
  # @option options [Symbol, String] :by the name of the columnt to sort by
45
45
  # @option options [String] :as the text used in link, defaults to human_method_name of :by
46
- # @option options [String] :params hash with additional params which will be added to generated url
46
+ # @option options [String] :url url options when order link does not correspond to current collection_path
47
47
  def order(options = {}, html_options = {})
48
+ options[:class] ||= resource_class
48
49
  options[:by] = options[:by].to_sym
49
- options[:as] ||= human(resource_class, options[:by])
50
+ options[:as] ||= human(options[:class], options[:by])
50
51
  asc_orders = Array(params[:ascending]).map(&:to_sym)
51
52
  desc_orders = Array(params[:descending]).map(&:to_sym)
52
53
  ascending = asc_orders.include?(options[:by])
53
54
  selected = ascending || desc_orders.include?(options[:by])
54
55
  new_scope = ascending ? :descending : :ascending
55
- url_options = params.dup.merge(ascending: asc_orders, descending: desc_orders)
56
+ url_options = {page: params[:page]}
57
+ url_options[new_scope] = [options[:by]]
56
58
 
57
59
  if selected
58
60
  css_classes = html_options[:class] ? html_options[:class].split(/\s+/) : []
59
61
  if ascending # selected
60
62
  options[:as] = "▲ #{options[:as]}"
61
63
  css_classes << 'ascending'
62
- url_options[:ascending] = url_options[:ascending] - [options[:by]]
63
64
  else # descending selected
64
65
  options[:as] = "&#9660;&nbsp;#{options[:as]}"
65
66
  css_classes << 'descending'
66
- url_options[:descending] = url_options[:descending] - [options[:by]]
67
67
  end
68
68
  html_options[:class] = css_classes.join(' ')
69
69
  end
70
- url_options[new_scope] += [options[:by]]
71
- url_options[:ascending] = url_options[:ascending].uniq
72
- url_options[:descending] = url_options[:descending].uniq
73
- link_to(options[:as].html_safe, collection_path(url_options.deep_merge(options[:params] || {})), html_options)
70
+ url = options[:url] ? url_for(options[:url].merge(url_options)) : collection_path(url_options)
71
+
72
+ link_to(options[:as].html_safe, url, html_options)
74
73
  end
75
74
 
76
75
  def collection_title(collection = nil, tag = :h1)
@@ -113,7 +112,9 @@ module Neuron
113
112
  result << if collection.any?
114
113
  collection_list(collection)
115
114
  else
116
- content_tag(:p, t(:no_entries, :scope => [:resources, :collection, :no_entries], :default => [controller_i18n_scope.to_sym, :all]))
115
+ content_tag(:p, t(:no_entries,
116
+ scope: [:resources, :collection, :no_entries],
117
+ default: [controller_i18n_scope.to_sym, :all]))
117
118
  end
118
119
  end
119
120
  end
@@ -124,9 +125,9 @@ module Neuron
124
125
  resource ||= self.resource
125
126
  action = action_name.to_sym
126
127
  ''.html_safe.tap do |result|
127
- result << title(t("navigation.#{controller_i18n_scope}.#{action}",
128
- resource: link_to(resource, canonical_path(resource)),
129
- default: resource.to_s).html_safe)
128
+ result << title(nil,
129
+ resource: link_to(resource, canonical_path(resource)),
130
+ default: resource.to_s)
130
131
  if (action == :show) && can?(:update, resource)
131
132
  result << content_tag(:sup,
132
133
  link_to(t(:edit,
@@ -1,3 +1,3 @@
1
1
  module Neuron
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neuron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: