summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/web/new_bug.js
blob: cd1b164534eab08bde1415094de7db11ac8c774b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$(document).ready(function() {
    bugzilla_ajax(
            {
                url: 'rest/bug_modal/products'
            },
            function(data) {
                $('#product').empty()
                $('#product').append($('<option>', { value: 'Select Product', text: 'Select Product' }));
                // populate select menus
                $.each(data.products, function(key, value) {
                    $('#product').append($('<option>', { value: value.name, text: value.name }));
                });
            },
            function() {}
        );

    $('#component').empty()
    $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' }));

    $('#product')
    .change(function(event) {
        $('#product-throbber').show();
        $('#component').attr('disabled', true);
        $("#product option[value='Select Product']").remove();
        bugzilla_ajax(
            {
                url: 'rest/bug_modal/components?product=' + encodeURIComponent($('#product').val())
            },
            function(data) {
                $('#product-throbber').hide();
                $('#component').attr('disabled', false);
                $('#component').empty();
                $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' }));
                $('#comp_desc').text('Select a component to read its description.');
                $.each(data.components, function(key, value) {  
                    $('#component').append('<option value=' + value.name + ' desc=' + value.description.split(' ').join('_') + '>' + value.name + '</option>');
                });
            },
            function() {}
        );
    });
    $('#component')
    .change(function(event) {
        $("#component option[value='Select Product']").remove();
        $('#comp_desc').text($('#component').find(":selected").attr('desc').split('_').join(' '));
    });
    
});