diff options
| author | Raphael Collet <rco@openerp.com> | 2012-08-31 16:53:05 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2012-08-31 16:53:05 +0200 |
| commit | 0304a1eadad77620c1939a4c7734d4a24d420d32 (patch) | |
| tree | 63441f0d83d6a0074590abd24a496a0f3b2a8904 /addons/web/static/src/js | |
| parent | e79baa9e8a5759a3626c15dba76b1f03d8ecd098 (diff) | |
| parent | 21a645fb6dbf01319cb10ff94c8dbfbda141332e (diff) | |
[MERGE] from trunk
bzr revid: jam@tinyerp.com-20120831045217-xoy25yc9ignfi94v
bzr revid: rco@openerp.com-20120831145305-4wf3sl8un59k61he
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 30 | ||||
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 7 | ||||
| -rw-r--r-- | addons/web/static/src/js/test_support.js | 1 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 121 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list_editable.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 12 |
6 files changed, 75 insertions, 98 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 19493fefb05..736e10875f6 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -193,29 +193,9 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({ on_traceback: function(error) { var self = this; var buttons = {}; - if (instance.session.openerp_entreprise) { - buttons[_t("Send OpenERP Enterprise Report")] = function() { - var $this = $(this); - var issuename = $('#issuename').val(); - var explanation = $('#explanation').val(); - var remark = $('#remark').val(); - // Call the send method from server to send mail with details - new instance.web.DataSet(self, 'publisher_warranty.contract').call_and_eval('send', [error.data,explanation,remark,issuename]).then(function(result){ - if (result === false) { - alert('There was a communication error.'); - } else { - $this.dialog('close'); - } - }); - }; - buttons[_t("Dont send")] = function() { - $(this).dialog("close"); - }; - } else { - buttons[_t("Ok")] = function() { - $(this).dialog("close"); - }; - } + buttons[_t("Ok")] = function() { + $(this).dialog("close"); + }; var dialog = new instance.web.Dialog(this, { title: "OpenERP " + _.str.capitalize(error.type), width: '80%', @@ -1043,10 +1023,6 @@ instance.web.WebClient = instance.web.Client.extend({ self.user_menu.on_action.add(this.proxy('on_menu_action')); self.user_menu.do_update(); self.bind_hashchange(); - if (!self.session.openerp_entreprise) { - var version_label = _t("OpenERP - Unsupported/Community Version"); - self.$el.find('.oe_footer_powered').append(_.str.sprintf('<span> - <a href="http://www.openerp.com/support-or-publisher-warranty-contract" target="_blank">%s</a></span>', version_label)); - } self.set_title(); }, destroy_content: function() { diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 8e0f4da4148..38cf57387d1 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -35,7 +35,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess this.username = false; this.user_context= {}; this.db = false; - this.openerp_entreprise = false; this.module_list = instance._modules.slice(); this.module_loaded = {}; _(this.module_list).each(function (mod) { @@ -78,8 +77,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess db: result.db, username: result.login, uid: result.uid, - user_context: result.context, - openerp_entreprise: result.openerp_entreprise + user_context: result.context }); }); }, @@ -103,8 +101,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess db: result.db, username: result.login, uid: result.uid, - user_context: result.context, - openerp_entreprise: result.openerp_entreprise + user_context: result.context }); if (!_volatile) { self.set_cookie('session_id', self.session_id); diff --git a/addons/web/static/src/js/test_support.js b/addons/web/static/src/js/test_support.js index 314a12c91c6..8e1317ba2b0 100644 --- a/addons/web/static/src/js/test_support.js +++ b/addons/web/static/src/js/test_support.js @@ -12,7 +12,6 @@ openerp.test_support = { username: false, user_context: {}, db: false, - openerp_entreprise: false, // this.module_list = openerp._modules.slice(); // this.module_loaded = {}; // _(this.module_list).each(function (mod) { diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a6b8fe346b9..2e577e740f8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -697,7 +697,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, on_button_save: function() { var self = this; - return this.do_save().then(function(result) { + return this.do_save().then(function(result) { self.to_view_mode(); }); }, @@ -767,10 +767,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM * record or saving an existing one depending on whether the record * already has an id property. * - * @param {Function} [success] callback on save success - * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new record, should that record be inserted at the start of the dataset (by default, records are added at the end) + * @param {Boolean} [prepend_on_create=false] if ``do_save`` creates a new + * record, should that record be inserted at the start of the dataset (by + * default, records are added at the end) */ - do_save: function(success, prepend_on_create) { + do_save: function(prepend_on_create) { var self = this; return this.mutating_mutex.exec(function() { return self.is_initialized.pipe(function() { try { @@ -805,21 +806,21 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.set({'display_invalid_fields': false}); var save_deferral; if (!self.datarecord.id) { - // console.log("FormView(", self, ") : About to create", values); + // Creation save save_deferral = self.dataset.create(values).pipe(function(r) { - return self.on_created(r, undefined, prepend_on_create); + return self.on_created(r, prepend_on_create); }, null); } else if (_.isEmpty(values) && ! self.force_dirty) { - // console.log("FormView(", self, ") : Nothing to save"); + // Not dirty, noop save save_deferral = $.Deferred().resolve({}).promise(); } else { self.force_dirty = false; - // console.log("FormView(", self, ") : About to save", values); + // Write save save_deferral = self.dataset.write(self.datarecord.id, values, {}).pipe(function(r) { return self.on_saved(r); }, null); } - return save_deferral.then(success); + return save_deferral; } } catch (e) { console.error(e); @@ -838,14 +839,19 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM warnings.push('</ul>'); this.do_warn("The following fields are invalid :", warnings.join('')); }, - on_saved: function(r, success) { + /** + * Reload the form after saving + * + * @param {Object} r result of the write function. + */ + on_saved: function(r) { if (!r.result) { // should not happen in the server, but may happen for internal purpose return $.Deferred().reject(); } else { return $.when(this.reload()).pipe(function () { - return r; }) - .then(success); + return r; + }); } }, /** @@ -858,10 +864,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM * * Updates the pager and sidebar displays * * @param {Object} r - * @param {Function} success callback to execute after having updated the dataset - * @param {Boolean} [prepend_on_create=false] adds the newly created record at the beginning of the dataset instead of the end + * @param {Boolean} [prepend_on_create=false] adds the newly created record + * at the beginning of the dataset instead of the end */ - on_created: function(r, success, prepend_on_create) { + on_created: function(r, prepend_on_create) { if (!r.result) { // should not happen in the server, but may happen for internal purpose return $.Deferred().reject(); @@ -880,8 +886,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } //openerp.log("The record has been created with id #" + this.datarecord.id); return $.when(this.reload()).pipe(function () { - return _.extend(r, {created: true}); }) - .then(success); + return _.extend(r, {created: true}); + }); } }, on_action: function (action) { @@ -2324,11 +2330,16 @@ instance.web.form.FieldDate = instance.web.form.FieldDatetime.extend({ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { template: 'FieldText', + init: function (field_manager, node) { + this._super(field_manager, node); + }, initialize_content: function() { + var self = this; this.$textarea = this.$el.find('textarea'); + this.default_height = this.$textarea.css('height'); if (!this.get("effective_readonly")) { this.$textarea.change(_.bind(function() { - this.set({'value': instance.web.parse_value(this.$textarea.val(), this)}); + self.set({'value': instance.web.parse_value(self.$textarea.val(), self)}); }, this)); } else { this.$textarea.attr('disabled', 'disabled'); @@ -2341,15 +2352,17 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we this.setupFocus(this.$textarea); }, set_value: function(value_) { - this._super.apply(this, arguments); + this._super(value_); this.render_value(); + $(window).resize(); }, render_value: function() { var show_value = instance.web.format_value(this.get('value'), this, ''); - this.$textarea.val(show_value); - if (show_value && this.view.options.resize_textareas) { - this.do_resize(this.view.options.resize_textareas); + if (show_value === '') { + this.$textarea.css('height', parseInt(this.default_height)+"px"); } + this.$textarea.val(show_value); + this.$textarea.autosize(); }, is_syntax_valid: function() { if (!this.get("effective_readonly")) { @@ -2368,26 +2381,6 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we focus: function($el) { this.$textarea.focus(); }, - do_resize: function(max_height) { - max_height = parseInt(max_height, 10); - var $input = this.$textarea, - $div = $('<div style="position: absolute; z-index: 1000; top: 0"/>').width($input.width()), - new_height; - $div.text($input.val()); - _.each('font-family,font-size,white-space'.split(','), function(style) { - $div.css(style, $input.css(style)); - }); - $div.appendTo($('body')); - new_height = $div.height(); - if (new_height < 90) { - new_height = 90; - } - if (!isNaN(max_height) && new_height > max_height) { - new_height = max_height; - } - $div.remove(); - $input.height(new_height); - }, }); /** @@ -2412,7 +2405,7 @@ instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instanc self._updating_editor = false; this.$textarea = this.$el.find('textarea'); var width = ((this.node.attrs || {}).editor_width || 468); - var height = ((this.node.attrs || {}).editor_height || 100); + var height = ((this.node.attrs || {}).editor_height || 250); this.$textarea.cleditor({ width: width, // width not including margins, borders or padding height: height, // height not including margins, borders or padding @@ -2565,7 +2558,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan } }); -// jquery autocomplete tweak to allow html +// jquery autocomplete tweak to allow html and classnames (function() { var proto = $.ui.autocomplete.prototype, initSource = proto._initSource; @@ -2592,7 +2585,8 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan return $( "<li></li>" ) .data( "item.autocomplete", item ) .append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) ) - .appendTo( ul ); + .appendTo( ul ) + .addClass(item.classname); } }); })(); @@ -2632,25 +2626,36 @@ instance.web.form.CompletionFieldMixin = { // search more... if more results that max if (values.length > self.limit) { values = values.slice(0, self.limit); - values.push({label: _t("<em> Search More...</em>"), action: function() { - dataset.name_search(search_val, self.build_domain(), 'ilike' - , false, function(data) { - self._search_create_popup("search", data); - }); - }}); + values.push({ + label: _t("Search More..."), + action: function() { + dataset.name_search(search_val, self.build_domain(), 'ilike', false, function(data) { + self._search_create_popup("search", data); + }); + }, + classname: 'oe_m2o_dropdown_option' + }); } // quick create var raw_result = _(data.result).map(function(x) {return x[1];}); if (search_val.length > 0 && !_.include(raw_result, search_val)) { - values.push({label: _.str.sprintf(_t('<em> Create "<strong>%s</strong>"</em>'), - $('<span />').text(search_val).html()), action: function() { - self._quick_create(search_val); - }}); + values.push({ + label: _.str.sprintf(_t('Create "<strong>%s</strong>"'), + $('<span />').text(search_val).html()), + action: function() { + self._quick_create(search_val); + }, + classname: 'oe_m2o_dropdown_option' + }); } // create... - values.push({label: _t("<em> Create and Edit...</em>"), action: function() { - self._search_create_popup("form", undefined, self._create_context(search_val)); - }}); + values.push({ + label: _t("Create and Edit..."), + action: function() { + self._search_create_popup("form", undefined, self._create_context(search_val)); + }, + classname: 'oe_m2o_dropdown_option' + }); return values; }); diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 5256b0268a4..2615d8c66dd 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -716,7 +716,7 @@ openerp.web.list_editable = function (instance) { save: function () { var self = this; return this.form - .do_save(null, this.delegate.prepends_on_create()) + .do_save(this.delegate.prepends_on_create()) .pipe(function (result) { var created = result.created && !self.record.id; if (created) { diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 79e9704cad4..6ec579e59e4 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -874,7 +874,7 @@ instance.web.Sidebar = instance.web.Widget.extend({ var view = this.getParent(); this.sections = [ { 'name' : 'print', 'label' : _t('Print'), }, - { 'name' : 'files', 'label' : _t('Attachment'), }, + { 'name' : 'files', 'label' : _t('Attachment(s)'), }, { 'name' : 'other', 'label' : _t('More'), } ]; this.items = { @@ -1077,14 +1077,13 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({ start: function() { var self = this; this._super(); - $.when(this.languages_loaded).then(function() { + return $.when(this.languages_loaded).then(function() { self.$el.html(instance.web.qweb.render('TranslateDialog', { widget: self })); self.$fields_form = self.$el.find('.oe_translation_form'); self.$fields_form.find('.oe_trad_field').change(function() { $(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value'))); }); }); - return this; }, on_languages_loaded: function(langs) { this.languages = langs; @@ -1136,9 +1135,9 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({ }); }, on_btn_save: function() { - var trads = {}, - self = this, - trads_mutex = new $.Mutex(); + var trads = {}; + var self = this; + var trads_mutex = new $.Mutex(); self.$fields_form.find('.oe_trad_field.touched').each(function() { var field = $(this).attr('name').split('-'); if (!trads[field[0]]) { @@ -1157,6 +1156,7 @@ instance.web.TranslateDialog = instance.web.Dialog.extend({ }); }); this.close(); + return trads_mutex; }, on_btn_close: function() { this.close(); |
