aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2014-08-13 11:27:54 +0200
committerMichel Etienne2014-08-13 11:27:54 +0200
commit6fe711e4bcbae42a290943d3eb0b5c352247b7eb (patch)
tree9c18c379477dd029a0a4c504984f4df0b24faaa8
parenta6e3c34993735302136581f5631e578786e6f971 (diff)
parent8c9988fc61b20c4c8ca5506e354c1c27ad301c54 (diff)
downloadchouette-core-6fe711e4bcbae42a290943d3eb0b5c352247b7eb.tar.bz2
Merge branch 'V2_4' of github.com:afimb/chouette2 into V2_4
-rw-r--r--app/assets/javascripts/multiple_selection.js.coffee37
-rw-r--r--app/views/lines/index.html.erb2
2 files changed, 20 insertions, 19 deletions
diff --git a/app/assets/javascripts/multiple_selection.js.coffee b/app/assets/javascripts/multiple_selection.js.coffee
index 1ff473c4d..86b260fb7 100644
--- a/app/assets/javascripts/multiple_selection.js.coffee
+++ b/app/assets/javascripts/multiple_selection.js.coffee
@@ -1,5 +1,5 @@
jQuery ->
- enable_multiple_selection = (event) ->
+ enable_multiple_selection = (event) ->
event.preventDefault()
$('#multiple_selection_menu div.enabled').show()
$('#multiple_selection_menu div.disabled').hide()
@@ -7,7 +7,7 @@ jQuery ->
$('#multiple_selection_menu a.enable').click(enable_multiple_selection)
- disable_multiple_selection = (event) ->
+ disable_multiple_selection = (event) ->
event.preventDefault()
$('#multiple_selection_menu div.enabled').hide()
$('#multiple_selection_menu div.disabled').show()
@@ -15,13 +15,13 @@ jQuery ->
$('#multiple_selection_menu a.disable').click(disable_multiple_selection)
- select_all = (event) ->
+ select_all = (event) ->
event.preventDefault()
$('input[type=checkbox].multiple_selection').prop("checked", true)
$('#multiple_selection_menu a.select_all').click(select_all)
- deselect_all = (event) ->
+ deselect_all = (event) ->
event.preventDefault()
$('input[type=checkbox].multiple_selection').prop("checked", false)
@@ -30,24 +30,25 @@ jQuery ->
handle_multiple_action = (event) ->
event.preventDefault()
link = $(event.target)
+ r = confirm( link.attr( "confirmation-text" ) );
+ if (r == true)
+ href = link.attr("href")
+ method = link.data('multiple-method')
+ csrf_token = $('meta[name=csrf-token]').attr('content')
+ csrf_param = $('meta[name=csrf-param]').attr('content')
+ form = $('<form method="post" action="' + href + '"></form>')
+ target = link.attr('target')
- href = link.attr("href")
- method = link.data('multiple-method')
- csrf_token = $('meta[name=csrf-token]').attr('content')
- csrf_param = $('meta[name=csrf-param]').attr('content')
- form = $('<form method="post" action="' + href + '"></form>')
- target = link.attr('target')
+ metadata_input = '<input name="_method" value="' + method + '" type="hidden" />'
- metadata_input = '<input name="_method" value="' + method + '" type="hidden" />'
+ if csrf_param? and csrf_token?
+ metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />'
- if csrf_param? and csrf_token?
- metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />'
+ form.append($(input).clone()) for input in $('input[type=checkbox].multiple_selection:checked')
- form.append($(input).clone()) for input in $('input[type=checkbox].multiple_selection:checked')
-
- form.attr('target', target) if target?
+ form.attr('target', target) if target?
- form.hide().append(metadata_input).appendTo('body')
- form.submit()
+ form.hide().append(metadata_input).appendTo('body')
+ form.submit()
$('#multiple_selection_menu .actions a.remove').click(handle_multiple_action)
diff --git a/app/views/lines/index.html.erb b/app/views/lines/index.html.erb
index 83fea102f..2a8357113 100644
--- a/app/views/lines/index.html.erb
+++ b/app/views/lines/index.html.erb
@@ -85,7 +85,7 @@
<a class="disable" href="#"><%= t(".multi_selection_disable") %></a>
<ul class="actions">
- <%= link_to t(".delete_selected"), referential_lines_path(@referential), "data-multiple-method" => "delete", :class => "remove", :confirm => t("lines.actions.destroy_selection_confirm") %>
+ <%= link_to t(".delete_selected"), referential_lines_path(@referential), "data-multiple-method" => "delete", :class => "remove", "confirmation-text" => t("lines.actions.destroy_selection_confirm") %>
</ul>
<a class="select_all" href="#"><%= t(".select_all") %></a> | <a class="deselect_all" href="#"><%= t(".deselect_all") %></a>