Commit 46a481f93070d7f87d8aa5d916237f198947cc65

Authored by Victor Costa
1 parent b14ea061
Exists in master

Customize pairwise content views when it belongs to a group

lib/pairwise_plugin/helpers/viewer_helper.rb
@@ -81,14 +81,24 @@ module PairwisePlugin::Helpers::ViewerHelper @@ -81,14 +81,24 @@ module PairwisePlugin::Helpers::ViewerHelper
81 end 81 end
82 82
83 def pairwise_embeded_code(pairwise_content) 83 def pairwise_embeded_code(pairwise_content)
84 - embeded_url = url_for({:controller => "pairwise_plugin_profile",  
85 - :profile => pairwise_content.profile.identifier,  
86 - :action => "prompt",  
87 - :id => pairwise_content.id,  
88 - :question_id => pairwise_content.question.id,  
89 - :embeded => 1,  
90 - :source => "SOURCE_NAME",  
91 - :only_path => false}) 84 + embeded_url = nil
  85 + if pairwise_content.in_group?
  86 + embeded_url = url_for({:controller => "pairwise_plugin_profile",
  87 + :profile => pairwise_content.profile.identifier,
  88 + :action => "group",
  89 + :id => pairwise_content.parent.id,
  90 + :embeded => 1,
  91 + :only_path => false})
  92 + else
  93 + embeded_url = url_for({:controller => "pairwise_plugin_profile",
  94 + :profile => pairwise_content.profile.identifier,
  95 + :action => "prompt",
  96 + :id => pairwise_content.id,
  97 + :question_id => pairwise_content.question.id,
  98 + :embeded => 1,
  99 + :source => "SOURCE_NAME",
  100 + :only_path => false})
  101 + end
92 embeded_code = "<iframe src='#{embeded_url}' style='width:100%;height:400px' frameborder='0' allowfullscreen ></iframe>" 102 embeded_code = "<iframe src='#{embeded_url}' style='width:100%;height:400px' frameborder='0' allowfullscreen ></iframe>"
93 103
94 label = "<hr/>" 104 label = "<hr/>"
lib/pairwise_plugin/pairwise_content.rb
@@ -324,6 +324,10 @@ class PairwisePlugin::PairwiseContent &lt; Article @@ -324,6 +324,10 @@ class PairwisePlugin::PairwiseContent &lt; Article
324 20 324 20
325 end 325 end
326 326
  327 + def in_group?
  328 + parent.kind_of?(PairwisePlugin::PairwiseGroup)
  329 + end
  330 +
327 private 331 private
328 332
329 def set_next_prompt(prompt) 333 def set_next_prompt(prompt)
views/content_viewer/_prompt_body.html.erb
@@ -2,7 +2,15 @@ @@ -2,7 +2,15 @@
2 <div id="pairwise_main" class="pairwise_main"> 2 <div id="pairwise_main" class="pairwise_main">
3 <%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :prompt} %> 3 <%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :prompt} %>
4 <div class="pairwise_content"> 4 <div class="pairwise_content">
5 - <div class="pairwise_body"><%= pairwise_content.title %></div> 5 + <% if pairwise_content.in_group? %>
  6 + <div class="pairwise_body"><%= pairwise_content.parent.title %></div>
  7 + <div class="body">
  8 + <%= pairwise_content.parent.body %>
  9 + </div>
  10 + <div class="group-item-title"><%= pairwise_content.title %></div>
  11 + <% else %>
  12 + <div class="pairwise_body"><%= pairwise_content.title %></div>
  13 + <% end %>
6 <div class="pairwise_call_for_action"><%= pairwise_content.body %></div> 14 <div class="pairwise_call_for_action"><%= pairwise_content.body %></div>
7 <%= render :partial => 'content_viewer/pairwise_prompts', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => question, :source => (defined?(source) ? source : '') } %> 15 <%= render :partial => 'content_viewer/pairwise_prompts', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => question, :source => (defined?(source) ? source : '') } %>
8 <% if embeded %> 16 <% if embeded %>