2012-03-01 17:33:46 +00:00
|
|
|
$(document).ready(function() {
|
2012-05-25 08:26:42 +01:00
|
|
|
// TODO: Refactor this handler!! It's too complicated.
|
2012-09-13 17:08:41 +01:00
|
|
|
$('#build_list_save_to_repository_id').change(function() {
|
|
|
|
var selected_option = $(this).find("option:selected");
|
|
|
|
|
|
|
|
var platform_id = selected_option.attr('platform_id');
|
|
|
|
var rep_name = selected_option.text().match(/[\w-]+\/([\w-]+)/)[1];
|
2012-03-01 17:33:46 +00:00
|
|
|
|
2012-09-13 23:22:10 +01:00
|
|
|
var build_platform = $('#build_for_pl_' + platform_id);
|
|
|
|
var all_repositories = $('.all_platforms input');
|
|
|
|
all_repositories.removeAttr('checked');
|
2013-02-01 10:00:56 +00:00
|
|
|
var use_save_to_repository = $('#build_list_use_save_to_repository');
|
2013-02-22 10:20:47 +00:00
|
|
|
var auto_create_container = $('#build_list_auto_create_container');
|
2012-12-24 12:35:29 +00:00
|
|
|
|
2012-09-14 15:49:08 +01:00
|
|
|
if (build_platform.size() == 0) {
|
2012-09-13 23:22:10 +01:00
|
|
|
all_repositories.removeAttr('disabled');
|
2013-02-01 10:00:56 +00:00
|
|
|
use_save_to_repository.removeAttr('disabled');
|
2013-02-22 10:20:47 +00:00
|
|
|
auto_create_container.removeAttr('checked');
|
2012-09-13 23:22:10 +01:00
|
|
|
} else {
|
2013-02-22 11:04:14 +00:00
|
|
|
updateExtraReposAndBuildLists();
|
2013-02-04 11:56:27 +00:00
|
|
|
use_save_to_repository.attr('disabled', 'disabled').attr('checked', 'checked');
|
2012-09-13 23:22:10 +01:00
|
|
|
all_repositories.attr('disabled', 'disabled');
|
|
|
|
var parent = build_platform.parent();
|
|
|
|
parent.find('input').removeAttr('disabled');
|
|
|
|
parent.find('input[rep_name="main"]').attr('checked', 'checked');
|
|
|
|
if (rep_name != 'main') {
|
|
|
|
parent.find('input[rep_name="' + rep_name + '"]').attr('checked', 'checked');
|
2012-03-01 17:33:46 +00:00
|
|
|
}
|
2012-09-14 15:49:08 +01:00
|
|
|
setBranchSelected(selected_option);
|
2012-05-25 09:28:43 +01:00
|
|
|
}
|
2012-09-13 17:16:13 +01:00
|
|
|
var build_list_auto_publish = $('#build_list_auto_publish');
|
|
|
|
if (selected_option.attr('publish_without_qa') == '1') {
|
|
|
|
build_list_auto_publish.removeAttr('disabled').attr('checked', 'checked');
|
|
|
|
} else {
|
|
|
|
build_list_auto_publish.removeAttr('checked').attr('disabled', 'disabled');
|
2013-02-22 10:20:47 +00:00
|
|
|
auto_create_container.attr('checked', 'checked');
|
2012-09-13 17:16:13 +01:00
|
|
|
}
|
2013-02-21 14:21:58 +00:00
|
|
|
|
2013-02-22 11:04:14 +00:00
|
|
|
var path = '/build_lists/autocomplete_to_extra_repos_and_builds?platform_id=' + platform_id;
|
2013-02-21 14:21:58 +00:00
|
|
|
$('#extra_repos').attr('data-autocomplete', path);
|
2012-09-06 16:34:33 +01:00
|
|
|
});
|
|
|
|
|
2012-09-13 17:08:41 +01:00
|
|
|
$('#build_list_save_to_repository_id').trigger('change');
|
2013-02-18 15:43:30 +00:00
|
|
|
|
2013-02-22 11:04:14 +00:00
|
|
|
$('#extra-repos-and-build-lists #add').click(function() {
|
|
|
|
updateExtraReposAndBuildLists();
|
2013-02-18 15:43:30 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2013-02-22 11:04:14 +00:00
|
|
|
$(document).on('click', '#extra-repos-and-build-lists .delete', function() {
|
2013-02-18 16:23:54 +00:00
|
|
|
$(this)[0].parentElement.parentElement.remove();
|
|
|
|
});
|
|
|
|
|
2013-02-22 11:04:14 +00:00
|
|
|
$('#extra-repos-and-build-lists-dialog').dialog({
|
2013-02-21 22:12:37 +00:00
|
|
|
autoOpen: false,
|
|
|
|
resizable: false,
|
2013-02-25 14:49:40 +00:00
|
|
|
width: 500
|
2013-02-21 22:12:37 +00:00
|
|
|
});
|
|
|
|
|
2013-02-22 11:04:14 +00:00
|
|
|
$('#extra-repos-and-build-lists .icon-question-sign').click(function() {
|
|
|
|
var dialog = $('#extra-repos-and-build-lists-dialog');
|
2013-02-21 22:12:37 +00:00
|
|
|
if (dialog.is(':visible')) { dialog.dialog('close'); } else { dialog.dialog('open'); }
|
|
|
|
});
|
|
|
|
|
2013-02-20 15:07:11 +00:00
|
|
|
var ownership_btn = $('.btn.ownership');
|
|
|
|
ownership_btn.click(function() {
|
|
|
|
ownership_btn.removeClass('active');
|
|
|
|
$('#filter_ownership').val($(this).val());
|
|
|
|
$(this).addClass('active');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
var perpage_btn = $('.btn.per_page');
|
|
|
|
perpage_btn.click(function() {
|
|
|
|
perpage_btn.removeClass('active');
|
|
|
|
$('#per_page').val($(this).val());
|
|
|
|
$(this).addClass('active');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('a#updated_at_clear').click(function() {
|
|
|
|
$($(this).attr('href')).val('');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#filter_clear').click(function() {
|
2013-02-21 12:23:48 +00:00
|
|
|
$('#monitoring_filter .input_cleanse').val('');
|
2013-02-20 15:07:11 +00:00
|
|
|
$('.btn-group .btn').removeClass('active');
|
|
|
|
if(ownership_btn.length > 0) { ownership_btn[0].click(); }
|
|
|
|
perpage_btn[0].click();
|
|
|
|
return false;
|
|
|
|
});
|
2013-02-20 18:43:00 +00:00
|
|
|
|
|
|
|
$('.mediumheight.min').datepicker({
|
|
|
|
dateFormat: 'dd/mm/yy',
|
|
|
|
showButtonPanel: true
|
|
|
|
});
|
2012-03-01 17:33:46 +00:00
|
|
|
});
|
2012-09-14 15:49:08 +01:00
|
|
|
|
2013-02-21 22:17:20 +00:00
|
|
|
|
2013-02-22 11:04:14 +00:00
|
|
|
function updateExtraReposAndBuildLists() {
|
|
|
|
$.get("/build_lists/update_extra_repos_and_builds", $('#new_build_list').serialize())
|
2013-02-21 14:21:58 +00:00
|
|
|
.done(function(data) {
|
2013-02-22 11:04:14 +00:00
|
|
|
$("#extra-repos-and-build-lists table tbody").html(data);
|
2013-02-21 14:21:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-09-14 15:49:08 +01:00
|
|
|
function setBranchSelected(selected_option) {
|
|
|
|
var pl_name = selected_option.text().match(/([\w-.]+)\/[\w-.]+/)[1];
|
|
|
|
var bl_version_sel = $('#build_list_project_version');
|
2013-01-21 17:08:19 +00:00
|
|
|
var branch_pl_opt = bl_version_sel.find('option[value="' + pl_name + '"]');
|
2012-09-14 15:49:08 +01:00
|
|
|
// If there is branch we need - set it selected:
|
|
|
|
if (branch_pl_opt.size() > 0) {
|
|
|
|
bl_version_sel.find('option[selected]').removeAttr('selected');
|
|
|
|
branch_pl_opt.attr('selected', 'selected');
|
|
|
|
bl_version_sel.val(branch_pl_opt);
|
|
|
|
// hack for FF to force render of select box.
|
|
|
|
bl_version_sel[0].innerHTML = bl_version_sel[0].innerHTML;
|
|
|
|
}
|
2013-02-21 22:17:20 +00:00
|
|
|
}
|