aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm13
-rw-r--r--perllib/FixMyStreet/App/Model/DB.pm11
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm6
-rw-r--r--perllib/FixMyStreet/DB/Schema.pm2
-rw-r--r--templates/web/base/report/_item.html2
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js8
7 files changed, 36 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4cc06e07a..775328559 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@
- Include MapIt API key on admin config page. #1778
- Bugfixes:
- Set up action scheduled field when report loaded. #1789
+ - Fix display of thumbnail images on page reload. #1815
- Fix sidebar hover behaviour being lost. #1808
- Stop errors from JS validator due to form in form.
- Stop update form toggle causing report submission.
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 20ec8f0a2..b597cb7a8 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -414,8 +414,17 @@ sub load_and_group_problems : Private {
order_by => $c->stash->{sort_order},
rows => $c->cobrand->reports_per_page,
};
- if ($c->user_exists && $c->stash->{body} && $c->user->has_permission_to('planned_reports', $c->stash->{body}->id)) {
- $filter->{prefetch} = 'user_planned_reports';
+ if ($c->user_exists && $c->stash->{body}) {
+ my $bid = $c->stash->{body}->id;
+ my $prefetch = [];
+ if ($c->user->has_permission_to('planned_reports', $bid)) {
+ push @$prefetch, 'user_planned_reports';
+ }
+ if ($c->user->has_permission_to('report_edit_priority', $bid) || $c->user->has_permission_to('report_inspect', $bid)) {
+ push @$prefetch, 'response_priority';
+ }
+ $prefetch = $prefetch->[0] if @$prefetch == 1;
+ $filter->{prefetch} = $prefetch;
}
if (defined $c->stash->{filter_status}{shortlisted}) {
diff --git a/perllib/FixMyStreet/App/Model/DB.pm b/perllib/FixMyStreet/App/Model/DB.pm
index 9d09186b8..ffd867485 100644
--- a/perllib/FixMyStreet/App/Model/DB.pm
+++ b/perllib/FixMyStreet/App/Model/DB.pm
@@ -5,19 +5,28 @@ use strict;
use warnings;
use FixMyStreet;
+use Moose;
+
+with 'Catalyst::Component::InstancePerContext';
__PACKAGE__->config(
schema_class => 'FixMyStreet::DB::Schema',
connect_info => sub { FixMyStreet::DB->schema->storage->dbh },
);
+sub build_per_context_instance {
+ my ( $self, $c ) = @_;
+ $self->schema->cache({});
+ return $self;
+}
+
=head1 NAME
FixMyStreet::App::Model::DB - Catalyst DBIC Schema Model
=head1 DESCRIPTION
-L<Catalyst::Model::DBIC::Schema> Model using schema L<FixMyStreet::DB>
+L<Catalyst::Model::DBIC::Schema> Model using schema L<FixMyStreet::DB::Schema>
=cut
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 19e76f6ed..0d1b396a9 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -508,12 +508,16 @@ has bodies => (
default => sub {
my $self = shift;
return {} unless $self->bodies_str;
+ my $cache = $self->result_source->schema->cache;
+ return $cache->{bodies}{$self->bodies_str} if $cache->{bodies}{$self->bodies_str};
+
my $bodies = $self->bodies_str_ids;
my @bodies = $self->result_source->schema->resultset('Body')->search(
{ id => $bodies },
{ prefetch => 'body_areas' },
)->all;
- return { map { $_->id => $_ } @bodies };
+ $cache->{bodies}{$self->bodies_str} = { map { $_->id => $_ } @bodies };
+ return $cache->{bodies}{$self->bodies_str};
},
);
diff --git a/perllib/FixMyStreet/DB/Schema.pm b/perllib/FixMyStreet/DB/Schema.pm
index 45d731c33..10bbd434f 100644
--- a/perllib/FixMyStreet/DB/Schema.pm
+++ b/perllib/FixMyStreet/DB/Schema.pm
@@ -25,4 +25,6 @@ __PACKAGE__->connection(FixMyStreet->dbic_connect_info);
has lang => ( is => 'rw' );
+has cache => ( is => 'rw', lazy => 1, default => sub { {} } );
+
1;
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index a892086ca..153fbf58e 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -43,7 +43,7 @@
<span class="item-list__item__state">[% loc('Fixed') %]</span>
[% ELSIF NOT no_fixed AND problem.is_closed %]
<span class="item-list__item__state">[% loc('Closed') %]</span>
- [% ELSIF problem.response_priority AND (c.user.has_permission_to('report_edit_priority', problem.bodies_str_ids) OR c.user.has_permission_to('report_inspect', problem.bodies_str_ids)) %]
+ [% ELSIF (c.user.has_permission_to('report_edit_priority', problem.bodies_str_ids) OR c.user.has_permission_to('report_inspect', problem.bodies_str_ids)) AND problem.response_priority %]
<span class="item-list__item__state">[% problem.response_priority.name %]</span>
[% END %]
[%- IF c.cobrand.moniker != 'fixamingata' %] [%# Default: %]
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 246a97b51..39117be4a 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -579,9 +579,13 @@ $.extend(fixmystreet.set_up, {
if (!f) {
return;
}
- var mockFile = { name: f, server_id: f };
+ var mockFile = { name: f, server_id: f, dataURL: '/photo/temp.' + f };
photodrop.emit("addedfile", mockFile);
- photodrop.createThumbnailFromUrl(mockFile, '/photo/temp.' + f);
+ photodrop.createThumbnailFromUrl(mockFile,
+ photodrop.options.thumbnailWidth, photodrop.options.thumbnailHeight,
+ photodrop.options.thumbnailMethod, true, function(thumbnail) {
+ photodrop.emit('thumbnail', mockFile, thumbnail);
+ });
photodrop.emit("complete", mockFile);
photodrop.options.maxFiles -= 1;
});