[MERGE] Less intrusive timezone offset warning (comes with corresponding server branch)
authorOlivier Dony <odo@openerp.com>
Fri, 30 Nov 2012 17:56:58 +0000 (18:56 +0100)
committerOlivier Dony <odo@openerp.com>
Fri, 30 Nov 2012 17:56:58 +0000 (18:56 +0100)
bzr revid: odo@openerp.com-20121130175658-r3zvuhx75iqa5sus

addons/web/static/src/css/base.css
addons/web/static/src/css/base.sass
addons/web/static/src/js/chrome.js
addons/web/static/src/xml/base.xml

index a71a071..ac8efd6 100644 (file)
   cursor: pointer;
 }
 .openerp .oe_dropdown_toggle {
-  color: #4C4C4C;
+  color: #4c4c4c;
   font-weight: normal;
 }
 .openerp .oe_dropdown_hover:hover .oe_dropdown_menu, .openerp .oe_dropdown_menu.oe_opened {
 .openerp .oe_notification {
   z-index: 1050;
 }
+.openerp .oe_webclient_timezone_notification a {
+  color: white;
+  text-decoration: underline;
+}
+.openerp .oe_webclient_timezone_notification p {
+  margin-top: 1em;
+}
+.openerp .oe_webclient_timezone_notification dt {
+  font-weight: bold;
+}
+.openerp .oe_timezone_systray span {
+  margin-top: 1px;
+  background-color: #f6cf3b;
+}
 .openerp .oe_login {
   background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAKUlEQVQIHWO8e/fufwYsgAUkJigoiCIF5DMyoYggcUiXgNnBiGQKmAkARpcEQeriln4AAAAASUVORK5CYII=);
   text-align: center;
index f634452..c320230 100644 (file)
@@ -671,9 +671,21 @@ $sheet-padding: 16px
         border-bottom-right-radius: 8px
         border-bottom-left-radius: 8px
     // }}}
-    // Notification {{{
+    // Notifications {{{
     .oe_notification
         z-index: 1050
+    .oe_webclient_timezone_notification
+        a
+            color: white
+            text-decoration: underline
+        p
+            margin-top: 1em
+        dt
+            font-weight: bold
+    .oe_timezone_systray
+        span
+            margin-top: 1px
+            background-color: #f6cf3b
     // }}}
     // Login {{{
     .oe_login
index 875ca38..cc7b267 100644 (file)
@@ -1167,26 +1167,32 @@ instance.web.WebClient = instance.web.Client.extend({
     },
     check_timezone: function() {
         var self = this;
-        var user_offset = instance.session.user_context.tz_offset;
-        var offset = -(new Date().getTimezoneOffset());
-        // _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually
-        var browser_offset = (offset < 0) ? "-" : "+";
-        browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60));
-        browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60));
-        if (browser_offset !== user_offset) {
-            var notification = this.do_warn(_t("Timezone"), QWeb.render('WebClient.timezone_notification', {
-                user_timezone: instance.session.user_context.tz || 'UTC',
-                user_offset: user_offset,
-                browser_offset: browser_offset,
-            }), true);
-            notification.element.find('.oe_webclient_timezone_notification').on('click', function() {
-                notification.close();
-            }).find('a').on('click', function() {
-                notification.close();
-                self.user_menu.on_menu_settings();
-                return false;
-            });
-        }
+        return new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']]).then(function(result) {
+            var user_offset = result[0]['tz_offset'];
+            var offset = -(new Date().getTimezoneOffset());
+            // _.str.sprintf()'s zero front padding is buggy with signed decimals, so doing it manually
+            var browser_offset = (offset < 0) ? "-" : "+";
+            browser_offset += _.str.sprintf("%02d", Math.abs(offset / 60));
+            browser_offset += _.str.sprintf("%02d", Math.abs(offset % 60));
+            if (browser_offset !== user_offset) {
+                var $icon = $(QWeb.render('WebClient.timezone_systray'));
+                $icon.on('click', function() {
+                    var notification = self.do_warn(_t("Timezone mismatch"), QWeb.render('WebClient.timezone_notification', {
+                        user_timezone: instance.session.user_context.tz || 'UTC',
+                        user_offset: user_offset,
+                        browser_offset: browser_offset,
+                    }), true);
+                    notification.element.find('.oe_webclient_timezone_notification').on('click', function() {
+                        notification.close();
+                    }).find('a').on('click', function() {
+                        notification.close();
+                        self.user_menu.on_menu_settings();
+                        return false;
+                    });
+                });
+                $icon.appendTo(self.$('.oe_systray'));
+            }
+        });
     },
     destroy_content: function() {
         _.each(_.clone(this.getChildren()), function(el) {
index 62d8a87..65c96d0 100644 (file)
         <p><a href="#">Click here to change your user's timezone.</a></p>
     </div>
 </t>
+<t t-name="WebClient.timezone_systray">
+    <div class="oe_topbar_item oe_timezone_systray" title="Timezone mismatch">
+        <span class="ui-icon ui-state-error ui-icon-alert"/>
+    </div>
+</t>
 
 <t t-name="EmbedClient">
     <div class="openerp">