effective_polls 0.5.5 → 0.6.0

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: 79eb25948f2ebc9941e30fcd61a0cb22819edf51c299743695804c7bd15fc397
4
- data.tar.gz: 82e25d870de53b57b2b92d532a9cb320af53599cdee44d2dad0f20103ac43f2c
3
+ metadata.gz: 1544136785e983f59fec3e24eb2b5f84e2c62bc23afc117c07c79e48707a46bd
4
+ data.tar.gz: 37ba582d1fab4f48d064f276b9b4e16dc7a3282fe59d654634cde177185ff9a8
5
5
  SHA512:
6
- metadata.gz: 886937adcee737cac28400c53847f25d0e941028f7c9aa3c33525bae580ec8354fd19bf74693fca131c0ac3f99b32f7836704d148a736d5090a1e5bfc9a648c9
7
- data.tar.gz: 84f5b4670ff8b659e893570bcea9b8fd3cbd6028c5693f91a0e64f0d7ddfaa8b580199fb1a5931ffea77e3b09572f76f9b197d1b2b048e7f0761a16399d8f945
6
+ metadata.gz: 489b7a8ee1acb43014e2fd76386a97bb643b8c4607a3bff709f1e90db3626ffc9369eddd591057f757087eccba86c2dae1a0825f8e35835b92048c2758f3b531
7
+ data.tar.gz: e0ed04e867e31649852e68e80fb2fbc1348ca45c852246582258c7627ecd6f5adfa8deb332e3f9f1ce629ccd08f12f0e6695d4202ab5a215e338f4d3976486ce
@@ -21,6 +21,9 @@ class Admin::EffectivePollsDatatable < Effective::Datatable
21
21
  col :poll_notifications
22
22
  col :poll_questions, visible: false
23
23
 
24
+ col :hide_results, visible: false
25
+ col :skip_logging, visible: false
26
+
24
27
  actions_col
25
28
  end
26
29
 
@@ -60,6 +60,12 @@ module Effective
60
60
  model_name.human
61
61
  end
62
62
 
63
+ # Disable effective_logging log_changes for this resource
64
+ def log_changes?
65
+ return false if poll&.skip_logging?
66
+ true
67
+ end
68
+
63
69
  # Find or build
64
70
  def ballot_response(poll_question)
65
71
  ballot_response = ballot_responses.find { |br| br.poll_question_id == poll_question.id }
@@ -37,6 +37,9 @@ module Effective
37
37
  start_at :datetime
38
38
  end_at :datetime
39
39
 
40
+ hide_results :boolean, default: false
41
+ skip_logging :boolean, default: false
42
+
40
43
  audience :string
41
44
  audience_class_name :string
42
45
  audience_scope :text # An Array of user_ids or named scopes on the User model
@@ -9,6 +9,14 @@
9
9
  .alert.alert-info
10
10
  Please be aware of the existing #{ets(f.object.poll_notifications)} when changing the start or end availability date.
11
11
 
12
+ = f.check_box :hide_results,
13
+ label: 'Hide results until the poll has ended',
14
+ hint: 'If checked, admin users will be unable to view the poll results until the poll has ended.'
15
+
16
+ = f.check_box :skip_logging,
17
+ label: 'Skip logging of ballots',
18
+ hint: 'If checked, no logs of who has submitted or completed ballots will be kept.'
19
+
12
20
  -# Audience
13
21
  - f.object.audience_class_name ||= current_user.class.name
14
22
 
@@ -1,5 +1,8 @@
1
1
  = render 'effective/poll_results/results', poll: @poll
2
2
 
3
3
  = card('Raw Data') do
4
- - datatable = Admin::EffectivePollResultsDatatable.new(poll: @poll)
5
- = render_datatable(datatable)
4
+ - if poll.hide_results? && !poll.ended?
5
+ %p The raw data for this poll will be displayed once it has ended.
6
+ - else
7
+ - datatable = Admin::EffectivePollResultsDatatable.new(poll: @poll)
8
+ = render_datatable(datatable)
@@ -8,31 +8,38 @@
8
8
  %strong
9
9
  = pluralize(poll.completed_ballots.count, 'user')
10
10
  completed
11
- ballots from an audience of
12
- = succeed('.') do
13
- %strong= pluralize(poll.users.count, 'total user')
11
+ ballots
12
+
13
+ - users_count = (poll.users.count rescue nil)
14
+ - if users_count.present?
15
+ from an audience of
16
+ = succeed('.') do
17
+ %strong= pluralize(users_count, 'total user')
14
18
 
15
19
  .card.mb-3
16
20
  .card-body
17
21
  %h5.card-title Question Results
18
22
 
19
- .effective-ballot
20
- %table.table.table-hover
21
- %thead
22
- %tr
23
- %th Question
24
- %th Results
23
+ - if poll.hide_results? && !poll.ended?
24
+ %p The results of this poll will be displayed once it has ended.
25
+ - else
26
+ .effective-ballot
27
+ %table.table.table-hover
28
+ %thead
29
+ %tr
30
+ %th Question
31
+ %th Results
25
32
 
26
- %tbody
27
- - ballots = poll.ballots
33
+ %tbody
34
+ - ballots = poll.ballots
28
35
 
29
- - poll.poll_questions.each_with_index do |poll_question, index|
30
- - ballot_responses = poll.poll_results(poll_question: poll_question)
36
+ - poll.poll_questions.each_with_index do |poll_question, index|
37
+ - ballot_responses = poll.poll_results(poll_question: poll_question)
31
38
 
32
- %tr
33
- %td
34
- #{poll_question.position + 1}. #{poll_question}
35
- %br
36
- %small.text-muted= poll_question.category
39
+ %tr
40
+ %td
41
+ #{poll_question.position + 1}. #{poll_question}
42
+ %br
43
+ %small.text-muted= poll_question.category
37
44
 
38
- %td= render('effective/poll_results/poll_result', poll_question: poll_question, ballot_responses: ballot_responses)
45
+ %td= render('effective/poll_results/poll_result', poll_question: poll_question, ballot_responses: ballot_responses)
@@ -12,6 +12,9 @@ class CreateEffectivePolls < ActiveRecord::Migration[6.0]
12
12
  t.string :audience_class_name
13
13
  t.text :audience_scope
14
14
 
15
+ t.boolean :hide_results, default: false
16
+ t.boolean :skip_logging, default: false
17
+
15
18
  t.datetime :updated_at
16
19
  t.datetime :created_at
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePolls
2
- VERSION = '0.5.5'
2
+ VERSION = '0.6.0'
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.5
4
+ version: 0.6.0
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-11-29 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails