effective_polls 0.5.0 → 0.5.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
  SHA256:
3
- metadata.gz: e014f4462a07752d6e06f332934f392c6b396c0f7f6279501f11036005d627fa
4
- data.tar.gz: a108863da8039d6aa608d10aa043fef580b435c5c8dff564d382e69120338027
3
+ metadata.gz: '0866cfca4a02dfa03072115499d8170354a405a59dc5b3f7c41fa0cd47572488'
4
+ data.tar.gz: 1c281a7ef70e127dfa155011d1be9d5976bde1750b09ef7d30ae3ae72d549fbc
5
5
  SHA512:
6
- metadata.gz: e790818639b367c3357f162ff66ee9f795242e337f01d79bab869d0fd63da2b6a9b7b82b097793149f8e1576460253945535161d5e982023e471fa7f3c47b431
7
- data.tar.gz: 7197c7a2dcec5fb46a781e5979998ed9602e2dda492f9c885b1f8b3b0be28dc9796255b0e7a9f9a7ccf42b3a4ced34f6e61b81d32fc8fa8cb41699b4fe13d196
6
+ metadata.gz: 7d754ccfdbd61b07fbd358b2e32b71ba3d04eab8baffc35d7c8d95267f08cbbbc469812bda3661ddab70173fbe08825472185fe5ddbeeb4f88c300835ebc0839
7
+ data.tar.gz: c66bb05e2cc63164b889591e5239b58a094e803b64c406ceef6d10ff575d1a218d10751b66d20ff639891e8c242d5e1cb0ac3e457ae513b3d4172c27bd17b630
@@ -13,7 +13,7 @@ class Admin::EffectivePollQuestionsDatatable < Effective::Datatable
13
13
  end
14
14
 
15
15
  col :title
16
- col :body
16
+ col :body, as: :text
17
17
  col :required
18
18
 
19
19
  col :category, label: 'Type'
@@ -1,10 +1,5 @@
1
1
  module EffectivePollsHelper
2
2
 
3
- # Used on dashboard
4
- def polls_name_label
5
- et('effective_polls.name')
6
- end
7
-
8
3
  # Used by admin/polls form
9
4
  def effective_polls_audience_scope_collection(poll)
10
5
  klass = poll.try(:audience_class)
@@ -21,6 +21,9 @@ module EffectivePollsUser
21
21
 
22
22
  # The list of all available audience scopes for the Poll Selected Users
23
23
  def poll_audience_scopes
24
+ end
25
+
26
+ def default_poll_audience_scopes
24
27
  scopes = [
25
28
  ['All Users', :all]
26
29
  ]
@@ -39,6 +42,12 @@ module EffectivePollsUser
39
42
  end
40
43
  end
41
44
 
45
+ if self.class.try(:acts_as_role_restricted?)
46
+ scopes += EffectiveRoles.roles.map do |role|
47
+ ["All #{role} role users", "with_role_id_#{role}"]
48
+ end
49
+ end
50
+
42
51
  scopes
43
52
  end
44
53
 
@@ -46,18 +55,21 @@ module EffectivePollsUser
46
55
  def poll_audience_scope(value)
47
56
  collection = self.class.respond_to?(:unarchived) ? self.class.unarchived : self.class
48
57
 
49
- # If we respond to the fill value, call it
50
- return collection.send(value) if collection.respond_to?(value)
51
-
52
58
  # Parse the value
53
59
  name, id = value.to_s.split('_id_')
54
60
 
55
61
  case name.try(:to_sym)
56
62
  when :members_with_category
57
- collection.members_with_category(EffectiveMemberships.Category.find(id))
58
- else
59
- raise("unknown poll_audience_scope for #{value}")
63
+ return collection.members_with_category(EffectiveMemberships.Category.find(id))
64
+ when :with_role
65
+ return collection.with_role(id)
60
66
  end
67
+
68
+ # Otherwise we don't know what this scope is
69
+ raise("unknown poll_audience_scope for #{value}. Expected #{self.class.name} to have a scope named #{value}") unless collection.respond_to?(value)
70
+
71
+ # If we respond to the fill value, call it
72
+ collection.send(value)
61
73
  end
62
74
 
63
75
  def available_polls
@@ -36,6 +36,6 @@
36
36
  .card-body
37
37
  %h5 Selected Users
38
38
  %p Users within any of the following groups may complete this #{etd(poll)}
39
- = f.checks :audience_scope, effective_polls_audience_scope_collection(f.object), multiple: true, label: false
39
+ = f.checks :audience_scope, effective_polls_audience_scope_collection(f.object), multiple: true
40
40
 
41
41
  = effective_submit(f)
@@ -16,7 +16,7 @@
16
16
 
17
17
  %hr
18
18
 
19
- %h2 #{polls_name_label}
19
+ %h2 #{et('effective_polls.name')}
20
20
 
21
21
  - if datatable.present?
22
22
  %p The following #{etsd(Effective::Poll)} are available:
@@ -1,3 +1,3 @@
1
1
  module EffectivePolls
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_polls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails