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

add title to collection modal

parent 1be5ea49
No related branches found
No related tags found
No related merge requests found
......@@ -92,14 +92,14 @@ $ ->
$(document).on 'click', '.collection-selector', ->
if this.checked
if selected_objects.indexOf(this.value) < 0
selected_objects.push { name: 'learning_object', value: this.value }
$(document).trigger('check_selected_collection');
selected_objects.push this.value
$(document).trigger('check_selected_collection')
return
else
index = selected_objects.indexOf({ name: 'learning_object', value: this.value })
index = selected_objects.indexOf(this.value)
if !!(~index)
selected_objects.splice(index, 1)
$(document).trigger('check_selected_collection');
$(document).trigger('check_selected_collection')
return
# clear selected objects
......@@ -114,15 +114,13 @@ $ ->
# manipulation buttons
$(document).on 'click', '.collection-button', ->
index = permitted_types.indexOf($(this).data('action'))
learning_objects = selected_objects.map (o) ->
return o.value
if permitted_types[index] == 'remove'
url = '/collections/' + encodeURIComponent(collection) + '/learning_objects/' + encodeURIComponent(learning_objects.join())
url = '/collections/' + encodeURIComponent(collection) + '/learning_objects/' + encodeURIComponent(selected_objects.join())
$.ajax { method: 'DELETE', url: url } if confirm('Você tem certeza?')
location.reload(true)
else
$(document).trigger('open_collections_modal', [collection: collection, type: permitted_types[index], learning_object: learning_objects ]) if !!(~index)
$(document).trigger('open_collections_modal', [collection: collection, type: permitted_types[index], learning_object: selected_objects ]) if !!(~index)
# update interface when add/remove an object
$(document).on 'check_selected_collection', (e) ->
......
......@@ -83,7 +83,18 @@ class CollectionsController < ApplicationController
@collections = collection_repository.all(Collections::UserContext.new(current_user))
@collections.select! { |c| c.id != @collection.id } unless @collection.blank?
@type = params[:type] unless params[:type].blank?
unless params[:type].blank?
@type = params[:type]
@send = case @type
when 'add' then 'Adicionar'
when 'copy' then 'Copiar'
when 'move' then 'Mover'
else 'Enviar'
end
@title = (@send == 'Enviar') ? 'Coleções' : @send + ' objeto(s) às coleções'
end
render layout: false
end
......
......@@ -3,7 +3,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Coleções</h4>
<h4 class="modal-title"><%= @title %></h4>
</div>
<form id="collections-modal-form">
<div class="modal-body">
......@@ -23,7 +23,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<button type="submit" class="btn btn-primary">Enviar</button>
<button type="submit" class="btn btn-primary"><%= @send %></button>
</div>
</form>
</div>
......
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