compendium 1.2.1 → 1.2.2

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: ec146d9508f108284dd9e6c0ebc8f6923b8ef28f
4
- data.tar.gz: cd65c29f25480eb032eed1ddabed3beb7b042cdf
3
+ metadata.gz: 70ea06fc11dfdf1ec6b5ff0c8f3c3cbcdb047e3f
4
+ data.tar.gz: 9689e65a9366fa884b6f25ac25e595cd648c4e9d
5
5
  SHA512:
6
- metadata.gz: 89688133b46136042dee8ae70d41c1b04627dcf61440ea8d198063a3d94e93422bc5d7271a756034296e318a4ca733e7bd26fcb1629ba3fa2f5e3417466d56a0
7
- data.tar.gz: e45b2225269ced9fc313b52a3952f2d639b9603f60ae42dce6f159306014598e9e0eccd4522b48ef409566ed43e671fe800d6f7fcf980ff335832d6102b20ec6
6
+ metadata.gz: b8a0938d0199d1003aa34ae4e98983edc470616028b190c15346c3d1c9175483358b329c13f8cb9957ec00bba4198cc41aa5753b4a79810bc8037c40b58de368
7
+ data.tar.gz: 9d56fb0a805b5ad449727657e1a186cc75cf3102e1501095b5dcad7f1c737504c502cc7ce5077a1885541e151f9a74d7d3461afc520e909259005f711c821d63
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.2.2
4
+ * Allow report options to be hidden
5
+ * Allow the collection in a CollectionQuery to be generated at report runtime using a proc
6
+
3
7
  ## 1.2.1
4
8
  * Fix crash when converting a ResultSet to JSON when the results is a flat array
5
9
  * Remove haml implicit dependency
@@ -19,4 +19,10 @@
19
19
  font-weight: bold;
20
20
  color: #575757;
21
21
  }
22
- }
22
+
23
+ .option.hidden
24
+ {
25
+ display: none;
26
+ visibility: hidden;
27
+ }
28
+ }
@@ -3,6 +3,7 @@ module Compendium::Presenters
3
3
  MISSING_CHOICES_ERROR = "choices must be specified"
4
4
 
5
5
  presents :option
6
+ delegate :hidden?, to: :option
6
7
 
7
8
  def name
8
9
  t("options.#{option.name}", cascade: { offset: 2 })
@@ -72,6 +73,10 @@ module Compendium::Presenters
72
73
  out
73
74
  end
74
75
 
76
+ def hidden_field(form)
77
+ form.hidden_field option.name
78
+ end
79
+
75
80
  private
76
81
 
77
82
  def date_field(form, include_time = false)
@@ -104,4 +109,4 @@ module Compendium::Presenters
104
109
  end
105
110
  end
106
111
  end
107
- end
112
+ end
@@ -10,12 +10,18 @@
10
10
 
11
11
  <% report.options.each do |option| %>
12
12
  <% expose option, Compendium::Presenters::Option do |opt| %>
13
- <div class="option">
14
- <%= opt.label(f) %>
15
- <div class="option-element-group">
16
- <%= opt.input(self, f) %>
13
+ <% if opt.hidden? %>
14
+ <div class="option hidden">
15
+ <%= opt.hidden_field(f) %>
17
16
  </div>
18
- </div>
17
+ <% else %>
18
+ <div class="option">
19
+ <%= opt.label(f) %>
20
+ <div class="option-element-group">
21
+ <%= opt.input(self, f) %>
22
+ </div>
23
+ </div>
24
+ <% end %>
19
25
  <% end %>
20
26
  <% end %>
21
27
 
@@ -31,13 +31,15 @@ module Compendium
31
31
  if collection.is_a?(Query)
32
32
  collection.run(params, context) unless collection.ran?
33
33
  collection.results
34
+ elsif collection.is_a?(Proc)
35
+ prepare_collection(collection.call(params))
34
36
  else
35
37
  collection
36
38
  end
37
39
  end
38
40
 
39
41
  def prepare_collection(collection)
40
- return collection if collection.is_a?(Query) || collection.is_a?(Symbol)
42
+ return collection if collection.is_a?(Query) || collection.is_a?(Symbol) || collection.is_a?(Proc)
41
43
  collection.is_a?(Hash) ? collection : Hash[collection.zip(collection)]
42
44
  end
43
45
  end
@@ -1,3 +1,3 @@
1
1
  module Compendium
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -42,5 +42,22 @@ describe Compendium::CollectionQuery do
42
42
  subject.run(nil)
43
43
  end
44
44
  end
45
+
46
+ context 'when given a proc' do
47
+ let(:proc) { -> * { [1, 2, 3] } }
48
+ subject { described_class.new(:collection, { collection: proc }, -> _, key, item { [ item * 2 ] }) }
49
+
50
+ it 'should use the collection from the proc' do
51
+ subject.run(nil)
52
+ subject.results.should == { 1 => [2], 2 => [4], 3 => [6] }
53
+ end
54
+
55
+ context do
56
+ let(:proc) { -> * { raise ArgumentError } }
57
+ it 'should not run the proc until runtime' do
58
+ expect { subject }.to_not raise_error
59
+ end
60
+ end
61
+ end
45
62
  end
46
- end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compendium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vandersluis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails