Clean up `protected_branches.js.coffee`
- Only send a param for the currently changed checkbox. - Have the controller use strong parameters correctly, so that the PATCH works as expected.
This commit is contained in:
parent
60245bbe22
commit
959d63ab1a
|
@ -1,21 +1,18 @@
|
|||
$ ->
|
||||
$(".protected-branches-list :checkbox").change (e) ->
|
||||
name = $(this).attr("name")
|
||||
row = $(this).parents("tr")
|
||||
if name == "developers_can_push" || name == "developers_can_merge"
|
||||
id = $(this).val()
|
||||
can_push = row.find("input[name=developers_can_push]").is(":checked")
|
||||
can_merge = row.find("input[name=developers_can_merge]").is(":checked")
|
||||
can_push = $(this).is(":checked")
|
||||
url = $(this).data("url")
|
||||
$.ajax
|
||||
type: "PUT"
|
||||
type: "PATCH"
|
||||
url: url
|
||||
dataType: "json"
|
||||
data:
|
||||
id: id
|
||||
protected_branch:
|
||||
developers_can_push: can_push
|
||||
developers_can_merge: can_merge
|
||||
"#{name}": can_push
|
||||
|
||||
success: ->
|
||||
row = $(e.target)
|
||||
|
|
Loading…
Reference in New Issue