summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorDivyesh Makwana (Open ERP) <mdi@tinyerp.com>2012-11-28 09:53:03 +0530
committerDivyesh Makwana (Open ERP) <mdi@tinyerp.com>2012-11-28 09:53:03 +0530
commit91b19d1a7ce76d8d5a86b846f54bcf6824de705d (patch)
tree80ccd5e6a2eab1eff55574b6b1c768d71f1a02fc /addons/web/static/src
parent1db3fca04a217de4083a63c72dc04e943e252589 (diff)
parentf63bdc67e28692028afcb31e46009e969d11d130 (diff)
[Merge] Merge with trunk.
bzr revid: mdi@tinyerp.com-20121128042303-eu3ttdp9nvt99o2k
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/css/base.css4
-rw-r--r--addons/web/static/src/css/base.sass2
-rw-r--r--addons/web/static/src/js/chrome.js62
-rw-r--r--addons/web/static/src/js/corelib.js146
-rw-r--r--addons/web/static/src/js/search.js6
-rw-r--r--addons/web/static/src/js/view_form.js14
-rw-r--r--addons/web/static/src/js/view_list.js31
-rw-r--r--addons/web/static/src/js/view_list_editable.js6
-rw-r--r--addons/web/static/src/js/views.js20
-rw-r--r--addons/web/static/src/xml/base.xml29
10 files changed, 182 insertions, 138 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css
index 9b99258a3a7..ee81492b8ad 100644
--- a/addons/web/static/src/css/base.css
+++ b/addons/web/static/src/css/base.css
@@ -30,7 +30,7 @@
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
/* http://www.quirksmode.org/dom/inputfile.html
* http://stackoverflow.com/questions/2855589/replace-input-type-file-by-an-image
- */ */
+ */
}
.openerp.openerp_webclient_container {
height: 100%;
@@ -807,8 +807,6 @@
padding: 0 0 4px 0;
}
.openerp .oe_login button {
- float: right;
- display: inline-block;
cursor: pointer;
padding: 6px 16px;
border: 1px solid #222222;
diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass
index 2bc13dc26c9..2474ba9dc06 100644
--- a/addons/web/static/src/css/base.sass
+++ b/addons/web/static/src/css/base.sass
@@ -686,8 +686,6 @@ $sheet-padding: 16px
list-style-type: none
padding: 0 0 4px 0
button
- float: right
- display: inline-block
cursor: pointer
padding: 6px 16px
border: 1px solid #222
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 7829a3e0cc7..1bca6bf94cd 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -67,9 +67,11 @@ instance.web.Dialog = instance.web.Widget.extend({
@param {Widget} parent
@param {dictionary} options A dictionary that will be forwarded to jQueryUI Dialog. Additionaly, that
dictionary can contain the following keys:
- - buttons: The buttons key is not propagated to jQueryUI Dialog. It must be a dictionary (key = button label,
- value = click handler) or a list of dictionaries (each element in the dictionary is send to the corresponding
- method of a jQuery element targeting the <button> tag).
+ - buttons: Deprecated. The buttons key is not propagated to jQueryUI Dialog. It must be a dictionary (key = button
+ label, value = click handler) or a list of dictionaries (each element in the dictionary is send to the
+ corresponding method of a jQuery element targeting the <button> tag). It is deprecated because all dialogs
+ in OpenERP must be personalized in some way (button in red, link instead of button, ...) and this
+ feature does not allow that kind of personalization.
- destroy_on_close: Default true. If true and the dialog is closed, it is automatically destroyed.
@param {jQuery object} content Some content to replace this.$el .
*/
@@ -102,9 +104,9 @@ instance.web.Dialog = instance.web.Widget.extend({
this.on("closing", this, this._closing);
this.$buttons = $('<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"><span class="oe_dialog_custom_buttons"/></div>');
},
- _get_options: function(options) {
+ _get_options: function() {
var self = this;
- var o = _.extend({}, this.dialog_options, options || {});
+ var o = _.extend({}, this.dialog_options);
var sizes = {
width: $(window.top).width(),
height: $(window.top).height(),
@@ -143,12 +145,11 @@ instance.web.Dialog = instance.web.Widget.extend({
/**
Opens the popup. Inits the dialog if it is not already inited.
- @param {dictionary} options Additional options, see the options param in init().
@return this
*/
- open: function(options) {
+ open: function() {
if (!this.dialog_inited) {
- this.init_dialog(options);
+ this.init_dialog();
}
this.$el.dialog('open');
this.$el.dialog("widget").append(this.$buttons);
@@ -173,11 +174,10 @@ instance.web.Dialog = instance.web.Widget.extend({
/**
Initializes the popup.
- @param {dictionary} options Additional options, see the options param in init().
@return The result returned by start().
*/
- init_dialog: function(options) {
- var options = this._get_options(options);
+ init_dialog: function() {
+ var options = this._get_options();
if (options.buttons) {
this._add_buttons(options.buttons);
delete(options.buttons);
@@ -765,20 +765,24 @@ instance.web.ChangePassword = instance.web.Widget.extend({
template: "ChangePassword",
start: function() {
var self = this;
- self.$el.validate({
- submitHandler: function (form) {
- self.rpc("/web/session/change_password",{
- 'fields': $(form).serializeArray()
- }).done(function(result) {
- if (result.error) {
- self.display_error(result);
- return;
- } else {
- instance.webclient.on_logout();
- }
- });
- }
- });
+ this.getParent().dialog_title = "Change Password";
+ var $button = self.$el.find('.oe_form_button');
+ $button.appendTo(this.getParent().$buttons);
+ $button.eq(2).click(function(){
+ self.getParent().close();
+ })
+ $button.eq(0).click(function(){
+ self.rpc("/web/session/change_password",{
+ 'fields': $("form[name=change_password_form]").serializeArray()
+ }).done(function(result) {
+ if (result.error) {
+ self.display_error(result);
+ return;
+ } else {
+ instance.webclient.on_logout();
+ }
+ });
+ })
},
display_error: function (error) {
return instance.web.dialog($('<div>'), {
@@ -985,6 +989,14 @@ instance.web.UserMenu = instance.web.Widget.extend({
if(res.company_id[0] > 1)
topbar_name = _.str.sprintf("%s (%s)", topbar_name, res.company_id[1]);
self.$el.find('.oe_topbar_name').text(topbar_name);
+ if(!instance.session.debug) {
+ self.rpc("/web/database/get_list", {}).done( function(result) {
+ if (result.length > 1) {
+ topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db);
+ }
+ self.$el.find('.oe_topbar_name').text(topbar_name);
+ });
+ }
var avatar_src = self.session.url('/web/binary/image', {model:'res.users', field: 'image_small', id: self.session.uid});
$avatar.attr('src', avatar_src);
});
diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js
index 06b3940f1e1..6d7e3c39054 100644
--- a/addons/web/static/src/js/corelib.js
+++ b/addons/web/static/src/js/corelib.js
@@ -430,6 +430,85 @@ instance.web.PropertiesMixin = _.extend({}, instance.web.EventDispatcherMixin, {
// Classes
/**
+ A class containing common utility methods useful when working with OpenERP as well as the PropertiesMixin.
+*/
+instance.web.Controller = instance.web.Class.extend(instance.web.PropertiesMixin, {
+ /**
+ * Constructs the object and sets its parent if a parent is given.
+ *
+ * @param {instance.web.Controller} parent Binds the current instance to the given Controller instance.
+ * When that controller is destroyed by calling destroy(), the current instance will be
+ * destroyed too. Can be null.
+ */
+ init: function(parent) {
+ instance.web.PropertiesMixin.init.call(this);
+ this.setParent(parent);
+ },
+ /**
+ * Proxies a method of the object, in order to keep the right ``this`` on
+ * method invocations.
+ *
+ * This method is similar to ``Function.prototype.bind`` or ``_.bind``, and
+ * even more so to ``jQuery.proxy`` with a fundamental difference: its
+ * resolution of the method being called is lazy, meaning it will use the
+ * method as it is when the proxy is called, not when the proxy is created.
+ *
+ * Other methods will fix the bound method to what it is when creating the
+ * binding/proxy, which is fine in most javascript code but problematic in
+ * OpenERP Web where developers may want to replace existing callbacks with
+ * theirs.
+ *
+ * The semantics of this precisely replace closing over the method call.
+ *
+ * @param {String|Function} method function or name of the method to invoke
+ * @returns {Function} proxied method
+ */
+ proxy: function (method) {
+ var self = this;
+ return function () {
+ var fn = (typeof method === 'string') ? self[method] : method;
+ return fn.apply(self, arguments);
+ }
+ },
+ /**
+ * Informs the action manager to do an action. This supposes that
+ * the action manager can be found amongst the ancestors of the current widget.
+ * If that's not the case this method will simply return `false`.
+ */
+ do_action: function() {
+ var parent = this.getParent();
+ if (parent) {
+ return parent.do_action.apply(parent, arguments);
+ }
+ return false;
+ },
+ do_notify: function() {
+ if (this.getParent()) {
+ return this.getParent().do_notify.apply(this,arguments);
+ }
+ return false;
+ },
+ do_warn: function() {
+ if (this.getParent()) {
+ return this.getParent().do_warn.apply(this,arguments);
+ }
+ return false;
+ },
+ rpc: function(url, data, options) {
+ var def = $.Deferred();
+ var self = this;
+ instance.session.rpc(url, data, options).done(function() {
+ if (!self.isDestroyed())
+ def.resolve.apply(def, arguments);
+ }).fail(function() {
+ if (!self.isDestroyed())
+ def.reject.apply(def, arguments);
+ });
+ return def.promise();
+ }
+});
+
+/**
* Base class for all visual components. Provides a lot of functionalities helpful
* for the management of a part of the DOM.
*
@@ -477,7 +556,7 @@ instance.web.PropertiesMixin = _.extend({}, instance.web.EventDispatcherMixin, {
*
* That will kill the widget in a clean way and erase its content from the dom.
*/
-instance.web.Widget = instance.web.Class.extend(instance.web.PropertiesMixin, {
+instance.web.Widget = instance.web.Controller.extend({
// Backbone-ish API
tagName: 'div',
id: null,
@@ -501,8 +580,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.PropertiesMixin, {
* destroyed too. Can be null.
*/
init: function(parent) {
- instance.web.PropertiesMixin.init.call(this);
- this.setParent(parent);
+ this._super(parent);
// Bind on_/do_* methods to this
// We might remove this automatic binding in the future
for (var name in this) {
@@ -605,32 +683,6 @@ instance.web.Widget = instance.web.Class.extend(instance.web.PropertiesMixin, {
return $.when();
},
/**
- * Proxies a method of the object, in order to keep the right ``this`` on
- * method invocations.
- *
- * This method is similar to ``Function.prototype.bind`` or ``_.bind``, and
- * even more so to ``jQuery.proxy`` with a fundamental difference: its
- * resolution of the method being called is lazy, meaning it will use the
- * method as it is when the proxy is called, not when the proxy is created.
- *
- * Other methods will fix the bound method to what it is when creating the
- * binding/proxy, which is fine in most javascript code but problematic in
- * OpenERP Web where developers may want to replace existing callbacks with
- * theirs.
- *
- * The semantics of this precisely replace closing over the method call.
- *
- * @param {String|Function} method function or name of the method to invoke
- * @returns {Function} proxied method
- */
- proxy: function (method) {
- var self = this;
- return function () {
- var fn = (typeof method === 'string') ? self[method] : method;
- return fn.apply(self, arguments);
- }
- },
- /**
* Renders the element. The default implementation renders the widget using QWeb,
* `this.template` must be defined. The context given to QWeb contains the "widget"
* key that references `this`.
@@ -749,42 +801,6 @@ instance.web.Widget = instance.web.Class.extend(instance.web.PropertiesMixin, {
*/
$: function(selector) {
return this.$el.find(selector);
- },
- /**
- * Informs the action manager to do an action. This supposes that
- * the action manager can be found amongst the ancestors of the current widget.
- * If that's not the case this method will simply return `false`.
- */
- do_action: function() {
- var parent = this.getParent();
- if (parent) {
- return parent.do_action.apply(parent, arguments);
- }
- return false;
- },
- do_notify: function() {
- if (this.getParent()) {
- return this.getParent().do_notify.apply(this,arguments);
- }
- return false;
- },
- do_warn: function() {
- if (this.getParent()) {
- return this.getParent().do_warn.apply(this,arguments);
- }
- return false;
- },
- rpc: function(url, data, options) {
- var def = $.Deferred();
- var self = this;
- instance.session.rpc(url, data, options).done(function() {
- if (!self.isDestroyed())
- def.resolve.apply(def, arguments);
- }).fail(function() {
- if (!self.isDestroyed())
- def.reject.apply(def, arguments);
- });
- return def.promise();
}
});
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index 67d5911ee3f..88d45793173 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -1924,7 +1924,8 @@ instance.web.search.ExtendedSearchProposition.Integer = instance.web.search.Exte
},
get_value: function() {
try {
- return instance.web.parse_value(this.$el.val(), {'widget': 'integer'});
+ var val =this.$el.val();
+ return instance.web.parse_value(val == "" ? 0 : val, {'widget': 'integer'});
} catch (e) {
return "";
}
@@ -1948,7 +1949,8 @@ instance.web.search.ExtendedSearchProposition.Float = instance.web.search.Extend
},
get_value: function() {
try {
- return instance.web.parse_value(this.$el.val(), {'widget': 'float'});
+ var val =this.$el.val();
+ return instance.web.parse_value(val == "" ? 0.0 : val, {'widget': 'float'});
} catch (e) {
return "";
}
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 7170bdcec72..b0ad23d6854 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -4238,16 +4238,14 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
var self = this;
self.load_view();
- this.is_loaded.done(function() {
- self.on("change:effective_readonly", self, function() {
- self.is_loaded = self.is_loaded.then(function() {
- self.kanban_view.destroy();
- return $.when(self.load_view()).done(function() {
- self.render_value();
- });
+ self.on("change:effective_readonly", self, function() {
+ self.is_loaded = self.is_loaded.then(function() {
+ self.kanban_view.destroy();
+ return $.when(self.load_view()).done(function() {
+ self.render_value();
});
});
- })
+ });
},
set_value: function(value_) {
value_ = value_ || [];
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 55e3c17b494..13c41d48599 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -25,6 +25,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
'disable_editable_mode': false,
},
view_type: 'tree',
+ events: {
+ 'click thead th.oe_sortable[data-id]': 'sort_by_column'
+ },
/**
* Core class for list-type displays.
*
@@ -264,21 +267,6 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
'selected', [selection.ids, selection.records]);
});
- // Sorting columns
- this.$el.find('thead').delegate('th.oe_sortable[data-id]', 'click', function (e) {
- e.stopPropagation();
- var $this = $(this);
- self.dataset.sort($this.data('id'));
- if($this.hasClass("sortdown") || $this.hasClass("sortup")) {
- $this.toggleClass("sortdown").toggleClass("sortup");
- } else {
- $this.toggleClass("sortdown");
- }
- $this.siblings('.oe_sortable').removeClass("sortup sortdown");
-
- self.reload_content();
- });
-
// Add button
if (!this.$buttons) {
this.$buttons = $(QWeb.render("ListView.buttons", {'widget':self}));
@@ -360,6 +348,19 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
}
this.trigger('list_view_loaded', data, this.grouped);
},
+ sort_by_column: function (e) {
+ e.stopPropagation();
+ var $column = $(e.currentTarget);
+ this.dataset.sort($column.data('id'));
+ if($column.hasClass("sortdown") || $column.hasClass("sortup")) {
+ $column.toggleClass("sortup sortdown");
+ } else {
+ $column.addClass("sortdown");
+ }
+ $column.siblings('.oe_sortable').removeClass("sortup sortdown");
+
+ this.reload_content();
+ },
/**
* Configures the ListView pager based on the provided dataset's information
*
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index db7e22e5f32..7fe6a8ec42b 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -63,6 +63,12 @@ openerp.web.list_editable = function (instance) {
}
this._super();
},
+ sort_by_column: function (e) {
+ e.stopPropagation();
+ if (!this.editor.is_editing()) {
+ this._super.apply(this, arguments);
+ }
+ },
/**
* Handles the activation of a record in editable mode (making a record
* editable), called *after* the record has become editable.
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 81662ac6487..ddedcdd2ff6 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -978,11 +978,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
this.fileupload_id = _.uniqueId('oe_fileupload');
$(window).on(this.fileupload_id, function() {
var args = [].slice.call(arguments).slice(1);
- if (args[0] && args[0].error) {
- alert(args[0].error);
- } else {
- self.do_attachement_update(self.dataset, self.model_id);
- }
+ self.do_attachement_update(self.dataset, self.model_id,args);
instance.web.unblockUI();
});
},
@@ -1092,9 +1088,21 @@ instance.web.Sidebar = instance.web.Widget.extend({
});
});
},
- do_attachement_update: function(dataset, model_id) {
+ do_attachement_update: function(dataset, model_id,args) {
+ var self = this;
this.dataset = dataset;
this.model_id = model_id;
+ if (args && args[0]["erorr"]) {
+ instance.web.dialog($('<div>'),{
+ modal: true,
+ title: "OpenERP " + _.str.capitalize(args[0]["title"]),
+ buttons: [{
+ text: _t("Ok"),
+ click: function(){
+ $(this).dialog("close");
+ }}]
+ }).html(args[0]["erorr"]);
+ }
if (!model_id) {
this.on_attachments_loaded([]);
} else {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 6476462ff19..b1bd959e4fb 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -71,9 +71,9 @@
</div>
<ul>
<li>Username</li>
- <li><input type="text" name="login" t-att-value="widget.selected_login || ''" autofocus="autofocus"/></li>
+ <li><input name="login" type="text" t-att-value="widget.selected_login || ''" autofocus="autofocus"/></li>
<li>Password</li>
- <li><input type="password" name="password" t-att-value="widget.selected_password || ''"/></li>
+ <li><input name="password" type="password" t-att-value="widget.selected_password || ''"/></li>
<li><button name="submit">Log in</button></li>
</ul>
</form>
@@ -98,7 +98,6 @@
</select>
</t>
-
<t t-name="DatabaseManager">
<div class="oe_view_manager_view_form">
<div class="oe_form">
@@ -315,26 +314,32 @@
<t t-name="ChangePassword">
<form name="change_password_form" method="POST">
+ <div class="oe_form">
<table align="center">
<tr>
- <td><label for="old_pwd">Old Password:</label></td>
- <td><input type="password" name="old_pwd"
+ <td class="oe_form_group_cell oe_form_group_cell_label"><label for="old_pwd" class="oe_form_label">Old Password:</label></td>
+ <td class="oe_form_group_cell"><input type="password" name="old_pwd"
minlength="1" autofocus="autofocus"/></td>
</tr>
<tr>
- <td><label for="new_password">New Password:</label></td>
- <td><input type="password" name="new_password"
+ <td class="oe_form_group_cell oe_form_group_cell_label"><label for="new_password" class="oe_form_label">New Password:</label></td>
+ <td class="oe_form_group_cell"><input type="password" name="new_password"
minlength="1"/></td>
</tr>
<tr>
- <td><label for="confirm_pwd">Confirm Password:</label></td>
- <td><input type="password" name="confirm_pwd"
+ <td class="oe_form_group_cell oe_form_group_cell_label"><label for="confirm_pwd" class="oe_form_label">Confirm New Password:</label></td>
+ <td class="oe_form_group_cell"><input type="password" name="confirm_pwd"
minlength="1"/></td>
</tr>
<tr>
- <td colspan="2" align="right"><button class="oe_button">Change Password</button></td>
+ <td colspan="2" align="right">
+ <button class='oe_button oe_form_button'>Change Password</button>
+ <span class="oe_fade oe_form_button"> or </span>
+ <button type="button" class="oe_button oe_form_button_cancel oe_form_button oe_link" href="javascript:void(0)"><span>Cancel</span></button>
+ </td>
</tr>
</table>
+ </div>
</form>
</t>
@@ -1597,10 +1602,10 @@
<span/>
</t>
<t t-name="SearchView.extended_search.proposition.integer">
- <input type="number" class="field_integer" step="1"/>
+ <input type="number" class="field_integer" value = "0" step="1"/>
</t>
<t t-name="SearchView.extended_search.proposition.float">
- <input type="number" class="field_float" step="0.01"/>
+ <input type="number" class="field_float" value = "0.0" step="0.01"/>
</t>
<t t-name="SearchView.extended_search.proposition.selection">
<select>