biovision-poll 0.1.180917.0 → 0.2.200324.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/poll_answers_controller.rb +6 -5
  3. data/app/controllers/admin/poll_questions_controller.rb +6 -5
  4. data/app/controllers/admin/polls_controller.rb +7 -6
  5. data/app/controllers/poll_answers_controller.rb +15 -9
  6. data/app/controllers/poll_questions_controller.rb +15 -9
  7. data/app/controllers/polls_controller.rb +25 -16
  8. data/app/helpers/polls_helper.rb +19 -29
  9. data/app/models/poll.rb +50 -18
  10. data/app/models/poll_answer.rb +29 -36
  11. data/app/models/poll_question.rb +33 -39
  12. data/app/models/poll_user.rb +10 -1
  13. data/app/models/poll_vote.rb +20 -5
  14. data/app/services/biovision/components/polls_component.rb +21 -0
  15. data/app/views/admin/components/links/_polls.html.erb +1 -0
  16. data/app/views/admin/poll_answers/entity/_data.html.erb +0 -0
  17. data/app/views/admin/poll_answers/entity/_in_list.html.erb +0 -3
  18. data/app/views/admin/poll_answers/show.html.erb +25 -35
  19. data/app/views/admin/poll_questions/entity/_data.html.erb +0 -0
  20. data/app/views/admin/poll_questions/entity/_in_list.html.erb +6 -5
  21. data/app/views/admin/poll_questions/show.html.erb +29 -37
  22. data/app/views/admin/poll_votes/entity/_data.html.erb +0 -0
  23. data/app/views/admin/poll_votes/entity/_in_list.html.erb +6 -5
  24. data/app/views/admin/polls/entity/_data.html.erb +0 -0
  25. data/app/views/admin/polls/entity/_in_list.html.erb +1 -3
  26. data/app/views/admin/polls/index.html.erb +8 -2
  27. data/app/views/admin/polls/show.html.erb +32 -30
  28. data/app/views/admin/polls/users.html.erb +2 -1
  29. data/app/views/poll_answers/_form.html.erb +36 -30
  30. data/app/views/poll_answers/_poll_answer.html.erb +22 -2
  31. data/app/views/poll_answers/edit.html.erb +6 -5
  32. data/app/views/poll_answers/new.html.erb +8 -7
  33. data/app/views/poll_questions/_form.html.erb +53 -43
  34. data/app/views/poll_questions/edit.html.erb +6 -5
  35. data/app/views/poll_questions/new.html.erb +7 -6
  36. data/app/views/polls/_form.html.erb +64 -41
  37. data/app/views/polls/_poll.html.erb +11 -6
  38. data/app/views/polls/edit.html.erb +5 -4
  39. data/app/views/polls/new.html.erb +3 -2
  40. data/app/views/polls/results.html.erb +22 -0
  41. data/config/locales/polls-ru.yml +28 -26
  42. data/config/routes.rb +19 -15
  43. data/db/migrate/20200323000001_create_biovision_polls.rb +121 -0
  44. data/lib/biovision/poll/version.rb +3 -1
  45. metadata +10 -12
  46. data/app/uploaders/poll_image_uploader.rb +0 -46
  47. data/app/views/admin/index/dashboard/_biovision_poll.html.erb +0 -10
  48. data/db/migrate/20170906000001_create_polls.rb +0 -70
  49. data/db/migrate/20170906000002_create_poll_questions.rb +0 -22
  50. data/db/migrate/20170906000003_create_poll_answers.rb +0 -20
  51. data/db/migrate/20170906000004_create_poll_votes.rb +0 -20
  52. data/db/migrate/20180412000010_create_poll_users.rb +0 -21
  53. data/db/migrate/20180903111111_rename_vote_footprint.rb +0 -11
File without changes
@@ -1,16 +1,17 @@
1
1
  <div class="data">
2
2
  <div><%= admin_user_link(entity.user) %></div>
3
3
  <div class="info">
4
- <%= entity.ip %>,
5
4
  <%= time_tag(entity.created_at) %>
6
5
  </div>
7
6
  <div class="secondary info">
8
- <%= t('activerecord.attributes.poll_vote.footprint') %>:
9
- <%= entity.footprint %>
7
+ <%= t('attributes.slug') %>:
8
+ <%= entity.slug %>
10
9
  </div>
