diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 608172a8ce87f463e76c3ad98f01d9fb013897e7..762e2e50258187419db06451678a9daefda8975c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,4 +16,8 @@ //= require jquery.turbolinks //= require bootstrap-sprockets //= require select2 -//= require_tree ./application \ No newline at end of file +//= require_tree ./application + +$(document).ready(function(){ +$('.btn-success').popover({title: "Header", content: "Blabla", trigger: "click"}); +}); diff --git a/app/assets/javascripts/application/complaints.coffee b/app/assets/javascripts/application/complaints.coffee index c4f6cb8e7c1002ecf0cd1ba71ab5631d7d913483..149f06dc8666751b27ff649bb82eac0f24f352e1 100644 --- a/app/assets/javascripts/application/complaints.coffee +++ b/app/assets/javascripts/application/complaints.coffee @@ -1,8 +1,10 @@ $ -> - $('#create_complaint_popover').popover + $('.add_to_complaint').popover html: true - content: -> - $('#create_complaint_popover_content').html() + placement: "left" title: -> - $('#create_complaint_popover_title').html() + $('#complaints_list_popover_title').html() + content: -> + $('#complaints_list_popover').html() + return diff --git a/app/assets/javascripts/application/learning_objects.coffee b/app/assets/javascripts/application/learning_objects.coffee index 13d52976df233b0f4e6b77fb12584bf14ad6d291..b50f394bdc37e5076efe2796d8e44d89eaec4d13 100644 --- a/app/assets/javascripts/application/learning_objects.coffee +++ b/app/assets/javascripts/application/learning_objects.coffee @@ -5,13 +5,3 @@ $ -> $('#collections_list_popover').html() return - -$ -> - $('.add_to_complaint').popover - html: true - placement: "left" - title: "<strong>Product search</strong> enter number or name" - content: -> - $('#complaints_list_popover').html() - - return diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 77857c1a404ece2579314cc554794e5fff6404f6..6e39e46ce3571faeb6340cbf50c4b454f2097f30 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -62,33 +62,17 @@ a, a:focus, a:hover { top: 45%; } -.popover { - max-width: 800px; - width:500px; - height:550px; +.popover{ + display: none; + z-index: 999; + max-width: 600px; + width: auto; } -.collection_popover{ - - - max-width: 800px; - width:30px; - height:15px; +.radio { + margin-left: 20px; } - - - -.popover-title { - background-color: #2178f5; - align-content: center; - font-style: oblique; - font: bold; - font-size: 150%; - color: white; - -} - //// HEADER header { border: 0; diff --git a/app/controllers/complaints_controller.rb b/app/controllers/complaints_controller.rb index ef8f87bb5afaa385f35678fbc058638a545a3694..dc7dfd32a5751f84431e9ce287db77543ad6226a 100644 --- a/app/controllers/complaints_controller.rb +++ b/app/controllers/complaints_controller.rb @@ -5,14 +5,7 @@ class ComplaintsController < ApplicationController # POST /complaints.json def create @complaint = Complaint.new(complaint_params) - @messages = [ - Complaint.copyrights, - Complaint.ofensive_content, - Complaint.ofensive_user, - Complaint.fake_user - - ] - + respond_to do |format| if complaint_repository.report @complaint format.html { redirect_to @complaint, notice: 'complaint was successfully created.' } @@ -28,7 +21,7 @@ class ComplaintsController < ApplicationController complaint_repository.destroy @complaint respond_to do |format| - format.html { redirect_to complaints_url, notice: 'Learning object was successfully destroyed.' } + format.html { redirect_to complaints_url, notice: 'Complaint was successfully destroyed.' } end end diff --git a/app/controllers/concerns/reportable.rb b/app/controllers/concerns/reportable.rb new file mode 100644 index 0000000000000000000000000000000000000000..e53469daf34c818bf66be44bec181984a47f26d5 --- /dev/null +++ b/app/controllers/concerns/reportable.rb @@ -0,0 +1,14 @@ +module Reportable + extend ActiveSupport::Concern + + included do + @complaint = Complaint.new + @messages = [ + Complaint.copyrights, + Complaint.ofensive_content, + Complaint.ofensive_user, + Complaint.fake_user + ] + end + +end diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index 38ee2cad47b12c307b2741fe8f7ba6d6a2760f9d..c7a83f2a27f9db0ff9b6b7daca48e7452cad0cd9 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -1,4 +1,6 @@ class LearningObjectsController < ApplicationController + include Reportable + before_action :set_learning_object, only: [:show, :edit, :update, :destroy, :like] after_action :increment_learning_object_views, only: [:show] before_action :authenticate_user!, except: [:index, :show] @@ -12,6 +14,13 @@ class LearningObjectsController < ApplicationController # GET /learning_objects/1 # GET /learning_objects/1.json def show + @complaint = Complaint.new + @messages = [ + Complaint.copyrights, + Complaint.ofensive_content, + Complaint.ofensive_user, + Complaint.fake_user + ] end # GET /learning_objects/new @@ -65,7 +74,7 @@ class LearningObjectsController < ApplicationController redirect_to :back end - def report_object + def report_object learning_object_repository.report current_user, @learning_object, message, description end diff --git a/app/models/complaint.rb b/app/models/complaint.rb index 8e571e74f650c29ea19e20af2278ef3238f65c07..f5815c162ac3840058331a5ef4c82d971da2b9f8 100644 --- a/app/models/complaint.rb +++ b/app/models/complaint.rb @@ -3,20 +3,20 @@ class Complaint attr_accessor :user,:object,:message,:description validates_presence_of :user,:object,:message - + def self.copyrights - "Objeto viola direitos autorais" + ComplaintMessage.new("Objeto viola direitos autorais") end def self.ofensive_content - "Objeto contém conteúdo ofensivo/abusivo" + ComplaintMessage.new "Objeto contém conteúdo ofensivo/abusivo" end def self.ofensive_user - "Usuário ofensivo/agressivo" + ComplaintMessage.new "Usuário ofensivo/agressivo" end def self.fake_user - "Usuário falso" + ComplaintMessage.new "Usuário falso" end end diff --git a/app/models/complaint_message.rb b/app/models/complaint_message.rb new file mode 100644 index 0000000000000000000000000000000000000000..a87abecbfeac95fbc8431adc9c7ad80fc40dc3f3 --- /dev/null +++ b/app/models/complaint_message.rb @@ -0,0 +1,11 @@ +class ComplaintMessage + attr_accessor :message + + def initialize(message) + @message = message + end + + def to_s + @message.to_s + end +end diff --git a/app/views/complaints/_add_to_complaint_btn.html.erb b/app/views/complaints/_add_to_complaint_btn.html.erb deleted file mode 100644 index 5e9d0f72ddb23c6ddf0ec8a2d3b337ad391f42ce..0000000000000000000000000000000000000000 --- a/app/views/complaints/_add_to_complaint_btn.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<a href="#" id="add_to_complaint">Adicionar as coleções</a> - -<div id="complaints_list_popover" style="display: none"> - <ul> - <%= ComplaintsController.copyrights %> - </ul> -</div> - -<div id="complaints_list_popover_title" style="display: none"> - Adicione esse objeto a uma coleção -</div> diff --git a/app/views/complaints/_complaints_button.html.erb b/app/views/complaints/_complaints_button.html.erb index d8692267fd665a243424f22106d0e67f27003bfa..25d6f5669caa9eb37975e096cc1741bdb0268730 100644 --- a/app/views/complaints/_complaints_button.html.erb +++ b/app/views/complaints/_complaints_button.html.erb @@ -1,7 +1,7 @@ -<button type="button" class="btn btn-default btn-xs add_to_complaint" data-toggle="button" aria-pressed="false" autocomplete="off" title="Denunciar Objeto" border-style: "none" > +<button type="button" class="btn btn-default btn-xs add_to_complaint " data-toggle="button" data-trigger="click" aria-pressed="false" autocomplete="off" title="Denunciar Objeto" border-style: "none" > <%= image_tag "icons/report-circle.png", alt: "Denunciar objeto" %> </button> -<div id="complaints_list_popover" style="display: none; z-index: 999;"> - <%= render 'form' %> +<div id="complaints_list_popover" class="popover"> + <%= render 'complaints/form' %> </div> diff --git a/app/views/complaints/_form.html.erb b/app/views/complaints/_form.html.erb index 2cdad432765ac999a25337a1cda9be8430fa7388..9b61b68bba058ad3d06f6d8ed3fef688f8531e6a 100644 --- a/app/views/complaints/_form.html.erb +++ b/app/views/complaints/_form.html.erb @@ -1,26 +1,29 @@ -<%= form_tag @complaint do |f| %> + +<%= form_for @complaint do |f| %> <fieldset> - <div class="ls-label " align="center"> + <div class="ls-label " > <h4 class="ls-title-4"><p><b>Escolha a razão da denúncia:</b></p></h4> <br><br> <%= f.collection_radio_buttons :message, @messages, :message, :message do |m| %> - <div class="radio"> - <%= m.label { m.radio_button } %> + <div class="radio" > + <%= f.radio_button :message, m.text %> + <%= f.label :message, m.text %> </div> <% end %> <br><br> <div align="center"> - <%= m.text_area :description, placeholder: "mais informações", rows: "10", cols: "30" %> + <%= f.text_area :description, placeholder: "mais informações", rows: "10", cols: "30" %> </div> </div> </fieldset> - <div align="center" class="ls-actions-btn"> - <%= f.submit "Salvar", class: "ls-btn" %> - <%= link_to "Cancelar", {}, class: "ls-btn-alert" %> + <div align="center" class="ls-btn-primary"> + <%= f.submit "Salvar" %> + <%= link_to "Fechar", class:"btn-success" %> + </div> <%end%> diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb index fa1d7e4a4b6cd0b7f88c5ce29ea746404cb61e37..5f87f10d8fd61f54426dd947166baa18912327ed 100644 --- a/app/views/learning_objects/show.html.erb +++ b/app/views/learning_objects/show.html.erb @@ -81,7 +81,7 @@ <div class="col-md-3 action"> - <%= render "learning_objects/complaints_button" %> + <%= render "complaints/complaints_button" %> <h6>denunciar objeto</h6> </div> </div> diff --git a/config/routes.rb b/config/routes.rb index 6502cb0d6e4690758143a4760b87a8ab69eed303..a15076e02ed680480982f4411f9e0e7863687e6f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,7 +44,13 @@ Rails.application.routes.draw do resources :institutions resources :collections resources :subjects, only: [:index, :show] - resources :complaints, only: [:create, :destroy] + resources :complaints, only: [:create, :destroy] do + member do + post :create + end + end + + resources :users, only: [:show] do collection do @@ -52,7 +58,6 @@ Rails.application.routes.draw do end end get 'users/:id', to: 'users#show', as: 'users_show' - get '/faq' => 'welcome#faq' get '/contact' => 'welcome#contact', as: 'contact' get '/search' => 'search#index', as: 'search'