para 0.8.2.3 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b43dc650c2fb0d9c67ff9b771fdb8243031eb1c3
4
- data.tar.gz: 75620be33e4832580a3ffe3625562287708fbdef
2
+ SHA256:
3
+ metadata.gz: 932450574c9f0ae3df18f694ec0e85292fae9c13e89bae9e0c4e3170acf31b5e
4
+ data.tar.gz: affb81684ce4e7f0fba86a8e6f31c31e40aa5a43bcb400a6cf6e0effd964a0d6
5
5
  SHA512:
6
- metadata.gz: b5f7bb37bd65ca8271cb14e12523451e199a2aecbef91968b7f3c893ab04b2a5dbcd60cf4839a1a478748c121e60127ef4a8e3535de065779daf49f214bfcfd5
7
- data.tar.gz: 02b26099d86b4723cfe7827f973988d2318ce9c085f7639109c1be544354e6cba0ee9dc7dacba41136eaaa8417eb51f649767ec52a3ef188a040515c40299c80
6
+ metadata.gz: ecb83cf77fa7d9ac72461a9537e936bc72c890a755a36f6ad4441235dfdf9c7c9bc561aa17fd3352920d177bbf8e00909498c3e3548c7814b7393369bd739052
7
+ data.tar.gz: 1728f4c124e70866df8eb0d83ede63a63c194eff93d3941361d62d7a43493b6126789187fc9de12f0523ad38c5af7239d3c734f17da515ce8eb5f2800952237c
@@ -18,5 +18,10 @@ module Para
18
18
  end
19
19
  end.sort_by(&:name)
20
20
  end
21
+
22
+ def show_component?(component)
23
+ config = Para.components.component_configuration_for(component.identifier)
24
+ !config.shown_if || instance_exec(&config.shown_if)
25
+ end
21
26
  end
22
27
  end
@@ -14,7 +14,7 @@
14
14
 
15
15
  %ul.component-section-list-items.collapse.in{ id: "collapse-section-#{index}" }
16
16
  - component_section.components.each do |component|
17
- - if can? :manage, component
17
+ - if can?(:manage, component) && show_component?(component)
18
18
  %li.component-item{ class: (@component == component) && 'active' }
19
19
  = link_to component.name, component.path
20
20
 
@@ -47,6 +47,10 @@ module Para
47
47
  end
48
48
  end
49
49
 
50
+ def component_configuration_for(identifier)
51
+ sections.map(&:components).flatten.find { |c| c.identifier.to_s == identifier.to_s }
52
+ end
53
+
50
54
  private
51
55
 
52
56
  def build
@@ -145,12 +149,13 @@ module Para
145
149
  end
146
150
 
147
151
  class Component
148
- attr_accessor :identifier, :type, :options, :model
152
+ attr_accessor :identifier, :type, :shown_if, :options, :model
149
153
 
150
- def initialize(identifier, type_identifier, options = {})
154
+ def initialize(identifier, type_identifier, shown_if: nil, **options)
151
155
  self.identifier = identifier.to_s
152
156
  self.type = Para::Component.registered_components[type_identifier]
153
157
  self.options = options
158
+ self.shown_if = shown_if
154
159
 
155
160
  unless type
156
161
  raise UndefinedComponentTypeError.new(
@@ -11,7 +11,7 @@ module Para
11
11
  input_html_options[:class] << "multi-select"
12
12
 
13
13
  # Load existing resources
14
- resources = object.send(attribute_name)
14
+ resources = input_html_options[:value] || object.send(attribute_name)
15
15
  # Order them if the list should be orderable
16
16
  resources = resources.sort_by(&method(:resource_position)) if orderable?
17
17
 
data/lib/para/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Para
2
- VERSION = '0.8.2.3'
2
+ VERSION = '0.8.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: para
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2.3
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-23 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -849,8 +849,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
849
849
  - !ruby/object:Gem::Version
850
850
  version: '0'
851
851
  requirements: []
852
- rubyforge_project:
853
- rubygems_version: 2.6.11
852
+ rubygems_version: 3.0.3
854
853
  signing_key:
855
854
  specification_version: 4
856
855
  summary: Rails admin engine