11
- <% unless entity.agent.nil? %>
12
10
  <div class="secondary info">
13
11
  <%= entity.agent.name %>
14
12
  </div>
15
- <% end %>
13
+ <div class="secondary info">
14
+ <%= entity.uuid %>
15
+ </div>
16
+ <%= render partial: 'admin/poll_votes/entity/data', locals: { entity: entity } %>
16
17
  </div>
File without changes
@@ -1,6 +1,3 @@
1
- <div class="image">
2
- <%= poll_image_preview(entity) %>
3
- </div>
4
1
  <div class="data">
5
2
  <div><%= admin_poll_link(entity) %></div>
6
3
  <% unless entity.description.blank? %>
@@ -39,6 +36,7 @@
39
36
  %>
40
37
 
41
38
  <ul class="actions">
39
+ <li><%= world_icon(poll_path(id: entity.id)) %></li>
42
40
  <li><%= edit_icon(edit_poll_path(id: entity.id)) %></li>
43
41
  </ul>
44
42
  </div>
@@ -1,16 +1,22 @@
1
1
  <% content_for :meta_title, t('.title', page: current_page) %>
2
2
  <% content_for :breadcrumbs do %>
3
- <span><%= t('admin.polls.nav_item.text') %></span>
3
+ <%= admin_biovision_component_link(component_handler.component) %>
4
+ <span><%= t('.nav_text') %></span>
4
5
  <% end %>
5
6
 
6
7
  <article>
7
8
  <h1><%= t('.heading') %></h1>
9
+
8
10
  <ul class="actions">
9
11
  <li><%= back_icon(admin_path) %></li>
10
12
  <li><%= create_icon(new_poll_path) %></li>
11
13
  </ul>
12
14
 
13
15
  <%= paginate @collection %>
14
- <%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
16
+ <%=
17
+ render(
18
+ partial: 'shared/admin/list', locals: { collection: @collection }
19
+ )
20
+ %>
15
21
  <%= paginate @collection %>
16
22
  </article>
@@ -1,6 +1,7 @@
1
1
  <% content_for :meta_title, t('.title', name: @entity.name) %>
2
2
  <% content_for :breadcrumbs do %>
3
- <%= link_to(t('admin.polls.nav_item.text'), admin_polls_path) %>
3
+ <%= admin_biovision_component_link(component_handler.component) %>
4
+ <%= link_to(t('admin.polls.index.nav_text'), admin_polls_path) %>
4
5
  <span><%= @entity.name %></span>
5
6
  <% end %>
6
7
 
@@ -25,43 +26,44 @@
25
26
  </nav>
26
27
  <% end %>
27
28
 
28
- <% unless @entity.image.blank? %>
29
- <figure>
30
- <%= poll_image_medium(@entity) %>
31
- <figcaption><%= t('activerecord.attributes.poll.image') %></figcaption>
32
- </figure>
33
- <% end %>
34
-
35
29
  <dl>
36
- <dt><%= t(:created_at) %></dt>
37
- <dd>
38
- <%= time_tag(@entity.created_at) %>
39
- </dd>
40
-
41
- <dt><%= t(:updated_at) %></dt>
42
- <dd>
43
- <%= time_tag(@entity.updated_at) %>
44
- </dd>
45
-
46
- <dt><%= t('activerecord.attributes.poll.name') %></dt>
47
- <dd>
48
- <%= @entity.name %>
49
- </dd>
50
-
51
- <% unless @entity.description.blank? %>
52
- <dt><%= t('activerecord.attributes.poll.description') %></dt>
30
+ <div>
31
+ <dt><%= t('activerecord.attributes.poll.name') %></dt>
53
32
  <dd>
54
- <%= @entity.description %>
33
+ <%= @entity.name %>
55
34
  </dd>
35
+ </div>
36
+
37
+ <% unless @entity.description.blank? %>
38
+ <div>
39
+ <dt><%= t('activerecord.attributes.poll.description') %></dt>
40
+ <dd>
41
+ <div class="text">
42
+ <%= @entity.description %>
43
+ </div>
44
+ </dd>
45
+ </div>
46
+ <% end %>
47
+
48
+ <% unless @entity.end_date.blank? %>
49
+ <div>
50
+ <dt><%= t('activerecord.attributes.poll.end_date') %></dt>
51
+ <dd><%= time_tag(@entity.end_date) %></dd>
52
+ </div>
56
53
  <% end %>
