diff options
| author | Antony Lesuisse <al@openerp.com> | 2011-10-25 12:06:07 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2011-10-25 12:06:07 +0200 |
| commit | f1f4c2a95a987df2f0cae0598c607f56e2ce208f (patch) | |
| tree | ae12469e3c15a4aeca8a41a21aad804ed9c102e3 /addons/share/static/src | |
| parent | bf3465b3b5bebeb3d2d033f9536bbf4afbb4642f (diff) | |
| parent | 2102484af45a6bfae846db2a317f5b0561d4941c (diff) | |
[MERGE] share, needs style fixing
bzr revid: al@openerp.com-20111025100607-fub4h85n8w20omth
Diffstat (limited to 'addons/share/static/src')
| -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> |
