diff options
| author | Roberto López López (OpenERP) <rlo@openerp.com> | 2012-02-27 10:02:24 +0100 |
|---|---|---|
| committer | Roberto López López (OpenERP) <rlo@openerp.com> | 2012-02-27 10:02:24 +0100 |
| commit | ebfb0be2e156b49a14790300ce746dba78a159d5 (patch) | |
| tree | 227bc5201715c14d4b51b80a2010f6fbb208cdcf /addons/google_docs/static/src | |
| parent | fd914eb2e3e09fec08733989e5c8456d4516194a (diff) | |
[IMP] copy from pad
bzr revid: rlo@openerp.com-20120227090224-zujpg9zhf2nd5ioe
Diffstat (limited to 'addons/google_docs/static/src')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 29 | ||||
| -rw-r--r-- | addons/google_docs/static/src/xml/gdocs.xml | 13 |
2 files changed, 42 insertions, 0 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js new file mode 100644 index 00000000000..e605577d45a --- /dev/null +++ b/addons/google_docs/static/src/js/gdocs.js @@ -0,0 +1,29 @@ +openerp.gdocs = function(instance) { + +instance.web.form.SidebarAttachments = instance.web.form.SidebarAttachments.extend({ + on_attachments_loaded: function(attachments) { + this._super(attachments); + var self = this; + var $padbtn = self.$element.find('button.gdocs'); + var is_pad = function(a) { + return a.type == 'url' && a.name == 'GDocs'; + }; + if (_.any(attachments, is_pad)) { + $padbtn.hide(); + } else { + $padbtn.show().click(self.on_add_pad); + } + }, + on_add_pad: function() { + var self = this; + var $padbtn = this.$element.find('button.gdocs'); + $padbtn.attr('disabled', 'true').find('img, span').toggle(); + this.view.dataset.call_button('pad_get', [[this.view.datarecord.id], this.view.dataset.get_context()], function(r) { + $padbtn.hide(); + self.do_update(); + self.do_action(r.result); + }); + } +}); + +}; diff --git a/addons/google_docs/static/src/xml/gdocs.xml b/addons/google_docs/static/src/xml/gdocs.xml new file mode 100644 index 00000000000..52decbfdbc1 --- /dev/null +++ b/addons/google_docs/static/src/xml/gdocs.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- vim:fdl=1: +--> +<templates id="template" xml:space="preserve"> + <t t-extend="FormView.sidebar.attachments"> + <t t-jquery="div.oe-binary-file-set" t-operation="append"> + <button class="button gdoc" type="button"> + <img src="/web/static/src/img/throbber.gif" width="16" height="16" style="display: none"/> + <span>Add GDoc</span> + </button> + </t> + </t> +</templates> |
