diff options
| author | Rucha (Open ERP) <rpa@tinyerp.com> | 2011-11-02 10:58:27 +0530 |
|---|---|---|
| committer | Rucha (Open ERP) <rpa@tinyerp.com> | 2011-11-02 10:58:27 +0530 |
| commit | 2fdecf4717080ea98a514b67dedefc27d76c6727 (patch) | |
| tree | bb54dd0e81af0bbf999fee1110fecb9e507f51e1 /addons/share/static | |
| parent | 9fe0f6fa83b84d0806359bdc2a3ae31dfb7e997a (diff) | |
| parent | 3d22bb8b55d48e5ee8226f023555f003288b157a (diff) | |
[MERGE]: Merge with latest trunk
bzr revid: rpa@tinyerp.com-20111102052827-0bctjrhb4amyg6pl
Diffstat (limited to 'addons/share/static')
| -rw-r--r-- | addons/share/static/src/css/share.css | 13 | ||||
| -rw-r--r-- | addons/share/static/src/js/share.js | 83 | ||||
| -rw-r--r-- | addons/share/static/src/xml/share.xml | 14 |
3 files changed, 110 insertions, 0 deletions
diff --git a/addons/share/static/src/css/share.css b/addons/share/static/src/css/share.css new file mode 100644 index 00000000000..3b47a065b1e --- /dev/null +++ b/addons/share/static/src/css/share.css @@ -0,0 +1,13 @@ + +.openerp li.oe-share { + background: url(../img/share.png) no-repeat; + padding-left: 20px; +} + +.openerp a.oe-share { + background: url(../img/share.png) no-repeat; + display: block; + float: left; + width: 20px; + height: 20px; +} diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js new file mode 100644 index 00000000000..6d02a39cf1f --- /dev/null +++ b/addons/share/static/src/js/share.js @@ -0,0 +1,83 @@ + +openerp.share = function(instance) { +var QWeb = instance.web.qweb; +QWeb.add_template('/share/static/src/xml/share.xml'); + +function launch_wizard(self, view) { + var action = view.widget_parent.action; + var Share = new instance.web.DataSet(self, 'share.wizard', view.dataset.get_context()); + var domain = view.dataset.domain; + + if (view.fields_view.type == 'form') { + domain = new instance.web.CompoundDomain(domain, [['id', '=', view.datarecord.id]]); + } + + Share.create({ + name: action.name, + domain: domain, + action_id: action.id, + }, function(result) { + var share_id = result.result; + var step1 = Share.call('go_step_1', [[share_id],], function(result) { + var action = result; + self.do_action(action); + }); + }); +} + +var _has_share = null; +function if_has_share(yes, no) { + if (!_has_share) { + _has_share = $.Deferred(function() { + var self = this; + var session = instance.webclient.session; + session.on_session_invalid.add_last(function() { _has_share = null; }); + var func = new instance.web.Model(session, "share.wizard").get_func("has_share"); + func(session.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 + launch_wizard(this, view); + }, +}); + +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) { + e.preventDefault(); + launch_wizard(this, this.views[this.active_view].controller); + }, +}); + +}; diff --git a/addons/share/static/src/xml/share.xml b/addons/share/static/src/xml/share.xml new file mode 100644 index 00000000000..9a1363846a0 --- /dev/null +++ b/addons/share/static/src/xml/share.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- vim:fdl=1: +--> +<templates id="template" xml:space="preserve"> + + <t t-extend="ViewManagerAction"> + <t t-jquery=".oe-shortcut-toggle" t-operation="after"> + <a class="oe-share" href="#share" title="Share this in 2 clicks..."> + <!--<img src="/share/static/src/img/share.png"/>--> + </a> + </t> + </t> + +</templates> |
