wonder_navigation 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 7ccbeb8086d596d332843f980ed45de96f9b487f
4
- data.tar.gz: 120137f6651aadb6b0b61605222515ff339c6f0c
3
+ metadata.gz: 5ca4bc76bc44b679073fd91deae81f09045296fe
4
+ data.tar.gz: 0bee60511910d014f6053a23e7dac46412eb03a7
5
5
  SHA512:
6
- metadata.gz: ae5aef2589c4093c0d8860d572ab8c4977ebfa02908c7234b8755c91019da1820acbc6c474ecf16ab7cb41baca8ead16ee44f15d3532b07071cab4a143395f3f
7
- data.tar.gz: 3b8bba0191d0616b1063ecb107636014dc4399ced55704a9a8257d48bd0042aff6fed68e29e060e6c89276a4d2cadcacf47a32b3264c481d2f27aa3068373bd1
6
+ metadata.gz: 700d2603afda969f73ec5ee7e986d31702e179bc7005f88d4a777dc1c506eee52a1c3cf00ea1e09aa1359282b7d91065c89cb645604211836f39bd17972f28f2
7
+ data.tar.gz: 906921d8d34e8fc8fa18cd112fc2c5ad3b66b6c76431b44da709739c9323b5a4a3e3df6987274ff2f5cff6da8464cc709b435eeb5aa9b3f10b9d071d15d6aff8
@@ -2,3 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.4
4
4
  before_install: gem install bundler -v 1.11.2
5
+ addons:
6
+ code_climate:
7
+ repo_token: 9470cd577799cb417b2e4040760f00c4e2c9cd33de6674dfc30e216263ef30e3
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/douglaslise/wonder_navigation/badges/gpa.svg)](https://codeclimate.com/github/douglaslise/wonder_navigation)
4
4
  [![Gem Version](https://badge.fury.io/rb/wonder_navigation.svg)](https://badge.fury.io/rb/wonder_navigation)
5
+ [![Build Status](https://travis-ci.org/douglaslise/wonder_navigation.svg?branch=master)](https://travis-ci.org/douglaslise/wonder_navigation)
5
6
 
6
7
  Describe your Rails' menus and breadcrumbs in a single place, with support for permissions, fixed and resource based labels.
7
8
 
@@ -1,6 +1,6 @@
1
1
  module WonderNavigation
2
2
  class MenuEntry
3
- attr_accessor :id, :label, :path, :level, :active, :visible, :children
3
+ attr_accessor :id, :label, :path, :level, :active, :visible, :children, :icon
4
4
  def initialize(id, level)
5
5
  @id = id
6
6
  @level = level
@@ -1,7 +1,7 @@
1
1
  module WonderNavigation
2
2
  class ELabelNotDefined < StandardError; end
3
3
  class MenuItem
4
- attr_accessor :menu_instance, :level, :id, :parent_item, :subitems, :deferrables, :permission
4
+ attr_accessor :menu_instance, :level, :id, :parent_item, :subitems, :deferrables, :permission, :icon
5
5
 
6
6
  def initialize(menu_instance, level, id, options = {}, &block)
7
7
  @level = level
@@ -9,6 +9,7 @@ module WonderNavigation
9
9
  @id = id
10
10
  @subitems = []
11
11
  @permission = options[:permission]
12
+ @icon = options[:icon]
12
13
  @menu_instance.items[id] = self
13
14
  initialize_deferrables(options)
14
15
 
@@ -37,11 +38,11 @@ module WonderNavigation
37
38
  def resource(id, options = {}, &block)
38
39
  new = show = nil
39
40
  index = menu "#{id}_index", options do
40
- new = menu "#{id}_new", options.fetch(:new_label, I18n.t("wonder_navigation.resource.new", default: "New")), visible: false
41
+ new = menu "#{id}_new", options.fetch(:new_label, translate_resource_action(:new, "New")), visible: false
41
42
  show = menu "#{id}_show" do
42
43
  label {|obj| obj.to_s }
43
44
  path {|obj| obj }
44
- menu "#{id}_edit", I18n.t("wonder_navigation.resource.edit", default: "Edit")
45
+ menu "#{id}_edit", translate_resource_action(:edit, "Edit")
45
46
  end
46
47
  end
47
48
  index.instance_exec(index, new, show, &block) if block_given?
@@ -76,6 +77,7 @@ module WonderNavigation
76
77
  MenuEntry.new(id, level).tap do |entry|
77
78
  entry.active = id == current_page
78
79
  entry.visible = entry_visible?(max_depth, current_user)
80
+ entry.icon = icon
79
81
  if entry.visible
80
82
  entry.label = label_deferrable.resolve(nil)
81
83
  entry.path = path_deferrable.try_resolve(nil)
@@ -153,5 +155,13 @@ module WonderNavigation
153
155
  sub_item.tree(current_page, max_depth, current_user)
154
156
  end
155
157
  end
158
+
159
+ def translate_resource_action(action, default)
160
+ if defined?(I18n)
161
+ I18n.t("wonder_navigation.resource.#{action}", default: default)
162
+ else
163
+ default
164
+ end
165
+ end
156
166
  end
157
167
  end
@@ -1,3 +1,3 @@
1
1
  module WonderNavigation
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wonder_navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Lise
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-04-08 00:00:00.000000000 Z
12
+ date: 2016-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails