Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
112 lines (94 sloc) 3.34 KB
<!DOCTYPE html>
<html>
<head>
<title>Custom YouTrack Submit Form</title>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script>
</head>
<body>
<h3>Submit Issue <span id="total"></span></h3>
<form onsubmit="createIssue(); return false;" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="project">Project</label>
<div class="controls">
<select name="project" id="project">
<option>Loading projects...</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="summary">Summary</label>
<div class="controls">
<input type="text" id="summary" style="width: 50%"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="description">Description</label>
<div class="controls">
<textarea name="description" id="description" cols="30" rows="10" style="width: 50%"></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="submit" value="Create Issue" class="btn btn-primary"/>
<span id="result">Issue created!</span>
</div>
</div>
</form>
<script type="text/javascript">
baseUrl = "http://scrumboard.myjetbrains.com/youtrack/rest";
function createIssue() {
$.ajax({
url: baseUrl + "/issue",
dataType:"json",
type:"POST",
data:{
project:$("#project").val(),
summary:$("#summary").val(),
description:$("#description").val()
}
}).done(function (data) {
$("#result").show();
$("#summary").val('');
$("#description").val('');
});
}
function loadProjects() {
$.ajax({
url: baseUrl + "/project/all",
dataType:"json"
}).done(function (data) {
var project = $("#project");
project.empty();
$.each(data, function(index, value) {
project.append($("<option/>", {
value: value.shortName,
text: value.name
}))
});
});
}
function countTotalIssues() {
$.ajax({
url: baseUrl + "/issue/count",
dataType:"json"
}).done(function (data) {
var val = parseInt(data.entity.value);
if (val < 0) {
window.setTimeout(function() {
countTotalIssues();
}, 1000);
} else {
$("#total").text("(total issues " + val + ")");
}
});
}
$(function(){
$("#result").hide();
countTotalIssues();
loadProjects();
})
</script>
</body>
</html>