summaryrefslogtreecommitdiff
path: root/addons/google_docs/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/google_docs/static/src/js')
-rw-r--r--addons/google_docs/static/src/js/gdocs.js29
1 files changed, 29 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);
+ });
+ }
+});
+
+};