Christophe (OpenERP) has proposed merging 
lp:~openerp-dev/openerp-web/trunk-notif-chs into lp:openerp-web.

Requested reviews:
  OpenERP R&D Web Team (openerp-dev-web)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-notif-chs/+merge/79248
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-notif-chs/+merge/79248
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-notif-chs.
=== modified file 'addons/web/static/src/js/chrome.js'
--- addons/web/static/src/js/chrome.js	2011-10-13 08:14:45 +0000
+++ addons/web/static/src/js/chrome.js	2011-10-13 10:31:33 +0000
@@ -5,15 +5,11 @@
 var QWeb = openerp.web.qweb;
 
 openerp.web.Notification =  openerp.web.Widget.extend(/** @lends openerp.web.Notification# */{
-    /**
-     * @constructs openerp.web.Notification
-     * @extends openerp.web.Widget
-     *
-     * @param parent
-     * @param element_id
-     */
-    init: function(parent, element_id) {
-        this._super(parent, element_id);
+    template: 'Notification',
+    identifier_prefix: 'notification-',
+
+    start: function() {
+        this._super.apply(this, arguments);
         this.$element.notify({
             speed: 500,
             expires: 1500
@@ -28,10 +24,39 @@
     warn: function(title, text) {
         this.$element.notify('create', 'oe_notification_alert', {
             title: title,
-            text: text
+            text: text,
+        }, {
+            expires: false,
         });
-    }
-});
+    },
+    
+    do_notify: function() { this.notify.apply(this, arguments); },
+    do_warn: function() {this.warn.apply(this, arguments); },
+
+});
+
+openerp.web.NotifiableWidget = openerp.web.Widget.extend({
+
+    init: function(/*arguments*/) {
+        this._super.apply(this, arguments);
+        this.notification = new openerp.web.Notification(this);
+    },
+
+    start: function() {
+        this._super.apply(this, arguments);
+        this.notification.prependTo(this.$element);
+    },
+
+    stop: function() {
+        this.notification.stop();
+        return this._super.apply(this, arguments);
+    },
+
+    do_notify: function() { this.notification.notify.apply(this.notification, arguments); },
+    do_warn: function() { this.notification.warn.apply(this.notification, arguments); },
+});
+
+
 
 openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# */{
     dialog_title: "",
@@ -369,7 +394,7 @@
                     }
                     $db_list.find(':selected').remove();
                     self.db_list.splice(_.indexOf(self.db_list, db, true), 1);
-                    self.notification.notify("Dropping database", "The database '" + db + "' has been dropped");
+                    self.do_notify("Dropping database", "The database '" + db + "' has been dropped");
                 });
             }
         });
@@ -454,7 +479,7 @@
                         self.display_error(result);
                         return;
                     }
-                    self.notification.notify("Changed Password", "Password has been changed successfully");
+                    self.do_notify("Changed Password", "Password has been changed successfully");
                 });
             }
         });
@@ -920,7 +945,7 @@
     }
 });
 
-openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClient */{
+openerp.web.WebClient = openerp.web.NotifiableWidget.extend(/** @lends openerp.web.WebClient */{
     /**
      * @constructs openerp.web.WebClient
      * @extends openerp.web.Widget
@@ -943,9 +968,6 @@
         this.crashmanager =  new openerp.web.CrashManager(this);
         this.crashmanager.start();
 
-        // Do you autorize this ? will be replaced by notify() in controller
-        openerp.web.Widget.prototype.notification = new openerp.web.Notification(this, "oe_notification");
-
         this.header = new openerp.web.Header(this);
         this.login = new openerp.web.Login(this);
         this.header.on_logout.add(this.login.on_logout);
@@ -965,6 +987,7 @@
 
     },
     start: function() {
+        this._super.apply(this, arguments);
         this.header.appendTo($("#oe_header"));
         this.session.start();
         this.login.appendTo($('#oe_login'));
@@ -1058,7 +1081,8 @@
         this.action_manager.do_action(action);
     },
     do_about: function() {
-    }
+    },
+
 });
 
 };

=== modified file 'addons/web/static/src/js/search.js'
--- addons/web/static/src/js/search.js	2011-10-07 08:29:05 +0000
+++ addons/web/static/src/js/search.js	2011-10-13 10:31:33 +0000
@@ -336,7 +336,7 @@
      * @param {Array} errors a never-empty array of error objects
      */
     on_invalid: function (errors) {
-        this.notification.notify("Invalid Search", "triggered from search view");
+        this.do_notify("Invalid Search", "triggered from search view");
     },
     do_clear: function () {
         this.$element.find('.filter_label, .filter_icon').removeClass('enabled');

=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2011-10-13 09:38:14 +0000
+++ addons/web/static/src/js/view_form.js	2011-10-13 10:31:33 +0000
@@ -443,7 +443,7 @@
             }
         });
         msg += "</ul>";
-        this.notification.warn("The following fields are invalid :", msg);
+        this.do_warn("The following fields are invalid :", msg);
     },
     on_saved: function(r, success) {
         if (!r.result) {
@@ -616,7 +616,7 @@
                 ids: [parseInt($e.attr('data-id'))]
             }, function(r) {
                 $e.parent().remove();
-                self.notification.notify("Delete an attachment", "The attachment '" + name + "' has been deleted");
+                self.do_notify("Delete an attachment", "The attachment '" + name + "' has been deleted");
             });
         }
     }
