summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorNiko <nwi@openerp.com>2012-12-20 11:03:14 +0100
committerNiko <nwi@openerp.com>2012-12-20 11:03:14 +0100
commitfb07bf7234eeafffd6a7e9c85d48c6ed0ebf1887 (patch)
treeab720b42e26fd1aad6223433c6ed888f43f79f88 /addons/web/static/src
parent988b89a02ce7cdd129a5e7ee05e2be18dd6347c9 (diff)
parent2315050bab19cd1ec7e087a6751c3ca96d6c34e6 (diff)
[MERGE] merge with trunk
bzr revid: nwi@openerp.com-20121220100314-98ka2wahul3lbu57
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/css/base.css29
-rw-r--r--addons/web/static/src/css/base.sass23
-rw-r--r--addons/web/static/src/css/full.css8
-rw-r--r--addons/web/static/src/js/chrome.js114
-rw-r--r--addons/web/static/src/js/coresetup.js11
-rw-r--r--addons/web/static/src/js/view_form.js20
-rw-r--r--addons/web/static/src/js/view_list.js2
-rw-r--r--addons/web/static/src/xml/base.xml23
8 files changed, 180 insertions, 50 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css
index 93fae7ce3a5..c43a2ba10d2 100644
--- a/addons/web/static/src/css/base.css
+++ b/addons/web/static/src/css/base.css
@@ -819,6 +819,16 @@
margin-top: 1px;
background-color: #f6cf3b;
}
+.openerp .oe_dialog_warning {
+ width: 100%;
+}
+.openerp .oe_dialog_warning p {
+ text-align: center;
+}
+.openerp .oe_dialog_icon {
+ padding: 5px;
+ width: 32px;
+}
.openerp .oe_login {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAKUlEQVQIHWO8e/fufwYsgAUkJigoiCIF5DMyoYggcUiXgNnBiGQKmAkARpcEQeriln4AAAAASUVORK5CYII=);
text-align: center;
@@ -1182,6 +1192,7 @@
padding-bottom: 16px;
}
.openerp a.oe_logo {
+ position: relative;
width: 220px;
display: block;
text-align: center;
@@ -1190,6 +1201,24 @@
margin: 14px 0;
border: 0;
}
+.openerp a.oe_logo .oe_logo_edit {
+ margin: 14px 0;
+ position: absolute;
+ top: 1px;
+ padding: 4px;
+ width: 100%;
+ display: none;
+ text-align: center;
+ color: #eeeeee;
+ background: rgba(37, 37, 37, 0.9);
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.openerp a.oe_logo:hover .oe_logo_edit_admin {
+ display: block;
+}
.openerp .oe_footer {
position: fixed;
bottom: 0;
diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass
index 30f88678c79..5ab7332be7f 100644
--- a/addons/web/static/src/css/base.sass
+++ b/addons/web/static/src/css/base.sass
@@ -696,6 +696,15 @@ $sheet-padding: 16px
margin-top: 1px
background-color: #f6cf3b
// }}}
+ // CrashManager {{{
+ .oe_dialog_warning
+ width: 100%
+ p
+ text-align: center
+ .oe_dialog_icon
+ padding: 5px
+ width: 32px
+ // }}}
// Login {{{
.oe_login
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAKUlEQVQIHWO8e/fufwYsgAUkJigoiCIF5DMyoYggcUiXgNnBiGQKmAkARpcEQeriln4AAAAASUVORK5CYII=)
@@ -958,12 +967,26 @@ $sheet-padding: 16px
text-shadow: 0 1px 1px white
padding-bottom: 16px
a.oe_logo
+ position: relative
width: 220px
display: block
text-align: center
img
margin: 14px 0
border: 0
+ .oe_logo_edit
+ margin: 14px 0
+ position: absolute
+ top: 1px
+ padding: 4px
+ width: 100%
+ display: none
+ text-align: center
+ color: #eee
+ background: rgba(37,37,37,0.9)
+ @include box-sizing(border)
+ &:hover .oe_logo_edit_admin
+ display: block
.oe_footer
position: fixed
bottom: 0
diff --git a/addons/web/static/src/css/full.css b/addons/web/static/src/css/full.css
index 7f3a2f60ea4..2692792d46d 100644
--- a/addons/web/static/src/css/full.css
+++ b/addons/web/static/src/css/full.css
@@ -1,6 +1,12 @@
+/* This css contains the styling specific to the 'normal mode'. (as opposite to the embedded mode) */
+/* In embedded mode [1], this stylesheet won't be loaded. */
+
+/* [1] The web client features an embedded mode in which the webclient */
+/* or a part of it can be started in any element of any webpage host. */
+
body {
padding: 0;
margin: 0;
overflow-y: scroll;
height: 100%;
-} \ No newline at end of file
+}
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 9e5a5936089..db418eb6827 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -691,6 +691,7 @@ instance.web.Login = instance.web.Widget.extend({
});
instance.web.client_actions.add("login", "instance.web.Login");
+
/**
* Redirect to url by replacing window.location
* If wait is true, sleep 1s and wait for the server i.e. after a restart.
@@ -804,6 +805,7 @@ instance.web.Menu = instance.web.Widget.extend({
this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
this.data = {data:{children:[]}};
this.on("menu_loaded", this, function (menu_data) {
+ self.reflow();
// launch the fetch of needaction counters, asynchronous
if (!_.isEmpty(menu_data.all_menu_ids)) {
this.rpc("/web/menu/load_needaction", {menu_ids: menu_data.all_menu_ids}).done(function(r) {
@@ -811,6 +813,11 @@ instance.web.Menu = instance.web.Widget.extend({
});
}
});
+ var lazyreflow = _.debounce(this.reflow.bind(this), 200);
+ instance.web.bus.on('resize', this, function() {
+ self.$el.height(0);
+ lazyreflow();
+ });
},
start: function() {
this._super.apply(this, arguments);
@@ -828,12 +835,6 @@ instance.web.Menu = instance.web.Widget.extend({
var self = this;
this.data = {data: data};
this.renderElement();
- this.limit_entries();
- // Hide toplevel item if there is only one
- var $toplevel = this.$("li");
- if($toplevel.length == 1) {
- $toplevel.hide();
- }
this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
this.$el.on('click', 'a[data-menu]', this.on_menu_click);
// Hide second level submenus
@@ -855,24 +856,35 @@ instance.web.Menu = instance.web.Widget.extend({
}
});
},
- limit_entries: function() {
- var maximum_visible_links = this.maximum_visible_links;
- if (maximum_visible_links === 'auto') {
- maximum_visible_links = this.auto_limit_entries();
- }
- if (maximum_visible_links < this.data.data.children.length) {
- var $more = $(QWeb.render('Menu.more')),
- $index = this.$el.find('li').eq(maximum_visible_links - 1);
- $index.after($more);
- //$('.oe_topbar').append($more);
- $more.find('.oe_menu_more').append($index.next().nextAll());
+ /**
+ * Reflow the menu items and dock overflowing items into a "More" menu item.
+ * Automatically called when 'menu_loaded' event is triggered and on window resizing.
+ */
+ reflow: function() {
+ var self = this;
+ this.$el.height('auto').show();
+ var $more_container = this.$('.oe_menu_more_container').hide();
+ var $more = this.$('.oe_menu_more');
+ $more.children('li').insertBefore($more_container);
+ var $toplevel_items = this.$el.children('li').not($more_container).hide();
+ $toplevel_items.each(function() {
+ var remaining_space = self.$el.parent().width() - $more_container.outerWidth();
+ self.$el.parent().children(':visible').each(function() {
+ remaining_space -= $(this).outerWidth();
+ });
+ if ($(this).width() > remaining_space) {
+ return false;
+ }
+ $(this).show();
+ });
+ $more.append($toplevel_items.filter(':hidden').show());
+ $more_container.toggle(!!$more.children().length);
+ // Hide toplevel item if there is only one
+ var $toplevel = this.$el.children("li:visible");
+ if ($toplevel.length === 1) {
+ $toplevel.hide();
}
},
- auto_limit_entries: function() {
- // TODO: auto detect overflow and bind window on resize
- var width = $(window).width();
- return Math.floor(width / 125);
- },
/**
* Opens a given menu by id, as if a user had browsed to that menu by hand
* except does not trigger any event on the way
@@ -1118,6 +1130,9 @@ instance.web.Client = instance.web.Widget.extend({
instance.web.WebClient = instance.web.Client.extend({
_template: 'WebClient',
+ events: {
+ 'click .oe_logo_edit_admin': 'logo_edit'
+ },
init: function(parent) {
this._super(parent);
this._current_state = null;
@@ -1188,7 +1203,29 @@ instance.web.WebClient = instance.web.Client.extend({
},
update_logo: function() {
var img = this.session.url('/web/binary/company_logo');
- this.$el.find('.oe_logo img').attr('src', '').attr('src', img);
+ this.$('.oe_logo img').attr('src', '').attr('src', img);
+ this.$('.oe_logo_edit').toggleClass('oe_logo_edit_admin', this.session.uid === 1);
+ },
+ logo_edit: function(ev) {
+ var self = this;
+ new instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"]).then(function(res) {
+ self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) {
+ result.res_id = res['company_id'][0];
+ result.target = "new";
+ result.views = [[false, 'form']];
+ result.flags = {
+ action_buttons: true,
+ };
+ self.action_manager.do_action(result);
+ var form = self.action_manager.dialog_widget.views.form.controller;
+ form.on("on_button_cancel", self.action_manager.dialog, self.action_manager.dialog.close);
+ form.on('record_saved', self, function() {
+ self.action_manager.dialog.close();
+ self.update_logo();
+ });
+ });
+ });
+ return false;
},
check_timezone: function() {
var self = this;
@@ -1343,17 +1380,17 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
_template: 'EmbedClient',
init: function(parent, origin, dbname, login, key, action_id, options) {
this._super(parent, origin);
-
- this.dbname = dbname;
- this.login = login;
- this.key = key;
+ this.bind_credentials(dbname, login, key);
this.action_id = action_id;
this.options = options || {};
},
start: function() {
var self = this;
return $.when(this._super()).then(function() {
- return instance.session.session_authenticate(self.dbname, self.login, self.key, true).then(function() {
+ return self.authenticate().then(function() {
+ if (!self.action_id) {
+ return;
+ }
return self.rpc("/web/action/load", { action_id: self.action_id }).done(function(result) {
var action = result;
action.flags = _.extend({
@@ -1364,11 +1401,30 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
//pager : false
}, self.options, action.flags || {});
- self.action_manager.do_action(action);
+ self.do_action(action);
});
});
});
},
+
+ do_action: function(action) {
+ return this.action_manager.do_action(action);
+ },
+
+ authenticate: function() {
+ var s = instance.session;
+ if (s.session_is_valid() && s.db === this.dbname && s.login === this.login) {
+ return $.when();
+ }
+ return instance.session.session_authenticate(this.dbname, this.login, this.key, true);
+ },
+
+ bind_credentials: function(dbname, login, key) {
+ this.dbname = dbname;
+ this.login = login;
+ this.key = key;
+ },
+
});
instance.web.embed = function (origin, dbname, login, key, action, options) {
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js
index c88e0ca0512..a8b0510389b 100644
--- a/addons/web/static/src/js/coresetup.js
+++ b/addons/web/static/src/js/coresetup.js
@@ -30,6 +30,12 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
* Setup a sessionm
*/
session_bind: function(origin) {
+ if (!_.isUndefined(this.origin)) {
+ if (this.origin === origin) {
+ return $.when();
+ }
+ throw new Error('Session already bound to ' + this.origin);
+ }
var self = this;
this.setup(origin);
instance.web.qweb.default_dict['_s'] = this.origin;
@@ -471,6 +477,11 @@ $.fn.openerpClass = function(additionalClass) {
$(this).addClass('openerp ' + additionalClass);
});
};
+$.fn.openerpBounce = function() {
+ return this.each(function() {
+ $(this).css('box-sizing', 'content-box').effect('bounce', {distance: 18, times: 5}, 250);
+ });
+};
/** Jquery extentions */
$.Mutex = (function() {
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index cfc8be391b4..5c76a13ef0d 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -206,16 +206,16 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.$el.find(".oe_form_group_row,.oe_form_field,label").on('click', function (e) {
if(self.get("actual_mode") == "view") {
var $button = self.options.$buttons.find(".oe_form_button_edit");
- $button.css('box-sizing', 'content-box').effect('bounce', {distance: 18, times: 5}, 150);
+ $button.openerpBounce();
e.stopPropagation();
instance.web.bus.trigger('click', e);
}
});
//bounce effect on red button when click on statusbar.
this.$el.find(".oe_form_field_status:not(.oe_form_status_clickable)").on('click', function (e) {
- if((self.get("actual_mode") == "view")) {
+ if((self.get("actual_mode") == "view")) {
var $button = self.$el.find(".oe_highlight:not(.oe_form_invisible)").css({'float':'left','clear':'none'});
- $button.effect('bounce', {distance:18, times: 5}, 150);
+ $button.openerpBounce();
e.stopPropagation();
}
});
@@ -919,7 +919,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
this.do_update_pager();
if (this.sidebar) {
this.sidebar.do_attachement_update(this.dataset, this.datarecord.id);
- }
+ }
//openerp.log("The record has been created with id #" + this.datarecord.id);
return $.when(this.reload()).then(function () {
self.trigger('record_created', r);
@@ -2289,7 +2289,10 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we
});
instance.web.form.FieldID = instance.web.form.FieldChar.extend({
-
+ process_modifiers: function () {
+ this._super();
+ this.set({ readonly: true });
+ },
});
instance.web.form.FieldEmail = instance.web.form.FieldChar.extend({
@@ -2389,7 +2392,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({
var self = this;
this.$input = this.$el.find('input.oe_datepicker_master');
this.$input_picker = this.$el.find('input.oe_datepicker_container');
-
+
this.picker({
onClose: this.on_picker_select,
onSelect: this.on_picker_select,
@@ -5092,7 +5095,7 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie
_.each(datas, function (data) {
data.no_unlink = true;
data.url = self.session.url('/web/binary/saveas', {model: 'ir.attachment', field: 'datas', filename_field: 'datas_fname', id: data.id});
-
+
_.each(self.get('value'), function (val, key) {
if(val == data.id) {
self.get('value')[key] = data;
@@ -5258,7 +5261,8 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
if (this.field.type == "many2one") {
var domain = [];
if(!_.isEmpty(this.field.domain) || !_.isEmpty(this.node.attrs.domain)) {
- domain = new instance.web.CompoundDomain(['|'], self.build_domain(), [['id', '=', self.get('value')]]);
+ var d = instance.web.pyeval.eval('domain', self.build_domain());
+ domain = ['|', ['id', '=', self.get('value')]].concat(d);
}
var ds = new instance.web.DataSetSearch(this, this.field.relation, self.build_context(), domain);
return ds.read_slice(['name'], {}).then(function (records) {
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index f6794bd435c..4687b3cb2ba 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -833,7 +833,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
);
var create_nocontent = this.$buttons;
this.$el.find('.oe_view_nocontent').click(function() {
- create_nocontent.effect('bounce', {distance: 18, times: 5}, 150);
+ create_nocontent.openerpBounce();
});
}
});
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index dc31a24dc31..877a2c183ee 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -36,7 +36,7 @@
<t t-name="CrashManager.warning">
<table cellspacing="0" cellpadding="0" border="0" class="oe_dialog_warning">
<tr>
- <td><img t-att-src='_s + "/web/static/src/img/warning.png"' class="oe_dialog_icon"/></td>
+ <td class="oe_dialog_icon"><img t-att-src='_s + "/web/static/src/img/warning.png"'/></td>
<td>
<p>
<t t-js="d">
@@ -348,16 +348,14 @@
<li t-foreach="widget.data.data.children" t-as="menu">
<t t-call="Menu.link"/>
</li>
+ <li class="oe_menu_more_container" style="display: none;">
+ <span class="oe_topbar_item oe_menu_more_link oe_dropdown_toggle oe_dropdown_arrow">
+ More
+ <ul class="oe_menu_more oe_dropdown_menu"/>
+ </span>
+ </li>
</ul>
</t>
-<t t-name="Menu.more">
- <li class="oe_menu_more_container">
- <span class="oe_topbar_item oe_menu_more_link oe_dropdown_toggle oe_dropdown_arrow">
- More
- <ul class="oe_menu_more oe_dropdown_menu"/>
- </span>
- </li>
-</t>
<t t-name="Menu.secondary">
<div t-foreach="widget.data.data.children" t-as="menu" style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu.id">
<t t-foreach="menu.children" t-as="menu">
@@ -414,7 +412,7 @@
<div class="oe_about">
<a class="oe_activate_debug_mode oe_right" href="?debug" style="background-color: white; padding:2px 6px; border-radius: 10px;">Activate the developer mode</a>
<img class="oe_logo" src="/web/static/src/img/logo2.png"/>
- <h3>Version <t t-esc="version_info.version"/></h3>
+ <h3>Version <t t-esc="version_info.server_version"/></h3>
<div class="oe_bottom">
<p>Copyright © 2004-TODAY OpenERP SA. All Rights Reserved.<br />
@@ -439,7 +437,10 @@
<tr>
<td class="oe_leftbar" valign="top">
<t t-set="debug" t-value="__debug__ ? '&amp;debug' : ''"/>
- <a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}"><img t-att-src='widget.session.url("/web/binary/company_logo")'/></a>
+ <a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}">
+ <span class="oe_logo_edit">Edit Company data</span>
+ <img t-att-src='widget.session.url("/web/binary/company_logo")'/>
+ </a>
<div class="oe_secondary_menus_container"/>
<div class="oe_footer">
Powered by <a href="http://www.openerp.com" target="_blank"><span>OpenERP</span></a>