mebil
[kivitendo-erp.git] / scripts / generate_client_js_actions.tpl
index 6572e22..9e21802 100644 (file)
@@ -4,10 +4,24 @@
 // "scripts/generate_client_js_actions.pl". See the documentation for
 // SL/ClientJS.pm for instructions.
 
-function eval_json_result(data) {
+namespace("kivi", function(ns) {
+ns.display_flash = function(type, message) {
+  $('#flash_' + type + '_content').text(message);
+  $('#flash_' + type).show();
+};
+
+ns.eval_json_result = function(data) {
   if (!data)
     return;
 
+  if (data.error)
+    return ns.display_flash('error', data.error);
+
+  $(['info', 'warning', 'error']).each(function(idx, category) {
+    $('#flash_' + category).hide();
+    $('#flash_' + category + '_content').empty();
+  });
+
   if ((data.js || '') != '')
     eval(data.js);
 
@@ -19,4 +33,10 @@ function eval_json_result(data) {
     });
 
   // console.log("current_content_type " + $('#current_content_type').val() + ' ID ' + $('#current_content_id').val());
-}
+};
+
+});
+
+// Local Variables:
+// mode: js
+// End: