[IMP] show and hide search view based on whether the currently displayed view is searchable
Note: searchability is *opt-out*, a view is searchable until it unambiguously states 'do not search me' bzr revid: xmo@openerp.com-20110401104500-n7g6so01xb8oow3n
This commit is contained in:
parent
f40d778c2e
commit
0a5a8cd81a
|
@ -88,6 +88,7 @@ class Session(openerpweb.Controller):
|
|||
@openerpweb.jsonrequest
|
||||
def login(self, req, db, login, password):
|
||||
req.session.login(db, login, password)
|
||||
|
||||
return {
|
||||
"session_id": req.session_id,
|
||||
"uid": req.session._uid,
|
||||
|
|
|
@ -2,7 +2,20 @@
|
|||
openerp.base.form = function (openerp) {
|
||||
|
||||
openerp.base.views.add('form', 'openerp.base.FormView');
|
||||
openerp.base.FormView = openerp.base.Controller.extend({
|
||||
openerp.base.FormView = openerp.base.Controller.extend(
|
||||
/** @lends openerp.base.FormView# */{
|
||||
/**
|
||||
* Indicates that this view is not searchable, and thus that no search
|
||||
* view should be displayed (if there is one active).
|
||||
*/
|
||||
searchable: false,
|
||||
/**
|
||||
* @constructs
|
||||
* @param {openerp.base.Session} session the current openerp session
|
||||
* @param {String} element_id this view's root element id
|
||||
* @param {openerp.base.DataSet} dataset the dataset this view will work with
|
||||
* @param {String} view_id the identifier of the OpenERP view object
|
||||
*/
|
||||
init: function(session, element_id, dataset, view_id) {
|
||||
this._super(session, element_id);
|
||||
this.dataset = dataset;
|
||||
|
|
|
@ -16,6 +16,12 @@ openerp.base.SearchView = openerp.base.Controller.extend({
|
|||
//this.log('Starting SearchView '+this.model+this.view_id)
|
||||
this.rpc("/base/searchview/load", {"model": this.model, "view_id":this.view_id}, this.on_loaded);
|
||||
},
|
||||
show: function () {
|
||||
this.$element.show();
|
||||
},
|
||||
hide: function () {
|
||||
this.$element.hide();
|
||||
},
|
||||
/**
|
||||
* Builds a list of widget rows (each row is an array of widgets)
|
||||
*
|
||||
|
|
|
@ -56,6 +56,12 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
|
|||
this.views[view_type].controller = controller;
|
||||
}
|
||||
|
||||
if (view.controller.searchable === false) {
|
||||
this.searchview.hide();
|
||||
} else {
|
||||
this.searchview.show();
|
||||
}
|
||||
|
||||
this.$element
|
||||
.find('.views-switchers button').removeAttr('disabled')
|
||||
.filter('[data-view-type="' + view_type + '"]')
|
||||
|
|
Loading…
Reference in New Issue