decidim-decidim_awesome 0.6.5 → 0.6.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f080eae1f34847934c143b7bdc9c091632701cb339f269754640d5f2a78f879
|
4
|
+
data.tar.gz: 64f8f793914cf99e2f5ac37801039000936911799c518da44528698f6c3fba92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 507f43c02cfe83261c5e0caa656387aba8dc7ffa15a80c70305e71736e1aeebec90a6678f663ca4de854740f17ef2960a29f9d58caf980e1c0dbd534b1d0c46b
|
7
|
+
data.tar.gz: 7398b5cacb4eed3ff628a7026c2934c089dcbe8b1cf9ff9cd22275228816fa1ddc9ba50909dbf4bccf4e0e671349517c8bea4485e8c3dd709868f17000ef55a2
|
data/README.md
CHANGED
@@ -2,16 +2,24 @@
|
|
2
2
|
|
3
3
|
Decidim::MenuPresenter.class_eval do
|
4
4
|
def evaluated_menu
|
5
|
-
@evaluated_menu ||= if
|
5
|
+
@evaluated_menu ||= if awesome_override?
|
6
|
+
Decidim::DecidimAwesome::MenuHacker.new(@name, @view)
|
7
|
+
else
|
6
8
|
begin
|
7
9
|
menu = Decidim::Menu.new(@name)
|
8
10
|
menu.build_for(@view)
|
9
11
|
menu
|
10
12
|
end
|
11
|
-
else
|
12
|
-
Decidim::DecidimAwesome::MenuHacker.new(@name, @view)
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def awesome_override?
|
19
|
+
return false unless Decidim::DecidimAwesome.config.has_key?(@name)
|
20
|
+
|
21
|
+
Decidim::DecidimAwesome.config.send(@name) != :disabled
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
17
25
|
Decidim::MenuItemPresenter.class_eval do
|
@@ -22,9 +22,10 @@ module Decidim
|
|
22
22
|
item.send("overrided?=", true)
|
23
23
|
@items.reject! { |i| i.url.gsub(/\?.*/, "") == item.url }
|
24
24
|
end
|
25
|
-
@items << item
|
25
|
+
@items << item
|
26
26
|
end
|
27
27
|
|
28
|
+
@items.select!(&:visible?) unless include_invisible
|
28
29
|
@items.sort_by!(&:position)
|
29
30
|
end
|
30
31
|
|
@@ -33,19 +34,6 @@ module Decidim
|
|
33
34
|
attr_accessor :organization, :user
|
34
35
|
attr_reader :name, :view
|
35
36
|
|
36
|
-
def visible?(item)
|
37
|
-
case item.visibility
|
38
|
-
when "hidden"
|
39
|
-
false
|
40
|
-
when "logged"
|
41
|
-
user.present?
|
42
|
-
when "non_logged"
|
43
|
-
user.blank?
|
44
|
-
else
|
45
|
-
true
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
37
|
def default_items
|
50
38
|
@default_items ||= build_menu.instance_variable_get(:@items).map do |item|
|
51
39
|
item.instance_variable_set(:@active, method(:activate?)) unless item.active == :exact
|
@@ -69,6 +57,7 @@ module Decidim
|
|
69
57
|
# see options in https://github.com/comfy/active_link_to
|
70
58
|
active: method(:activate?),
|
71
59
|
visibility: item["visibility"],
|
60
|
+
visible?: visible?(item),
|
72
61
|
target: item["target"],
|
73
62
|
overrided?: false
|
74
63
|
)
|
@@ -80,6 +69,19 @@ module Decidim
|
|
80
69
|
url == urls.find { |u| view.request.original_fullpath.start_with?(u) }
|
81
70
|
end
|
82
71
|
|
72
|
+
def visible?(item)
|
73
|
+
case item["visibility"]
|
74
|
+
when "hidden"
|
75
|
+
false
|
76
|
+
when "logged"
|
77
|
+
user.present?
|
78
|
+
when "non_logged"
|
79
|
+
user.blank?
|
80
|
+
else
|
81
|
+
true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
83
85
|
def current_config
|
84
86
|
@current_config ||= (AwesomeConfig.find_by(var: name, organization: organization)&.value || []).filter { |i| i.is_a? Hash }
|
85
87
|
end
|