diff options
| author | Jigar Amin - OpenERP <jam@tinyerp.com> | 2012-07-16 11:54:16 +0530 |
|---|---|---|
| committer | Jigar Amin - OpenERP <jam@tinyerp.com> | 2012-07-16 11:54:16 +0530 |
| commit | 68998d4c827bb080d262da593c7766e25fb3427e (patch) | |
| tree | 4fbb30b8bba9b3eb2ada84591e0f06b97e05e9df /addons/web/static/src/js | |
| parent | d23af2550dc93113bbc81f43f4d580a1aed2f575 (diff) | |
| parent | 21832994f9d5feb158f593bfd69fec695e72e453 (diff) | |
[MERGE] openerp-web
bzr revid: jam@tinyerp.com-20120716062416-xa18xmtkj5mgj2ag
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 59 | ||||
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 6 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 62 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 17 |
5 files changed, 82 insertions, 64 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index c32d4feafe1..094e2f184e6 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -63,7 +63,7 @@ instance.web.Dialog = instance.web.Widget.extend({ this.dialog_options = { modal: true, destroy_on_close: true, - width: 750, + width: 900, min_width: 0, max_width: '95%', height: 'auto', @@ -145,9 +145,9 @@ instance.web.Dialog = instance.web.Widget.extend({ _.each(this.getChildren(), function(el) { el.destroy(); }); - if (! this.isDestroyed()) { - this.$element.dialog('destroy'); - } + if (! this.isDestroyed()) { + this.$element.dialog('destroy'); + } this._super(); } }); @@ -212,11 +212,11 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({ dialog.$element.html(QWeb.render('CrashManager.error', {session: instance.connection, error: error})); }, on_javascript_exception: function(exception) { - this.on_traceback({ - type: _t("Client Error"), - message: exception, - data: {debug: ""} - }); + this.on_traceback({ + type: _t("Client Error"), + message: exception, + data: {debug: ""} + }); }, }); @@ -482,24 +482,26 @@ instance.web.Login = instance.web.Widget.extend({ } } }, + open_db_manager: function(){ + var self = this; + self.$element.find('.oe_login_bottom').hide(); + self.$element.find('.oe_login_pane').hide(); + self.databasemanager = new instance.web.DatabaseManager(self); + self.databasemanager.appendTo(self.$element); + self.databasemanager.do_exit.add_last(function() { + self.databasemanager.destroy(); + self.$element.find('.oe_login_bottom').show(); + self.$element.find('.oe_login_pane').show(); + self.load_db_list(true).then(self.on_db_list_loaded); + }); + }, start: function() { var self = this; - self.$element.find("form").submit(self.on_submit); - self.$element.find('.oe_login_manage_db').click(function() { - self.$element.find('.oe_login_bottom').hide(); - self.$element.find('.oe_login_pane').hide(); - self.databasemanager = new instance.web.DatabaseManager(self); - self.databasemanager.appendTo(self.$element); - self.databasemanager.do_exit.add_last(function() { - self.databasemanager.destroy(); - self.$element.find('.oe_login_bottom').show(); - self.$element.find('.oe_login_pane').show(); - self.load_db_list(true).then(self.proxy('_db_list_loaded')); - }); + self.open_db_manager(); }); - return self.load_db_list().then(self.proxy('_db_list_loaded')); + return self.load_db_list().then(self.on_db_list_loaded); }, load_db_list: function (force) { var d = $.when(), self = this; @@ -514,11 +516,14 @@ instance.web.Login = instance.web.Widget.extend({ } return d; }, - _db_list_loaded: function () { - var list = this._db_list, - dbdiv = this.$element.find('div.oe_login_dbpane'); + on_db_list_loaded: function () { + var self = this; + var list = this._db_list; + var dbdiv = this.$element.find('div.oe_login_dbpane'); this.$element.find("[name=db]").replaceWith(instance.web.qweb.render('Login.dblist', { db_list: list, selected_db: this.selected_db})); - if(list && list.length === 1) { + if(list.length === 0) { + self.open_db_manager(); + } else if(list && list.length === 1) { dbdiv.hide(); } else { dbdiv.show(); @@ -667,7 +672,7 @@ instance.web.Menu = instance.web.Widget.extend({ * @param {Number} id the action_id to match */ open_action: function (id) { - var $menu = this.$element.add(this.$secondary_menus).find('a[data-action-id=' + id + ']'); + var $menu = this.$element.add(this.$secondary_menus).find('a[data-action-id="' + id + '"]'); var menu_id = $menu.data('menu'); if (menu_id) { this.open_menu(menu_id); diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index a00ca4002e5..a5a62b9bcc1 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -404,10 +404,11 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess } }); + /** * Event Bus used to bind events scoped in the current instance */ -instance.web.bus = new (instance.web.Class.extend(instance.web.EventDispatcherMixin, { +instance.web.Bus = instance.web.Class.extend(instance.web.EventDispatcherMixin, { init: function() { instance.web.EventDispatcherMixin.init.call(this, parent); var self = this; @@ -425,7 +426,8 @@ instance.web.bus = new (instance.web.Class.extend(instance.web.EventDispatcherMi }); }); } -}))(); +}) +instance.web.bus = new instance.web.Bus(); /** OpenERP Translations */ instance.web.TranslationDataBase = instance.web.Class.extend(/** @lends instance.web.TranslationDataBase# */{ diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a90654b2cf5..b103ce83699 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -9,7 +9,7 @@ instance.web.form = {}; /** * Interface implemented by the form view or any other object * able to provide the features necessary for the fields to work. - * + * * Properties: * - display_invalid_fields : if true, all fields where is_valid() return true should * be displayed as invalid. @@ -526,7 +526,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.on_form_changed(); } if (!_.isEmpty(result.warning)) { - instance.web.dialog($(QWeb.render("CrashManager.warning", result.warning)), { + instance.web.dialog($(QWeb.render("CrashManager.warning", result.warning)), { title:result.warning.title, modal: true, buttons: [ @@ -955,7 +955,7 @@ instance.web.form.FormRenderingEngineInterface = instance.web.Class.extend({ /** * Default rendering engine for the form view. - * + * * It is necessary to set the view using set_view() before usage. */ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInterface.extend({ @@ -1278,7 +1278,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt page_attrs.__page = $new_page; page_attrs.__ic = ic; pages.push(page_attrs); - + $new_page.children().each(function() { self.process($(this)); }); @@ -1304,7 +1304,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt } }); }); - + this.handle_common_properties($new_notebook, $notebook); return $new_notebook; }, @@ -1605,7 +1605,7 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi if (! v_context) { v_context = (this.field || {}).context || {}; } - + if (v_context.__ref || true) { //TODO: remove true var fields_values = this._build_eval_context(blacklist); v_context = new instance.web.CompoundContext(v_context).set_eval_context(fields_values); @@ -1713,14 +1713,14 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ /** * Interface to be implemented by fields. - * + * * Properties: * - readonly: boolean. If set to true the field should appear in readonly mode. * - force_readonly: boolean, When it is true, the field should always appear * in read only mode, no matter what the value of the "readonly" property can be. * Events: * - changed_value: triggered to inform the view to check on_changes - * + * */ instance.web.form.FieldInterface = { /** @@ -1731,14 +1731,14 @@ instance.web.form.FieldInterface = { init: function(field_manager, node) {}, /** * Called by the form view to indicate the value of the field. - * + * * set_value() may return an object that can be passed to $.when() that represents the moment when * the field has finished all operations necessary before the user can effectively use the widget. - * + * * Multiple calls to set_value() can occur at any time and must be handled correctly by the implementation, * regardless of any asynchronous operation currently running and the status of any promise that a * previous call to set_value() could have returned. - * + * * set_value() must be able, at any moment, to handle the syntax returned by the "read" method of the * osv class in the OpenERP server as well as the syntax used by the set_value() (see below). It must * also be able to handle any other format commonly used in the _defaults key on the models in the addons @@ -1748,16 +1748,16 @@ instance.web.form.FieldInterface = { set_value: function(value_) {}, /** * Get the current value of the widget. - * + * * Must always return a syntaxically correct value to be passed to the "write" method of the osv class in * the OpenERP server, although it is not assumed to respect the constraints applied to the field. * For example if the field is marqued as "required", a call to get_value() can return false. - * + * * get_value() can also be called *before* a call to set_value() and, in that case, is supposed to * return a defaut value according to the type of field. - * + * * This method is always assumed to perform synchronously, it can not return a promise. - * + * * If there was no user interaction to modify the value of the field, it is always assumed that * get_value() return the same semantic value than the one passed in the last call to set_value(), * altough the syntax can be different. This can be the case for type of fields that have a different @@ -1787,14 +1787,14 @@ instance.web.form.FieldInterface = { /** * Abstract class for classes implementing FieldInterface. - * + * * Properties: * - effective_readonly: when it is true, the widget is displayed as readonly. Vary depending * the values of the "readonly" property and the "force_readonly" property on the field manager. * - value: useful property to hold the value of the field. By default, set_value() and get_value() * set and retrieve the value property. Changing the value property also triggers automatically * a 'changed_value' event that inform the view to trigger on_changes. - * + * */ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.web.form.FieldInterface, { /** @@ -1813,7 +1813,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w this.string = this.node.attrs.string || this.field.string || this.name; this.set({'value': false}); this.set({required: this.modifiers['required'] === true}); - + // some events to make the property "effective_readonly" sync automatically with "readonly" and // "force_readonly" this.set({"readonly": this.modifiers['readonly'] === true}); @@ -1823,7 +1823,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w this.on("change:readonly", this, test_effective_readonly); this.on("change:force_readonly", this, test_effective_readonly); _.bind(test_effective_readonly, this)(); - + this.on("change:value", this, function() { if (! this._inhibit_on_change) this.trigger('changed_value'); @@ -2005,7 +2005,7 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we }); instance.web.form.FieldID = instance.web.form.FieldChar.extend({ - + }); instance.web.form.FieldEmail = instance.web.form.FieldChar.extend({ @@ -2398,7 +2398,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan } else { var self = this; var option = _(this.values) - .detect(function (record) { return record[0] === self.get('value'); }); + .detect(function (record) { return record[0] === self.get('value'); }); this.$element.text(option ? option[1] : this.values[0][1]); } }, @@ -2577,7 +2577,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc render_editable: function() { var self = this; this.$input = this.$element.find("input"); - + self.$input.tipsy({ title: function() { return "No element was selected, you should create or select one from the dropdown list."; @@ -2585,10 +2585,10 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc trigger:'manual', fade: true, }); - + this.$drop_down = this.$element.find(".oe_m2o_drop_down_button"); this.$follow_button = $(".oe_m2o_cm_button", this.$element); - + this.$follow_button.click(function() { if (!self.get('value')) { self.focus(); @@ -2882,7 +2882,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ }, load_views: function() { var self = this; - + var modes = this.node.attrs.mode; modes = !!modes ? modes.split(",") : ["tree"]; var views = []; @@ -3464,7 +3464,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in $("textarea", self.$element).css("padding-left", "3px"); self.tags.addTags(_.map(data, function(el) {return {name: el[1], id:el[0]};})); } else { - self.$element.html(QWeb.render("FieldMany2ManyTags.box", {elements: data})); + self.$element.html(QWeb.render("FieldMany2ManyTag", {elements: data})); } }; if (! self.get('values') || self.get('values').length > 0) { @@ -3636,7 +3636,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( this.dataset.on_unlink.add_last(function(ids) { self.dataset_changed(); }); - + this.is_setted.then(function() { self.load_view(); }); @@ -3752,7 +3752,7 @@ instance.web.form.Many2ManyKanbanView = instance.web_kanban.KanbanView.extend({ }); instance.web.form.Many2ManyQuickCreate = instance.web.Widget.extend({ template: 'Many2ManyKanban.quick_create', - + /** * close_btn: If true, the widget will display a "Close" button able to trigger * a "close" event. @@ -3868,8 +3868,8 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ var self = this; this.renderElement(); new instance.web.Dialog(this, { - width: '90%', min_width: '800px', + dialogClass: 'oe_act_window', close: function() { self.check_exit(true); }, @@ -4445,7 +4445,7 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ this.selection = []; // get fold information from widget var fold = ((this.node.attrs || {}).statusbar_fold || true); - // build final domain: if fold option required, add the + // build final domain: if fold option required, add the if (fold == true) { var domain = new instance.web.CompoundDomain(['|'], ['&'], self.build_domain(), [['fold', '=', false]], [['id', '=', self.selected_value]]); } else { @@ -4477,7 +4477,7 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ var shown = _.map(((this.node.attrs || {}).statusbar_visible || "").split(","), function(x) { return _.str.trim(x); }); shown = _.select(shown, function(x) { return x.length > 0; }); - + if (shown.length == 0) { this.to_show = this.selection; } else { diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 3033404b387..edc53f82042 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1045,7 +1045,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web. render_cell: function () { return self.render_cell.apply(self, arguments); } }, this))); - this.pad_table_to(5); + this.pad_table_to(4); }, pad_table_to: function (count) { if (this.records.length >= count || diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 423bf3f9d46..e11adb9d595 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -178,7 +178,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ }); }, do_action: function(action, on_close) { - if (_.isNumber(action)) { + if (_.isNumber(action) || _.isString(action)) { var self = this; return self.rpc("/web/action/load", { action_id: action }, function(result) { self.do_action(result.result, on_close); @@ -220,7 +220,11 @@ instance.web.ActionManager = instance.web.Widget.extend({ } if (action.target === 'new') { if (this.dialog === null) { - this.dialog = new instance.web.Dialog(this, { width: '80%' }); + // These buttons will be overwrited by <footer> if any + this.dialog = new instance.web.Dialog(this, { + buttons: { "Close": function() { $(this).dialog("close"); }}, + dialogClass: 'oe_act_window' + }); if(on_close) this.dialog.on_close.add(on_close); } else { @@ -404,6 +408,13 @@ instance.web.ViewManager = instance.web.Widget.extend({ container.hide(); controller.do_hide(); } + // put the <footer> in the dialog's buttonpane + if (self.$element.parent('.ui-dialog-content') && self.$element.find('footer')) { + self.$element.parent('.ui-dialog-content').parent().find('div.ui-dialog-buttonset').hide() + self.$element.find('footer').appendTo( + self.$element.parent('.ui-dialog-content').parent().find('div.ui-dialog-buttonpane') + ); + } } }); }); @@ -1252,7 +1263,7 @@ instance.web.View = instance.web.Widget.extend({ args.push(context); return dataset.call_button(action_data.name, args, handler); } else if (action_data.type=="action") { - return this.rpc('/web/action/load', { action_id: parseInt(action_data.name, 10), context: context, do_not_eval: true}, handler); + return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}, handler); } else { return dataset.exec_workflow(record_id, action_data.name, handler); } |
