diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-03-22 12:31:42 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-03-22 12:31:42 +0100 |
| commit | 1da49a44a57aa413e5eb96afe9c6d294e09848fd (patch) | |
| tree | 77a4158ac5a2a6fa8be77f13402be81178849bd6 /addons/web/static/src/js | |
| parent | ff245d6eb5e0b5f34d9bbaab963e99afa4897e3f (diff) | |
| parent | 5a5791474a495d230f997c69cb24405722c8f407 (diff) | |
[MERGE] 6.1 fixes into trunk
bzr revid: xmo@openerp.com-20120322113142-gim4svx01p336nxm
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 56 | ||||
| -rw-r--r-- | addons/web/static/src/js/core.js | 8 | ||||
| -rw-r--r-- | addons/web/static/src/js/data.js | 31 | ||||
| -rw-r--r-- | addons/web/static/src/js/formats.js | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/search.js | 25 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 11 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_page.js | 20 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 3 |
8 files changed, 84 insertions, 74 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 829610f2988..f8af815d187 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -351,44 +351,6 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab return result; }, /** - * Waits until the new database is done creating, then unblocks the UI and - * logs the user in as admin - * - * @param {Number} db_creation_id identifier for the db-creation operation, used to fetch the current installation progress - * @param {Object} info info fields for this database creation - * @param {String} info.db name of the database being created - * @param {String} info.password super-admin password for the database - */ - wait_for_newdb: function (db_creation_id, info) { - var self = this; - self.rpc('/web/database/progress', { - id: db_creation_id, - password: info.password - }, function (result) { - var progress = result[0]; - // I'd display a progress bar, but turns out the progress status - // the server report kind-of blows goats: it's at 0 for ~75% of - // the installation, then jumps to 75%, then jumps down to either - // 0 or ~40%, then back up to 75%, then terminates. Let's keep that - // mess hidden behind a not-very-useful but not overly weird - // message instead. - if (progress < 1) { - setTimeout(function () { - self.wait_for_newdb(db_creation_id, info); - }, 500); - return; - } - - var admin = result[1][0]; - setTimeout(function () { - self.getParent().do_login( - info.db, admin.login, admin.password); - self.destroy(); - self.unblockUI(); - }); - }); - }, - /** * Blocks UI and replaces $.unblockUI by a noop to prevent third parties * from unblocking the UI */ @@ -427,23 +389,19 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab self.$option_id.find("form[name=create_db_form]").validate({ submitHandler: function (form) { var fields = $(form).serializeArray(); - self.blockUI(); self.rpc("/web/database/create", {'fields': fields}, function(result) { - if (result.error) { - self.unblockUI(); - self.display_error(result); - return; - } if (self.db_list) { self.db_list.push(self.to_object(fields)['db_name']); self.db_list.sort(); - self.getParent().set_db_list(self.db_list); + self.widget_parent.set_db_list(self.db_list); } + var form_obj = self.to_object(fields); - self.wait_for_newdb(result, { - password: form_obj['super_admin_pwd'], - db: form_obj['db_name'] - }); + self.getParent().do_login( + form_obj['db_name'], + 'admin', + form_obj['create_admin_pwd']); + self.destroy(); }); } }); diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 650939c843c..d0d8f037bf6 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -886,6 +886,14 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. var file_list = ["/web/static/lib/datejs/globalization/" + lang.replace("_", "-") + ".js"]; return self.rpc('/web/webclient/jslist', {mods: to_load}).pipe(function(files) { return self.do_load_js(file_list.concat(files)); + }).then(function () { + if (!Date.CultureInfo.pmDesignator) { + // If no am/pm designator is specified but the openerp + // datetime format uses %i, date.js won't be able to + // correctly format a date. See bug#938497. + Date.CultureInfo.amDesignator = 'AM'; + Date.CultureInfo.pmDesignator = 'PM'; + } }); })) } diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 8e200951eaa..d9cfc5c4002 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -741,18 +741,25 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({ : (v1 > v2) ? 1 : 0; }; - records.sort(function (a, b) { - return _.reduce(sort_fields, function (acc, field) { - if (acc) { return acc; } - - var sign = 1; - if (field[0] === '-') { - sign = -1; - field = field.slice(1); - } - return sign * compare(a[field], b[field]); - }, 0); - }); + // Array.sort is not necessarily stable. We must be careful with this because + // sorting an array where all items are considered equal is a worst-case that + // will randomize the array with an unstable sort! Therefore we must avoid + // sorting if there are no sort_fields (i.e. all items are considered equal) + // See also: http://ecma262-5.com/ELS5_Section_15.htm#Section_15.4.4.11 + // http://code.google.com/p/v8/issues/detail?id=90 + if (sort_fields.length) { + records.sort(function (a, b) { + return _.reduce(sort_fields, function (acc, field) { + if (acc) { return acc; } + var sign = 1; + if (field[0] === '-') { + sign = -1; + field = field.slice(1); + } + return sign * compare(a[field], b[field]); + }, 0); + }); + } completion.resolve(records); }; if(to_get.length > 0) { diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 90d95f70ec5..53863e63e97 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -148,7 +148,7 @@ openerp.web.format_value = function (value, descriptor, value_if_empty) { if (typeof(value) == "string") value = openerp.web.auto_str_to_date(value); return value.toString(normalize_format(l10n.time_format)); - case 'selection': + case 'selection': case 'statusbar': // Each choice is [value, label] if(_.isArray(value)) { value = value[0] @@ -336,7 +336,7 @@ openerp.web.format_cell = function (row_data, column, options) { case 'progressbar': return _.template( '<progress value="<%-value%>" max="100"><%-value%>%</progress>', { - value: _.str.sprintf("%.0f", row_data[column.id].value) + value: _.str.sprintf("%.0f", row_data[column.id].value || 0) }); } diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index d2ccbfaa5c3..b78c3be23fa 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -32,6 +32,8 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea this.hidden = !!hidden; this.headless = this.hidden && !this.has_defaults; + this.filter_data = {}; + this.ready = $.Deferred(); }, start: function() { @@ -271,7 +273,12 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea group_by instanceof Array ? group_by : group_by.split(','), function (el) { return { group_by: el }; }); } - this.on_search([filter.domain], [filter.context], groupbys); + this.filter_data = { + domains: [filter.domain], + contexts: [filter.context], + groupbys: groupbys + }; + this.do_search(); }, this)); } else { select.val(''); @@ -339,9 +346,6 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea if (this.headless && !this.has_defaults) { return this.on_search([], [], []); } - // reset filters management - var select = this.$element.find(".oe_search-view-filters-management"); - select.val("_filters"); if (e && e.preventDefault) { e.preventDefault(); } @@ -385,6 +389,16 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea .map(function (filter) { return filter.get_context();}) .compact() .value(); + + if (this.filter_data.contexts) { + contexts = this.filter_data.contexts.concat(contexts) + } + if (this.filter_data.domains) { + domains = this.filter_data.domains.concat(domains); + } + if (this.filter_data.groupbys) { + groupbys = this.filter_data.groupbys.concat(groupbys); + } return {domains: domains, contexts: contexts, errors: errors, groupbys: groupbys}; }, /** @@ -423,6 +437,9 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea * @param {Boolean} [reload_view=true] */ do_clear: function (reload_view) { + this.filter_data = {}; + this.$element.find(".oe_search-view-filters-management").val(''); + this.$element.find('.filter_label, .filter_icon').removeClass('enabled'); this.enabled_filters.splice(0); var string = $('a.searchview_group_string'); diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3ecc35d677f..8b1ec3098a6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1605,16 +1605,11 @@ openerp.web.form.FieldFloat = openerp.web.form.FieldChar.extend({ init: function (view, node) { this._super(view, node); if (node.attrs.digits) { - this.parse_digits(node.attrs.digits); + this.digits = py.eval(node.attrs.digits).toJSON(); } else { this.digits = view.fields_view.fields[node.attrs.name].digits; } }, - parse_digits: function (digits_attr) { - // could use a Python parser instead. - var match = /^\s*[\(\[](\d+),\s*(\d+)/.exec(digits_attr); - return [parseInt(match[1], 10), parseInt(match[2], 10)]; - }, set_value: function(value) { if (value === false || value === undefined) { // As in GTK client, floats default to 0 @@ -2920,6 +2915,10 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope this.new_object(); } }, + stop: function () { + this.$element.dialog('close'); + this._super(); + }, setup_search_view: function(search_defaults) { var self = this; if (this.searchview) { diff --git a/addons/web/static/src/js/view_page.js b/addons/web/static/src/js/view_page.js index 95259a01927..50cc95cdea6 100644 --- a/addons/web/static/src/js/view_page.js +++ b/addons/web/static/src/js/view_page.js @@ -89,6 +89,16 @@ openerp.web.page = function (openerp) { return show_value; } }); + openerp.web.page.FieldFloatReadonly = openerp.web.page.FieldCharReadonly.extend({ + init: function (view, node) { + this._super(view, node); + if (node.attrs.digits) { + this.digits = py.eval(node.attrs.digits).toJSON(); + } else { + this.digits = view.fields_view.fields[node.attrs.name].digits; + } + } + }); openerp.web.page.FieldURIReadonly = openerp.web.page.FieldCharReadonly.extend({ form_template: 'FieldURI.readonly', scheme: null, @@ -96,6 +106,10 @@ openerp.web.page = function (openerp) { return value; }, set_value: function (value) { + if (!value) { + this.$element.find('a').text('').attr('href', '#'); + return; + } this.$element.find('a') .attr('href', this.scheme + ':' + value) .text(this.format_value(value)); @@ -106,6 +120,10 @@ openerp.web.page = function (openerp) { }); openerp.web.page.FieldUrlReadonly = openerp.web.page.FieldURIReadonly.extend({ set_value: function (value) { + if (!value) { + this.$element.find('a').text('').attr('href', '#'); + return; + } var s = /(\w+):(.+)/.exec(value); if (!s) { value = "http://" + value; @@ -261,7 +279,7 @@ openerp.web.page = function (openerp) { 'one2many_list' : 'openerp.web.page.FieldOne2ManyReadonly', 'reference': 'openerp.web.page.FieldReferenceReadonly', 'boolean': 'openerp.web.page.FieldBooleanReadonly', - 'float': 'openerp.web.page.FieldCharReadonly', + 'float': 'openerp.web.page.FieldFloatReadonly', 'integer': 'openerp.web.page.FieldCharReadonly', 'float_time': 'openerp.web.page.FieldCharReadonly', 'binary': 'openerp.web.page.FieldBinaryFileReadonly', diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 503ec360013..5be0fad74f0 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -411,6 +411,9 @@ session.web.ViewManager = session.web.OldWidget.extend(/** @lends session.web.V var groupby = results.group_by.length ? results.group_by : action_context.group_by; + if (_.isString(groupby)) { + groupby = [groupby]; + } controller.do_search(results.domain, results.context, groupby || []); }); }, |