54
+
55
+ <%= render partial: 'shared/entity/uuid', locals: { entity: @entity } %>
56
+ <%= render partial: 'shared/entity/timestamps', locals: { entity: @entity } %>
57
57
  </dl>
58
58
 
59
+ <%= render partial: 'admin/polls/entity/data', locals: { entity: @entity } %>
60
+
59
61
  <%=
60
62
  render(
61
63
  partial: 'shared/admin/toggleable',
62
- locals: {
64
+ locals: {
63
65
  entity: @entity,
64
- url: toggle_admin_poll_path(id: @entity.id)
66
+ url: toggle_admin_poll_path(id: @entity.id)
65
67
  }
66
68
  )
67
69
  %>
@@ -72,7 +74,7 @@
72
74
  <%=
73
75
  render(
74
76
  partial: 'shared/admin/list_with_priority',
75
- locals: { collection: @entity.poll_questions.ordered_by_priority }
77
+ locals: { collection: @entity.poll_questions.ordered_by_priority }
76
78
  )
77
79
  %>
78
80
  </section>
@@ -84,7 +86,7 @@
84
86
  <%=
85
87
  render(
86
88
  partial: 'poll_questions/form',
87
- locals: { entity: @entity.poll_questions.new }
89
+ locals: { entity: @entity.poll_questions.new }
88
90
  )
89
91
  %>
90
92
  </section>
@@ -1,6 +1,7 @@
1
1
  <% content_for :meta_title, t('.title', name: @entity.name, page: current_page) %>
2
2
  <% content_for :breadcrumbs do %>
3
- <%= link_to(t('admin.polls.nav_item.text'), admin_polls_path) %>
3
+ <%= admin_biovision_component_link(component_handler.component) %>
4
+ <%= link_to(t('admin.polls.index.nav_text'), admin_polls_path) %>
4
5
  <%= admin_poll_link(@entity) %>
5
6
  <span><%= t('.heading') %></span>
6
7
  <% end %>
@@ -1,44 +1,50 @@
1
1
  <% model_name = entity.class.to_s.underscore %>
2
- <%= form_with model: entity, html: { id: "#{model_name}-form" } do |f| %>
2
+ <%=
3
+ form_with(
4
+ model: entity,
5
+ html: {
6
+ id: "#{model_name}-form",
7
+ data: { check_url: check_poll_questions_path }
8
+ }
9
+ ) do |f|
10
+ %>
3
11
  <%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
4
- <dl>
12
+
13
+ <dl class="fields">
5
14
  <% unless entity.id.nil? %>
6
- <dt><%= t('activerecord.attributes.poll_answer.poll_question_id') %></dt>
7
- <dd><%= admin_poll_question_link(entity.poll_question) %></dd>
15
+ <div>
16
+ <dt><%= t('activerecord.attributes.poll_answer.poll_question_id') %></dt>
17
+ <dd><%= admin_poll_question_link(entity.poll_question) %></dd>
18
+ </div>
8
19
  <% end %>
9
20
 
10
- <dt><%= f.label :priority %></dt>
11
- <dd>
12
- <%=
13
- f.number_field(
14
- :priority,
15
- id: "#{model_name}_priority",
16
- in: PollAnswer::PRIORITY_RANGE,
17
- required: true
18
- )
19
- %>
20
- </dd>
21
+ <%= render partial: 'shared/forms/priority', locals: { f: f } %>
21
22
 
22
- <dt><%= f.label :text %></dt>
23
- <dd>
24
- <%=
25
- f.text_field(
26
- :text,
27
- id: "#{model_name}_text",
28
- required: true,
29
- size: nil,
30
- maxlength: PollAnswer::TEXT_LIMIT,
31
- placeholder: t('.placeholders.text')
32
- )
33
- %>
34
- <div class="guideline"><%= t('.guidelines.text') %></div>
35
- </dd>
23
+ <div>
24
+ <dt><%= f.label :text %></dt>
25
+ <dd>
26
+ <%=
27
+ f.text_field(
28
+ :text,
29
+ class: 'input-text',
30
+ data: { check: :text },
31
+ maxlength: PollAnswer::TEXT_LIMIT,
32
+ placeholder: t('.placeholders.text'),
33
+ required: true,
34
+ size: nil
35
+ )
36
+ %>
37
+ <div class="check-result-error" data-field="name"></div>
38
+ <div class="guideline"><%= t('.guidelines.text') %></div>
39
+ </dd>
40
+ </div>
36
41
  </dl>
37
42
 
38
43
  <%= render 'shared/forms/state_container' %>
39
44
 
40
45
  <div class="buttons">
46
+ <%= hidden_field_tag :entity_id, entity.id %>
41
47
  <%= f.hidden_field :poll_question_id if entity.id.nil? %>
42
- <%= f.button t(:save), type: :submit, class: 'button-save' %>
48
+ <%= f.button t(:save), class: 'button-save' %>
43
49
  </div>
44
50
  <% end %>
@@ -1,6 +1,26 @@
1
+ <% question = poll_answer.poll_question %>
1
2
  <div>
2
3
  <% qid = poll_answer.poll_question_id %>
3
4
  <% field_id = "poll_votes_#{qid}_#{poll_answer.id}" %>
4
- <%= radio_button_tag "poll_votes_#{qid}", poll_answer.id, false, required: true, id: field_id %>
5
+ <% if question.multiple_choice? %>
6
+ <%=
7
+ check_box_tag(
8
+ "answer[#{qid}][]",
9
+ poll_answer.id,
10
+ false,
11
+ id: field_id
12
+ )
13
+ %>
14
+ <% else %>
15
+ <%=
16
+ radio_button_tag(
17
+ "answer[#{qid}][]",
18
+ poll_answer.id,
19
+ false,
20
+ required: true,
21
+ id: field_id
22
+ )
23
+ %>
24
+ <% end %>
5
25
  <%= label_tag(field_id, poll_answer.text) %>
6
- </div>
26
+ </div>
@@ -1,10 +1,11 @@
1
1
  <% content_for :meta_title, t('.title') %>
2
2
  <% content_for :breadcrumbs do %>
3
- <%= link_to(t('admin.polls.nav_item.text'), admin_polls_path) %>
4
- <%= admin_poll_link(@entity.poll) %>
5
- <%= admin_poll_question_link(@entity.poll_question) %>
6
- <%= admin_poll_answer_link(@entity) %>
7
- <span><%= t(:edit) %></span>
3
+ <%= admin_biovision_component_link(component_handler.component) %>
4
+ <%= link_to(t('admin.polls.index.nav_text'), admin_polls_path) %>
5
+ <%= admin_poll_link(@entity.poll) %>
6
+ <%= admin_poll_question_link(@entity.poll_question) %>
7
+ <%= admin_poll_answer_link(@entity) %>
8
+ <span><%= t('.nav_text') %></span>
8
9
  <% end %>
9
10
 
10
11
  <article class="entity-page">
@@ -1,18 +1,19 @@
1
1
  <% content_for :meta_title, t('.title') %>
2
2
  <% content_for :breadcrumbs do %>
3
- <%= link_to(t('admin.polls.nav_item.text'), admin_polls_path) %>
4
- <%= admin_poll_link(@entity.poll) unless @entity.poll.nil? %>
5
- <%= admin_poll_question_link(@entity.poll_question) unless @entity.poll_question.nil? %>
6
- <span><%= t('.heading') %></span>
3
+ <%= admin_biovision_component_link(component_handler.component) %>
4
+ <%= link_to(t('admin.polls.index.nav_text'), admin_polls_path) %>
5
+ <%= admin_poll_link(@entity.poll) unless @entity.poll.nil? %>
6
+ <%= admin_poll_question_link(@entity.poll_question) unless @entity.poll_question.nil? %>
7
+ <span><%= t('.nav_text') %></span>
7
8
  <% end %>
8
9
 
9
10
  <article>
10
11
  <h1><%= t('.title') %></h1>
11
12
 
12
13
  <% unless @entity.poll_id.nil? %>
13
- <ul class="actions">
14
- <li><%= return_icon(admin_poll_question_path(id: @entity.poll_question_id)) %></li>
15
- </ul>
14
+ <ul class="actions">
15
+ <li><%= return_icon(admin_poll_question_path(id: @entity.poll_question_id)) %></li>
16
+ </ul>
16
17
  <% end %>
17
18
 
18
19
  <%= render partial: 'form', locals: { entity: @entity } %>
@@ -1,53 +1,62 @@
1
1
  <% model_name = entity.class.to_s.underscore %>
2
- <%= form_with model: entity, html: { id: "#{model_name}-form" } do |f| %>
2
+ <%=
3
+ form_with(
4
+ model: entity,
5
+ html: {
6
+ id: "#{model_name}-form",
7
+ data: { check_url: check_poll_questions_path }
8
+ }
9
+ ) do |f|
10
+ %>
3
11
  <%= render partial: 'shared/list_of_errors', locals: { entity: entity } %>
4
- <dl>
12
+
13
+ <dl class="fields">
5
14
  <% unless entity.id.nil? %>
6
- <dt><%= t('activerecord.attributes.poll_question.poll_id') %></dt>
7
- <dd><%= admin_poll_link(entity.poll) %></dd>
15
+ <div>
16
+ <dt><%= t('attributes.poll') %></dt>
17
+ <dd><%= admin_poll_link(entity.poll) %></dd>
18
+ </div>
8
19
  <% end %>
9
20
 
10
- <dt><%= f.label :priority %></dt>
11
- <dd>
12
- <%=
13
- f.number_field(
14
- :priority,
15
- id: "#{model_name}_priority",
16
- in: PollQuestion::PRIORITY_RANGE,
17
- required: true
18
- )
19
- %>
20
- </dd>
21
+ <%= render partial: 'shared/forms/priority', locals: { f: f } %>
21
22
 
22
- <dt><%= f.label :text %></dt>
23
- <dd>
24
- <%=
25
- f.text_field(
26
- :text,
27
- id: "#{model_name}_text",
28
- required: true,
29
- size: nil,
30
- maxlength: PollQuestion::TEXT_LIMIT,
31
- placeholder: t('.placeholders.text')
32
- )
33
- %>
34
- <div class="guideline"><%= t('.guidelines.text') %></div>
35
- </dd>
23
+ <div>
24
+ <dt><%= f.label :text %></dt>
25
+ <dd>
26
+ <%=
27
+ f.text_field(
28
+ :text,
29
+ class: 'input-text',
30
+ data: { check: :name },
31
+ maxlength: PollQuestion::TEXT_LIMIT,
32
+ placeholder: t('.placeholders.text'),
33
+ required: true,
34
+ size: nil
35
+ )
36
+ %>
37
+ <div class="check-result-error" data-field="name"></div>
38
+ <div class="guideline"><%= t('.guidelines.text') %></div>
39
+ </dd>
40
+ </div>
36
41
 
37
42
  <!--
38
- <dt><%= f.label :comment %></dt>
39
- <dd>
40
- <%=
41
- f.text_field(
42
- :comment,
43
- id: "#{model_name}_comment",
44
- size: nil,
45
- maxlength: PollQuestion::COMMENT_LIMIT,
46
- placeholder: t('.placeholders.comment')
47
- )
48
- %>
49
- <div class="guideline"><%= t('.guidelines.comment') %></div>
50
- </dd>
43
+ <div>
44
+ <dt><%= f.label :comment %></dt>
45
+ <dd>
46
+ <%=
47
+ f.text_field(
48
+ :comment,
49
+ class: 'input-text',
50
+ data: { check: :comment },
51
+ maxlength: PollQuestion::COMMENT_LIMIT,
52
+ placeholder: t('.placeholders.comment'),
53
+ size: nil
54
+ )
55
+ %>
56
+ <div class="check-result-error" data-field="comment"></div>
57
+ <div class="guideline"><%= t('.guidelines.comment') %></div>
58
+ </dd>
59
+ </div>
51
60
  -->
52
61
 
53
62
  <%= render(partial: 'shared/forms/entity_flags', locals: { f: f }) %>
@@ -56,7 +65,8 @@
56
65
  <%= render 'shared/forms/state_container' %>
57
66
 
58
67
  <div class="buttons">
68
+ <%= hidden_field_tag :entity_id, entity.id %>
59
69
  <%= f.hidden_field :poll_id if entity.id.nil? %>
60
- <%= f.button t(:save), type: :submit, class: 'button-save' %>
70
+ <%= f.button t(:save), class: 'button-save' %>
61
71
  </div>
62
72
  <% end %>