Commit 8d24d6f6e3d96ead5988c9e4ebfdc4f3bea69137
Committed by
Álvaro Fernando Matos de Souza
1 parent
e9757353
Exists in
master
and in
5 other branches
Add new fields to comment
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
8 changed files
with
100 additions
and
1 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +class AddNewFieldsToComments < ActiveRecord::Migration | |
| 2 | + def self.up | |
| 3 | + change_table :comments do |t| | |
| 4 | + t.integer :people_benefited | |
| 5 | + t.decimal :saved_value | |
| 6 | + end | |
| 7 | + end | |
| 8 | + | |
| 9 | + def self.down | |
| 10 | + remove_column :comments, :people_benefited | |
| 11 | + remove_column :comments, :saved_value | |
| 12 | + end | |
| 13 | +end | ... | ... |
lib/software_communities_plugin.rb
| ... | ... | @@ -63,12 +63,21 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 63 | 63 | views/search-software-catalog.js |
| 64 | 64 | views/profile-tabs-software.js |
| 65 | 65 | views/new-community.js |
| 66 | + views/comments-software-extra-fields.js | |
| 66 | 67 | blocks/software-download.js |
| 67 | 68 | initializer.js |
| 68 | 69 | app.js |
| 69 | 70 | ) |
| 70 | 71 | end |
| 71 | 72 | |
| 73 | + def communities_ratings_plugin_comments_extra_fields | |
| 74 | + Proc::new do render :file => 'comments_extra_fields' end | |
| 75 | + end | |
| 76 | + | |
| 77 | + def communities_ratings_plugin_star_message | |
| 78 | + Proc::new do _("Rate this software") end | |
| 79 | + end | |
| 80 | + | |
| 72 | 81 | # FIXME - if in error log apears has_permission?, try to use this method |
| 73 | 82 | def has_permission?(person, permission, target) |
| 74 | 83 | person.has_permission_without_plugins?(permission, target) | ... | ... |
public/initializer.js
public/style.css
| ... | ... | @@ -162,3 +162,13 @@ |
| 162 | 162 | display: block; |
| 163 | 163 | background-color:rgba(255, 255, 255, 0.9); |
| 164 | 164 | } |
| 165 | + | |
| 166 | +/*===== Communities rate hotspot extra fields =====*/ | |
| 167 | +.comments-software-extra-fields span { | |
| 168 | + cursor: pointer; | |
| 169 | +} | |
| 170 | + | |
| 171 | +.comments-software-extra-fields div { | |
| 172 | + display: none; | |
| 173 | +} | |
| 174 | + | ... | ... |
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +modulejs.define('CommentsSoftwareExtraFields', ['jquery'], function($) { | |
| 2 | + 'use strict'; | |
| 3 | + | |
| 4 | + var DATA = { | |
| 5 | + information_display_state: "hidden" | |
| 6 | + } | |
| 7 | + | |
| 8 | + function set_show_aditional_information() { | |
| 9 | + $(".comments-software-extra-fields span").on("click", function() { | |
| 10 | + if (DATA.information_display_state === "hidden") { | |
| 11 | + DATA.information_display_state = "show"; | |
| 12 | + $(this).parent().children("div").show(); | |
| 13 | + } else { | |
| 14 | + DATA.information_display_state = "hidden"; | |
| 15 | + $(this).parent().children("div").hide(); | |
| 16 | + } | |
| 17 | + }); | |
| 18 | + } | |
| 19 | + | |
| 20 | + return { | |
| 21 | + isCurrentPage: function() { | |
| 22 | + return $(".comments-software-extra-fields span").length === 1; | |
| 23 | + }, | |
| 24 | + | |
| 25 | + | |
| 26 | + init: function() { | |
| 27 | + set_show_aditional_information(); | |
| 28 | + } | |
| 29 | + } | |
| 30 | +}); | ... | ... |
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
| 2 | +require File.dirname(__FILE__) + '/../../lib/ext/comments.rb' | |
| 3 | + | |
| 4 | +class CommentsTest < ActiveSupport::TestCase | |
| 5 | + | |
| 6 | + def teardown | |
| 7 | + Comment.destroy_all | |
| 8 | + end | |
| 9 | + | |
| 10 | + should 'create comments with new fields' do | |
| 11 | + @person = fast_create(Person) | |
| 12 | + @article = Article.create(:profile => @person, :name => "Test") | |
| 13 | + | |
| 14 | + comment = Comment.new(:body => "Comment new", :author => @person, :people_benefited => 2, :saved_value => 38.5) | |
| 15 | + assert comment.save | |
| 16 | + end | |
| 17 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +<div class="comments-software-extra-fields"> | |
| 2 | + <span> | |
| 3 | + <%= _("Aditional informations") %> | |
| 4 | + </span> | |
| 5 | + | |
| 6 | + <div class="comments-software-people-benefited"> | |
| 7 | + <%= label_tag "comments_people_benefited", _("Number of Beneficiaries")%> | |
| 8 | + <%= text_field_tag "comments[people_benefited]", "" %> | |
| 9 | + </div> | |
| 10 | + <div class="comments-software-saved-values"> | |
| 11 | + <%= label_tag "comments_saved_value", _("Saved resources")%> | |
| 12 | + <%= text_field_tag "comments[saved_value]", ""%> | |
| 13 | + </div> | |
| 14 | +</div> | ... | ... |