aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-02-10 10:08:33 +0000
committerMatthew Somerville <matthew@mysociety.org>2016-02-10 10:08:33 +0000
commitf39f0f4f02a035cb208c4ce208cf4b0f01e48e52 (patch)
treee8486f21fc2e75b91cf79861eb57cbf56a7d9773
parentce25130c2a9789ad832848db1098f36065045673 (diff)
Show remembered uploaded photos when Back used.
The uploaded_files solution in cbdfcad6, to show already uploaded files stored in upload_fileid, worked if you submitted the form to the server and had it returned, but did not show remembered photos if you used the browser's Back button to return to the form from another page. Instead, always read the data from upload_fileid, which works whichever way you have come to the page. Fixes #1332.
-rw-r--r--templates/web/base/questionnaire/index.html4
-rw-r--r--templates/web/base/report/new/form_report.html4
-rw-r--r--templates/web/base/report/update/form_update.html4
-rw-r--r--templates/web/bromley/report/display.html4
-rw-r--r--templates/web/bromley/report/new/fill_in_details_form.html4
-rw-r--r--templates/web/eastsussex/report/update-form.html4
-rw-r--r--templates/web/zurich/report/new/fill_in_details_form.html4
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js19
8 files changed, 10 insertions, 37 deletions
diff --git a/templates/web/base/questionnaire/index.html b/templates/web/base/questionnaire/index.html
index c8b6907a1..5a5efee30 100644
--- a/templates/web/base/questionnaire/index.html
+++ b/templates/web/base/questionnaire/index.html
@@ -80,10 +80,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/templates/web/base/report/new/form_report.html b/templates/web/base/report/new/form_report.html
index a236b6a1f..d76d69ec0 100644
--- a/templates/web/base/report/new/form_report.html
+++ b/templates/web/base/report/new/form_report.html
@@ -29,10 +29,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this report. Note that you can attach a maximum of 3 to this report (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/templates/web/base/report/update/form_update.html b/templates/web/base/report/update/form_update.html
index 3a46694cf..40260886c 100644
--- a/templates/web/base/report/update/form_update.html
+++ b/templates/web/base/report/update/form_update.html
@@ -11,10 +11,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/templates/web/bromley/report/display.html b/templates/web/bromley/report/display.html
index 569275841..88a6fbddc 100644
--- a/templates/web/bromley/report/display.html
+++ b/templates/web/bromley/report/display.html
@@ -70,10 +70,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/templates/web/bromley/report/new/fill_in_details_form.html b/templates/web/bromley/report/new/fill_in_details_form.html
index 2f853b506..c953f53c7 100644
--- a/templates/web/bromley/report/new/fill_in_details_form.html
+++ b/templates/web/bromley/report/new/fill_in_details_form.html
@@ -58,10 +58,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this report. Note that you can attach a maximum of 3 to this report (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/templates/web/eastsussex/report/update-form.html b/templates/web/eastsussex/report/update-form.html
index 8c15db904..c2e445f22 100644
--- a/templates/web/eastsussex/report/update-form.html
+++ b/templates/web/eastsussex/report/update-form.html
@@ -70,10 +70,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/templates/web/zurich/report/new/fill_in_details_form.html b/templates/web/zurich/report/new/fill_in_details_form.html
index 1e036c087..d24474084 100644
--- a/templates/web/zurich/report/new/fill_in_details_form.html
+++ b/templates/web/zurich/report/new/fill_in_details_form.html
@@ -52,10 +52,6 @@
<div id="form_photos">
[% IF upload_fileid %]
- <script>
- var fixmystreet = fixmystreet || {};
- fixmystreet.uploaded_files = "[% upload_fileid %]".split(',');
- </script>
<p>[% loc('You have already attached photos to this report. Note that you can attach a maximum of 3 to this report (if you try to upload more, the oldest will be removed).') %]</p>
[% FOREACH id IN upload_fileid.split(',') %]
<img align="right" src="/photo/[% id %].temp.jpeg" alt="">
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 7c0a752d2..21701ce5f 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -246,15 +246,16 @@ $(function(){
}
});
- if (typeof fixmystreet !== 'undefined') {
- $.each(fixmystreet.uploaded_files || [], function(i, f) {
- var mockFile = { name: f, server_id: f };
- photodrop.emit("addedfile", mockFile);
- photodrop.createThumbnailFromUrl(mockFile, '/photo/' + f + '.temp.jpeg');
- photodrop.emit("complete", mockFile);
- photodrop.options.maxFiles -= 1;
- });
- }
+ $.each($('input[name=upload_fileid]').val().split(','), function(i, f) {
+ if (!f) {
+ return;
+ }
+ var mockFile = { name: f, server_id: f };
+ photodrop.emit("addedfile", mockFile);
+ photodrop.createThumbnailFromUrl(mockFile, '/photo/' + f + '.temp.jpeg');
+ photodrop.emit("complete", mockFile);
+ photodrop.options.maxFiles -= 1;
+ });
}
/*