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

add flash notice via javascript

parent fa609326
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,8 @@ $(document).on 'submit', '#collections-modal-form', (evt, params) ->
if (data.type == "move")
url = '/collections/' + encodeURIComponent(data.collection_id) + '/learning_objects/' + encodeURIComponent(data.learning_objects_ids.join())
$.ajax {method: "DELETE", url: url, data: data }
$(document).trigger 'flash_notice', {text: 'Operação efetuada com sucesso!', type: 'notice'}
$(document).trigger('clear_collections')
location.reload(true) if !(refreshable_type.indexOf(data.type) < 0)
$('#collections-modal').modal('hide')
return
......@@ -121,8 +123,9 @@ $(document).on 'click', '.collection-button', ->
if permitted_types[index] == 'remove'
url = '/collections/' + encodeURIComponent(collection) + '/learning_objects/' + encodeURIComponent(selected_objects.join())
$.ajax { method: 'DELETE', url: url } if confirm('Você tem certeza?')
location.reload(true)
if confirm('Você tem certeza?')
$.ajax { method: 'DELETE', url: url }
location.reload(true)
else
$(document).trigger('open_collections_modal', [collection: collection, type: permitted_types[index], learning_object: selected_objects ]) if !!(~index)
......
# flash notice ()
$(document).on 'flash_notice', (e, params) ->
text = params.text
type = params.type
alert_type = if (type == 'alert') then 'alert-danger alert-dismissible' else 'alert-info'
html = '<div class="alert '+ alert_type + '" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Fechar">
<span aria-hidden="true">&times;</span></button>' + text + '</div>'
$('#content').prepend($(html))
......@@ -28,7 +28,9 @@
</div>
<% end %>
<%= yield %>
<div id="content">
<%= yield %>
</div>
</div>
<%= render 'shared/application/footer' %>
......
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