Commit c584cf3ac683dd51a80e1d8ab37b1fa59324b8c5
1 parent
90c91c4a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
rails3: fix pairwise plugin
Showing
50 changed files
with
583 additions
and
564 deletions
Show diff stats
plugins/pairwise/controllers/profile/pairwise_plugin_profile_controller.rb
@@ -8,9 +8,9 @@ class PairwisePluginProfileController < ProfileController | @@ -8,9 +8,9 @@ class PairwisePluginProfileController < ProfileController | ||
8 | source = params[:source] | 8 | source = params[:source] |
9 | locals = {:source => source, :pairwise_content => @pairwise_content, :embeded => embeded, :source => source, :prompt_id => prompt_id } | 9 | locals = {:source => source, :pairwise_content => @pairwise_content, :embeded => embeded, :source => source, :prompt_id => prompt_id } |
10 | if embeded | 10 | if embeded |
11 | - render 'content_viewer/prompt.rhtml', :layout => "embeded", :locals => locals | 11 | + render 'content_viewer/prompt', :layout => "embeded", :locals => locals |
12 | else | 12 | else |
13 | - render 'content_viewer/prompt.rhtml', :locals => locals | 13 | + render 'content_viewer/prompt', :locals => locals |
14 | end | 14 | end |
15 | end | 15 | end |
16 | 16 | ||
@@ -18,7 +18,7 @@ class PairwisePluginProfileController < ProfileController | @@ -18,7 +18,7 @@ class PairwisePluginProfileController < ProfileController | ||
18 | def load_prompt | 18 | def load_prompt |
19 | @pairwise_content = find_content(params) | 19 | @pairwise_content = find_content(params) |
20 | if request.xhr? | 20 | if request.xhr? |
21 | - render 'content_viewer/prompt.rjs' | 21 | + render 'content_viewer/load_prompt.rjs' |
22 | else | 22 | else |
23 | redirect_to after_action_url | 23 | redirect_to after_action_url |
24 | end | 24 | end |
@@ -28,7 +28,7 @@ class PairwisePluginProfileController < ProfileController | @@ -28,7 +28,7 @@ class PairwisePluginProfileController < ProfileController | ||
28 | @pairwise_content = find_content(params) | 28 | @pairwise_content = find_content(params) |
29 | vote = @pairwise_content.vote_to(params[:prompt_id], params[:direction], user_identifier, params[:appearance_id]) | 29 | vote = @pairwise_content.vote_to(params[:prompt_id], params[:direction], user_identifier, params[:appearance_id]) |
30 | if request.xhr? | 30 | if request.xhr? |
31 | - render 'content_viewer/prompt.rjs' | 31 | + render 'content_viewer/load_prompt.rjs' |
32 | else | 32 | else |
33 | redirect_to after_action_url | 33 | redirect_to after_action_url |
34 | end | 34 | end |
@@ -41,7 +41,7 @@ class PairwisePluginProfileController < ProfileController | @@ -41,7 +41,7 @@ class PairwisePluginProfileController < ProfileController | ||
41 | reason = params[:reason] | 41 | reason = params[:reason] |
42 | skip = @pairwise_content.skip_prompt(params[:prompt_id], user_identifier, params[:appearance_id], reason) | 42 | skip = @pairwise_content.skip_prompt(params[:prompt_id], user_identifier, params[:appearance_id], reason) |
43 | if request.xhr? | 43 | if request.xhr? |
44 | - render 'content_viewer/prompt.rjs' | 44 | + render 'content_viewer/load_prompt.rjs' |
45 | else | 45 | else |
46 | redirect_to after_action_url | 46 | redirect_to after_action_url |
47 | end | 47 | end |
@@ -53,7 +53,7 @@ class PairwisePluginProfileController < ProfileController | @@ -53,7 +53,7 @@ class PairwisePluginProfileController < ProfileController | ||
53 | @page = @pairwise_content = find_content(params) | 53 | @page = @pairwise_content = find_content(params) |
54 | 54 | ||
55 | if request.xhr? | 55 | if request.xhr? |
56 | - render 'content_viewer/result' | 56 | + render 'content_viewer/load_result.rjs' |
57 | else | 57 | else |
58 | render 'pairwise_plugin_profile/result' | 58 | render 'pairwise_plugin_profile/result' |
59 | end | 59 | end |
plugins/pairwise/lib/pairwise/choice.rb
1 | class Pairwise::Choice < ActiveResource::Base | 1 | class Pairwise::Choice < ActiveResource::Base |
2 | extend Pairwise::Resource | 2 | extend Pairwise::Resource |
3 | + | ||
3 | self.element_name = "choice" | 4 | self.element_name = "choice" |
5 | + self.format = :xml | ||
4 | 6 | ||
5 | -end | ||
6 | \ No newline at end of file | 7 | \ No newline at end of file |
8 | +end |
plugins/pairwise/lib/pairwise/prompt.rb
1 | class Pairwise::Prompt < ActiveResource::Base | 1 | class Pairwise::Prompt < ActiveResource::Base |
2 | extend Pairwise::Resource | 2 | extend Pairwise::Resource |
3 | + | ||
3 | self.element_name = "prompt" | 4 | self.element_name = "prompt" |
5 | + self.format = :xml | ||
6 | + | ||
4 | # extend Resource | 7 | # extend Resource |
5 | # self.site = self.site + "questions/:question_id/" | 8 | # self.site = self.site + "questions/:question_id/" |
6 | #attr_accessor :name, :question_text, :question_ideas | 9 | #attr_accessor :name, :question_text, :question_ideas |
plugins/pairwise/lib/pairwise/question.rb
@@ -2,6 +2,7 @@ class Pairwise::Question < ActiveResource::Base | @@ -2,6 +2,7 @@ class Pairwise::Question < ActiveResource::Base | ||
2 | extend Pairwise::Resource | 2 | extend Pairwise::Resource |
3 | 3 | ||
4 | self.element_name = "question" | 4 | self.element_name = "question" |
5 | + self.format = :xml | ||
5 | 6 | ||
6 | def get_choices(filter=nil, order=nil) | 7 | def get_choices(filter=nil, order=nil) |
7 | Pairwise::Choice.find( | 8 | Pairwise::Choice.find( |
plugins/pairwise/lib/pairwise/visitor.rb
plugins/pairwise/lib/pairwise_plugin/choices_related.rb
1 | -class PairwisePlugin::ChoicesRelated < Noosfero::Plugin::ActiveRecord | 1 | +class PairwisePlugin::ChoicesRelated < ActiveRecord::Base |
2 | set_table_name "pairwise_plugin_choices_related" | 2 | set_table_name "pairwise_plugin_choices_related" |
3 | belongs_to :question, :class_name => 'PairwisePlugin::PairwiseContent' | 3 | belongs_to :question, :class_name => 'PairwisePlugin::PairwiseContent' |
4 | belongs_to :user | 4 | belongs_to :user |
5 | 5 | ||
6 | validates_presence_of :question, :choice_id, :parent_choice_id | 6 | validates_presence_of :question, :choice_id, :parent_choice_id |
7 | 7 | ||
8 | + attr_accessible :question, :choice_id, :parent_choice_id | ||
9 | + | ||
8 | def self.related_choices_for choice_id | 10 | def self.related_choices_for choice_id |
9 | PairwisePlugin::ChoicesRelated.find_all_by_choice_id(choice_id) + PairwisePlugin::ChoicesRelated.find_all_by_parent_choice_id(choice_id) | 11 | PairwisePlugin::ChoicesRelated.find_all_by_choice_id(choice_id) + PairwisePlugin::ChoicesRelated.find_all_by_parent_choice_id(choice_id) |
10 | end | 12 | end |
plugins/pairwise/lib/pairwise_plugin/helpers/viewer_helper.rb
@@ -17,7 +17,7 @@ module PairwisePlugin::Helpers::ViewerHelper | @@ -17,7 +17,7 @@ module PairwisePlugin::Helpers::ViewerHelper | ||
17 | end | 17 | end |
18 | 18 | ||
19 | def skip_vote_open_function(pairwise_content) | 19 | def skip_vote_open_function(pairwise_content) |
20 | - link_to_function _('Skip vote'), "jQuery(\"#skip_vote_reasons_#{pairwise_content.id}\").slideToggle()" | 20 | + link_to_function _('Skip vote'), "jQuery('#skip_vote_reasons_#{pairwise_content.id}').slideToggle()" |
21 | end | 21 | end |
22 | 22 | ||
23 | def skip_vote_link(pairwise_content, question, prompt, embeded = false, source = nil, appearance_id = nil, reason = nil) | 23 | def skip_vote_link(pairwise_content, question, prompt, embeded = false, source = nil, appearance_id = nil, reason = nil) |
plugins/pairwise/lib/pairwise_plugin/pairwise_content.rb
@@ -5,7 +5,9 @@ class PairwisePlugin::PairwiseContent < Article | @@ -5,7 +5,9 @@ class PairwisePlugin::PairwiseContent < Article | ||
5 | 5 | ||
6 | before_save :send_question_to_service | 6 | before_save :send_question_to_service |
7 | 7 | ||
8 | - validate_on_create :validate_choices | 8 | + validate :validate_choices, :on => :create |
9 | + | ||
10 | + attr_accessible :pairwise_question_id, :allow_new_ideas, :choices, :choices_saved | ||
9 | 11 | ||
10 | REASONS_ARRAY = [ | 12 | REASONS_ARRAY = [ |
11 | {:text => _("I like both ideas"), :compare => false}, | 13 | {:text => _("I like both ideas"), :compare => false}, |
@@ -59,7 +61,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -59,7 +61,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
59 | pairwise_content = self | 61 | pairwise_content = self |
60 | lambda do | 62 | lambda do |
61 | locals = {:pairwise_content => pairwise_content, :source => source, :embeded => embeded, :prompt_id => prompt_id } | 63 | locals = {:pairwise_content => pairwise_content, :source => source, :embeded => embeded, :prompt_id => prompt_id } |
62 | - render :file => 'content_viewer/prompt.rhtml', :locals => locals | 64 | + render :file => 'content_viewer/prompt', :locals => locals |
63 | end | 65 | end |
64 | end | 66 | end |
65 | 67 | ||
@@ -83,7 +85,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -83,7 +85,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
83 | begin | 85 | begin |
84 | @question ||= pairwise_client.find_question_by_id(pairwise_question_id) | 86 | @question ||= pairwise_client.find_question_by_id(pairwise_question_id) |
85 | rescue Exception => error | 87 | rescue Exception => error |
86 | - errors.add_to_base(error.message) | 88 | + errors.add(:base, error.message) |
87 | end | 89 | end |
88 | @question | 90 | @question |
89 | end | 91 | end |
@@ -135,7 +137,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -135,7 +137,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
135 | @choices = [] | 137 | @choices = [] |
136 | else | 138 | else |
137 | begin | 139 | begin |
138 | - @choices ||= question.get_choices.map {|q| { q.id.to_s, q.data } } | 140 | + @choices ||= question.get_choices.map {|q| { q.id.to_s => q.data } } |
139 | rescue | 141 | rescue |
140 | @choices = [] | 142 | @choices = [] |
141 | end | 143 | end |
@@ -182,12 +184,12 @@ class PairwisePlugin::PairwiseContent < Article | @@ -182,12 +184,12 @@ class PairwisePlugin::PairwiseContent < Article | ||
182 | end | 184 | end |
183 | 185 | ||
184 | def validate_choices | 186 | def validate_choices |
185 | - errors.add_to_base(_("Choices empty")) if choices.nil? | ||
186 | - errors.add_to_base(_("Choices invalid format")) unless choices.is_a?(Array) | ||
187 | - errors.add_to_base(_("Choices invalid")) if choices.size == 0 | 187 | + errors.add(:base, _("Choices empty")) if choices.nil? |
188 | + errors.add(:base, _("Choices invalid format")) unless choices.is_a?(Array) | ||
189 | + errors.add(:base, _("Choices invalid")) if choices.size == 0 | ||
188 | choices.each do | choice | | 190 | choices.each do | choice | |
189 | if choice.empty? | 191 | if choice.empty? |
190 | - errors.add_to_base(_("Choice empty")) | 192 | + errors.add(:base, _("Choice empty")) |
191 | break | 193 | break |
192 | end | 194 | end |
193 | end | 195 | end |
@@ -197,7 +199,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -197,7 +199,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
197 | begin | 199 | begin |
198 | return pairwise_client.update_choice(question, choice_id, choice_text, active) | 200 | return pairwise_client.update_choice(question, choice_id, choice_text, active) |
199 | rescue Exception => e | 201 | rescue Exception => e |
200 | - errors.add_to_base(N_("Choices:") + " " + N_(e.message)) | 202 | + errors.add(:base, N_("Choices:") + " " + N_(e.message)) |
201 | return false | 203 | return false |
202 | end | 204 | end |
203 | end | 205 | end |
@@ -206,7 +208,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -206,7 +208,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
206 | begin | 208 | begin |
207 | return pairwise_client.approve_choice(question, choice_id) | 209 | return pairwise_client.approve_choice(question, choice_id) |
208 | rescue Exception => e | 210 | rescue Exception => e |
209 | - errors.add_to_base(N_("Choices:") + " " + N_(e.message)) | 211 | + errors.add(:base, N_("Choices:") + " " + N_(e.message)) |
210 | return false | 212 | return false |
211 | end | 213 | end |
212 | end | 214 | end |
@@ -239,7 +241,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -239,7 +241,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
239 | pairwise_client.approve_choice(question, choice.id) | 241 | pairwise_client.approve_choice(question, choice.id) |
240 | end | 242 | end |
241 | rescue Exception => e | 243 | rescue Exception => e |
242 | - errors.add_to_base(N_("Choices: Error adding new choice to question") + N_(e.message)) | 244 | + errors.add(:base, N_("Choices: Error adding new choice to question") + N_(e.message)) |
243 | return false | 245 | return false |
244 | end | 246 | end |
245 | end | 247 | end |
@@ -250,7 +252,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -250,7 +252,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
250 | begin | 252 | begin |
251 | pairwise_client.update_choice(question, id, data, true) | 253 | pairwise_client.update_choice(question, id, data, true) |
252 | rescue Exception => e | 254 | rescue Exception => e |
253 | - errors.add_to_base(N_("Choices:") + " " + N_(e.message)) | 255 | + errors.add(:base, (N_("Choices:") + " " + N_(e.message))) |
254 | return false | 256 | return false |
255 | end | 257 | end |
256 | end | 258 | end |
@@ -258,7 +260,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -258,7 +260,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
258 | begin | 260 | begin |
259 | pairwise_client.update_question(pairwise_question_id, name) | 261 | pairwise_client.update_question(pairwise_question_id, name) |
260 | rescue Exception => e | 262 | rescue Exception => e |
261 | - errors.add_to_base(N_("Question not saved: ") + N_(e.message)) | 263 | + errors.add(:base, (N_("Question not saved: ") + N_(e.message))) |
262 | return false | 264 | return false |
263 | end | 265 | end |
264 | end | 266 | end |
@@ -304,7 +306,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -304,7 +306,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
304 | obj.pairwise_question_id = self.pairwise_question_id | 306 | obj.pairwise_question_id = self.pairwise_question_id |
305 | obj.allow_new_ideas = self.allow_new_ideas | 307 | obj.allow_new_ideas = self.allow_new_ideas |
306 | id = obj.send(:create_without_callbacks) | 308 | id = obj.send(:create_without_callbacks) |
307 | - raise "Objeto não gravado" unless id | 309 | + raise "object not saved" unless id |
308 | end | 310 | end |
309 | 311 | ||
310 | def copy!(options = {}) | 312 | def copy!(options = {}) |
@@ -315,7 +317,7 @@ class PairwisePlugin::PairwiseContent < Article | @@ -315,7 +317,7 @@ class PairwisePlugin::PairwiseContent < Article | ||
315 | obj.pairwise_question_id = self.pairwise_question_id | 317 | obj.pairwise_question_id = self.pairwise_question_id |
316 | obj.allow_new_ideas = self.allow_new_ideas | 318 | obj.allow_new_ideas = self.allow_new_ideas |
317 | id = obj.send(:create_without_callbacks) | 319 | id = obj.send(:create_without_callbacks) |
318 | - raise "Objeto não gravado" unless id | 320 | + raise "object not saved" unless id |
319 | end | 321 | end |
320 | 322 | ||
321 | def page_size | 323 | def page_size |
plugins/pairwise/lib/pairwise_plugin/questions_group_list_block.rb
@@ -18,7 +18,7 @@ class PairwisePlugin::QuestionsGroupListBlock < Block | @@ -18,7 +18,7 @@ class PairwisePlugin::QuestionsGroupListBlock < Block | ||
18 | # content += ( question ? article_to_html(question,:gallery_view => false, :format => 'full').html_safe : _('No Question selected yet.') ) | 18 | # content += ( question ? article_to_html(question,:gallery_view => false, :format => 'full').html_safe : _('No Question selected yet.') ) |
19 | #end | 19 | #end |
20 | lambda do | 20 | lambda do |
21 | - render :file => 'blocks/questions_group_list.rhtml', :locals => {:block => block} | 21 | + render :file => 'blocks/questions_group_list', :locals => {:block => block} |
22 | end | 22 | end |
23 | end | 23 | end |
24 | 24 |
plugins/pairwise/test/fixtures/http_stub_fixtures.rb
1 | require 'vcr' | 1 | require 'vcr' |
2 | 2 | ||
3 | VCR.configure do |c| | 3 | VCR.configure do |c| |
4 | - c.cassette_library_dir = "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/vcr_cassettes" | 4 | + c.cassette_library_dir = "#{Rails.root}/plugins/pairwise/test/fixtures/vcr_cassettes" |
5 | c.hook_into :webmock | 5 | c.hook_into :webmock |
6 | end | 6 | end |
7 | 7 | ||
@@ -19,4 +19,4 @@ class HttpStubFixtures | @@ -19,4 +19,4 @@ class HttpStubFixtures | ||
19 | @client.create_question(name, choices) | 19 | @client.create_question(name, choices) |
20 | end | 20 | end |
21 | end | 21 | end |
22 | -end | ||
23 | \ No newline at end of file | 22 | \ No newline at end of file |
23 | +end |
plugins/pairwise/test/fixtures/pairwise_content_fixtures.rb
@@ -77,4 +77,4 @@ class PairwiseContentFixtures | @@ -77,4 +77,4 @@ class PairwiseContentFixtures | ||
77 | choices << Pairwise::Choice.new(:id => 2, :data => "Choice2", :wins => 0, :losses => 0, :score => 0.0) | 77 | choices << Pairwise::Choice.new(:id => 2, :data => "Choice2", :wins => 0, :losses => 0, :score => 0.0) |
78 | choices << Pairwise::Choice.new(:id => 3, :data => "Choice3", :wins => 0, :losses => 0, :score => 0.0) | 78 | choices << Pairwise::Choice.new(:id => 3, :data => "Choice3", :wins => 0, :losses => 0, :score => 0.0) |
79 | end | 79 | end |
80 | -end | ||
81 | \ No newline at end of file | 80 | \ No newline at end of file |
81 | +end |
plugins/pairwise/test/functional/profile/pairwise_plugin_profile_controller_test.rb
1 | require 'test_helper' | 1 | require 'test_helper' |
2 | 2 | ||
3 | -require "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" | 3 | +require "#{Rails.root}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" |
4 | 4 | ||
5 | class PairwisePluginProfileControllerTest < ActionController::TestCase | 5 | class PairwisePluginProfileControllerTest < ActionController::TestCase |
6 | 6 | ||
@@ -35,10 +35,10 @@ class PairwisePluginProfileControllerTest < ActionController::TestCase | @@ -35,10 +35,10 @@ class PairwisePluginProfileControllerTest < ActionController::TestCase | ||
35 | login_as(@user.user.login) | 35 | login_as(@user.user.login) |
36 | PairwisePluginProfileController.any_instance.expects(:find_content).returns(@content) | 36 | PairwisePluginProfileController.any_instance.expects(:find_content).returns(@content) |
37 | @content.expects(:question_with_prompt_for_visitor).with(@user.identifier, nil).returns(@question) | 37 | @content.expects(:question_with_prompt_for_visitor).with(@user.identifier, nil).returns(@question) |
38 | - get :prompt, | ||
39 | - :profile => @profile.identifier, | 38 | + get :prompt, |
39 | + :profile => @profile.identifier, | ||
40 | :id => @content.id, | 40 | :id => @content.id, |
41 | - :question_id => @question.id | 41 | + :question_id => @question.id |
42 | assert_not_nil assigns(:pairwise_content) | 42 | assert_not_nil assigns(:pairwise_content) |
43 | assert_match /#{@question.name}/, @response.body | 43 | assert_match /#{@question.name}/, @response.body |
44 | assert_match /#{@question.prompt.left_choice_text}/, @response.body | 44 | assert_match /#{@question.prompt.left_choice_text}/, @response.body |
@@ -49,14 +49,14 @@ class PairwisePluginProfileControllerTest < ActionController::TestCase | @@ -49,14 +49,14 @@ class PairwisePluginProfileControllerTest < ActionController::TestCase | ||
49 | login_as(@user.user.login) | 49 | login_as(@user.user.login) |
50 | PairwisePluginProfileController.any_instance.expects(:find_content).returns(@content) | 50 | PairwisePluginProfileController.any_instance.expects(:find_content).returns(@content) |
51 | @content.expects(:question_with_prompt_for_visitor).with(@user.identifier, @question.prompt.id.to_s).returns(@question) | 51 | @content.expects(:question_with_prompt_for_visitor).with(@user.identifier, @question.prompt.id.to_s).returns(@question) |
52 | - get :prompt, | ||
53 | - :profile => @profile.identifier, | 52 | + get :prompt, |
53 | + :profile => @profile.identifier, | ||
54 | :id => @content.id, | 54 | :id => @content.id, |
55 | :question_id => @question.id, | 55 | :question_id => @question.id, |
56 | - :prompt_id => @question.prompt.id | ||
57 | - | 56 | + :prompt_id => @question.prompt.id |
57 | + | ||
58 | assert_not_nil assigns(:pairwise_content) | 58 | assert_not_nil assigns(:pairwise_content) |
59 | - | 59 | + |
60 | assert_match /#{@question.name}/, @response.body | 60 | assert_match /#{@question.name}/, @response.body |
61 | assert_match /#{@question.prompt.left_choice_text}/, @response.body | 61 | assert_match /#{@question.prompt.left_choice_text}/, @response.body |
62 | assert_match /#{@question.prompt.right_choice_text}/, @response.body | 62 | assert_match /#{@question.prompt.right_choice_text}/, @response.body |
plugins/pairwise/test/unit/pairwise/client_test.rb
@@ -3,7 +3,7 @@ require "test_helper" | @@ -3,7 +3,7 @@ require "test_helper" | ||
3 | require 'vcr' | 3 | require 'vcr' |
4 | 4 | ||
5 | VCR.configure do |c| | 5 | VCR.configure do |c| |
6 | - c.cassette_library_dir = "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/vcr_cassettes" | 6 | + c.cassette_library_dir = "#{Rails.root}/plugins/pairwise/test/fixtures/vcr_cassettes" |
7 | c.hook_into :webmock | 7 | c.hook_into :webmock |
8 | end | 8 | end |
9 | 9 |
plugins/pairwise/test/unit/pairwise_plugin/choices_related_test.rb
1 | require "test_helper" | 1 | require "test_helper" |
2 | -require "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" | 2 | +require "#{Rails.root}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" |
3 | 3 | ||
4 | class PairwisePlugin::ChoicesRelatedTest < ActiveSupport::TestCase | 4 | class PairwisePlugin::ChoicesRelatedTest < ActiveSupport::TestCase |
5 | 5 | ||
@@ -10,31 +10,31 @@ class PairwisePlugin::ChoicesRelatedTest < ActiveSupport::TestCase | @@ -10,31 +10,31 @@ class PairwisePlugin::ChoicesRelatedTest < ActiveSupport::TestCase | ||
10 | should 'have choice id' do | 10 | should 'have choice id' do |
11 | choices_related = PairwisePlugin::ChoicesRelated.new | 11 | choices_related = PairwisePlugin::ChoicesRelated.new |
12 | choices_related.valid? | 12 | choices_related.valid? |
13 | - assert choices_related.errors.invalid?(:choice_id) | 13 | + assert choices_related.errors.include?(:choice_id) |
14 | 14 | ||
15 | choices_related.choice_id = 1 | 15 | choices_related.choice_id = 1 |
16 | choices_related.valid? | 16 | choices_related.valid? |
17 | - assert !choices_related.errors.invalid?(:choice_id) | 17 | + assert !choices_related.errors.include?(:choice_id) |
18 | end | 18 | end |
19 | 19 | ||
20 | should 'have parent choice id' do | 20 | should 'have parent choice id' do |
21 | choices_related = PairwisePlugin::ChoicesRelated.new | 21 | choices_related = PairwisePlugin::ChoicesRelated.new |
22 | choices_related.valid? | 22 | choices_related.valid? |
23 | - assert choices_related.errors.invalid?(:parent_choice_id) | 23 | + assert choices_related.errors.include?(:parent_choice_id) |
24 | 24 | ||
25 | choices_related.parent_choice_id = 1 | 25 | choices_related.parent_choice_id = 1 |
26 | choices_related.valid? | 26 | choices_related.valid? |
27 | - assert !choices_related.errors.invalid?(:parent_choice_id) | 27 | + assert !choices_related.errors.include?(:parent_choice_id) |
28 | end | 28 | end |
29 | 29 | ||
30 | should 'belongs to a question' do | 30 | should 'belongs to a question' do |
31 | choices_related = PairwisePlugin::ChoicesRelated.new | 31 | choices_related = PairwisePlugin::ChoicesRelated.new |
32 | choices_related.valid? | 32 | choices_related.valid? |
33 | - assert choices_related.errors.invalid?(:question) | 33 | + assert choices_related.errors.include?(:question) |
34 | 34 | ||
35 | choices_related.question = @pairwise_content | 35 | choices_related.question = @pairwise_content |
36 | choices_related.valid? | 36 | choices_related.valid? |
37 | - assert !choices_related.errors.invalid?(:question) | 37 | + assert !choices_related.errors.include?(:question) |
38 | end | 38 | end |
39 | 39 | ||
40 | should 'optionally have an user' do | 40 | should 'optionally have an user' do |
@@ -50,4 +50,4 @@ class PairwisePlugin::ChoicesRelatedTest < ActiveSupport::TestCase | @@ -50,4 +50,4 @@ class PairwisePlugin::ChoicesRelatedTest < ActiveSupport::TestCase | ||
50 | assert_equal 1, PairwisePlugin::ChoicesRelated.related_choices_for(1).size | 50 | assert_equal 1, PairwisePlugin::ChoicesRelated.related_choices_for(1).size |
51 | assert_equal 1, PairwisePlugin::ChoicesRelated.related_choices_for(2).size | 51 | assert_equal 1, PairwisePlugin::ChoicesRelated.related_choices_for(2).size |
52 | end | 52 | end |
53 | -end | ||
54 | \ No newline at end of file | 53 | \ No newline at end of file |
54 | +end |
plugins/pairwise/test/unit/pairwise_plugin/pairwise_content_test.rb
1 | require "test_helper" | 1 | require "test_helper" |
2 | -require "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" | ||
3 | -require "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/http_stub_fixtures" | 2 | +require "#{Rails.root}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" |
3 | +require "#{Rails.root}/plugins/pairwise/test/fixtures/http_stub_fixtures" | ||
4 | 4 | ||
5 | # require 'vcr' | 5 | # require 'vcr' |
6 | 6 | ||
7 | # VCR.configure do |c| | 7 | # VCR.configure do |c| |
8 | -# c.cassette_library_dir = "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/vcr_cassettes" | 8 | +# c.cassette_library_dir = "#{Rails.root}/plugins/pairwise/test/fixtures/vcr_cassettes" |
9 | # c.hook_into :webmock | 9 | # c.hook_into :webmock |
10 | # c.before_playback do |i| | 10 | # c.before_playback do |i| |
11 | # puts "I in PLAYBACK: #{i.inspect}" | 11 | # puts "I in PLAYBACK: #{i.inspect}" |
@@ -70,7 +70,7 @@ class PairwisePlugin::PairwiseContentTest < ActiveSupport::TestCase | @@ -70,7 +70,7 @@ class PairwisePlugin::PairwiseContentTest < ActiveSupport::TestCase | ||
70 | 70 | ||
71 | should 'prepare prompt' do | 71 | should 'prepare prompt' do |
72 | @question = Pairwise::Question.new(:id => @pairwise_content.pairwise_question_id, :name => 'Question 1') | 72 | @question = Pairwise::Question.new(:id => @pairwise_content.pairwise_question_id, :name => 'Question 1') |
73 | - @pairwise_content.expects(:pairwise_client).returns(@pairwise_client) | 73 | + @pairwise_content.expects(:pairwise_client).returns(@pairwise_client).at_least_once |
74 | @pairwise_client.expects(:question_with_prompt).with(@question.id,'any_user', nil).returns(@question) | 74 | @pairwise_client.expects(:question_with_prompt).with(@question.id,'any_user', nil).returns(@question) |
75 | prompt = @pairwise_content.prepare_prompt('any_user') | 75 | prompt = @pairwise_content.prepare_prompt('any_user') |
76 | assert_not_nil prompt | 76 | assert_not_nil prompt |
@@ -84,11 +84,12 @@ class PairwisePlugin::PairwiseContentTest < ActiveSupport::TestCase | @@ -84,11 +84,12 @@ class PairwisePlugin::PairwiseContentTest < ActiveSupport::TestCase | ||
84 | @pairwise_client.expects(:find_question_by_id).with(@pairwise_content.pairwise_question_id).raises(ActiveResource::ResourceNotFound.new(@response)) | 84 | @pairwise_client.expects(:find_question_by_id).with(@pairwise_content.pairwise_question_id).raises(ActiveResource::ResourceNotFound.new(@response)) |
85 | 85 | ||
86 | @pairwise_content.expects(:pairwise_client).returns(@pairwise_client) | 86 | @pairwise_content.expects(:pairwise_client).returns(@pairwise_client) |
87 | - assert_nil @pairwise_content.errors[:base] | 87 | + assert @pairwise_content.errors[:base].blank? |
88 | @pairwise_content.question | 88 | @pairwise_content.question |
89 | 89 | ||
90 | - assert_not_nil @pairwise_content.errors[:base] | ||
91 | - assert_equal 'Failed with 422 Any error', @pairwise_content.errors[:base] | 90 | + assert !@pairwise_content.errors[:base].blank? |
91 | + assert_match /Any error/, @pairwise_content.errors[:base].first | ||
92 | + assert_match /422/, @pairwise_content.errors[:base].first | ||
92 | end | 93 | end |
93 | 94 | ||
94 | should 'send question to pairwise service' do | 95 | should 'send question to pairwise service' do |
@@ -146,7 +147,7 @@ class PairwisePlugin::PairwiseContentTest < ActiveSupport::TestCase | @@ -146,7 +147,7 @@ class PairwisePlugin::PairwiseContentTest < ActiveSupport::TestCase | ||
146 | assert_equal true, @pairwise_content.allow_new_ideas? | 147 | assert_equal true, @pairwise_content.allow_new_ideas? |
147 | @question = Pairwise::Question.new(:id => @pairwise_content.pairwise_question_id, :name => 'Question 1', :active => false) | 148 | @question = Pairwise::Question.new(:id => @pairwise_content.pairwise_question_id, :name => 'Question 1', :active => false) |
148 | @pairwise_content.expects(:pairwise_client).returns(@pairwise_client).at_least_once | 149 | @pairwise_content.expects(:pairwise_client).returns(@pairwise_client).at_least_once |
149 | - @pairwise_client.expects(:add_new_idea).with(@question.id, "New idea").returns(true) | 150 | + @pairwise_client.expects(:add_new_idea).with(@question.id, "New idea", nil).returns(true) |
150 | assert_equal true, @pairwise_content.add_new_idea("New idea") | 151 | assert_equal true, @pairwise_content.add_new_idea("New idea") |
151 | end | 152 | end |
152 | 153 |
plugins/pairwise/test/unit/pairwise_plugin/questions_group_block_test.rb
1 | require 'test_helper' | 1 | require 'test_helper' |
2 | -require "#{RAILS_ROOT}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" | 2 | +require "#{Rails.root}/plugins/pairwise/test/fixtures/pairwise_content_fixtures" |
3 | 3 | ||
4 | class PairwisePlugin::QuestionsGroupBlockTest < ActiveSupport::TestCase | 4 | class PairwisePlugin::QuestionsGroupBlockTest < ActiveSupport::TestCase |
5 | 5 | ||
@@ -25,7 +25,7 @@ class PairwisePlugin::QuestionsGroupBlockTest < ActiveSupport::TestCase | @@ -25,7 +25,7 @@ class PairwisePlugin::QuestionsGroupBlockTest < ActiveSupport::TestCase | ||
25 | end | 25 | end |
26 | 26 | ||
27 | should 'have available question' do | 27 | should 'have available question' do |
28 | - assert_equal [@question1, @question2], @block.available_questions | 28 | + assert_equivalent [@question1, @question2], @block.available_questions |
29 | end | 29 | end |
30 | 30 | ||
31 | should 'add multiple questions to block' do | 31 | should 'add multiple questions to block' do |
plugins/pairwise/views/blocks/questions_group_list.html.erb
0 → 100644
@@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | + | ||
3 | +<%= block_title(block.title) %> | ||
4 | + | ||
5 | +<div id='pairwise_group_list_block_<%= block.id %>' class='pairwise_group_list_container' data-open-prompt="0"> | ||
6 | + <div class="description"> | ||
7 | + <%= block.group_description %> | ||
8 | + </div> | ||
9 | + <div class="question container"> | ||
10 | + <% if block.questions.nil? || block.questions.empty? %> | ||
11 | + <span><%= _("Empty") %></span> | ||
12 | + <% else | ||
13 | + block.questions_for_view.each_with_index do |pairwise_content, index| | ||
14 | + %> | ||
15 | + <div class='<%= pairwise_group_row_classes(index) %>'> | ||
16 | + <div class="number"><p><%= index + 1 %></p></div> | ||
17 | + <div class="title"><p><%= pairwise_content.title %></p></div> | ||
18 | + <div class="arrow" ><%= pairwise_span_arrow(index) %></div> | ||
19 | + </div> | ||
20 | + <%= pairwise_group_content_body(index, pairwise_content) %> | ||
21 | + <% end %> | ||
22 | + <% end %> | ||
23 | + </div> | ||
24 | +</div> | ||
25 | + | ||
26 | +<script type="text/javascript"> | ||
27 | +jQuery(document).ready(function($){ | ||
28 | + var block_id = '#pairwise_group_list_block_<%= block.id %>'; | ||
29 | + var block_element = $(block_id); | ||
30 | + var questions_arrows = $(block_id + ' .arrow'); | ||
31 | + var questions_rows = $(block_id + ' .row'); | ||
32 | + var questions_bodies = $(block_id + ' .pairwise_inner_body'); | ||
33 | + questions_rows.click(function(){ | ||
34 | + var current_open = parseInt(block_element.attr('data-open-prompt')); | ||
35 | + var index_clicked = questions_rows.index(this); | ||
36 | + if(index_clicked != current_open){ | ||
37 | + block_element.attr('data-open-prompt', index_clicked); | ||
38 | + $(questions_bodies[current_open]).slideToggle(); | ||
39 | + $(questions_rows[current_open]).toggleClass("secondary"); | ||
40 | + | ||
41 | + $(questions_bodies[index_clicked]).slideToggle(); | ||
42 | + $(questions_rows[index_clicked]).toggleClass("secondary"); | ||
43 | + } | ||
44 | + }); | ||
45 | +}); | ||
46 | +</script> |
plugins/pairwise/views/blocks/questions_group_list.rhtml
@@ -1,46 +0,0 @@ | @@ -1,46 +0,0 @@ | ||
1 | -<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | - | ||
3 | -<%= block_title(block.title) %> | ||
4 | - | ||
5 | -<div id='pairwise_group_list_block_<%= block.id %>' class='pairwise_group_list_container' data-open-prompt="0"> | ||
6 | - <div class="description"> | ||
7 | - <%= block.group_description %> | ||
8 | - </div> | ||
9 | - <div class="question container"> | ||
10 | - <% if block.questions.nil? || block.questions.empty? %> | ||
11 | - <span><%= _("Empty") %></span> | ||
12 | - <% else | ||
13 | - block.questions_for_view.each_with_index do |pairwise_content, index| | ||
14 | - %> | ||
15 | - <div class='<%= pairwise_group_row_classes(index) %>'> | ||
16 | - <div class="number"><p><%= index + 1 %></p></div> | ||
17 | - <div class="title"><p><%= pairwise_content.title %></p></div> | ||
18 | - <div class="arrow" ><%= pairwise_span_arrow(index) %></div> | ||
19 | - </div> | ||
20 | - <%= pairwise_group_content_body(index, pairwise_content) %> | ||
21 | - <% end %> | ||
22 | - <% end %> | ||
23 | - </div> | ||
24 | -</div> | ||
25 | - | ||
26 | -<script type="text/javascript"> | ||
27 | -jQuery(document).ready(function($){ | ||
28 | - var block_id = '#pairwise_group_list_block_<%= block.id %>'; | ||
29 | - var block_element = $(block_id); | ||
30 | - var questions_arrows = $(block_id + ' .arrow'); | ||
31 | - var questions_rows = $(block_id + ' .row'); | ||
32 | - var questions_bodies = $(block_id + ' .pairwise_inner_body'); | ||
33 | - questions_rows.click(function(){ | ||
34 | - var current_open = parseInt(block_element.attr('data-open-prompt')); | ||
35 | - var index_clicked = questions_rows.index(this); | ||
36 | - if(index_clicked != current_open){ | ||
37 | - block_element.attr('data-open-prompt', index_clicked); | ||
38 | - $(questions_bodies[current_open]).slideToggle(); | ||
39 | - $(questions_rows[current_open]).toggleClass("secondary"); | ||
40 | - | ||
41 | - $(questions_bodies[index_clicked]).slideToggle(); | ||
42 | - $(questions_rows[index_clicked]).toggleClass("secondary"); | ||
43 | - } | ||
44 | - }); | ||
45 | -}); | ||
46 | -</script> |
plugins/pairwise/views/box_organizer/pairwise_plugin/_questions_group_block.html.erb
0 → 100644
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +<div class="article-block-edition"> | ||
2 | +<% if @block.owner.kind_of?(Environment) and @block.owner.portal_community.nil? %> | ||
3 | + <p id="no_portal_community"> | ||
4 | + <%= _("You don't have an community defined as the portal community. Define it before use this block properly.") %> | ||
5 | + </p> | ||
6 | +<% else %> | ||
7 | + <% | ||
8 | + questions = @block.available_questions | ||
9 | + %> | ||
10 | + <div id="questions_content" %> | ||
11 | + <ul> | ||
12 | + <% questions.each do |question| %> | ||
13 | + <li> | ||
14 | + <%= labelled_check_box(question.name, "block[questions_ids][]", question.id, @block.settings[:questions_ids] !=null && @block.settings[:questions_ids].include?(question.id.to_s) ) %> | ||
15 | + </li> | ||
16 | + <% end %> | ||
17 | + </ul> | ||
18 | + </div> | ||
19 | +<% end %> | ||
0 | \ No newline at end of file | 20 | \ No newline at end of file |
plugins/pairwise/views/box_organizer/pairwise_plugin/_questions_group_block.rhtml
@@ -1,19 +0,0 @@ | @@ -1,19 +0,0 @@ | ||
1 | -<div class="article-block-edition"> | ||
2 | -<% if @block.owner.kind_of?(Environment) and @block.owner.portal_community.nil? %> | ||
3 | - <p id="no_portal_community"> | ||
4 | - <%= _("You don't have an community defined as the portal community. Define it before use this block properly.") %> | ||
5 | - </p> | ||
6 | -<% else %> | ||
7 | - <% | ||
8 | - questions = @block.available_questions | ||
9 | - %> | ||
10 | - <div id="questions_content" %> | ||
11 | - <ul> | ||
12 | - <% questions.each do |question| %> | ||
13 | - <li> | ||
14 | - <%= labelled_check_box(question.name, "block[questions_ids][]", question.id, @block.settings[:questions_ids] !=null && @block.settings[:questions_ids].include?(question.id.to_s) ) %> | ||
15 | - </li> | ||
16 | - <% end %> | ||
17 | - </ul> | ||
18 | - </div> | ||
19 | -<% end %> | ||
20 | \ No newline at end of file | 0 | \ No newline at end of file |
plugins/pairwise/views/box_organizer/pairwise_plugin/_questions_group_list_block.html.erb
0 → 100644
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +<div class="article-block-edition"> | ||
2 | +<% if @block.owner.kind_of?(Environment) and @block.owner.portal_community.nil? %> | ||
3 | + <p id="no_portal_community"> | ||
4 | + <%= _("You don't have an community defined as the portal community. Define it before use this block properly.") %> | ||
5 | + </p> | ||
6 | +<% else %> | ||
7 | + <% | ||
8 | + questions = @block.available_questions | ||
9 | + %> | ||
10 | + <div class="group_description"> | ||
11 | + <h3> <%= _('Description:') %> </h3> | ||
12 | + <%= text_area(:block, :group_description, :rows => 6, :cols => 50) %> | ||
13 | + </div> | ||
14 | + <div id="questions_content" %> | ||
15 | + <h3> <%= _('Choose which attributes should be displayed and drag to reorder them:') %> </h3> | ||
16 | + <ul id="pairwise_questions_list"> | ||
17 | + <% questions.each do |question| %> | ||
18 | + <li> | ||
19 | + <%= | ||
20 | + 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 | + content_tag( 'label', question.name, :for => "pairwise_question_#{question.id}" ) | ||
22 | + %> | ||
23 | + </li> | ||
24 | + <% end %> | ||
25 | + </ul> | ||
26 | + <div class="random_sort"> | ||
27 | + <%= labelled_form_field check_box(:block, :random_sort) + _('Show items in a random order'), '' %> | ||
28 | + </div> | ||
29 | + </div> | ||
30 | +<% end %> | ||
31 | + | ||
32 | +<script type="text/javascript"> | ||
33 | + jQuery( "#pairwise_questions_list" ).sortable(); | ||
34 | +</script> |
plugins/pairwise/views/box_organizer/pairwise_plugin/_questions_group_list_block.rhtml
@@ -1,34 +0,0 @@ | @@ -1,34 +0,0 @@ | ||
1 | -<div class="article-block-edition"> | ||
2 | -<% if @block.owner.kind_of?(Environment) and @block.owner.portal_community.nil? %> | ||
3 | - <p id="no_portal_community"> | ||
4 | - <%= _("You don't have an community defined as the portal community. Define it before use this block properly.") %> | ||
5 | - </p> | ||
6 | -<% else %> | ||
7 | - <% | ||
8 | - questions = @block.available_questions | ||
9 | - %> | ||
10 | - <div class="group_description"> | ||
11 | - <h3> <%= _('Description:') %> </h3> | ||
12 | - <%= text_area(:block, :group_description, :rows => 6, :cols => 50) %> | ||
13 | - </div> | ||
14 | - <div id="questions_content" %> | ||
15 | - <h3> <%= _('Choose which attributes should be displayed and drag to reorder them:') %> </h3> | ||
16 | - <ul id="pairwise_questions_list"> | ||
17 | - <% questions.each do |question| %> | ||
18 | - <li> | ||
19 | - <%= | ||
20 | - 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 | - content_tag( 'label', question.name, :for => "pairwise_question_#{question.id}" ) | ||
22 | - %> | ||
23 | - </li> | ||
24 | - <% end %> | ||
25 | - </ul> | ||
26 | - <div class="random_sort"> | ||
27 | - <%= labelled_form_field check_box(:block, :random_sort) + _('Show items in a random order'), '' %> | ||
28 | - </div> | ||
29 | - </div> | ||
30 | -<% end %> | ||
31 | - | ||
32 | -<script type="text/javascript"> | ||
33 | - jQuery( "#pairwise_questions_list" ).sortable(); | ||
34 | -</script> |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | + | ||
3 | +<ul class="pairwise_menu"> | ||
4 | + <li> | ||
5 | + <%= pairwise_tab_remote_link _('Pairwise Vote'), pairwise_content.prompt_url, pairwise_content, embeded, :class => active_tab == :prompt ? 'active' : '' %> | ||
6 | + </li> | ||
7 | + <li><%= pairwise_tab_remote_link _('Results'), pairwise_content.result_url, pairwise_content, embeded, :class => active_tab == :results ? 'active' : '' %></li> | ||
8 | + <% if !embeded && pairwise_content.allow_edit?(user) %> | ||
9 | + <li><%= pairwise_edit_link _('Edit'), pairwise_content %></li> | ||
10 | + <li><%= ideas_management_link _('Manage Ideas'), pairwise_content, user %></li> | ||
11 | + <% end %> | ||
12 | +</ul> |
plugins/pairwise/views/content_viewer/_menu.rhtml
@@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
1 | -<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | - | ||
3 | -<ul class="pairwise_menu"> | ||
4 | - <li> | ||
5 | - <%= pairwise_tab_remote_link _('Pairwise Vote'), pairwise_content.prompt_url, pairwise_content, embeded, :class => active_tab == :prompt ? 'active' : '' %> | ||
6 | - </li> | ||
7 | - <li><%= pairwise_tab_remote_link _('Results'), pairwise_content.result_url, pairwise_content, embeded, :class => active_tab == :results ? 'active' : '' %></li> | ||
8 | - <% if !embeded && pairwise_content.allow_edit?(user) %> | ||
9 | - <li><%= pairwise_edit_link _('Edit'), pairwise_content %></li> | ||
10 | - <li><%= ideas_management_link _('Manage Ideas'), pairwise_content, user %></li> | ||
11 | - <% end %> | ||
12 | -</ul> |
plugins/pairwise/views/content_viewer/_pairwise_prompts.html.erb
0 → 100644
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<div id="pairwise_prompts_<%= pairwise_content.id %>"> | ||
2 | + <%= pairwise_spinner(pairwise_content) %> | ||
3 | + <% unless question %> | ||
4 | + <div style="height: 190px"></div> | ||
5 | + <script> | ||
6 | + <%= pairwise_spinner_show_function_call(pairwise_content) %> | ||
7 | + jQuery.ajax({ | ||
8 | + url: "<%= url_for :controller=>'pairwise_plugin_profile', :action=>'load_prompt', :profile => pairwise_content.profile.identifier, :id => pairwise_content.id %>", | ||
9 | + dataType: 'script' | ||
10 | + }); | ||
11 | + </script> | ||
12 | + <% else %> | ||
13 | + <div class="prompt left"><%= choose_left_link(pairwise_content, question, question.prompt, embeded, source, question.appearance_id) %></div> | ||
14 | + <div class="separator"></div> | ||
15 | + <div class="prompt right"><%= choose_right_link(pairwise_content, question, question.prompt, embeded, source, question.appearance_id ) %></div> | ||
16 | + <% end %> | ||
17 | +</div> |
plugins/pairwise/views/content_viewer/_pairwise_prompts.rhtml
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -<div id="pairwise_prompts_<%= pairwise_content.id %>"> | ||
2 | - <%= pairwise_spinner(pairwise_content) %> | ||
3 | - <% unless question %> | ||
4 | - <div style="height: 190px"></div> | ||
5 | - <script> | ||
6 | - <%= pairwise_spinner_show_function_call(pairwise_content) %> | ||
7 | - jQuery.ajax({ | ||
8 | - url: "<%= url_for :controller=>'pairwise_plugin_profile', :action=>'load_prompt', :profile => pairwise_content.profile.identifier, :id => pairwise_content.id %>", | ||
9 | - dataType: 'script' | ||
10 | - }); | ||
11 | - </script> | ||
12 | - <% else %> | ||
13 | - <div class="prompt left"><%= choose_left_link(pairwise_content, question, question.prompt, embeded, source, question.appearance_id) %></div> | ||
14 | - <div class="separator"></div> | ||
15 | - <div class="prompt right"><%= choose_right_link(pairwise_content, question, question.prompt, embeded, source, question.appearance_id ) %></div> | ||
16 | - <% end %> | ||
17 | -</div> |
plugins/pairwise/views/content_viewer/_pairwise_skips.html.erb
0 → 100644
@@ -0,0 +1,5 @@ | @@ -0,0 +1,5 @@ | ||
1 | +<ul> | ||
2 | + <% pairwise_content.ask_skip_reasons(question.prompt).each do |reason| %> | ||
3 | + <%= skip_vote_link(pairwise_content, question, question.prompt, embeded, source, question.appearance_id, reason ) %> | ||
4 | + <% end %> | ||
5 | +</ul> | ||
0 | \ No newline at end of file | 6 | \ No newline at end of file |
plugins/pairwise/views/content_viewer/_pairwise_skips.rhtml
@@ -1,5 +0,0 @@ | @@ -1,5 +0,0 @@ | ||
1 | -<ul> | ||
2 | - <% pairwise_content.ask_skip_reasons(question.prompt).each do |reason| %> | ||
3 | - <%= skip_vote_link(pairwise_content, question, question.prompt, embeded, source, question.appearance_id, reason ) %> | ||
4 | - <% end %> | ||
5 | -</ul> | ||
6 | \ No newline at end of file | 0 | \ No newline at end of file |
plugins/pairwise/views/content_viewer/_prompt_body.html.erb
0 → 100644
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +<div id="pairwise_<%= pairwise_content.id %>"> | ||
2 | +<div id="pairwise_main" class="pairwise_main"> | ||
3 | + <%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :prompt} %> | ||
4 | + <div class="pairwise_content"> | ||
5 | + <div class="pairwise_body"><%= pairwise_content.title %></div> | ||
6 | + <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 : '') } %> | ||
8 | + <% if embeded %> | ||
9 | + <div class="footer"><%= _('Powered by') + ' ' + pairwise_content.environment.name%></div> | ||
10 | + <% end %> | ||
11 | + </div> | ||
12 | + <div class="skip_vote"> | ||
13 | + <%= skip_vote_open_function(pairwise_content) %> | ||
14 | + </div> | ||
15 | + <div id="skip_vote_reasons_<%= pairwise_content.id %>" class="skip_vote_reasons"> | ||
16 | + <% if question %> | ||
17 | + <%= render :partial => 'content_viewer/pairwise_skips', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => question, :source => (defined?(source) ? source : '') } %> | ||
18 | + <% end %> | ||
19 | + </div> | ||
20 | + | ||
21 | + <% if pairwise_content.allow_new_ideas? %> | ||
22 | + <% if user %> | ||
23 | + <div id="suggestions_box"> | ||
24 | + <span>Gostaria de sugerir uma ideia?</span> | ||
25 | + <div class="suggestion_form"> | ||
26 | + <%= render :partial => "pairwise_plugin_profile/suggestion_form", | ||
27 | + :locals => {:pairwise_content => pairwise_content, :embeded => embeded, :source => source} %> | ||
28 | + </div> | ||
29 | + </div> | ||
30 | + <% else %> | ||
31 | + <div id="suggestions_box_not_logged"> | ||
32 | + <%= link_to(_("Add new idea"), '#', :id => 'new_idea_button_not_logged', :class => 'require-login-popup') %> | ||
33 | + </div> | ||
34 | + <% end %> | ||
35 | + <% end %> | ||
36 | +</div> | ||
37 | +</div> |
plugins/pairwise/views/content_viewer/_prompt_body.rhtml
@@ -1,37 +0,0 @@ | @@ -1,37 +0,0 @@ | ||
1 | -<div id="pairwise_<%= pairwise_content.id %>"> | ||
2 | -<div id="pairwise_main" class="pairwise_main"> | ||
3 | - <%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :prompt} %> | ||
4 | - <div class="pairwise_content"> | ||
5 | - <div class="pairwise_body"><%= pairwise_content.title %></div> | ||
6 | - <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 : '') } %> | ||
8 | - <% if embeded %> | ||
9 | - <div class="footer"><%= _('Powered by') + ' ' + pairwise_content.environment.name%></div> | ||
10 | - <% end %> | ||
11 | - </div> | ||
12 | - <div class="skip_vote"> | ||
13 | - <%= skip_vote_open_function(pairwise_content) %> | ||
14 | - </div> | ||
15 | - <div id="skip_vote_reasons_<%= pairwise_content.id %>" class="skip_vote_reasons"> | ||
16 | - <% if question %> | ||
17 | - <%= render :partial => 'content_viewer/pairwise_skips', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => question, :source => (defined?(source) ? source : '') } %> | ||
18 | - <% end %> | ||
19 | - </div> | ||
20 | - | ||
21 | - <% if pairwise_content.allow_new_ideas? %> | ||
22 | - <% if user %> | ||
23 | - <div id="suggestions_box"> | ||
24 | - <span>Gostaria de sugerir uma ideia?</span> | ||
25 | - <div class="suggestion_form"> | ||
26 | - <%= render :partial => "pairwise_plugin_profile/suggestion_form", | ||
27 | - :locals => {:pairwise_content => pairwise_content, :embeded => embeded, :source => source} %> | ||
28 | - </div> | ||
29 | - </div> | ||
30 | - <% else %> | ||
31 | - <div id="suggestions_box_not_logged"> | ||
32 | - <%= link_to(_("Add new idea"), '#', :id => 'new_idea_button_not_logged', :class => 'require-login-popup') %> | ||
33 | - </div> | ||
34 | - <% end %> | ||
35 | - <% end %> | ||
36 | -</div> | ||
37 | -</div> |
@@ -0,0 +1,63 @@ | @@ -0,0 +1,63 @@ | ||
1 | +<div id="pairwise_<%= pairwise_content.id %>"> | ||
2 | +<div id="pairwise_main" class="pairwise_main"> | ||
3 | + | ||
4 | +<% | ||
5 | + @question = @page.question | ||
6 | + %> | ||
7 | + | ||
8 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
9 | + | ||
10 | +<% unless @page.errors[:base].blank? %> | ||
11 | + <h3><%= _('Pairwise Integration Error') %></h3> | ||
12 | + <p> <%= _('Please contact the administrator') %></p> | ||
13 | + <pre> | ||
14 | + <%= @page.errors[:base] %> | ||
15 | + </pre> | ||
16 | +<% else %> | ||
17 | + | ||
18 | + <%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :results} %> | ||
19 | + | ||
20 | + <% cache_timeout("pairwise-result-#{pairwise_content.id}", 1.hours) do %> | ||
21 | + <div class="pairwise_content"> | ||
22 | +<%= pairwise_spinner(pairwise_content) %> | ||
23 | + | ||
24 | + <div class="total_votes"> | ||
25 | + <span class="label"><%= _('Total votes:') %></span> | ||
26 | + <span class="value"><%= @page.question.votes_count %></span> | ||
27 | + </div> | ||
28 | + <table> | ||
29 | + <thead> | ||
30 | + <tr> | ||
31 | + <th><%= _('Choice Text') %></th> | ||
32 | + <th title="<%= _('The ideia is better than the other ideas') %>" ><%= _('Choice Wins') %></th> | ||
33 | + <th title="<%= _('The other ideas were chosen') %>" ><%= _('Choice Losses') %></th> | ||
34 | + <th title="<%= _('Rank of the ideias') %>" ><%= _('Choice Score') %></th> | ||
35 | + </tr> | ||
36 | + </thead> | ||
37 | + <tbody> | ||
38 | + <% @page.question.get_choices.each do |choice| %> | ||
39 | + <tr> | ||
40 | + <td><%= choice.data %></td> | ||
41 | + <td><%= choice.wins %></td> | ||
42 | + <td><%= choice.losses %></td> | ||
43 | + <td><%= choice.score.round.to_s %></td> | ||
44 | + </tr> | ||
45 | + <% end %> | ||
46 | + </tbody> | ||
47 | + </table> | ||
48 | + </div> | ||
49 | + <% if @page.allow_edit?(user) %> | ||
50 | + <div class="embeded_code"> | ||
51 | + <span class="embeded_code_link"><a href="javascript:;"><%= _("Show/Hide Embeded Code") %></a></span> | ||
52 | + <div id="pairwise_embeded_box" style="display:none"> | ||
53 | + <%= pairwise_embeded_code(@page) %> | ||
54 | + </div> | ||
55 | + </div> | ||
56 | + <% end %> | ||
57 | + <%#= link_to _('Vote'), @page.url, :class=>"button with-text icon-edit" %> | ||
58 | +<% end %> | ||
59 | +<% end %> | ||
60 | + | ||
61 | +</div> | ||
62 | +</div> | ||
63 | + |
plugins/pairwise/views/content_viewer/_result.rhtml
@@ -1,63 +0,0 @@ | @@ -1,63 +0,0 @@ | ||
1 | -<div id="pairwise_<%= pairwise_content.id %>"> | ||
2 | -<div id="pairwise_main" class="pairwise_main"> | ||
3 | - | ||
4 | -<% | ||
5 | - @question = @page.question | ||
6 | - %> | ||
7 | - | ||
8 | -<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
9 | - | ||
10 | -<% unless @page.errors[:base].nil? %> | ||
11 | - <h3><%= _('Pairwise Integration Error') %></h3> | ||
12 | - <p> <%= _('Please contact the administrator') %></p> | ||
13 | - <pre> | ||
14 | - <%= @page.errors[:base] %> | ||
15 | - </pre> | ||
16 | -<% else %> | ||
17 | - | ||
18 | - <%= render :partial => 'content_viewer/menu', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :active_tab => :results} %> | ||
19 | - | ||
20 | - <% cache_timeout("pairwise-result-#{pairwise_content.id}", 1.hours) do %> | ||
21 | - <div class="pairwise_content"> | ||
22 | -<%= pairwise_spinner(pairwise_content) %> | ||
23 | - | ||
24 | - <div class="total_votes"> | ||
25 | - <span class="label"><%= _('Total votes:') %></span> | ||
26 | - <span class="value"><%= @page.question.votes_count %></span> | ||
27 | - </div> | ||
28 | - <table> | ||
29 | - <thead> | ||
30 | - <tr> | ||
31 | - <th><%= _('Choice Text') %></th> | ||
32 | - <th title="<%= _('The ideia is better than the other ideas') %>" ><%= _('Choice Wins') %></th> | ||
33 | - <th title="<%= _('The other ideas were chosen') %>" ><%= _('Choice Losses') %></th> | ||
34 | - <th title="<%= _('Rank of the ideias') %>" ><%= _('Choice Score') %></th> | ||
35 | - </tr> | ||
36 | - </thead> | ||
37 | - <tbody> | ||
38 | - <% @page.question.get_choices.each do |choice| %> | ||
39 | - <tr> | ||
40 | - <td><%= choice.data %></td> | ||
41 | - <td><%= choice.wins %></td> | ||
42 | - <td><%= choice.losses %></td> | ||
43 | - <td><%= choice.score.round.to_s %></td> | ||
44 | - </tr> | ||
45 | - <% end %> | ||
46 | - </tbody> | ||
47 | - </table> | ||
48 | - </div> | ||
49 | - <% if @page.allow_edit?(user) %> | ||
50 | - <div class="embeded_code"> | ||
51 | - <span class="embeded_code_link"><a href="javascript:;"><%= _("Show/Hide Embeded Code") %></a></span> | ||
52 | - <div id="pairwise_embeded_box" style="display:none"> | ||
53 | - <%= pairwise_embeded_code(@page) %> | ||
54 | - </div> | ||
55 | - </div> | ||
56 | - <% end %> | ||
57 | - <%#= link_to _('Vote'), @page.url, :class=>"button with-text icon-edit" %> | ||
58 | -<% end %> | ||
59 | -<% end %> | ||
60 | - | ||
61 | -</div> | ||
62 | -</div> | ||
63 | - |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +extend PairwisePlugin::Helpers::ViewerHelper | ||
2 | + | ||
3 | +question = @pairwise_content.prepare_prompt(pairwise_user_identifier(user), nil) | ||
4 | + | ||
5 | +spinner = "pairwise_spinner#{@pairwise_content.id}" | ||
6 | + | ||
7 | +div_id = "pairwise_prompts_#{@pairwise_content.id}" | ||
8 | + | ||
9 | +skip_div_id = "skip_vote_reasons_#{@pairwise_content.id}" | ||
10 | + | ||
11 | +page.replace div_id, :partial => 'content_viewer/pairwise_prompts', :locals => { | ||
12 | + :embeded => params[:embeded], | ||
13 | + :source => params[:source], | ||
14 | + :pairwise_content => @pairwise_content, | ||
15 | + :question => question | ||
16 | + } | ||
17 | + | ||
18 | +page.replace_html skip_div_id, :partial => 'content_viewer/pairwise_skips', :locals => { | ||
19 | + :embeded => params[:embeded], | ||
20 | + :source => params[:source], | ||
21 | + :pairwise_content => @pairwise_content, | ||
22 | + :question => question | ||
23 | + } | ||
24 | + | ||
25 | +page.call pairwise_spinner_hide_function_name(@pairwise_content) |
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +extend PairwisePlugin::Helpers::ViewerHelper | ||
2 | + | ||
3 | +div_id = "pairwise_#{@pairwise_content.id}" | ||
4 | + | ||
5 | +page.replace div_id, :partial => 'content_viewer/result', :locals => { | ||
6 | + :embeded => params[:embeded], | ||
7 | + :pairwise_content => @pairwise_content, | ||
8 | + } | ||
9 | + | ||
10 | +page.call pairwise_spinner_hide_function_name(@pairwise_content) |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | + | ||
3 | +<%= pairwise_plugin_stylesheet %> | ||
4 | + | ||
5 | +<% if embeded %> | ||
6 | + <%= javascript_include_tag :defaults, 'jquery-latest.js', | ||
7 | + 'jquery.noconflict.js', 'jquery.cycle.all.min.js', 'thickbox.js', 'lightbox', 'colorbox', | ||
8 | + 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', | ||
9 | + 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', | ||
10 | + 'add-and-join', 'report-abuse', 'catalog', 'manage-products', | ||
11 | + 'jquery-ui-timepicker-addon', :cache => 'cache-general' %> | ||
12 | +<% end %> | ||
13 | + | ||
14 | +<%= render :partial => 'content_viewer/prompt_body', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => nil, :source => (defined?(source) ? source : '') }%> |
plugins/pairwise/views/content_viewer/prompt.rhtml
@@ -1,14 +0,0 @@ | @@ -1,14 +0,0 @@ | ||
1 | -<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | - | ||
3 | -<%= pairwise_plugin_stylesheet %> | ||
4 | - | ||
5 | -<% if embeded %> | ||
6 | - <%= javascript_include_tag :defaults, 'jquery-latest.js', | ||
7 | - 'jquery.noconflict.js', 'jquery.cycle.all.min.js', 'thickbox.js', 'lightbox', 'colorbox', | ||
8 | - 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', | ||
9 | - 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', | ||
10 | - 'add-and-join', 'report-abuse', 'catalog', 'manage-products', | ||
11 | - 'jquery-ui-timepicker-addon', :cache => 'cache-general' %> | ||
12 | -<% end %> | ||
13 | - | ||
14 | -<%= render :partial => 'content_viewer/prompt_body', :locals => {:embeded => embeded, :pairwise_content => pairwise_content, :question => nil, :source => (defined?(source) ? source : '') }%> |
plugins/pairwise/views/content_viewer/prompt.rjs
@@ -1,25 +0,0 @@ | @@ -1,25 +0,0 @@ | ||
1 | -extend PairwisePlugin::Helpers::ViewerHelper | ||
2 | - | ||
3 | -question = @pairwise_content.prepare_prompt(pairwise_user_identifier(user), nil) | ||
4 | - | ||
5 | -spinner = "pairwise_spinner#{@pairwise_content.id}" | ||
6 | - | ||
7 | -div_id = "pairwise_prompts_#{@pairwise_content.id}" | ||
8 | - | ||
9 | -skip_div_id = "skip_vote_reasons_#{@pairwise_content.id}" | ||
10 | - | ||
11 | -page.replace div_id, :partial => 'content_viewer/pairwise_prompts', :locals => { | ||
12 | - :embeded => params[:embeded], | ||
13 | - :source => params[:source], | ||
14 | - :pairwise_content => @pairwise_content, | ||
15 | - :question => question | ||
16 | - } | ||
17 | - | ||
18 | -page.replace_html skip_div_id, :partial => 'content_viewer/pairwise_skips', :locals => { | ||
19 | - :embeded => params[:embeded], | ||
20 | - :source => params[:source], | ||
21 | - :pairwise_content => @pairwise_content, | ||
22 | - :question => question | ||
23 | - } | ||
24 | - | ||
25 | -page.call pairwise_spinner_hide_function_name(@pairwise_content) |
plugins/pairwise/views/content_viewer/result.rjs
@@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
1 | -extend PairwisePlugin::Helpers::ViewerHelper | ||
2 | - | ||
3 | -div_id = "pairwise_#{@pairwise_content.id}" | ||
4 | - | ||
5 | -page.replace div_id, :partial => 'content_viewer/result', :locals => { | ||
6 | - :embeded => params[:embeded], | ||
7 | - :pairwise_content => @pairwise_content, | ||
8 | - } | ||
9 | - | ||
10 | -page.call pairwise_spinner_hide_function_name(@pairwise_content) |
plugins/pairwise/views/pairwise_plugin_admin/index.html.erb
0 → 100644
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<h1><%= _('Pairwise settings')%></h1> | ||
2 | + | ||
3 | +<%= form_for(:settings) do |f| %> | ||
4 | + | ||
5 | + <div id="pairwise-config-fields"> | ||
6 | + <%= labelled_form_field _('Pairwise api host'), f.text_field(:api_host) %> | ||
7 | + <%= labelled_form_field _('Pairwise username'), f.text_field(:username) %> | ||
8 | + <%= labelled_form_field _('Pairwise password'), f.text_field(:password) %> | ||
9 | + | ||
10 | + | ||
11 | + | ||
12 | + <% button_bar do %> | ||
13 | + <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> | ||
14 | + <% end %> | ||
15 | + </div> | ||
16 | +<% end %> | ||
17 | + |
plugins/pairwise/views/pairwise_plugin_admin/index.rhtml
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -<h1><%= _('Pairwise settings')%></h1> | ||
2 | - | ||
3 | -<% form_for(:settings) do |f| %> | ||
4 | - | ||
5 | - <div id="pairwise-config-fields"> | ||
6 | - <%= labelled_form_field _('Pairwise api host'), f.text_field(:api_host) %> | ||
7 | - <%= labelled_form_field _('Pairwise username'), f.text_field(:username) %> | ||
8 | - <%= labelled_form_field _('Pairwise password'), f.text_field(:password) %> | ||
9 | - | ||
10 | - | ||
11 | - | ||
12 | - <% button_bar do %> | ||
13 | - <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> | ||
14 | - <% end %> | ||
15 | - </div> | ||
16 | -<% end %> | ||
17 | - |
plugins/pairwise/views/pairwise_plugin_profile/_suggestion_form.html.erb
0 → 100644
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | + <%= remote_form_for('idea', :url => pairwise_suggestion_url(pairwise_content, embeded, source), | ||
2 | + :html => {:id => "pairwise_suggestion_form_#{pairwise_content.id}"}, :loading => "jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_fields').hide();jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_loading').show();", :loaded => "jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_fields').show();jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_loading').hide();") do |f| %> | ||
3 | + <div class="suggestion_box_fields"> | ||
4 | + <div class="error"> | ||
5 | + <%= flash[:error] %> | ||
6 | + </div> | ||
7 | + <div class="notice"> | ||
8 | + <%= flash[:notice] %> | ||
9 | + </div> | ||
10 | + <div class="div_text_input_container"> | ||
11 | + <div id="text_idea_content_<%= pairwise_content.id %>" class="div_text_input"> | ||
12 | + <%= text_area :idea, :text, :maxlenght => 160, :rows => 4, :placeholder => _('Type your idea here') %> | ||
13 | + </div> | ||
14 | + <div class="suggest_idea_btn"> | ||
15 | + <%= submit_button('', '', :id => 'new_idea_button', :class => user ? '':'require-login-popup') %> | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + </div> | ||
19 | + <div class="suggestion_box_loading" style="display: none;"> | ||
20 | + <span>Processando...</span> | ||
21 | + </div> | ||
22 | + <script type='text/javascript'> | ||
23 | + jQuery(document).ready(function($){ | ||
24 | + var pairwise_id = '<%=pairwise_content.id %>'; | ||
25 | + $('#text_idea_content_' + pairwise_id).find('textarea').jqEasyCounter(); | ||
26 | + }); | ||
27 | + </script> | ||
28 | + <% end %> |
plugins/pairwise/views/pairwise_plugin_profile/_suggestion_form.rhtml
@@ -1,28 +0,0 @@ | @@ -1,28 +0,0 @@ | ||
1 | - <% remote_form_for('idea', :url => pairwise_suggestion_url(pairwise_content, embeded, source), | ||
2 | - :html => {:id => "pairwise_suggestion_form_#{pairwise_content.id}"}, :loading => "jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_fields').hide();jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_loading').show();", :loaded => "jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_fields').show();jQuery('#pairwise_suggestion_form_#{pairwise_content.id} .suggestion_box_loading').hide();") do |f| %> | ||
3 | - <div class="suggestion_box_fields"> | ||
4 | - <div class="error"> | ||
5 | - <%= flash[:error] %> | ||
6 | - </div> | ||
7 | - <div class="notice"> | ||
8 | - <%= flash[:notice] %> | ||
9 | - </div> | ||
10 | - <div class="div_text_input_container"> | ||
11 | - <div id="text_idea_content_<%= pairwise_content.id %>" class="div_text_input"> | ||
12 | - <%= f.text_area 'text', :maxlenght => 160, :rows => 4, :placeholder => _('Type your idea here') %> | ||
13 | - </div> | ||
14 | - <div class="suggest_idea_btn"> | ||
15 | - <%= submit_button('', '', :id => 'new_idea_button', :class => user ? '':'require-login-popup') %> | ||
16 | - </div> | ||
17 | - </div> | ||
18 | - </div> | ||
19 | - <div class="suggestion_box_loading" style="display: none;"> | ||
20 | - <span>Processando...</span> | ||
21 | - </div> | ||
22 | - <script type='text/javascript'> | ||
23 | - jQuery(document).ready(function($){ | ||
24 | - var pairwise_id = '<%=pairwise_content.id %>'; | ||
25 | - $('#text_idea_content_' + pairwise_id).find('textarea').jqEasyCounter(); | ||
26 | - }); | ||
27 | - </script> | ||
28 | - <% end %> |
plugins/pairwise/views/pairwise_plugin_profile/result.html.erb
0 → 100644
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | + | ||
3 | +<%= pairwise_plugin_stylesheet %> | ||
4 | + | ||
5 | +<h1 class="title"><%= @page.name %></h1> | ||
6 | + | ||
7 | +<%= render :partial => "content_viewer/result", :locals => { | ||
8 | + :embeded => @embeded, | ||
9 | + :pairwise_content => @pairwise_content, | ||
10 | + } %> |
plugins/pairwise/views/pairwise_plugin_profile/result.rhtml
@@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
1 | -<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | - | ||
3 | -<%= pairwise_plugin_stylesheet %> | ||
4 | - | ||
5 | -<h1 class="title"><%= @page.name %></h1> | ||
6 | - | ||
7 | -<%= render :partial => "content_viewer/result", :locals => { | ||
8 | - :embeded => @embeded, | ||
9 | - :pairwise_content => @pairwise_content, | ||
10 | - } %> |
plugins/pairwise/views/pairwise_plugin_suggestions/edit.html.erb
0 → 100644
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<h1><%= _("Edit Pairwise Question Choice") %> </h1> | ||
2 | + | ||
3 | +<h4><%= @pairwise_content.name %></h4> | ||
4 | + | ||
5 | +<%= form_for 'choice', | ||
6 | + :url => { | ||
7 | + :controller => 'pairwise_plugin_suggestions', | ||
8 | + :action => 'update', | ||
9 | + :id => @pairwise_content.id | ||
10 | + } do |f| %> | ||
11 | + <%= f.hidden_field 'id' %> | ||
12 | + <%= f.text_area 'data', :rows => 4, :style => "width:100%" %> | ||
13 | + <%= f.check_box 'active' %> <%= f.label _('Active') %> | ||
14 | + <br class="clear"> | ||
15 | + <%= submit_button('save', _('Update'), :id => 'update_choice_button') %> | ||
16 | +<% end %> |
plugins/pairwise/views/pairwise_plugin_suggestions/edit.rhtml
@@ -1,16 +0,0 @@ | @@ -1,16 +0,0 @@ | ||
1 | -<h1><%= _("Edit Pairwise Question Choice") %> </h1> | ||
2 | - | ||
3 | -<h4><%= @pairwise_content.name %></h4> | ||
4 | - | ||
5 | -<% form_for 'choice', | ||
6 | - :url => { | ||
7 | - :controller => 'pairwise_plugin_suggestions', | ||
8 | - :action => 'update', | ||
9 | - :id => @pairwise_content.id | ||
10 | - } do |f| %> | ||
11 | - <%= f.hidden_field 'id' %> | ||
12 | - <%= f.text_area 'data', :rows => 4, :style => "width:100%" %> | ||
13 | - <%= f.check_box 'active' %> <%= f.label _('Active') %> | ||
14 | - <br class="clear"> | ||
15 | - <%= submit_button('save', _('Update'), :id => 'update_choice_button') %> | ||
16 | -<% end %> |
plugins/pairwise/views/pairwise_plugin_suggestions/index.html.erb
0 → 100644
@@ -0,0 +1,154 @@ | @@ -0,0 +1,154 @@ | ||
1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | +<% extend PairwisePlugin::Helpers::SuggestionsHelper %> | ||
3 | + | ||
4 | +<%= pairwise_plugin_stylesheet %> | ||
5 | + | ||
6 | +<h1><%= _("Pairwise Question") %></h1> | ||
7 | +<h4><%= _("Question text" ) %>: </h4><span><%= @pairwise_content.name %></span> | ||
8 | +<div class="result_label"> | ||
9 | + <%= pairwise_result_link _("Results"), @pairwise_content %> | ||
10 | +</div> | ||
11 | +<% if flash[:error] %> | ||
12 | + <div class="error"> | ||
13 | + <%= flash[:error] %> | ||
14 | + </div> | ||
15 | +<% end %> | ||
16 | +<% if flash[:notice] %> | ||
17 | + <div class="notice"> | ||
18 | + <%= flash[:notice] %> | ||
19 | + </div> | ||
20 | +<% end %> | ||
21 | + | ||
22 | +<br /> | ||
23 | + | ||
24 | +<style type="text/css" media="all"> | ||
25 | + | ||
26 | + #tab_ideas_suggestions td.selected_tab { | ||
27 | + background-color: #f0f0f0; | ||
28 | + } | ||
29 | + | ||
30 | + #tab_ideas_suggestions td.not_selected_tab { | ||
31 | + background-color: white; | ||
32 | + } | ||
33 | + | ||
34 | + #tab_ideas_suggestions td.not_used_tab { | ||
35 | + background-color: white; | ||
36 | + border-bottom: 0px; | ||
37 | + } | ||
38 | + | ||
39 | + #tab_ideas_suggestions { | ||
40 | + background-color: #f0f0f0; | ||
41 | + } | ||
42 | + | ||
43 | + #tab_ideas_suggestions tr { | ||
44 | + border-bottom: 1px solid #c0c0c0; | ||
45 | + } | ||
46 | + | ||
47 | + #pairwise_search tr { | ||
48 | + background-color: white; | ||
49 | + } | ||
50 | + | ||
51 | + .pairwise_search_field { | ||
52 | + border: 1px solid #c0c0c0; | ||
53 | + background-color:white; | ||
54 | + width: 100%; | ||
55 | + height: 25px; | ||
56 | + } | ||
57 | + | ||
58 | + .selected_column { | ||
59 | + background-color: #f0f0f0; | ||
60 | + } | ||
61 | + | ||
62 | + .not_selected_column { | ||
63 | + background-color: #ffffff; | ||
64 | + } | ||
65 | + | ||
66 | + .soAscending { | ||
67 | + background:url(/designs/icons/default/outras/16x16/actions/go-up.gif) no-repeat 99% 60% #f0f0f0; | ||
68 | + } | ||
69 | + .soDescending { | ||
70 | + background:url(/designs/icons/default/outras/16x16/actions/go-down.gif) no-repeat 99% 60% #f0f0f0; | ||
71 | + } | ||
72 | + | ||
73 | +</style> | ||
74 | + | ||
75 | +<table border="0" id="tab_ideas_suggestions"> | ||
76 | + <tr> | ||
77 | + <td align="center" width="50%" class="<%= ! has_param_pending_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
78 | + <h5><%= link_to_if has_param_pending_choices?, _('Ideas'), :pending => '' %></h5> | ||
79 | + </td> | ||
80 | + <td align="center" width="50%" colspan="2" class="<%= has_param_pending_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
81 | + <h5><%= link_to_if ! has_param_pending_choices?, _('Suggestions'), :pending => '1', :reproved => '' %></h5> | ||
82 | + </td> | ||
83 | + </tr> | ||
84 | + <% if params[:pending] == '1' %> | ||
85 | + <tr> | ||
86 | + <td align="center" class="not_used_tab"> </td> | ||
87 | + <td align="center" width="25%" class="<%= ! has_param_reproved_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
88 | + <%= link_to_if has_param_reproved_choices?, _('Pending'), :pending => '1', :reproved => '' %> | ||
89 | + </td> | ||
90 | + <td align="center" width="25%" class="<%= has_param_reproved_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
91 | + <%= link_to_if ! has_param_reproved_choices?, _('Reproved'), :pending => '1', :reproved => '1' %> | ||
92 | + </td> | ||
93 | + </tr> | ||
94 | + <% end %> | ||
95 | +</table> | ||
96 | + | ||
97 | +<br /> | ||
98 | + | ||
99 | +<%= form_for( | ||
100 | + :filter, { | ||
101 | + :action => :index, | ||
102 | + :controller => 'pairwise_plugin_suggestions', | ||
103 | + :profile => profile.identifier | ||
104 | + }) do %> | ||
105 | +<table border="0" id="pairwise_search"> | ||
106 | + <tr> | ||
107 | + <td> | ||
108 | + <%= hidden_field_tag 'pending', params[:pending] %> | ||
109 | + <%= hidden_field_tag 'reproved', params[:reproved] %> | ||
110 | + <%= text_field_tag( | ||
111 | + 'filter[data]', | ||
112 | + params[:filter] ? params[:filter][:data]:'', | ||
113 | + :placeholder => _('Type words about ideas/suggestions you\'re looking for'), | ||
114 | + :class => "pairwise_search_field" | ||
115 | + ) %> | ||
116 | + </td> | ||
117 | + <td width="40px"><%= submit_button :search, _('Search') %></td> | ||
118 | + </tr> | ||
119 | +</table> | ||
120 | +<% end %> | ||
121 | + | ||
122 | +<br /> | ||
123 | + | ||
124 | +<table class="pairwise_choices_table"> | ||
125 | + <tr> | ||
126 | + <th class="<%= class_to_order_column("data", params[:order]) %>"> | ||
127 | + <%= link_to_sort_choices(@pairwise_content, _("Text"), "data") %> | ||
128 | + </th> | ||
129 | + <th class="<%= class_to_order_column("created_date", params[:order]) %>"> | ||
130 | + <%= link_to_sort_choices(@pairwise_content, _("Date"), "created_date") %> | ||
131 | + </th> | ||
132 | + <th class="<%= class_to_order_column("visitor_identifier", params[:order]) %>"> | ||
133 | + <%= link_to_sort_choices(@pairwise_content, _("Author"), "visitor_identifier") %> | ||
134 | + </th> | ||
135 | + <th></th> | ||
136 | + </tr> | ||
137 | + | ||
138 | + <% @choices.each do |choice| %> | ||
139 | + <tr> | ||
140 | + <td width="270px"><%= choice.data %></td> | ||
141 | + <td><%= show_date choice.created_at %></td> | ||
142 | + <td width="105px" ><%= choice.user_created ? choice.creator_identifier : profile.identifier %></td> | ||
143 | + <td width="50px"> | ||
144 | + <%= link_to_edit_choice(@pairwise_content, choice) unless choice.reproved %> | ||
145 | + <% unless choice.active || choice.reproved %> | ||
146 | + | | ||
147 | + <%= link_to_approve_choice(@pairwise_content, choice, params)%> | ||
148 | + | <%= link_to_reprove_idea @pairwise_content, choice, 'reprove', params %> | ||
149 | + <% end %> | ||
150 | + </td> | ||
151 | + </tr> | ||
152 | + <% end %> | ||
153 | +</table> | ||
154 | +<%= pagination_for_choices(@choices) %> |
plugins/pairwise/views/pairwise_plugin_suggestions/index.rhtml
@@ -1,154 +0,0 @@ | @@ -1,154 +0,0 @@ | ||
1 | -<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
2 | -<% extend PairwisePlugin::Helpers::SuggestionsHelper %> | ||
3 | - | ||
4 | -<%= pairwise_plugin_stylesheet %> | ||
5 | - | ||
6 | -<h1><%= _("Pairwise Question") %></h1> | ||
7 | -<h4><%= _("Question text" ) %>: </h4><span><%= @pairwise_content.name %></span> | ||
8 | -<div class="result_label"> | ||
9 | - <%= pairwise_result_link _("Results"), @pairwise_content %> | ||
10 | -</div> | ||
11 | -<% if flash[:error] %> | ||
12 | - <div class="error"> | ||
13 | - <%= flash[:error] %> | ||
14 | - </div> | ||
15 | -<% end %> | ||
16 | -<% if flash[:notice] %> | ||
17 | - <div class="notice"> | ||
18 | - <%= flash[:notice] %> | ||
19 | - </div> | ||
20 | -<% end %> | ||
21 | - | ||
22 | -<br /> | ||
23 | - | ||
24 | -<style type="text/css" media="all"> | ||
25 | - | ||
26 | - #tab_ideas_suggestions td.selected_tab { | ||
27 | - background-color: #f0f0f0; | ||
28 | - } | ||
29 | - | ||
30 | - #tab_ideas_suggestions td.not_selected_tab { | ||
31 | - background-color: white; | ||
32 | - } | ||
33 | - | ||
34 | - #tab_ideas_suggestions td.not_used_tab { | ||
35 | - background-color: white; | ||
36 | - border-bottom: 0px; | ||
37 | - } | ||
38 | - | ||
39 | - #tab_ideas_suggestions { | ||
40 | - background-color: #f0f0f0; | ||
41 | - } | ||
42 | - | ||
43 | - #tab_ideas_suggestions tr { | ||
44 | - border-bottom: 1px solid #c0c0c0; | ||
45 | - } | ||
46 | - | ||
47 | - #pairwise_search tr { | ||
48 | - background-color: white; | ||
49 | - } | ||
50 | - | ||
51 | - .pairwise_search_field { | ||
52 | - border: 1px solid #c0c0c0; | ||
53 | - background-color:white; | ||
54 | - width: 100%; | ||
55 | - height: 25px; | ||
56 | - } | ||
57 | - | ||
58 | - .selected_column { | ||
59 | - background-color: #f0f0f0; | ||
60 | - } | ||
61 | - | ||
62 | - .not_selected_column { | ||
63 | - background-color: #ffffff; | ||
64 | - } | ||
65 | - | ||
66 | - .soAscending { | ||
67 | - background:url(/designs/icons/default/outras/16x16/actions/go-up.gif) no-repeat 99% 60% #f0f0f0; | ||
68 | - } | ||
69 | - .soDescending { | ||
70 | - background:url(/designs/icons/default/outras/16x16/actions/go-down.gif) no-repeat 99% 60% #f0f0f0; | ||
71 | - } | ||
72 | - | ||
73 | -</style> | ||
74 | - | ||
75 | -<table border="0" id="tab_ideas_suggestions"> | ||
76 | - <tr> | ||
77 | - <td align="center" width="50%" class="<%= ! has_param_pending_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
78 | - <h5><%= link_to_if has_param_pending_choices?, _('Ideas'), :pending => '' %></h5> | ||
79 | - </td> | ||
80 | - <td align="center" width="50%" colspan="2" class="<%= has_param_pending_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
81 | - <h5><%= link_to_if ! has_param_pending_choices?, _('Suggestions'), :pending => '1', :reproved => '' %></h5> | ||
82 | - </td> | ||
83 | - </tr> | ||
84 | - <% if params[:pending] == '1' %> | ||
85 | - <tr> | ||
86 | - <td align="center" class="not_used_tab"> </td> | ||
87 | - <td align="center" width="25%" class="<%= ! has_param_reproved_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
88 | - <%= link_to_if has_param_reproved_choices?, _('Pending'), :pending => '1', :reproved => '' %> | ||
89 | - </td> | ||
90 | - <td align="center" width="25%" class="<%= has_param_reproved_choices? ? "selected_tab" : "not_selected_tab" %>"> | ||
91 | - <%= link_to_if ! has_param_reproved_choices?, _('Reproved'), :pending => '1', :reproved => '1' %> | ||
92 | - </td> | ||
93 | - </tr> | ||
94 | - <% end %> | ||
95 | -</table> | ||
96 | - | ||
97 | -<br /> | ||
98 | - | ||
99 | -<% form_for( | ||
100 | - :filter, { | ||
101 | - :action => :index, | ||
102 | - :controller => 'pairwise_plugin_suggestions', | ||
103 | - :profile => profile.identifier | ||
104 | - }) do %> | ||
105 | -<table border="0" id="pairwise_search"> | ||
106 | - <tr> | ||
107 | - <td> | ||
108 | - <%= hidden_field_tag 'pending', params[:pending] %> | ||
109 | - <%= hidden_field_tag 'reproved', params[:reproved] %> | ||
110 | - <%= text_field_tag( | ||
111 | - 'filter[data]', | ||
112 | - params[:filter] ? params[:filter][:data]:'', | ||
113 | - :placeholder => _('Type words about ideas/suggestions you\'re looking for'), | ||
114 | - :class => "pairwise_search_field" | ||
115 | - ) %> | ||
116 | - </td> | ||
117 | - <td width="40px"><%= submit_button :search, _('Search') %></td> | ||
118 | - </tr> | ||
119 | -</table> | ||
120 | -<% end %> | ||
121 | - | ||
122 | -<br /> | ||
123 | - | ||
124 | -<table class="pairwise_choices_table"> | ||
125 | - <tr> | ||
126 | - <th class="<%= class_to_order_column("data", params[:order]) %>"> | ||
127 | - <%= link_to_sort_choices(@pairwise_content, _("Text"), "data") %> | ||
128 | - </th> | ||
129 | - <th class="<%= class_to_order_column("created_date", params[:order]) %>"> | ||
130 | - <%= link_to_sort_choices(@pairwise_content, _("Date"), "created_date") %> | ||
131 | - </th> | ||
132 | - <th class="<%= class_to_order_column("visitor_identifier", params[:order]) %>"> | ||
133 | - <%= link_to_sort_choices(@pairwise_content, _("Author"), "visitor_identifier") %> | ||
134 | - </th> | ||
135 | - <th></th> | ||
136 | - </tr> | ||
137 | - | ||
138 | - <% @choices.each do |choice| %> | ||
139 | - <tr> | ||
140 | - <td width="270px"><%= choice.data %></td> | ||
141 | - <td><%= show_date choice.created_at %></td> | ||
142 | - <td width="105px" ><%= choice.user_created ? choice.creator_identifier : profile.identifier %></td> | ||
143 | - <td width="50px"> | ||
144 | - <%= link_to_edit_choice(@pairwise_content, choice) unless choice.reproved %> | ||
145 | - <% unless choice.active || choice.reproved %> | ||
146 | - | | ||
147 | - <%= link_to_approve_choice(@pairwise_content, choice, params)%> | ||
148 | - | <%= link_to_reprove_idea @pairwise_content, choice, 'reprove', params %> | ||
149 | - <% end %> | ||
150 | - </td> | ||
151 | - </tr> | ||
152 | - <% end %> | ||
153 | -</table> | ||
154 | -<%= pagination_for_choices(@choices) %> |