wonder_navigation 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +1 -0
- data/lib/wonder_navigation/menu_entry.rb +1 -1
- data/lib/wonder_navigation/menu_item.rb +13 -3
- data/lib/wonder_navigation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca4bc76bc44b679073fd91deae81f09045296fe
|
4
|
+
data.tar.gz: 0bee60511910d014f6053a23e7dac46412eb03a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 700d2603afda969f73ec5ee7e986d31702e179bc7005f88d4a777dc1c506eee52a1c3cf00ea1e09aa1359282b7d91065c89cb645604211836f39bd17972f28f2
|
7
|
+
data.tar.gz: 906921d8d34e8fc8fa18cd112fc2c5ad3b66b6c76431b44da709739c9323b5a4a3e3df6987274ff2f5cff6da8464cc709b435eeb5aa9b3f10b9d071d15d6aff8
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://codeclimate.com/github/douglaslise/wonder_navigation)
|
4
4
|
[](https://badge.fury.io/rb/wonder_navigation)
|
5
|
+
[](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,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,
|
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",
|
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
|
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.
|
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-
|
12
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|