gitlabhq/app/assets/javascripts/issues.js

146 lines
3.9 KiB
JavaScript
Raw Normal View History

function switchToNewIssue(){
2012-01-28 00:49:14 +01:00
$(".issues_content").hide("fade", { direction: "left" }, 150, function(){
$('select#issue_assignee_id').chosen();
2012-04-08 23:28:58 +02:00
$('select#issue_milestone_id').chosen();
2012-01-28 00:49:14 +01:00
$("#new_issue_dialog").show("fade", { direction: "right" }, 150);
2012-01-25 08:13:08 +01:00
$('.top-tabs .add_new').hide();
disableButtonIfEmptyField("#issue_title", ".save-btn");
setupGfmAutoComplete();
});
}
function switchToEditIssue(){
2012-01-28 00:49:14 +01:00
$(".issues_content").hide("fade", { direction: "left" }, 150, function(){
$('select#issue_assignee_id').chosen();
2012-04-08 23:28:58 +02:00
$('select#issue_milestone_id').chosen();
2012-01-28 00:49:14 +01:00
$("#edit_issue_dialog").show("fade", { direction: "right" }, 150);
2012-01-27 07:57:55 +01:00
$('.add_new').hide();
disableButtonIfEmptyField("#issue_title", ".save-btn");
setupGfmAutoComplete();
});
}
function switchFromNewIssue(){
backToIssues();
}
function switchFromEditIssue(){
backToIssues();
}
function backToIssues(){
2012-01-28 00:49:14 +01:00
$("#edit_issue_dialog, #new_issue_dialog").hide("fade", { direction: "right" }, 150, function(){
$(".issues_content").show("fade", { direction: "left" }, 150, function() {
$("#edit_issue_dialog").html("");
$("#new_issue_dialog").html("");
2012-01-27 07:57:55 +01:00
$('.add_new').show();
});
});
}
2012-06-12 10:31:38 +02:00
function initIssuesSearch() {
2012-11-14 01:20:37 +01:00
var href = $('#issue_search_form').attr('action');
2012-06-12 10:31:38 +02:00
var last_terms = '';
2012-11-14 01:20:37 +01:00
$('#issue_search').keyup(function() {
2012-06-12 10:31:38 +02:00
var terms = $(this).val();
var milestone_id = $('#milestone_id').val();
var status = $('#status').val();
if (terms != last_terms) {
last_terms = terms;
if (terms.length >= 2 || terms.length == 0) {
$.get(href, { 'f': status, 'terms': terms, 'milestone_id': milestone_id }, function(response) {
$('#issues-table').html(response);
});
}
}
});
}
2012-06-27 22:13:44 +02:00
/**
* Init issues page
*
*/
function issuesPage(){
initIssuesSearch();
2012-07-28 02:35:24 +02:00
$("#update_status").chosen();
$("#update_assignee_id").chosen();
$("#update_milestone_id").chosen();
2012-06-27 22:13:44 +02:00
$("#label_name").chosen();
$("#assignee_id").chosen();
$("#milestone_id").chosen();
$("#milestone_id, #assignee_id, #label_name").on("change", function(){
$(this).closest("form").submit();
});
2012-09-07 15:35:59 +02:00
$("#new_issue_link").click(function(){
updateNewIssueURL();
});
$('body').on('ajax:success', '.close_issue, .reopen_issue, #new_issue', function(){
var t = $(this),
totalIssues,
reopen = t.hasClass('reopen_issue'),
newIssue = false;
if( this.id == 'new_issue' ){
newIssue = true;
}
$('.issue_counter, #new_issue').each(function(){
var issue = $(this);
totalIssues = parseInt( $(this).html(), 10 );
if( newIssue || ( reopen && issue.closest('.main_menu').length ) ){
$(this).html( totalIssues+1 );
}else {
$(this).html( totalIssues-1 );
}
});
});
2012-07-28 02:35:24 +02:00
$(".check_all_issues").click(function () {
$('.selected_issue').attr('checked', this.checked);
issuesCheckChanged();
});
$('.selected_issue').bind('change', issuesCheckChanged);
}
function issuesCheckChanged() {
var checked_issues = $('.selected_issue:checked');
if(checked_issues.length > 0) {
var ids = []
$.each(checked_issues, function(index, value) {
ids.push($(value).attr("data-id"));
})
$('#update_issues_ids').val(ids);
$('.issues_filters').hide();
$('.issues_bulk_update').show();
} else {
$('#update_issues_ids').val([]);
$('.issues_bulk_update').hide();
$('.issues_filters').show();
}
2012-06-27 22:13:44 +02:00
}
2012-09-07 15:35:59 +02:00
function updateNewIssueURL(){
var new_issue_link = $("#new_issue_link");
var milestone_id = $("#milestone_id").val();
var assignee_id = $("#assignee_id").val();
var new_href = "";
if(milestone_id){
2012-09-07 19:59:12 +02:00
new_href = "issue[milestone_id]=" + milestone_id + "&";
2012-09-07 15:35:59 +02:00
}
if(assignee_id){
2012-09-07 19:59:12 +02:00
new_href = new_href + "issue[assignee_id]=" + assignee_id;
2012-09-07 15:35:59 +02:00
}
if(new_href.length){
new_href = new_issue_link.attr("href") + "?" + new_href;
new_issue_link.attr("href", new_href);
}
};