Commit 16ebeede authored by Marin Jankovski's avatar Marin Jankovski

Update branch status with ajax call.

parent 2cbfc515
$ ->
$(":checkbox").change ->
id = $(this).val()
checked = $(this).is(":checked")
url = $(this).data("url")
$.ajax
type: "PUT"
url: url
dataType: "json"
data:
id: id
developers_can_push: checked
success: ->
new Flash("Branch updated.", "notice")
location.reload true
error: ->
new Flash("Failed to update branch!", "alert")
...@@ -22,13 +22,14 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController ...@@ -22,13 +22,14 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
protected_branch.update_attributes( protected_branch.update_attributes(
developers_can_push: params[:developers_can_push] developers_can_push: params[:developers_can_push]
) )
flash[:notice] = 'Branch was successfully updated.'
else
flash[:alert] = 'Could not update the branch.'
end
respond_to do |format| respond_to do |format|
format.html { redirect_to project_protected_branches_path } format.json { render :json => protected_branch, status: :ok }
end
else
respond_to do |format|
format.json { render json: protected_branch.errors, status: :unprocessable_entity }
end
end end
end end
......
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