Commit 959d63ab authored by Timothy Andrew's avatar Timothy Andrew

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.
parent 60245bbe
$ ->
$(".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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment