Skip to content
Snippets Groups Projects
Commit 4d312cb3 authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

adding remove thumbnail feature


Signed-off-by: default avatarman13 <man13@inf.ufpr.br>
parent 5ec3f92a
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ class LearningObjectsController < ApplicationController ...@@ -6,7 +6,7 @@ class LearningObjectsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show] before_action :authenticate_user!, except: [:index, :show]
before_action :set_learning_object, only: [:show, :edit, :update, before_action :set_learning_object, only: [:show, :edit, :update,
:destroy, :destroy_attachment, :like, :bookmarks, :destroy, :destroy_attachment, :remove_thumbnail, :like, :bookmarks,
:collections, :upload, :upload_link, :download, :collections, :upload, :upload_link, :download,
:user_not_authorized] :user_not_authorized]
after_action :increment_learning_object_views, only: [:show] after_action :increment_learning_object_views, only: [:show]
...@@ -88,6 +88,12 @@ class LearningObjectsController < ApplicationController ...@@ -88,6 +88,12 @@ class LearningObjectsController < ApplicationController
render :nothing => true, :status => 204 render :nothing => true, :status => 204
end end
def remove_thumbnail
@learning_object.thumbnail = nil
@learning_object.save
render :nothing => true, :status => 204
end
def download def download
@learning_object.download current_user @learning_object.download current_user
......
...@@ -30,6 +30,10 @@ class LearningObjectPolicy < ApplicationPolicy ...@@ -30,6 +30,10 @@ class LearningObjectPolicy < ApplicationPolicy
record if owns? record if owns?
end end
def remove_thumbnail?
record if owns?
end
def show? def show?
if user.nil? if user.nil?
record.state == 'published' record.state == 'published'
......
...@@ -31,9 +31,24 @@ ...@@ -31,9 +31,24 @@
<%= form_for @learning_object, url: wizard_path, method: :put, html: { multipart: true } do |f| %> <%= form_for @learning_object, url: wizard_path, method: :put, html: { multipart: true } do |f| %>
<%= f.file_field :thumbnail, required: true %> <%= f.file_field :thumbnail, required: true %>
<% unless @learning_object.thumbnail.blank? %>
<div>Thumbnail: <%= @learning_object.thumbnail_file_name %>&nbsp;<i id="remove_thumbnail" class="fa fa-trash fa-1"></i></div>
<script>
$("#remove_thumbnail").click(function(){
if(confirm("Você tem certeza?")){
$(this).parent().remove()
$.ajax({
url: "<%= remove_thumbnail_path(@learning_object) %>",
method: 'POST'
})
}
});
</script>
<% end %>
<button type="submit" class="btn-submit btn btn-success btn-outline-rounded green"> <button type="submit" class="btn-submit btn btn-success btn-outline-rounded green">
Enviar <i style="margin-left:10px;" class="fa fa-paper-plane"></i> Enviar <i style="margin-left:10px;" class="fa fa-paper-plane"></i>
</button> </button>
<%= link_to next_wizard_path do %> <%= link_to next_wizard_path do %>
<button type="button" class="btn-submit btn btn-warning btn-outline-rounded yellow">Pular etapa</button> <button type="button" class="btn-submit btn btn-warning btn-outline-rounded yellow">Pular etapa</button>
<% end %> <% end %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment