Commit: 7e0c0ceed1d13766a2e47370495c9fc1a005b8b6 Author: Anatol Belski <a...@php.net> Fri, 11 Nov 2016 15:46:05 +0100 Parents: 94c917d08b89d77ef23e93751f8e208f3a4c592f Branches: master
Link: http://git.php.net/?p=web/qa.git;a=commitdiff;h=7e0c0ceed1d13766a2e47370495c9fc1a005b8b6 Log: added the basic labels form Changed paths: M pulls/index.php M pulls/pullrequests.js Diff: diff --git a/pulls/index.php b/pulls/index.php index 4c59bc3..4225748 100644 --- a/pulls/index.php +++ b/pulls/index.php @@ -77,6 +77,7 @@ common_header(); <div><a href="{{=html_url}}"><img src="../gfx/github.ico"> On GitHub</a> | <a href="{{=diff_url}}">Diff</a> | <a href="#" data-number="{{=number}}" data-state="{{=state}}" data-title="{{=title}}" class="pullinstructions">Show Pull Instructions</a> | + <a href="#" data-number="{{=number}}" data-state="{{=state}}" data-title="{{=title}}" class="handlelabels">Labels</a> | <a href="#" data-number="{{=number}}" data-state="{{=state}}" data-title="{{=title}}" class="updatepullrequest">Update</a> </div> </div> @@ -90,6 +91,10 @@ $ make test # you better not forget that $ git push origin master # everything okay? good, let's push it </pre> </script> + <script id="labelsDialogTemplate" type="text/x-jquery-tmpl"> + <dd></dd> + <button>OK</button> + </script> <script id="updatePullRequestTemplate" type="text/x-jquery-tmpl"> State: <select id="newState"> <option>open</option> diff --git a/pulls/pullrequests.js b/pulls/pullrequests.js index 8500b4a..7252a21 100644 --- a/pulls/pullrequests.js +++ b/pulls/pullrequests.js @@ -147,6 +147,52 @@ function loadRepo(repo, url) { .dialog({title: $(this).data("number")+': '+$(this).data("title")+' ('+$(this).data("state")+')', width: 800 }); ev.preventDefault(); }); + $(".handlelabels").click(function(ev) { + var that = $(this); + $("#loading").show(); + $.ajax({dataType: "jsonp", + url: GITHUB_BASEURL+'repos/'+GITHUB_ORG+"/"+repo+"/labels", + success: function(repo_labels) { + $.ajax({dataType: "jsonp", + url: GITHUB_BASEURL+'repos/'+GITHUB_ORG+"/"+repo+"/issues/" + that.data("number") + "/labels", + success: function(issue_labels) { + $("#loading").hide(); + + console.log(repo_labels.data); + console.log(issue_labels.data); + + var dia = $('<div></div>').html($("#labelsDialogTemplate").render({})) + .dialog({title: that.data("number")+': '+that.data("title")+' ('+that.data("state")+')' }); + var ul_el = $("dd", dia).append('<ul style="list-style: none;">'); + for (var i in repo_labels.data) { + + var li_el, input_html; + + li_el = ul_el.append('<li style="display: block;">') + + $('[id="pr-' + that.data("number") + '-label-' + repo_labels.data[i].name + '"]').each(function(i, v) { + $(v).remove(); + }); + + input_html ='<input type="checkbox" id="pr-' + that.data("number") + '-label-' + repo_labels.data[i].name + '"'; + for (var k in issue_labels.data) { + if (repo_labels.data[i].id == issue_labels.data[k].id) { + input_html += ' checked="checked"'; + break; + } + } + input_html += ' value="' + repo_labels.data[i].name + '"'; + input_html += " />"; + li_el.append(input_html + repo_labels.data[i].name); + } + + $("button", dia).click(function() { dia.dialog("close"); }); + } + }); + } + }); + ev.preventDefault(); + }); $(".updatepullrequest").click(function(ev) { var dia = $('<div></div>').html($("#updatePullRequestTemplate").render({})) .dialog({title: $(this).data("number")+': '+$(this).data("title")+' ('+$(this).data("state")+')' }); -- PHP Quality Assurance Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php