diff options
| author | Purnendu Singh (OpenERP) <psi@tinyerp.com> | 2012-10-23 15:35:28 +0530 |
|---|---|---|
| committer | Purnendu Singh (OpenERP) <psi@tinyerp.com> | 2012-10-23 15:35:28 +0530 |
| commit | a10c7b882b498fdfe2d84700fde65102783a14f0 (patch) | |
| tree | cd2b2b19abf0647f15f6fa41110dbf749a2ce169 /addons/web/static/src/js | |
| parent | 36cc003dc8dd9bb05b64e82753dad66a5bef95ce (diff) | |
| parent | 9bf9ca7a67a16b83cfa371c1377865e168d6c7dc (diff) | |
[MERGE] merge with main web
bzr revid: psi@tinyerp.com-20121023100528-w5z1yf2yj6cq1edj
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/data.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/search.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 27 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 34 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list_editable.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 56 |
6 files changed, 73 insertions, 54 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 30a8b9862fc..e279ade6fb3 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -135,6 +135,8 @@ instance.web.Query = instance.web.Class.extend({ }).pipe(function (results) { return _(results).map(function (result) { // FIX: querygroup initialization + result.__context = result.__context || {}; + result.__context.group_by = result.__context.group_by || []; _.defaults(result.__context, ctx); return new instance.web.QueryGroup( self._model.name, grouping[0], result); @@ -557,8 +559,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ return this._model.call('name_create', [name], {context: this._model.context()}); }, exec_workflow: function (id, signal) { - return this._model.exec_workflow(id, signal) - .pipe(function (result) { return { result: result }; }); + return this._model.exec_workflow(id, signal); }, get_context: function(request_context) { return this._model.context(request_context); diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 33d20980732..9351f621324 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -746,7 +746,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea this.on_invalid(search.errors); return; } - return this.trigger('search_data', search.domains, search.contexts, search.groupbys); + this.trigger('search_data', search.domains, search.contexts, search.groupbys); }, /** * Triggered after the SearchView has collected all relevant domains and @@ -777,6 +777,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea */ on_invalid: function (errors) { this.do_notify(_t("Invalid Search"), _t("triggered from search view")); + this.trigger('invalid_search', errors); } }); diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d096e15b51d..850a334c40b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -168,7 +168,6 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.$buttons = $(QWeb.render("FormView.buttons", {'widget':self})); if (this.options.$buttons) { - this.options.$buttons.children().remove(); this.$buttons.appendTo(this.options.$buttons); } else { this.$el.find('.oe_form_buttons').replaceWith(this.$buttons); @@ -3120,8 +3119,10 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc if (!this.get("effective_readonly")) { this.$input.val(str.split("\n")[0]); this.current_display = this.$input.val(); - if(this.is_false()){ + if (this.is_false()) { this.$('.oe_m2o_cm_button').css({'display':'none'}); + } else { + this.$('.oe_m2o_cm_button').css({'display':'inline'}); } } else { var lines = _.escape(str).split("\n"); @@ -3351,6 +3352,13 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ controller.on('edit:before', self, function (e) { e.cancel = true; }); + _(controller.columns).find(function (column) { + if (!column instanceof instance.web.list.Handle) { + return false; + } + column.modifiers.invisible = true; + return true; + }); } } else if (view_type === "form") { if (self.get("effective_readonly")) { @@ -3586,6 +3594,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ _template: 'One2Many.listview', init: function (parent, dataset, view_id, options) { this._super(parent, dataset, view_id, _.extend(options || {}, { + GroupsType: instance.web.form.One2ManyGroups, ListType: instance.web.form.One2ManyList })); this.on('edit:before', this, this.proxy('_before_edit')); @@ -3766,6 +3775,13 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ }); } }); +instance.web.form.One2ManyGroups = instance.web.ListView.Groups.extend({ + setup_resequence_rows: function () { + if (!this.view.o2m.get('effective_readonly')) { + this._super.apply(this, arguments); + } + } +}); instance.web.form.One2ManyList = instance.web.ListView.List.extend({ pad_table_to: function (count) { if (!this.view.is_action_enabled('create')) { @@ -4145,6 +4161,9 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( } this._super(value_); }, + get_value: function() { + return [commands.replace_with(this.get('value'))]; + }, load_view: function() { var self = this; this.kanban_view = new instance.web.form.Many2ManyKanbanView(this, this.dataset, false, { @@ -4178,7 +4197,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( }); }, dataset_changed: function() { - this.set({'value': [commands.replace_with(this.dataset.ids)]}); + this.set({'value': this.dataset.ids}); }, open_popup: function(type, unused) { if (type !== "form") @@ -4534,7 +4553,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend }); }); }); - this.searchview.appendTo($(".oe_popup_list", self.$el)); + this.searchview.appendTo($(".oe_popup_search", self.$el)); }, do_search: function(domains, contexts, groupbys) { var self = this; diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 79963561715..bfada2affba 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -22,6 +22,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi 'reorderable': true, 'action_buttons': true, }, + view_type: 'tree', /** * Core class for list-type displays. * @@ -83,7 +84,8 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi }); this.no_leaf = false; - this.on('view_load', self, self.load_list); + this.grouped = false; + this.on('view_loaded', self, self.load_list); }, set_default_options: function (options) { this._super(options); @@ -145,7 +147,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi */ start: function() { this.$el.addClass('oe_list'); - return this.reload_view(null, null, true); + return this._super(); }, /** * Returns the style for the provided record in the current view (from the @@ -219,7 +221,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi * @param {Object} data.fields_view.arch current list view descriptor * @param {Boolean} grouped Is the list view grouped */ - load_list: function(data, grouped) { + load_list: function(data) { var self = this; this.fields_view = data; this.name = "" + this.fields_view.arch.attrs.string; @@ -245,7 +247,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi }).value(); } - this.setup_columns(this.fields_view.fields, grouped); + this.setup_columns(this.fields_view.fields, this.grouped); this.$el.html(QWeb.render(this._template, this)); this.$el.addClass(this.fields_view.arch.attrs['class']); @@ -290,7 +292,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi } this.$buttons.find('.oe_list_add') .click(this.proxy('do_add_record')) - .prop('disabled', grouped); + .prop('disabled', this.grouped); } // Pager @@ -359,7 +361,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.sidebar.add_toolbar(this.fields_view.toolbar); this.sidebar.$el.hide(); } - this.trigger('list_view_loaded', data, grouped); + this.trigger('list_view_loaded', data, this.grouped); }, /** * Configures the ListView pager based on the provided dataset's information @@ -464,25 +466,12 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi /** * Reloads the list view based on the current settings (dataset & al) * + * @deprecated * @param {Boolean} [grouped] Should the list be displayed grouped * @param {Object} [context] context to send the server while loading the view */ reload_view: function (grouped, context, initial) { - var self = this; - var callback = function (field_view_get) { - self.load_list(field_view_get, grouped); - }; - if (this.embedded_view) { - return $.Deferred().then(callback).resolve(this.embedded_view); - } else { - return this.rpc('/web/view/load', { - model: this.model, - view_id: this.view_id, - view_type: "tree", - context: this.dataset.get_context(context), - toolbar: !!this.options.$sidebar - }).then(callback); - } + return this.load_view(context); }, /** * re-renders the content of the list view @@ -564,8 +553,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi group_by = null; } this.no_leaf = !!context['group_by_no_leaf']; + this.grouped = !!group_by; - this.reload_view(!!group_by, context).then( + return this.load_view(context).pipe( this.proxy('reload_content')); }, /** diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 9bc0e96032f..acc1d781976 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -150,7 +150,7 @@ openerp.web.list_editable = function (instance) { if (!id && done.created) { id = done.record.get('id'); } - self.handle_button.call(self, name, id, callback); + self.handle_button(name, id, callback); }); }, /** diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 705bc1b214e..66dfba99d9f 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -24,10 +24,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ }, dialog_stop: function () { if (this.dialog) { - this.dialog_widget.destroy(); - this.dialog_widget = null; this.dialog.destroy(); - this.dialog = null; } }, /** @@ -299,15 +296,14 @@ instance.web.ActionManager = instance.web.Widget.extend({ } var widget = executor.widget(); if (executor.action.target === 'new') { + if (this.dialog_widget && ! this.dialog_widget.isDestroyed()) + this.dialog_widget.destroy(); if (this.dialog === null || this.dialog.isDestroyed()) { this.dialog = new instance.web.Dialog(this, { - buttons: {"Close": function() {$(this).dialog("close")}}, dialogClass: executor.klass, }); this.dialog.on("closing", null, options.on_close); this.dialog.init_dialog(); - } else { - this.dialog_widget.destroy(); } this.dialog.dialog_title = executor.action.name; if (widget instanceof instance.web.ViewManager) { @@ -317,6 +313,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ }); } this.dialog_widget = widget; + this.dialog_widget.setParent(this.dialog); var initialized = this.dialog_widget.appendTo(this.dialog.$el); this.dialog.open(); return initialized; @@ -898,9 +895,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ var self = this; return $.when(this._super.apply(this, arguments)).then(function () { - var controller = self.views[self.active_view].controller, - fvg = controller.fields_view, - view_id = (fvg && fvg.view_id) || '--'; + var controller = self.views[self.active_view].controller; self.$el.find('.oe_debug_view').html(QWeb.render('ViewManagerDebug', { view: controller, view_manager: self @@ -914,8 +909,17 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ view.set({ 'title': this.action.name }); return r; }, + get_action_manager: function() { + var cur = this; + while (cur = cur.getParent()) { + if (cur instanceof instance.web.ActionManager) { + return cur; + } + } + return undefined; + }, set_title: function(title) { - this.$el.find('.oe_breadcrumb_title:first').html(this.getParent().get_title()); + this.$el.find('.oe_breadcrumb_title:first').html(this.get_action_manager().get_title()); }, do_push_state: function(state) { if (this.getParent() && this.getParent().do_push_state) { @@ -1061,9 +1065,11 @@ instance.web.Sidebar = instance.web.Widget.extend({ additional_context); result.flags = result.flags || {}; result.flags.new_window = true; - self.do_action(result, function () { - // reload view - self.getParent().reload(); + self.do_action(result, { + on_close: function() { + // reload view + self.getParent().reload(); + }, }); }); }); @@ -1134,28 +1140,28 @@ instance.web.View = instance.web.Widget.extend({ start: function () { return this.load_view(); }, - load_view: function() { + load_view: function(context) { var self = this; + var view_loaded; if (this.embedded_view) { - var def = $.Deferred(); - $.async_when().then(function() {def.resolve(self.embedded_view);}); - return def.pipe(function(r) { - self.trigger('view_loaded', r); + view_loaded = $.Deferred(); + $.async_when().then(function() { + view_loaded.resolve(self.embedded_view); }); } else { - var context = new instance.web.CompoundContext(this.dataset.get_context()); if (! this.view_type) console.warn("view_type is not defined", this); - return this.rpc("/web/view/load", { + view_loaded = this.rpc("/web/view/load", { "model": this.dataset.model, "view_id": this.view_id, "view_type": this.view_type, toolbar: !!this.options.$sidebar, - context: context - }).pipe(function(r) { - self.trigger('view_loaded', r); + context: this.dataset.get_context(context) }); } + return view_loaded.pipe(function(r) { + self.trigger('view_loaded', r); + }); }, set_default_options: function(options) { this.options = options || {}; @@ -1209,7 +1215,9 @@ instance.web.View = instance.web.Widget.extend({ /* niv: previously we were overriding once more with action_data.context, * I assumed this was not a correct behavior and removed it */ - return self.do_action(action, result_handler); + return self.do_action(action, { + on_close: result_handler, + }); }, null); } else { return result_handler(); |
