July 1, 2013

How to hide/remove OS field in Bugzilla

This method uses javascript to hide the unwanted fields

1. edit template/en/default/global/header.html.tmpl. Search for "global.js". After the line "[% END %]" add the following lines:

    [% starting_js_urls.push('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js') %]

    [% FOREACH javascript_url = starting_js_urls %]
      [% PROCESS format_js_link %]
    [% END %]
    [% starting_js_urls.push('js/my.js') %]

    [% FOREACH javascript_url = starting_js_urls %]
      [% PROCESS format_js_link %]
    [% END %]

2. create the file js/my.js with the following contents:
$(document).ready(function(){
        $("#os_guess_note").parent().hide();
        $("#field_container_op_sys").parent().hide();
        $("#field_container_rep_platform").parent().hide();
});

This hides three fields: OS, OS comment, and Hardware.

To remove more clutters, use the following js:

$(document).ready(function(){
        $("#os_guess_note").parent().hide();
        $("#field_container_op_sys").parent().hide();
        $("#field_container_rep_platform").parent().hide();
        $("#op_sys").closest("tr").hide();
        $("#bz_url_input_area").closest("tr").hide();
        $("#tag_container").closest("tr").hide();
        $("#dependson").closest("tr").hide();
        $("#blocked_input_area").closest("tr").hide();
        $("#show_dependency_tree_or_graph").closest("tr").hide();
        $("td.bz_section_spacer").closest("tr").hide();
        $(".bz_collapse_expand_comments").closest("td").hide();
        $("div.bz_add_comment").hide();
        $("#xml").hide();

        $("#comment").attr("rows","2");
        $("#attachment_table").hide().before("<button id='tz_bug_edit' style='width:50px'> <b>Edit</b> </button>");
        $("#add_comment").hide();
        $("#tz_bug_edit").prevAll("br").remove();
        $("#tz_bug_edit").click(function(){
                if ($("#attachment_table").is(":visible")){
                        $("#attachment_table").hide();
                        $("#add_comment").hide();
                }else{
                        $("#attachment_table").show();
                        $("#add_comment").show();
                }
                return false;
        });
});
        $("#bz_show_bug_column_1").append($("#bz_show_bug_column_2").html());
        $("#bz_show_bug_column_2").remove();
        $("table.edit_form").css("width","auto").css("float","right").find("th").css("text-align","left");

        $("#changeform").css("min-height","400px");


You can also change skins/standard/global.css to remove hyperlink underline, and change default font:

a {
        text-decoration: none;
}


/* this already exists, just edit it */
body, td, th, input {
    font-family: Verdana, sans-serif;
    font-size: 11pt;
}


2 comments:

  1. Thanks for this key information.
    Suppose I have remove field "version" . What code I need to add or remove from .js code.
    Many Many thanks in advance!!

    ReplyDelete
  2. In footer.html.tmpl just before tag, I've added the following 2 lines:






    In js/myscript.js
    $(document).ready(function(){
    //alert ('doc loaded');
    //New_bug
    $("#field_container_component").parent().hide();
    $("#field_label_version").parent().hide();
    $("#os_guess_note").parent().hide();
    $("#field_container_op_sys").parent().hide();
    $("#field_container_rep_platform").parent().hide();
    $("#field_label_bug_file_loc").parent().hide();
    $("#field_label_estimated_time").parent().hide();

    // set custom fields on
    $("#expert_fields_controller").parent().hide();
    $("#expert_fields_controller").removeClass('expert_fields_controller', 'bz_default_hidden');


    //show_bug.cgi
    $("#field_label_alias").parent().hide();
    $("#field_label_rep_platform").parent().hide();
    });

    ReplyDelete