maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH 2/2] Handle error of paper size ajax request and


From: Thomas Petazzoni
Subject: [Maposmatic-dev] [PATCH 2/2] Handle error of paper size ajax request and fix next link handling
Date: Sat, 14 Apr 2012 18:44:08 +0200

We now show an error when the Ajax request that fetches the compatible
paper sizes. We also fix some JS-code that shows/hide the prev/next
links in the wizard.

Signed-off-by: Thomas Petazzoni <address@hidden>
---
 www/media/js/newmap.js            |   59 +++++++++++++++++++++---------------
 www/templates/maposmatic/new.html |    1 +
 2 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/www/media/js/newmap.js b/www/media/js/newmap.js
index 78f2da4..37cfb5e 100644
--- a/www/media/js/newmap.js
+++ b/www/media/js/newmap.js
@@ -26,6 +26,26 @@
  * See the file COPYING for details.
  */
 
+/*
+ * Helper functions to hide/show the back/next links
+ */
+
+function allowPrevStep() {
+  $('#prevlink').addClass('allowed');
+}
+
+function disallowPrevStep() {
+  $("#prevlink").removeClass('allowed');
+}
+
+function allowNextStep() {
+  $("#nextlink").addClass('allowed');
+}
+
+function disallowNextStep() {
+  $("#nextlink").removeClass('allowed');
+}
+
 function mapTitleChange()
 {
   if ($("#id_maptitle").val().length != 0)
@@ -145,7 +165,8 @@ function preparePaperPanel()
   /* Start the Ajax request to get the list of allowed paper
    * sizes */
   $("#paperselection").hide();
-  $("#nextlink").hide();
+  disallowNextStep();
+  $("#papersizeerror").hide();
   if (getCurrentMode() == 'bbox') {
     args = {
       lat_upper_left   : $("#lat_upper_left").val(),
@@ -164,10 +185,18 @@ function preparePaperPanel()
     };
   }
 
-  $.post("/apis/papersize/", args,
-         function(data) { filterAllowedPaper(data);
-                          $("#nextlink").show()
-                        });
+  $.ajax({ type: 'POST',
+           url:  "/apis/papersize/",
+           data: args,
+           success: function(data) {
+                      filterAllowedPaper(data);
+                      allowNextStep();
+                    },
+           error: function(data) {
+                      $("#papersizeerror").show();
+                      disallowNextStep();
+                    },
+         });
 }
 
 /** When using a by admin boundary area, contains the country code of
@@ -264,26 +293,6 @@ function prepareNextPage(next)
         prepareLanguagePanel();
 }
 
-/*
- * Helper functions to hide/show the back/next links
- */
-
-function allowPrevStep() {
-  $('#prevlink').addClass('allowed');
-}
-
-function disallowPrevStep() {
-  $("#prevlink").removeClass('allowed');
-}
-
-function allowNextStep() {
-  $("#nextlink").addClass('allowed');
-}
-
-function disallowNextStep() {
-  $("#nextlink").removeClass('allowed');
-}
-
 /** Hide a panel and un-highlight the corresponding title in the
  * progress bar */
 function hidePanel(panel) {
diff --git a/www/templates/maposmatic/new.html 
b/www/templates/maposmatic/new.html
index fb41e70..c3df701 100644
--- a/www/templates/maposmatic/new.html
+++ b/www/templates/maposmatic/new.html
@@ -132,6 +132,7 @@
 
   <div id="step-paper" class="wizardstep">
     <h3>{% trans "Paper" %}</h3>
+    <span id="papersizeerror" style="display: none;">{% trans "An error 
occured while retrieving compatible paper sizes." %}</span>
     <table id="paperselection">
       <tr>
         <td id="papersizeselection">{{ form.papersize }}</td>
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]