diff --git a/app/assets/javascripts/application/collections.coffee b/app/assets/javascripts/application/collections.coffee index 46fc726d97a435afe67bfca9934690757b4a6ccf..fa82b5ea8e3042db942ac70bb6138bddfc3e7748 100644 --- a/app/assets/javascripts/application/collections.coffee +++ b/app/assets/javascripts/application/collections.coffee @@ -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 diff --git a/app/assets/javascripts/application/learning_objects.coffee b/app/assets/javascripts/application/learning_objects.coffee index 9730795c0383bf2153e389bbe3300bbf2dab6dfd..d3d5b5e89d0bfd4e93c45d8590b6b6eec5d5aba9 100644 --- a/app/assets/javascripts/application/learning_objects.coffee +++ b/app/assets/javascripts/application/learning_objects.coffee @@ -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 += '>' diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ab180a93c9739f4987b9ca6bc1911d7fee3c15c9..4987e68133cd5a6918d053a10ea865c301146f18 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -267,6 +267,11 @@ header { z-index: 999; max-width: 600px; width: auto; + + .popover-content { + max-height: 300px; + overflow: auto; + } } //// FOOTER diff --git a/app/views/learning_objects/_collections_button.html.erb b/app/views/learning_objects/_collections_button.html.erb index b9c2aeaf7c804073bd20349b94f0a7e62950c6d6..c35f0f4e2fc7f78ff0138fa05133a8a05a4ccb65 100644 --- a/app/views/learning_objects/_collections_button.html.erb +++ b/app/views/learning_objects/_collections_button.html.erb @@ -1,3 +1,3 @@ -<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>