summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/BMO/lib/Reports/ReleaseTracking.pm223
-rw-r--r--extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl31
-rw-r--r--extensions/BMO/web/js/release_tracking_report.js65
3 files changed, 251 insertions, 68 deletions
diff --git a/extensions/BMO/lib/Reports/ReleaseTracking.pm b/extensions/BMO/lib/Reports/ReleaseTracking.pm
index 2535340cb..bce59264c 100644
--- a/extensions/BMO/lib/Reports/ReleaseTracking.pm
+++ b/extensions/BMO/lib/Reports/ReleaseTracking.pm
@@ -14,10 +14,173 @@ use Bugzilla::Error;
use Bugzilla::Extension::BMO::Util;
use Bugzilla::Field;
use Bugzilla::FlagType;
-use Bugzilla::Util qw(correct_urlbase trick_taint);
+use Bugzilla::Util qw(correct_urlbase trick_taint validate_date);
use JSON qw(-convert_blessed_universally);
use List::MoreUtils qw(uniq);
+use constant DATE_RANGES => [
+ {
+ value => '20160126-20160307',
+ label => '2016-01-26 and 2016-03-07'
+ },
+ {
+ value => '20151215-20160125',
+ label => '2015-12-15 and 2016-01-25'
+ },
+ {
+ value => '20151103-20151214',
+ label => '2015-11-03 and 2015-12-14'
+ },
+ {
+ value => '20150922-20151102',
+ label => '2015-09-22 and 2015-11-02'
+ },
+ {
+ value => '20150811-20150921',
+ label => '2015-08-11 and 2015-09-21'
+ },
+ {
+ value => '20150630-20150810',
+ label => '2015-06-30 and 2015-08-10'
+ },
+ {
+ value => '20150512-20150629',
+ label => '2015-05-12 and 2015-06-29'
+ },
+ {
+ value => '20150331-20150511',
+ label => '2015-03-31 and 2015-05-11'
+ },
+ {
+ value => '20150224-20150330',
+ label => '2015-02-24 and 2015-03-30'
+ },
+ {
+ value => '20150113-20150223',
+ label => '2015-01-13 and 2015-02-23'
+ },
+ {
+ value => '20141111-20141222',
+ label => '2014-11-11 and 2014-12-22'
+ },
+ {
+ value => '20140930-20141110',
+ label => '2014-09-30 and 2014-11-10'
+ },
+ {
+ value => '20140819-20140929',
+ label => '2014-08-19 and 2014-09-29'
+ },
+ {
+ value => '20140708-20140818',
+ label => '2014-07-08 and 2014-08-18'
+ },
+ {
+ value => '20140527-20140707',
+ label => '2014-05-27 and 2014-07-07'
+ },
+ {
+ value => '20140415-20140526',
+ label => '2014-04-15 and 2014-05-26'
+ },
+ {
+ value => '20140304-20140414',
+ label => '2014-03-04 and 2014-04-14'
+ },
+ {
+ value => '20140121-20140303',
+ label => '2014-01-21 and 2014-03-03'
+ },
+ {
+ value => '20131210-20140120',
+ label => '2013-12-10 and 2014-01-20'
+ },
+ {
+ value => '20131029-20131209',
+ label => '2013-10-29 and 2013-12-09'
+ },
+ {
+ value => '20130917-20131028',
+ label => '2013-09-17 and 2013-10-28'
+ },
+ {
+ value => '20130806-20130916',
+ label => '2013-08-06 and 2013-09-16'
+ },
+ {
+ value => '20130625-20130805',
+ label => '2013-06-25 and 2013-08-05'
+ },
+ {
+ value => '20130514-20130624',
+ label => '2013-05-14 and 2013-06-24'
+ },
+ {
+ value => '20130402-20130513',
+ label => '2013-04-02 and 2013-05-13'
+ },
+ {
+ value => '20130219-20130401',
+ label => '2013-02-19 and 2013-04-01'
+ },
+ {
+ value => '20130108-20130218',
+ label => '2013-01-08 and 2013-02-18'
+ },
+ {
+ value => '20121120-20130107',
+ label => '2012-11-20 and 2013-01-07'
+ },
+ {
+ value => '20121009-20121119',
+ label => '2012-10-09 and 2012-11-19'
+ },
+ {
+ value => '20120828-20121008',
+ label => '2012-08-28 and 2012-10-08'
+ },
+ {
+ value => '20120717-20120827',
+ label => '2012-07-17 and 2012-08-27'
+ },
+ {
+ value => '20120605-20120716',
+ label => '2012-06-05 and 2012-07-16'
+ },
+ {
+ value => '20120424-20120604',
+ label => '2012-04-24 and 2012-06-04'
+ },
+ {
+ value => '20120313-20120423',
+ label => '2012-03-13 and 2012-04-23'
+ },
+ {
+ value => '20120131-20120312',
+ label => '2012-01-31 and 2012-03-12'
+ },
+ {
+ value => '20111220-20120130',
+ label => '2011-12-20 and 2012-01-30'
+ },
+ {
+ value => '20111108-20111219',
+ label => '2011-11-08 and 2011-12-19'
+ },
+ {
+ value => '20110927-20111107',
+ label => '2011-09-27 and 2011-11-07'
+ },
+ {
+ value => '20110816-20110926',
+ label => '2011-08-16 and 2011-09-26'
+ },
+ {
+ value => '*',
+ label => 'Anytime'
+ }
+];
+
sub report {
my ($vars) = @_;
my $dbh = Bugzilla->dbh;
@@ -181,55 +344,6 @@ sub report {
}
#
- # rapid release dates
- #
-
- my @ranges;
- my $start_date = string_to_datetime('2011-08-16');
- my $end_date = $start_date->clone->add(weeks => 6)->add(days => -1);
- my $now_date = string_to_datetime('2012-11-19');
-
- while ($start_date <= $now_date) {
- unshift @ranges, {
- value => sprintf("%s-%s", $start_date->ymd(''), $end_date->ymd('')),
- label => sprintf("%s and %s", $start_date->ymd('-'), $end_date->ymd('-')),
- };
-
- $start_date = $end_date->clone;;
- $start_date->add(days => 1);
- $end_date->add(weeks => 6);
- }
-
- # 2012-11-20 - 2013-01-06 was a 7 week release cycle instead of 6
- $start_date = string_to_datetime('2012-11-20');
- $end_date = $start_date->clone->add(weeks => 7)->add(days => -1);
- unshift @ranges, {
- value => sprintf("%s-%s", $start_date->ymd(''), $end_date->ymd('')),
- label => sprintf("%s and %s", $start_date->ymd('-'), $end_date->ymd('-')),
- };
-
- # Back on track with 6 week releases
- $start_date = string_to_datetime('2013-01-08');
- $end_date = $start_date->clone->add(weeks => 6)->add(days => -1);
- $now_date = time_to_datetime((time));
-
- while ($start_date <= $now_date) {
- unshift @ranges, {
- value => sprintf("%s-%s", $start_date->ymd(''), $end_date->ymd('')),
- label => sprintf("%s and %s", $start_date->ymd('-'), $end_date->ymd('-')),
- };
-
- $start_date = $end_date->clone;;
- $start_date->add(days => 1);
- $end_date->add(weeks => 6);
- }
-
- push @ranges, {
- value => '*',
- label => 'Anytime',
- };
-
- #
# run report
#
@@ -335,8 +449,9 @@ sub report {
$vars->{products_json} = $json->encode(\@products_json);
$vars->{fields_json} = $json->encode(\@fields_json);
$vars->{flag_names} = \@flag_names;
- $vars->{ranges} = \@ranges;
+ $vars->{ranges} = DATE_RANGES;
$vars->{default_query} = $input->{q};
+ $vars->{is_custom} = $input->{is_custom};
foreach my $field (qw(product flags range)) {
$vars->{$field} = $input->{$field};
}
@@ -370,6 +485,12 @@ sub _parse_query {
or ThrowUserError('report_invalid_parameter', { name => 'date_range' });
$query->{start_date} = "$1-$2-$3";
$query->{end_date} = "$4-$5-$6";
+ validate_date($query->{start_date})
+ || ThrowUserError('illegal_date', { date => $query->{start_date},
+ format => 'YYYY-MM-DD' });
+ validate_date($query->{end_date})
+ || ThrowUserError('illegal_date', { date => $query->{end_date},
+ format => 'YYYY-MM-DD' });
}
# product_id
diff --git a/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl b/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl
index 71228014a..25188ed41 100644
--- a/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl
+++ b/extensions/BMO/template/en/default/pages/release_tracking_report.html.tmpl
@@ -8,8 +8,10 @@
[% INCLUDE global/header.html.tmpl
title = "Release Tracking Report"
- style_urls = [ "extensions/BMO/web/styles/reports.css" ]
+ style_urls = [ "extensions/BMO/web/styles/reports.css",
+ "js/jquery/plugins/datetimepicker/datetimepicker.css" ]
javascript_urls = [ "extensions/BMO/web/js/release_tracking_report.js" ]
+ jquery = [ "datetimepicker" ]
%]
<noscript>
@@ -39,20 +41,31 @@ var default_query = '[% default_query FILTER js %]';
</select>
was changed to (and is currently)
- <select id="flag_value">
+ <select id="flag_value" onchange="serialiseForm()">
<option value="?">?</option>
<option value="-">-</option>
<option value="+">+</option>
</select>
between
- <select id="range" onChange="serialiseForm()">
- [% FOREACH range = ranges %]
- <option value="[% range.value FILTER html %]">
- [% range.label FILTER html %]
- </option>
- [% END %]
- </select>
+ <span id="fixed_range">
+ <select id="range" onChange="serialiseForm()">
+ [% FOREACH range = ranges %]
+ <option value="[% range.value FILTER html %]">
+ [% range.label FILTER html %]
+ </option>
+ [% END %]
+ </select>
+ </span>
+ <span id="custom_range" style="display:none;">
+ <input class="date_field" name="from" id="from" onChange="serialiseForm()">
+ <img class="date_field-img" id="from-img" src="extensions/BugModal/web/calendar.png" width="16" height="16">
+ and
+ <input class="date_field" name="to" id="to" onChange="serialiseForm()">
+ <img class="date_field-img" id="to-img" src="extensions/BugModal/web/calendar.png" width="16" height="16">
+ </span>
+ <input type="checkbox" id="is_custom" onchange="selectRangeType()" [% "checked" IF is_custom %]>
+ <label for="is_custom">Custom</label>
</td>
</tr>
diff --git a/extensions/BMO/web/js/release_tracking_report.js b/extensions/BMO/web/js/release_tracking_report.js
index adad6feb5..c91222e0f 100644
--- a/extensions/BMO/web/js/release_tracking_report.js
+++ b/extensions/BMO/web/js/release_tracking_report.js
@@ -115,6 +115,10 @@ function invertFields() {
}
function onFormSubmit() {
+ if ($('#is_custom').is(':checked') && (!$('#from').val() || !$('#to').val())) {
+ alert('You must enter both the start and end dates.');
+ return false;
+ }
serialiseForm();
return true;
}
@@ -123,13 +127,32 @@ function onFormReset() {
deserialiseForm('');
}
+function selectRangeType() {
+ if ($('#is_custom').is(':checked')) {
+ $('#custom_range').show();
+ $('#fixed_range').hide();
+ }
+ else {
+ $('#custom_range').hide();
+ $('#fixed_range').show();
+ }
+ serialiseForm();
+}
+
function serialiseForm() {
var q = flagEl.value + ':' +
- $('#flag_value').val() + ':' +
- $('#range').val() + ':' +
- productEl.value + ':' +
- $('#op').val() + ':';
-
+ $('#flag_value').val() + ':';
+ if ($('#is_custom').is(':checked')) {
+ var from = $('#from').val();
+ var to = $('#to').val();
+ q = q + from.replace(/-/g, '') +
+ '-' + to.replace(/-/g, '');
+ }
+ else {
+ q = q + $('#range').val();
+ }
+ q = q + ':' + productEl.value + ':' +
+ $('#op').val() + ':';
for(var id in selectedFields) {
if (selectedFields[id]) {
q += selectedFields[id] + $('#' + id + '_select').val() + ':';
@@ -137,7 +160,9 @@ function serialiseForm() {
}
$('#q').val(q);
- $('#bookmark').attr('href', 'page.cgi?id=release_tracking_report.html&q=' + encodeURIComponent(q));
+ var is_custom = $('#is_custom').is(':checked') ? 1 : 0;
+ $('#bookmark').attr('href', 'page.cgi?id=release_tracking_report.html&is_custom=' +
+ is_custom + '&q=' + encodeURIComponent(q));
}
function deserialiseForm(q) {
@@ -145,7 +170,13 @@ function deserialiseForm(q) {
selectValue(flagEl, parts[0]);
onFlagChange();
selectValue($('#flag_value')[0], parts[1]);
- selectValue($('#range')[0], parts[2]);
+ if (!selectValue($('#range')[0], parts[2]) && parts[2]) {
+ var match = parts[2].match(/^(\d\d\d\d)(\d\d)(\d\d)-(\d\d\d\d)(\d\d)(\d\d)$/);
+ if (match) {
+ $('#from').val(match[1] + '-' + match[2] + '-' + match[3]);
+ $('#to').val(match[4] + '-' + match[5] + '-' + match[6]);
+ }
+ }
selectValue(productEl, parts[3]);
onProductChange();
selectValue($('#op')[0], parts[4]);
@@ -171,6 +202,23 @@ $().ready(function() {
trackingEl = $('#tracking_span')[0];
onFlagChange();
deserialiseForm(default_query);
+ selectRangeType();
+});
+
+$(function() {
+ $('.date_field').datetimepicker({
+ format: 'Y-m-d',
+ datepicker: true,
+ timepicker: false,
+ scrollInput: false,
+ lazyInit: false,
+ closeOnDateSelect: true
+ });
+ $('.date_field-img')
+ .click(function(event) {
+ var id = $(event.target).attr('id').replace(/-img$/, '');
+ $('#' + id).datetimepicker('show');
+ });
});
function getFlagByName(name) {
@@ -198,8 +246,9 @@ function selectValue(el, value) {
for(var i = 0, l = el.options.length; i < l; i++) {
if (el.options[i].value == value) {
el.options[i].selected = true;
- return;
+ return true;
}
}
el.options[0].selected = true;
+ return false;
}