Commit 859bb0badc648c92205a7e5220e92b05fe98633d
1 parent
b18d03a7
Exists in
master
Option to display group of questions into menu
Showing
4 changed files
with
133 additions
and
13 deletions
Show diff stats
lib/pairwise_plugin/questions_group_list_block.rb
... | ... | @@ -9,8 +9,11 @@ class PairwisePlugin::QuestionsGroupListBlock < Block |
9 | 9 | end |
10 | 10 | |
11 | 11 | settings_items :group_description, :type => String |
12 | + settings_items :view_type, :type => String, :default => 'menu' | |
12 | 13 | |
13 | - attr_accessible :group_description, :questions_ids, :random_sort | |
14 | + attr_accessible :group_description, :questions_ids, :random_sort, :view_type | |
15 | + | |
16 | + AVAILABLE_VIEW_TYPES = [[_('Menu'), 'menu'], [_('List'), 'list']] | |
14 | 17 | |
15 | 18 | def content(args={}) |
16 | 19 | block = self |
... | ... | @@ -20,7 +23,7 @@ class PairwisePlugin::QuestionsGroupListBlock < Block |
20 | 23 | # content += ( question ? article_to_html(question,:gallery_view => false, :format => 'full').html_safe : _('No Question selected yet.') ) |
21 | 24 | #end |
22 | 25 | proc do |
23 | - render :file => 'blocks/questions_group_list', :locals => {:block => block} | |
26 | + render :file => "blocks/questions_group_#{block.view_type}", :locals => {:block => block} | |
24 | 27 | end |
25 | 28 | end |
26 | 29 | |
... | ... | @@ -38,8 +41,8 @@ class PairwisePlugin::QuestionsGroupListBlock < Block |
38 | 41 | |
39 | 42 | def contains_question?(id) |
40 | 43 | if self.settings[:questions_ids] |
41 | - self.settings[:questions_ids].include?(id.to_s) | |
42 | - else | |
44 | + self.settings[:questions_ids].include?(id.to_s) | |
45 | + else | |
43 | 46 | return false |
44 | 47 | end |
45 | 48 | end |
... | ... | @@ -94,19 +97,19 @@ class PairwisePlugin::QuestionsGroupListBlock < Block |
94 | 97 | conditions = {} |
95 | 98 | if questions_ids && !questions_ids.empty? |
96 | 99 | questions_ids.each do |id| |
97 | - if self.owner.kind_of?(Environment) | |
98 | - question = self.owner.portal_community.questions.find(id) | |
100 | + if self.owner.kind_of?(Environment) | |
101 | + question = self.owner.portal_community.questions.find(id) | |
99 | 102 | else |
100 | 103 | question = self.owner.questions.find(id) |
101 | - end | |
104 | + end | |
102 | 105 | result << question |
103 | - end | |
106 | + end | |
104 | 107 | conditions = { :conditions => ['id not in (?)', questions_ids] } |
105 | 108 | end |
106 | 109 | |
107 | - if self.owner.kind_of?(Environment) | |
110 | + if self.owner.kind_of?(Environment) | |
108 | 111 | result += self.owner.portal_community.questions.find(:all, conditions) |
109 | - else | |
112 | + else | |
110 | 113 | result += self.owner.questions.find(:all, conditions) |
111 | 114 | end |
112 | 115 | result | ... | ... |
public/style.css
... | ... | @@ -421,8 +421,8 @@ div.pairwise_group_list_container { |
421 | 421 | } |
422 | 422 | |
423 | 423 | div.pairwise_group_list_container .row { |
424 | - font-size: 14px; | |
425 | - height: 40px; | |
424 | + font-size: 14px; | |
425 | + height: 40px; | |
426 | 426 | width:100%; |
427 | 427 | background-color: #F8C300; |
428 | 428 | vertical-align: middle; |
... | ... | @@ -432,6 +432,46 @@ div.pairwise_group_list_container .row { |
432 | 432 | cursor: auto; |
433 | 433 | } |
434 | 434 | |
435 | +div.pairwise_group_menu_container .row { | |
436 | + cursor: auto; | |
437 | + font-weight: bold; | |
438 | +} | |
439 | +div.pairwise_group_menu_container .row.secondary { | |
440 | + font-weight: normal; | |
441 | +} | |
442 | +div.pairwise_group_menu_container .questions-menu .menu-icon { | |
443 | + float: right; | |
444 | + font-size: 16px; | |
445 | +} | |
446 | +div.pairwise_group_menu_container .questions-menu .icon-label { | |
447 | + float: right; | |
448 | +} | |
449 | +div.pairwise_group_menu_container .questions-menu .icon-bar { | |
450 | + background-color: rgb(100, 100, 100); | |
451 | + display: block; | |
452 | + width: 1.125em; | |
453 | + height: 0.125em; | |
454 | + border-radius: 1px; | |
455 | + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); | |
456 | + margin: 3px; | |
457 | +} | |
458 | +div.pairwise_group_menu_container .questions-menu .menu { | |
459 | + position: absolute; | |
460 | + background-color: rgb(247, 247, 247); | |
461 | + width: 96%; | |
462 | + z-index: 999; | |
463 | + padding: 10px; | |
464 | + top: 45px; | |
465 | + box-shadow: -5px 7px 10px #888888; | |
466 | +} | |
467 | +div.pairwise_group_menu_container .questions-menu .menu .item a { | |
468 | + text-decoration: none; | |
469 | +} | |
470 | +div.pairwise_group_menu_container .questions-menu .menu .label { | |
471 | + color: rgb(175, 175, 175); | |
472 | + margin-bottom: 10px; | |
473 | +} | |
474 | + | |
435 | 475 | div.pairwise_group_list_container .row p { |
436 | 476 | line-height: 30px; |
437 | 477 | margin: auto; | ... | ... |
... | ... | @@ -0,0 +1,73 @@ |
1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | |
2 | +<% questions = block.questions_for_view || [] %> | |
3 | + | |
4 | +<%= block_title(block.title) %> | |
5 | + | |
6 | +<div id='pairwise_group_list_block_<%= block.id %>' class="pairwise_group_menu_container" data-open-prompt="0"> | |
7 | + <div class="description"> | |
8 | + <%= block.group_description %> | |
9 | + </div> | |
10 | + | |
11 | + | |
12 | + <div class="questions-menu clearfix"> | |
13 | + <span class="menu-icon"> | |
14 | + <span class="icon-bar"></span> | |
15 | + <span class="icon-bar"></span> | |
16 | + <span class="icon-bar"></span> | |
17 | + </span> | |
18 | + <span class="icon-label"><%= _('Select theme') %></span> | |
19 | + <div class="menu" style="display: none"> | |
20 | + <div class="label"> | |
21 | + <%= _('Select a theme:') %> | |
22 | + </div> | |
23 | + <div class="items"> | |
24 | + <% questions.each_with_index do |pairwise_content, index| %> | |
25 | + <div class="item <%= pairwise_group_row_classes(index) %>"> | |
26 | + <a href="#"><%= pairwise_content.name %></a> | |
27 | + </div> | |
28 | + <% end %> | |
29 | + </div> | |
30 | + </div> | |
31 | + </div> | |
32 | + <div class="question container"> | |
33 | + <% if block.questions.nil? || block.questions.empty? %> | |
34 | + <span><%= _("Empty") %></span> | |
35 | + <% else %> | |
36 | + <% questions.each_with_index do |pairwise_content, index| %> | |
37 | + <%= pairwise_group_content_body(index, pairwise_content) %> | |
38 | + <% end %> | |
39 | + <% end %> | |
40 | + </div> | |
41 | +</div> | |
42 | + | |
43 | +<script type="text/javascript"> | |
44 | + jQuery(document).ready(function($){ | |
45 | + $('.pairwise_group_menu_container .questions-menu .menu-icon').click(function() { | |
46 | + $(this).siblings('.menu').toggle('fast'); | |
47 | + }); | |
48 | + $('.pairwise_group_menu_container .questions-menu .items .row').click(function() { | |
49 | + $('.pairwise_group_menu_container .questions-menu .menu').hide('fast'); | |
50 | + }); | |
51 | + }); | |
52 | + | |
53 | +// FIXME move to js file | |
54 | +jQuery(document).ready(function($){ | |
55 | + var block_id = '#pairwise_group_list_block_<%= block.id %>'; | |
56 | + var block_element = $(block_id); | |
57 | + var questions_arrows = $(block_id + ' .arrow'); | |
58 | + var questions_rows = $(block_id + ' .row'); | |
59 | + var questions_bodies = $(block_id + ' .pairwise_inner_body'); | |
60 | + questions_rows.click(function(){ | |
61 | + var current_open = parseInt(block_element.attr('data-open-prompt')); | |
62 | + var index_clicked = questions_rows.index(this); | |
63 | + if(index_clicked != current_open){ | |
64 | + block_element.attr('data-open-prompt', index_clicked); | |
65 | + $(questions_bodies[current_open]).slideToggle(); | |
66 | + $(questions_rows[current_open]).toggleClass("secondary"); | |
67 | + | |
68 | + $(questions_bodies[index_clicked]).slideToggle(); | |
69 | + $(questions_rows[index_clicked]).toggleClass("secondary"); | |
70 | + } | |
71 | + }); | |
72 | +}); | |
73 | +</script> | ... | ... |
views/box_organizer/pairwise_plugin/_questions_group_list_block.html.erb
... | ... | @@ -11,12 +11,16 @@ |
11 | 11 | <h3> <%= _('Description:') %> </h3> |
12 | 12 | <%= text_area(:block, :group_description, :rows => 6, :cols => 50) %> |
13 | 13 | </div> |
14 | + <div class="view-type"> | |
15 | + <h3> <%= _('Choose a view type:') %> </h3> | |
16 | + <%= select_tag "block[view_type]", options_for_select(PairwisePlugin::QuestionsGroupListBlock::AVAILABLE_VIEW_TYPES, @block.view_type) %> | |
17 | + </div> | |
14 | 18 | <div id="questions_content" %> |
15 | 19 | <h3> <%= _('Choose which attributes should be displayed and drag to reorder them:') %> </h3> |
16 | 20 | <ul id="pairwise_questions_list"> |
17 | 21 | <% questions.each do |question| %> |
18 | 22 | <li> |
19 | - <%= | |
23 | + <%= | |
20 | 24 | check_box_tag( "block[questions_ids][]", question.id, @block.settings[:questions_ids] && @block.settings[:questions_ids].include?(question.id.to_s), :id => "pairwise_question_#{question.id}" ) + |
21 | 25 | content_tag( 'label', question.name, :for => "pairwise_question_#{question.id}" ) |
22 | 26 | %> | ... | ... |