summaryrefslogtreecommitdiff
path: root/addons/google_docs/static/src
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-05-22 15:39:44 +0200
committerAntony Lesuisse <al@openerp.com>2012-05-22 15:39:44 +0200
commitdf52a73fc7456a8f0c401b6789e6eb06a177f756 (patch)
treebbeb83c9787179362bd42c645679f59c4503c7fd /addons/google_docs/static/src
parentec668c7c4ae89190a0b1b7b04f4062802d794881 (diff)
[FIX] google docs new sidebar api
bzr revid: al@openerp.com-20120522133944-71thw8qolitv8ft8
Diffstat (limited to 'addons/google_docs/static/src')
-rw-r--r--addons/google_docs/static/src/js/gdocs.js49
-rw-r--r--addons/google_docs/static/src/xml/gdocs.xml13
2 files changed, 19 insertions, 43 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js
index a8e941f01f6..6fe830d383c 100644
--- a/addons/google_docs/static/src/js/gdocs.js
+++ b/addons/google_docs/static/src/js/gdocs.js
@@ -1,29 +1,19 @@
-openerp.google_docs = function(instance, session) {
-
-
- instance.web.form.SidebarAttachments = instance.web.form.SidebarAttachments.extend({
- init: function() {
- this._super.apply(this, arguments);
- this.$element.delegate('.oe_google_docs_text_button', 'click', this.on_add_text_gdoc);
- },
-
-
- on_attachments_loaded: function(attachments) {
- this._super(attachments);
- var config = new instance.web.DataSet(this, 'google.docs.config', this.view.dataset.get_context());
- config.call('get_config', [[this.view.datarecord.id],this.view.dataset.model,this.view.dataset.get_context()], function(r) {
- if (r == false){
- $('.oe_google_docs_text_button',this.$element).hide();
- }
- });
- },
-
- on_add_text_gdoc: function() {
- var self = this;
- var $gdocbtn = this.$element.find('.oe_google_docs_text_button');
- $gdocbtn.attr('disabled', 'true').find('img, span').toggle();
- var ds = new instance.web.DataSet(this, 'google.docs', this.view.dataset.get_context());
- ds.call('doc_get', [this.view.dataset.model, [this.view.datarecord.id], 'text'], function(r) {
+openerp.google_docs = function(instance, m) {
+ instance.web.Sidebar = instance.web.Sidebar.extend({
+ on_attachments_loaded: function(attachments) {
+ self._super(attachements);
+ // if attachment contains a google doc url do nothing
+ // else
+ this.sidebar.add_items('other', [
+ { label: _t('Google Doc'), callback: self.on_google_doc },
+ ]);
+ },
+ on_google_doc: function() {
+ var self = this;
+ var form = self.getParent();
+ form.sidebar_context().then(function (context) {
+ var ds = new instance.web.DataSet(this, 'google.docs', context);
+ ds.call('doc_get', [form.view.dataset.model, [form.view.datarecord.id], 'text'], function(r) {
if (r == 'False') {
var params = {
error: response,
@@ -34,9 +24,8 @@ openerp.google_docs = function(instance, session) {
modal: true,
});
}
- self.do_update();
+ view.reload();
});
- },
- });
+ }
+ }
};
-
diff --git a/addons/google_docs/static/src/xml/gdocs.xml b/addons/google_docs/static/src/xml/gdocs.xml
deleted file mode 100644
index 2de7efcbd43..00000000000
--- a/addons/google_docs/static/src/xml/gdocs.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?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="oe_google_docs_text_button" type="button">
- <img src="/web/static/src/img/throbber.gif" width="16" height="16" style="display: none"/>
- <span>Goole Docs</span>
- </button>
- </t>
- </t>
-</templates>