[FIX] share js
bzr revid: al@openerp.com-20111216161909-dwkor7vq30hqmhli
This commit is contained in:
parent
c4edd73361
commit
a6bdfc5204
|
@ -27,37 +27,15 @@ function launch_wizard(self, view) {
|
|||
});
|
||||
}
|
||||
|
||||
var _has_share = null;
|
||||
function if_has_share(yes, no) {
|
||||
if (!_has_share) {
|
||||
_has_share = $.Deferred(function() {
|
||||
var self = this;
|
||||
instance.connection.on_session_invalid.add_last(function() { _has_share = null; });
|
||||
var func = new instance.web.Model(null, "share.wizard").get_func("has_share");
|
||||
func(instance.connection.uid).pipe(function(res) {
|
||||
if(res) {
|
||||
self.resolve();
|
||||
} else {
|
||||
self.reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
_has_share.done(yes).fail(no);
|
||||
}
|
||||
|
||||
|
||||
instance.web.Sidebar = instance.web.Sidebar.extend({
|
||||
add_default_sections: function() {
|
||||
this._super();
|
||||
var self = this;
|
||||
if_has_share(function() {
|
||||
self.add_items('other', [{
|
||||
label: 'Share',
|
||||
callback: self.on_sidebar_click_share,
|
||||
classname: 'oe-share',
|
||||
}]);
|
||||
});
|
||||
},
|
||||
on_sidebar_click_share: function(item) {
|
||||
var view = this.widget_parent
|
||||
|
@ -68,11 +46,7 @@ instance.web.Sidebar = instance.web.Sidebar.extend({
|
|||
instance.web.ViewManagerAction.include({
|
||||
start: function() {
|
||||
var self = this;
|
||||
if_has_share(function() {
|
||||
self.$element.find('a.oe-share').click(self.on_click_share);
|
||||
}, function() {
|
||||
self.$element.find('a.oe-share').remove();
|
||||
});
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
on_click_share: function(e) {
|
||||
|
|
Loading…
Reference in New Issue