From a95deb9f34a79efbe1a682b11d2a2146b82c40b5 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 7 Jun 2013 15:18:44 +0100 Subject: More explicable behaviour when you click cancel on the map screen If the report only has location details then just throw them away, otherwise leave the report as a draft and then create a new draft --- www/js/models/draft.js | 13 +++++++++++++ www/js/views/around.js | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'www/js') diff --git a/www/js/models/draft.js b/www/js/models/draft.js index b033f21..97a92ff 100644 --- a/www/js/models/draft.js +++ b/www/js/models/draft.js @@ -28,6 +28,19 @@ return desc; }, + isPartial: function() { + if ( + this.get('title') || + this.get('details') || + this.get('category') || + this.get('file') + ) { + return true; + } + + return false; + }, + createdDate: function() { return moment.utc( this.get('created') ).format( 'H:mm Do MMM' ); } diff --git a/www/js/views/around.js b/www/js/views/around.js index d1075f6..39d58e5 100644 --- a/www/js/views/around.js +++ b/www/js/views/around.js @@ -165,8 +165,12 @@ $('#view-my-reports').show(); $('#login-options').show(); $('#mark-here').show(); - this.model.set('lat', null); - this.model.set('lon', null); + if ( this.model.isPartial() ) { + FMS.clearCurrentDraft(); + } else { + this.model.set('lat', null); + this.model.set('lon', null); + } fixmystreet.markers.setVisibility(true); fixmystreet.select_feature.activate(); }, -- cgit v1.2.3