@@ -1202,7 +1202,7 @@
     },
     on_button_clicked: function() {
         if (!this.value || !this.is_valid()) {
-            this.notification.warn("E-mail error", "Can't send email to invalid e-mail address");
+            this.do_warn("E-mail error", "Can't send email to invalid e-mail address");
         } else {
             location.href = 'mailto:' + this.value;
         }
@@ -1217,7 +1217,7 @@
     },
     on_button_clicked: function() {
         if (!this.value) {
-            this.notification.warn("Resource error", "This resource is empty");
+            this.do_warn("Resource error", "This resource is empty");
         } else {
             window.open(this.value);
         }
@@ -2633,7 +2633,7 @@
     on_file_uploaded: function(size, name, content_type, file_base64) {
         delete(window[this.iframe]);
         if (size === false) {
-            this.notification.warn("File Upload", "There was a problem while uploading your file");
+            this.do_warn("File Upload", "There was a problem while uploading your file");
             // TODO: use openerp web crashmanager
             console.warn("Error while uploading file : ", name);
         } else {
@@ -2647,7 +2647,7 @@
     },
     on_save_as: function() {
         if (!this.view.datarecord.id) {
-            this.notification.warn("Can't save file", "The record has not yet been saved");
+            this.do_warn("Can't save file", "The record has not yet been saved");
         } else {
             var url = '/web/binary/saveas?session_id=' + this.session.session_id + '&model=' +
                 this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name +

=== modified file 'addons/web/static/src/js/views.js'
--- addons/web/static/src/js/views.js	2011-10-13 08:14:45 +0000
+++ addons/web/static/src/js/views.js	2011-10-13 10:31:33 +0000
@@ -902,7 +902,7 @@
         if (this.fields_view && this.fields_view.arch) {
             $('<xmp>' + db.web.json_node_to_xml(this.fields_view.arch, true) + '</xmp>').dialog({ width: '95%', height: 600});
         } else {
-            this.notification.warn("Manage Views", "Could not find current view declaration");
+            this.do_warn("Manage Views", "Could not find current view declaration");
         }
     },
     on_sidebar_edit_workflow: function() {

=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml	2011-10-12 13:57:35 +0000
+++ addons/web/static/src/xml/base.xml	2011-10-13 10:31:33 +0000
@@ -2,9 +2,10 @@
 <!-- vim:fdl=1:
 -->
 <templates id="template" xml:space="preserve">
-<t t-name="Interface">
-    <div id="oe_loading" class="loading"></div>
-    <div id="oe_notification" class="oe_notification">
+
+
+    <t t-name="Notification">
+        <div class="oe_notification">
         <div id="oe_notification_default">
             <a class="ui-notify-cross ui-notify-close" href="#">x</a>
             <h1>#{title}</h1>
@@ -16,7 +17,10 @@
             <h1>#{title}</h1>
             <p>#{text}</p>
         </div>
-    </div>
+        </div>
+    </t>
+<t t-name="Interface">
+    <div id="oe_loading" class="loading"></div>
     <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" class="main_table">
     <tr>
         <td colspan="2" valign="top">

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to