Skip to content
Snippets Groups Projects
Commit 63549f1c authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

add and remove collection from button

parent 988fee3b
No related branches found
No related tags found
No related merge requests found
......@@ -6,3 +6,14 @@ $ ->
title: ->
$('#create_collection_popover_title').html()
return
$ ->
$(document).on 'click', 'input[class=collection-element]', ->
url = '/collections/' + encodeURIComponent($(this).data('cid')) + '/learning_object/' + encodeURIComponent($(this).data('loid'))
if this.checked
$.ajax {method: "POST", url: url }, (d) ->
d
else
$.ajax {method: "DELETE", url: url }, (d) ->
d
return
......@@ -6,6 +6,7 @@ $ ->
all = undefined
objects = undefined
url = $(this).data('poload')
loid = $(this).data('loid')
$.get '/collections.json', (d) ->
all = d
$.get url, (d) ->
......@@ -25,7 +26,7 @@ $ ->
html = ''
while i < len
name = 'collection_' + all[i].id.split(':').slice(-1)[0]
html += '<input type="checkbox" id="' + name + '" value="' + all[i].id + '"'
html += '<input type="checkbox" class="collection-element" data-cid="' + all[i].id + '" data-loid="' + loid + '" id="' + name + '" value="' + all[i].id + '"'
if lookup[all[i].id] != undefined
html += " checked"
html += '>'
......
......@@ -267,6 +267,11 @@ header {
z-index: 999;
max-width: 600px;
width: auto;
.popover-content {
max-height: 300px;
overflow: auto;
}
}
//// FOOTER
......
<a tabindex="0" class="btn btn-default btn-xs add_to_collection" role="button" data-toggle="popover" data-placement="left" title="Adicionar as coleções" data-poload="/learning_objects/<%= ERB::Util.url_encode(learning_object.id) %>/collections.json">
<a tabindex="0" class="btn btn-default btn-xs add_to_collection" role="button" data-toggle="popover" data-placement="left" title="Adicionar as coleções" data-loid="<%= learning_object.id %>" data-poload="/learning_objects/<%= ERB::Util.url_encode(learning_object.id) %>/collections.json">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span>
</a>
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