aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm21
-rw-r--r--t/app/controller/dashboard.t39
-rw-r--r--templates/web/base/dashboard/index.html42
-rw-r--r--templates/web/borsetshire/around/postcode_form.html9
-rw-r--r--web/cobrands/borsetshire/base.scss41
-rw-r--r--web/cobrands/borsetshire/layout.scss8
-rw-r--r--web/cobrands/fixmystreet/dashboard.scss22
-rw-r--r--web/cobrands/sass/_base.scss4
9 files changed, 159 insertions, 28 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5224b3fd..5289a2be6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,7 @@
a public update #1873
- Report field pre-filling for inspectors configurable #1854
- Admins can now unban users #1881
+ - Council dashboard has date range for report generation #1885
- UK:
- Use SVG logo, inlined on front page. #1887
- Inline critical CSS on front page.
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index f961660c0..7f4a4bb27 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -157,6 +157,27 @@ sub index : Path : Args(0) {
%$prob_where,
'me.confirmed' => { '>=', $dtf->format_datetime( $now->clone->subtract( days => 30 ) ) },
};
+
+ if ( $c->get_param('start_date') or $c->get_param('end_date') ) {
+ my @parts;
+ if ($c->get_param('start_date')) {
+ my $date = $dtf->parse_datetime( $c->get_param('start_date') );
+ push @parts, { '>=', $dtf->format_datetime( $date ) };
+ $c->stash->{start_date} = $c->get_param('start_date');
+ }
+ if ($c->get_param('end_date')) {
+ my $date = $dtf->parse_datetime( $c->get_param('end_date') );
+ push @parts, { '<=', $dtf->format_datetime( $date ) };
+ $c->stash->{end_date} = $c->get_param('end_date');
+ }
+
+ if (scalar @parts == 2) {
+ $params->{'me.confirmed'} = [ -and => $parts[0], $parts[1] ];
+ } else {
+ $params->{'me.confirmed'} = $parts[0];
+ }
+ }
+
my $problems_rs = $c->cobrand->problems->to_body($body)->search( $params );
my @problems = $problems_rs->all;
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t
index 14bd76c41..3a22d4280 100644
--- a/t/app/controller/dashboard.t
+++ b/t/app/controller/dashboard.t
@@ -634,6 +634,45 @@ FixMyStreet::override_config {
is $rows[5]->[15], '610591', 'Correct Easting conversion';
is $rows[5]->[16], '126573', 'Correct Northing conversion';
};
+
+ delete_problems();
+ subtest 'check date restriction' => sub {
+ make_problem({ state => 'confirmed', conf_dt => DateTime->now->subtract( 'days' => 1 ) });
+ make_problem({ state => 'confirmed', conf_dt => DateTime->now->subtract( 'days' => 50 ) });
+ make_problem({ state => 'confirmed', conf_dt => DateTime->now->subtract( 'days' => 31 ) });
+
+ $mech->get_ok('/dashboard?export=1');
+ open my $data_handle, '<', \$mech->content;
+ my $csv = Text::CSV->new( { binary => 1 } );
+ my @rows;
+ while ( my $row = $csv->getline( $data_handle ) ) {
+ push @rows, $row;
+ }
+
+ is scalar @rows, 2, '1 (header) + 1 (reports) = 2 lines';
+
+ $mech->get_ok('/dashboard?export=1&start_date=' . DateTime->now->subtract('days' => 32)->ymd);
+
+ open $data_handle, '<', \$mech->content;
+ $csv = Text::CSV->new( { binary => 1 } );
+ @rows = ();
+ while ( my $row = $csv->getline( $data_handle ) ) {
+ push @rows, $row;
+ }
+
+ is scalar @rows, 3, '1 (header) + 2 (reports) = 3 lines';
+
+ $mech->get_ok('/dashboard?export=1&start_date=' . DateTime->now->subtract('days' => 51)->ymd . '&end_date=' . DateTime->now->subtract('days' => 49)->ymd );
+
+ open $data_handle, '<', \$mech->content;
+ $csv = Text::CSV->new( { binary => 1 } );
+ @rows = ();
+ while ( my $row = $csv->getline( $data_handle ) ) {
+ push @rows, $row;
+ }
+
+ is scalar @rows, 2, '1 (header) + 1 (reports) = 2 lines';
+ };
};
restore_time;
diff --git a/templates/web/base/dashboard/index.html b/templates/web/base/dashboard/index.html
index e47798573..d7ad6ddfa 100644
--- a/templates/web/base/dashboard/index.html
+++ b/templates/web/base/dashboard/index.html
@@ -34,11 +34,9 @@
</select>
</p>
- <p>
+ <p class="no-label">
<input type="submit" class="btn" value="[% loc('Look up') %]">
</p>
-
- <br clear="all" />
</div>
@@ -133,18 +131,32 @@
<h2>[% loc('Reports') %]</h2>
- </select>
-<p>[% loc('Report state:') %] <select class="form-control" name="state">
-<option value=''>[% loc('All') %]</option>
- [% FOR group IN filter_states %]
- [% FOR state IN group.1 %]
- [% NEXT IF state == 'hidden' %]
- <option [% 'selected ' IF state == q_state %] value="[% state %]">[% prettify_state(state, 1) %]</option>
- [% END %]
- [% END %]
-</select>
-<input type="submit" class="btn" value="[% loc('Look up') %]">
-<a class="export_as_csv" href="[% c.req.uri_with({ export => 1 }) %]">[% loc('Export as CSV') %]</a>
+<div class="filters">
+ <p>
+ <label for="state">[% loc('Report state:') %]</label>
+ <select class="form-control" name="state">
+ <option value=''>[% loc('All') %]</option>
+ [% FOR group IN filter_states %]
+ [% FOR state IN group.1 %]
+ [% NEXT IF state == 'hidden' %]
+ <option [% 'selected ' IF state == q_state %] value="[% state %]">[% prettify_state(state, 1) %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ </p>
+ <p>
+ <label for="start_date">[% loc('Start Date') %]</label>
+ <input name="start_date" type="date" value="[% start_date | html %]" class="form-control">
+ </p>
+ <p>
+ <label for="end_date">[% loc('End Date') %]</label>
+ <input name="end_date" type="date" value="[% end_date | html %]" class="form-control">
+ </p>
+ <p class="no-label">
+ <input type="submit" class="btn" value="[% loc('Look up') %]">
+ <a class="btn export_as_csv" href="[% c.req.uri_with({ export => 1 }) %]">[% loc('Export as CSV') %]</a>
+ </p>
+</div>
<table width="100%" id="reports">
<tr>
diff --git a/templates/web/borsetshire/around/postcode_form.html b/templates/web/borsetshire/around/postcode_form.html
index bb4accf26..4ad82dec6 100644
--- a/templates/web/borsetshire/around/postcode_form.html
+++ b/templates/web/borsetshire/around/postcode_form.html
@@ -1,3 +1,12 @@
+[% UNLESS c.user_exists %]
+<div class="homepage-login-hint">
+ <div class="container">
+ <h2>Psssst… Want to see behind the curtain?</h2>
+ <p>Try out FixMyStreet as a customer service rep, a highways inspector, or a site administrator. <a href="/auth">Sign in</a> to begin!</p>
+ </div>
+</div>
+[% END %]
+
<div id="front-main">
<div id="front-main-container">
[% INCLUDE 'around/intro.html' %]
diff --git a/web/cobrands/borsetshire/base.scss b/web/cobrands/borsetshire/base.scss
index efd729545..f5113e0be 100644
--- a/web/cobrands/borsetshire/base.scss
+++ b/web/cobrands/borsetshire/base.scss
@@ -22,3 +22,44 @@
.site-header__fake-nav {
display: none;
}
+
+.homepage-login-hint {
+ padding: 1.5em 0;
+ background-color: rgb(0, 61, 101);
+ background-color: darken($color-borsetshire-blue, 20%);
+ color: #fff;
+
+ .container {
+ position: relative;
+
+ // Little arrow.
+ &:before {
+ content: "";
+ display: block;
+ width: 0;
+ height: 0;
+ position: absolute;
+ border: 0.5em solid transparent;
+ border-top-width: 0;
+ border-bottom-color: darken($color-borsetshire-blue, 20%);
+ top: -1.5em;
+ right: 1em;
+ margin-top: -0.5em;
+ }
+ }
+
+ h2 {
+ margin: 0;
+ font-size: 1.3em;
+ }
+
+ p {
+ margin: 0.5em 0 0 0;
+ }
+
+ a {
+ font-weight: bold;
+ color: inherit;
+ text-decoration: underline;
+ }
+}
diff --git a/web/cobrands/borsetshire/layout.scss b/web/cobrands/borsetshire/layout.scss
index f4234d55f..6aa7f5801 100644
--- a/web/cobrands/borsetshire/layout.scss
+++ b/web/cobrands/borsetshire/layout.scss
@@ -46,3 +46,11 @@
margin: 0 0.5em 0 0;
}
}
+
+.homepage-login-hint {
+ .container {
+ &:before {
+ right: 16.4em;
+ }
+ }
+}
diff --git a/web/cobrands/fixmystreet/dashboard.scss b/web/cobrands/fixmystreet/dashboard.scss
index fb4fd7a8a..3e0de0d2b 100644
--- a/web/cobrands/fixmystreet/dashboard.scss
+++ b/web/cobrands/fixmystreet/dashboard.scss
@@ -5,8 +5,6 @@
}
#overview {
- margin-top: 1em;
-
th[scope=col] {
font-size:0.8em;
}
@@ -66,22 +64,25 @@
}
}
- .filters{
+ .filters {
+ @include clearfix();
background-color:#ffec99;
- margin:0 -1em;
+ margin: 0 -1em 1em -1em;
border-top:#ffd000 solid 0.75em;
padding:0 1em;
p {
float: $left;
padding:0 1em;
- width:25%;
+ max-width:25%;
font-size:0.75em;
color:#333333;
- input {
- margin-top: 2.5em;
- }
}
+
+ .no-label {
+ margin-top: 1.25em + 1.5em + 0.5em; // label line-height + margin-top + margin-bottom
+ }
+
select {
width:100%;
}
@@ -98,8 +99,3 @@
font-size:2.25em;
}
}
-
- .export_as_csv {
- font-size: 0.75em;
- font-weight: bold;
- }
diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss
index 016967457..27cb8fded 100644
--- a/web/cobrands/sass/_base.scss
+++ b/web/cobrands/sass/_base.scss
@@ -233,6 +233,10 @@ input[type=number],
input[type=text],
input[type=password],
input[type=email],
+input[type=date],
+input[type=time],
+input[type=datetime],
+input[type=url],
textarea {
@include box-sizing(border-box);
display: block;