[MERGE] Less intrusive timezone offset warning (comes with corresponding server branch)

bzr revid: odo@openerp.com-20121130175658-r3zvuhx75iqa5sus
This commit is contained in:
Olivier Dony 2012-11-30 18:56:58 +01:00
commit ab39c09a7b
4 changed files with 59 additions and 22 deletions

View File

@ -652,7 +652,7 @@
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 {
@ -795,6 +795,20 @@
.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;

View 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

View 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) {

View File

@ -462,6 +462,11 @@
<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">