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: 2be39606cbd0f92bc8232bbd4a1c8b04a27aed18e9a0732668af6f37126d66f4
4
- data.tar.gz: 5034f9d65042871ec4be47c313e90c46390e40751003666ea8a93166df087d31
3
+ metadata.gz: 5f080eae1f34847934c143b7bdc9c091632701cb339f269754640d5f2a78f879
4
+ data.tar.gz: 64f8f793914cf99e2f5ac37801039000936911799c518da44528698f6c3fba92
5
5
  SHA512:
6
- metadata.gz: b2219e00f0a35206d772032e1f259e5283e2085a39bf5f45e47af09a784ece3776c0824ed7dc6d191cdcbf036b34a647fb5c9c172e13f86ef21394f54275fc9a
7
- data.tar.gz: e2abb579c41c61b11377c986f692cba8b944671e1876616bf771309b8e62900a05b57582f72f1f458ef17309b55d8030c15727993ad99092c40ac4c4e31fd94a
6
+ metadata.gz: 507f43c02cfe83261c5e0caa656387aba8dc7ffa15a80c70305e71736e1aeebec90a6678f663ca4de854740f17ef2960a29f9d58caf980e1c0dbd534b1d0c46b
7
+ data.tar.gz: 7398b5cacb4eed3ff628a7026c2934c089dcbe8b1cf9ff9cd22275228816fa1ddc9ba50909dbf4bccf4e0e671349517c8bea4485e8c3dd709868f17000ef55a2
data/README.md CHANGED
@@ -135,7 +135,7 @@ Some things in the road-map:
135
135
  Add this line to your application's Gemfile:
136
136
 
137
137
  ```ruby
138
- gem "decidim-decidim_awesome", "~> 0.6.5"
138
+ gem "decidim-decidim_awesome", "~> 0.6.6"
139
139
  ```
140
140
 
141
141
  And then execute:
@@ -2,16 +2,24 @@
2
2
 
3
3
  Decidim::MenuPresenter.class_eval do
4
4
  def evaluated_menu
5
- @evaluated_menu ||= if Decidim::DecidimAwesome.config.send(@name) == :disabled
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 if include_invisible || visible?(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
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # This holds the decidim-decidim_awesome version.
5
5
  module DecidimAwesome
6
- VERSION = "0.6.5"
6
+ VERSION = "0.6.6"
7
7
  COMPAT_DECIDIM_VERSION = [">= 0.22.0", "< 0.24"].freeze
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-decidim_awesome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Vergés