From: Kohei Yoshino Date: Mon, 8 Apr 2019 21:06:15 +0000 (-0400) Subject: Bug 1541133 - Bug type field should be a radio button X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d343ebfeb0cf612eaa214b59b95df53a8af32086;p=thirdparty%2Fbugzilla.git Bug 1541133 - Bug type field should be a radio button --- diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index 5db09f633..d518c31f1 100644 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -466,6 +466,7 @@ [% WRAPPER bug_modal/field.html.tmpl field = bug_fields.bug_type field_type = constants.FIELD_TYPE_SINGLE_SELECT + use_buttons = 1 help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#bug_type" %] diff --git a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl index e6933ef29..cadfe7c63 100644 --- a/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/field.html.tmpl @@ -97,6 +97,7 @@ END;
+ [% IF use_buttons %] +
+ [% IF values.defined %] + [% FOREACH v IN values %] + [% NEXT IF NOT v.is_active AND NOT value.contains(v.name).size %] + [% NEXT IF NOT bug.check_can_change_field(name, bug.${field_name}, v.name) %] +
+ + +
+ [% END %] + [% ELSE %] +
+ + +
+ [% END %] +
+ [% ELSE %] + [% END %] [% CASE constants.FIELD_TYPE_MULTI_SELECT %] [%# multi value select %] diff --git a/extensions/BugModal/web/bug_modal.css b/extensions/BugModal/web/bug_modal.css index 82b0d67d4..2666a3400 100644 --- a/extensions/BugModal/web/bug_modal.css +++ b/extensions/BugModal/web/bug_modal.css @@ -221,6 +221,14 @@ a.activity-ref { width: 170px; } +.module .field.contains-buttons { + margin: 8px 0; +} + +.module .field.contains-buttons .name { + vertical-align: middle; +} + .field-button { float: right; margin-left: 8px; diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index ad8d3ba74..5c5d029b1 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -538,17 +538,36 @@ $(function() { $('#mode-btn').hide(); // populate select menus - $.each(data.options, function(key, value) { - var el = $('#' + key); - if (!el) return; - var selected = el.val(); - el.empty(); - $(value).each(function(i, v) { - el.append($(' + `); + } }); - el.val(selected); - if (el.attr('multiple') && value.length < 5) { - el.attr('size', value.length); + if ($select.matches('[multiple]') && value.length < 5) { + $select.size = value.length; } }); diff --git a/qa/t/test_bug_edit.t b/qa/t/test_bug_edit.t index e2457057f..b9fcd3d93 100644 --- a/qa/t/test_bug_edit.t +++ b/qa/t/test_bug_edit.t @@ -49,7 +49,7 @@ logout($sel); log_in($sel, $config, 'QA_Selenium_TEST'); file_bug_in_product($sel, 'TestProduct'); -$sel->select_ok("bug_type", "label=defect"); +$sel->check_ok('//input[@name="bug_type" and @value="defect"]'); $sel->select_ok("bug_severity", "label=critical"); $sel->type_ok("short_desc", "Test bug editing"); $sel->type_ok("comment", "ploc"); @@ -377,7 +377,7 @@ logout($sel); log_in($sel, $config, 'QA_Selenium_TEST'); file_bug_in_product($sel, 'TestProduct'); -$sel->select_ok("bug_type", "label=defect"); +$sel->check_ok('//input[@name="bug_type" and @value="defect"]'); $sel->select_ok("bug_severity", "label=blocker"); $sel->type_ok("short_desc", "New bug from me"); diff --git a/qa/t/test_custom_fields.t b/qa/t/test_custom_fields.t index 85f2fe3a2..5c0a09e40 100644 --- a/qa/t/test_custom_fields.t +++ b/qa/t/test_custom_fields.t @@ -342,7 +342,7 @@ go_to_bug($sel, $bug1_id); my @labels = $sel->get_select_options("cf_qa_list_$bug1_id"); ok(grep(/^ghost$/, @labels), "ghost is in the DOM of the page..."); my $disabled = $sel->get_attribute("v4_cf_qa_list_$bug1_id\@disabled"); -ok($disabled, "... but is not available for selection by default"); +ok(defined $disabled, "... but is not available for selection by default"); $sel->select_ok("bug_status", "label=RESOLVED"); $sel->select_ok("resolution", "label=FIXED"); $sel->select_ok("cf_qa_list_$bug1_id", "label=ghost"); diff --git a/skins/standard/enter_bug.css b/skins/standard/enter_bug.css index 7f610b82b..936b51f11 100644 --- a/skins/standard/enter_bug.css +++ b/skins/standard/enter_bug.css @@ -55,6 +55,15 @@ max-width: 35em; } +/* Adjust style for fields using radio-button-like UI */ +#Create .field_label.for-buttons { + vertical-align: middle; +} + +#Create .field_value.contains-buttons { + padding: .5em .25em; +} + /* Text inputs need to be a little shorter on enter_bug * than the 100% that they are on show_bug. */ diff --git a/skins/standard/global.css b/skins/standard/global.css index 76b24942f..22c142074 100644 --- a/skins/standard/global.css +++ b/skins/standard/global.css @@ -1242,11 +1242,13 @@ select, select[multiple] { } .buttons.toggle[role="radiogroup"] .item:first-child label { - border-radius: 4px 0 0 4px; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; } .buttons.toggle[role="radiogroup"] .item:last-child label { - border-radius: 0 4px 4px 0; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; } .buttons.toggle[role="radiogroup"] .item:not(:first-child) label { diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index cb92f137d..fa9729cf0 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -51,6 +51,10 @@ function init() { initCrashSignatureField(); init_take_handler('[% user.login FILTER js %]'); bz_attachment_form.update_requirements(false); + + document.querySelector('#bug_type').addEventListener('change', () => { + bug_type_changed = true; + }, { once: true }); } function initCrashSignatureField() { @@ -67,6 +71,7 @@ function initCrashSignatureField() { var initialowners = new Array([% product.components.size %]); var last_initialowner; var default_bug_types = new Array([% product.components.size %]); +let bug_type_changed = false; var initialccs = new Array([% product.components.size %]); var components = new Array([% product.components.size %]); var comp_desc = new Array([% product.components.size %]); @@ -131,7 +136,10 @@ function set_assign_to() { last_initialowner = owner; } - form.bug_type.value = default_bug_types[index]; + if (!bug_type_changed) { + form.bug_type.value = default_bug_types[index]; + } + document.getElementById('initial_cc').innerHTML = initialccs[index]; document.getElementById('comp_desc').innerHTML = comp_desc[index]; @@ -318,7 +326,7 @@ TUI_hide_default('expert_fields'); [% INCLUDE bug/field.html.tmpl - bug = default, field = bug_fields.bug_type, editable = 1, + bug = default, field = bug_fields.bug_type, editable = 1, use_buttons = 1, value = default.bug_type %] diff --git a/template/en/default/bug/field-label.html.tmpl b/template/en/default/bug/field-label.html.tmpl index 851935283..5d5c5452c 100644 --- a/template/en/default/bug/field-label.html.tmpl +++ b/template/en/default/bug/field-label.html.tmpl @@ -29,7 +29,7 @@ [% DEFAULT tag_name = "th" %] <[% tag_name FILTER html %] class="field_label [% ' bz_hidden_field' IF hidden %] - [%- ' required' IF field.is_mandatory && NOT bug.id %]" + [%- ' required' IF field.is_mandatory && NOT bug.id; ' for-buttons' IF use_buttons %]" id="field_label_[% field.name FILTER html %]" [% IF rowspan %] rowspan="[% rowspan FILTER html %]"[% END %]> diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl index 5e674f7b2..a38a5a07c 100644 --- a/template/en/default/bug/field.html.tmpl +++ b/template/en/default/bug/field.html.tmpl @@ -44,7 +44,7 @@ [% IF NOT no_tds %] [% PROCESS "bug/field-label.html.tmpl" %] - [% END %] @@ -101,6 +101,9 @@ [% CASE [ constants.FIELD_TYPE_SINGLE_SELECT constants.FIELD_TYPE_MULTI_SELECT ] %] + [% IF use_buttons %] +
+ [% ELSE %] + +
+ [% ELSE %] + + [% END %] [% END %] + [% IF use_buttons %] +
+ [% ELSE %] + [% END %] [%# When you pass an empty multi-select in the web interface, # it doesn't appear at all in the CGI object. Instead of # forcing all users of process_bug to always specify every