Commit f6f865af authored by Romain Courteaud's avatar Romain Courteaud 🐸

Desactivate submit icon on header in case of error.

Change the icon to an exclamation mark in case of error.
parent 5402bd2b
......@@ -147,6 +147,7 @@
loaded: false,\n
modified: false,\n
submitted: true,\n
error: false,\n
options: {}\n
};\n
})\n
......@@ -174,6 +175,16 @@
/////////////////////////////////////////////////////////////////\n
// declared methods\n
/////////////////////////////////////////////////////////////////\n
.declareMethod(\'notifyError\', function () {\n
this.stats.loaded = true;\n
this.stats.submitted = true;\n
this.stats.error = true;\n
var gadget = this;\n
return this.render(this.stats.options)\n
.push(function () {\n
gadget.stats.error = false;\n
});\n
})\n
.declareMethod(\'notifyLoading\', function () {\n
if (this.stats.loaded) {\n
this.stats.loaded = false;\n
......@@ -280,7 +291,9 @@
}\n
\n
// Handle right link\n
if (!gadget.stats.loaded) {\n
if (gadget.stats.error) {\n
default_right_icon = "exclamation";\n
} else if (!gadget.stats.loaded) {\n
default_right_icon = "spinner";\n
// Show default loading information\n
right_link = {\n
......@@ -315,6 +328,9 @@
title: possible_right_button_list[i][1],\n
icon: default_right_icon || possible_right_button_list[i][2]\n
};\n
if (gadget.stats.error) {\n
right_button.class = "ui-disabled";\n
}\n
}\n
}\n
if (right_button !== undefined) {\n
......@@ -509,7 +525,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>937.64299.47970.64017</string> </value>
<value> <string>938.142.63057.34594</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -527,7 +543,7 @@
</tuple>
<state>
<tuple>
<float>1412256721.33</float>
<float>1412343494.43</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -150,7 +150,7 @@
});\n
}\n
\n
function displayError(gadget, error) {\n
function displayErrorContent(gadget, error) {\n
// Do not break the application in case of errors.\n
// Display it to the user for now, and allow user to go back to the frontpage\n
var error_text = "";\n
......@@ -178,6 +178,24 @@
// XXX Improve error rendering\n
gadget.props.article.textContent = "Error: " + error_text;\n
}\n
\n
function displayError(gadget, error) {\n
return gadget.getDeclaredGadget("header")\n
.push(function (g) {\n
return g.notifyError();\n
})\n
.push(function () {\n
return displayErrorContent(gadget, error);\n
})\n
.push(function () {\n
return gadget.dropGadget("pg")\n
.push(undefined, function () {\n
// Do not crash the app if the pg gadget in not defined\n
// ie, keep the original error on screen\n
return;\n
});\n
});\n
}\n
\n
/////////////////////////////////////////////////////////////////\n
// Gadget behaviour\n
......@@ -532,7 +550,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>937.64000.63491.17493</string> </value>
<value> <string>938.273.44627.4590</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -550,7 +568,7 @@
</tuple>
<state>
<tuple>
<float>1412256764.71</float>
<float>1412347942.24</float>
<string>GMT</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment