Commit: 5344b77166b0826165792f12042a72383fcbba93 Author: zrhoffman <zrhoff...@ku.edu> Sun, 7 Oct 2018 14:48:20 -0500 Committer: Peter Kokot <peterko...@gmail.com> Tue, 23 Oct 2018 01:14:57 +0200 Parents: c2a40c6bf0a7ecf4eab0ff4f21d8abe6d32d1bfc Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=5344b77166b0826165792f12042a72383fcbba93 Log: Fix #76273: Package affected section should be split - include package-affected.js on bug reporting page - package-affected.js: a dropdown for package categories - package-affected.js: change the package list when the user selects a different package group - packages affected: change select size to 5 so the user can see when the the package list changes Bugs: https://bugs.php.net/76273 Changed paths: A www/js/package-affected.js M www/report.php Diff: diff --git a/www/js/package-affected.js b/www/js/package-affected.js new file mode 100644 index 0000000..1d44fa8 --- /dev/null +++ b/www/js/package-affected.js @@ -0,0 +1,104 @@ +'use strict'; + +window.addEventListener( + 'load', + function () { + document + .querySelectorAll('select[name="in[package_name]"]') + .forEach( + function (select) { + var packageGroup = document.createElement('select'), + initialValue = select.value, + initialGroup = select.querySelector(':scope option[value="' + initialValue + '"]').parentNode; + + packageGroup.name = 'in[package_group]'; + + select + .querySelectorAll(':scope optgroup') + .forEach( + function (optgroup) { + var packageOption = document.createElement('option'), + groupName = optgroup.label; + + packageOption.textContent = groupName; + packageOption.value = groupName; + packageGroup.appendChild(packageOption); + + optgroup + .querySelectorAll(':scope option') + .forEach( + function (option) { + option.setAttribute('bug-group', groupName); + } + ); + } + ); + + var instructions = select.querySelector(':scope option[value="none"]'); + if (instructions instanceof HTMLElement) { + instructions.textContent = 'Select a category'; + } + + select + .querySelectorAll(':scope optgroup') + .forEach( + function (optgroup) { + optgroup.style.display = 'none'; + } + ); + + function updateGroup() { + select.disabled = false; + + if (instructions instanceof HTMLElement) { + instructions.style.display = 'none'; + } + + var previousOptions = select.querySelectorAll(':scope > option:not([value=none])'), + nextLabel = packageGroup.value, + nextGroup = select.querySelector(':scope optgroup[label="' + nextLabel + '"]'); + + if (previousOptions.length !== 0) { + var previousLabel = previousOptions[0].getAttribute('bug-group'), + previousGroup = select.querySelector(':scope optgroup[label="' + previousLabel + '"]'); + + moveOptions(select, previousGroup); + } + + moveOptions(nextGroup, select); + } + + function moveOptions(from, to) { + from.querySelectorAll(':scope > option') + .forEach( + function (option) { + to.appendChild(option); + } + ); + } + + packageGroup.addEventListener('change', updateGroup); + + if (initialGroup instanceof HTMLOptGroupElement) { + packageGroup.value = initialGroup.label; + moveOptions(initialGroup, select); + } else { + select.disabled = true; + select.value = null; + } + + packageGroup.style.marginRight = '.5em'; + [select, packageGroup].forEach( + function (element) { + element.size = 5; + element.style.width = '22em'; + } + ); + + select + .parentNode + .insertBefore(packageGroup, select); + } + ); + } +); diff --git a/www/report.php b/www/report.php index 1b9606e..5151ffe 100644 --- a/www/report.php +++ b/www/report.php @@ -27,6 +27,10 @@ if (!$logged_in) { $numeralCaptcha = new Text_CAPTCHA_Numeral(); } +$packageAffectedScript = <<<SCRIPT + <script type="text/javascript" src="$site_method://$site_url$basedir/js/package-affected.js"></script> +SCRIPT; + // Handle input if (isset($_POST['in'])) { @@ -81,7 +85,7 @@ if (isset($_POST['in'])) { if (count($possible_duplicates) == 0) { $ok_to_submit_report = true; } else { - response_header("Report - Confirm"); + response_header("Report - Confirm", $packageAffectedScript); if (count($_FILES)) { echo '<h1>WARNING: YOU MUST RE-UPLOAD YOUR PATCH, OR IT WILL BE IGNORED</h1>'; } @@ -150,7 +154,7 @@ OUTPUT; if (isset($_POST['edit_after_preview'])) { $ok_to_submit_report = false; - response_header("Report - New"); + response_header("Report - New", $packageAffectedScript); } if ($ok_to_submit_report) { @@ -317,14 +321,14 @@ REPORT; } } else { // had errors... - response_header('Report - Problems'); + response_header('Report - Problems', $packageAffectedScript); } } // end of if input $package = !empty($_REQUEST['package']) ? $_REQUEST['package'] : (!empty($package_name) ? $package_name : (isset($_POST['in']) && $_POST['in'] && isset($_POST['in']['package_name']) ? $_POST['in']['package_name'] : '')); if (!is_string($package)) { - response_header('Report - Problems'); + response_header('Report - Problems', $packageAffectedScript); $errors[] = 'Invalid package name passed. Please fix it and try again.'; display_bug_error($errors); response_footer(); @@ -346,7 +350,9 @@ if (!isset($_POST['in'])) { 'php_os' => '', 'passwd' => '', ); - response_header('Report - New'); + + + response_header('Report - New', $packageAffectedScript); ?> <p> -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php