From f39f0f4f02a035cb208c4ce208cf4b0f01e48e52 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 10 Feb 2016 10:08:33 +0000 Subject: 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. --- templates/web/base/questionnaire/index.html | 4 ---- templates/web/base/report/new/form_report.html | 4 ---- templates/web/base/report/update/form_update.html | 4 ---- templates/web/bromley/report/display.html | 4 ---- .../web/bromley/report/new/fill_in_details_form.html | 4 ---- templates/web/eastsussex/report/update-form.html | 4 ---- .../web/zurich/report/new/fill_in_details_form.html | 4 ---- web/cobrands/fixmystreet/fixmystreet.js | 19 ++++++++++--------- 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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 @@
[% IF upload_fileid %] -

[% 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).') %]

[% FOREACH id IN upload_fileid.split(',') %] 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; + }); } /* -- cgit v1.2.3