diff options
| author | Quentin (OpenERP) <qdp-launchpad@openerp.com> | 2012-05-23 11:51:36 +0200 |
|---|---|---|
| committer | Quentin (OpenERP) <qdp-launchpad@openerp.com> | 2012-05-23 11:51:36 +0200 |
| commit | ab372e3dcf79744856ee658a0a4107b6cec7395c (patch) | |
| tree | 78b7e5abfe2b3e91ae822ba292db5ca379a46e87 /addons/google_docs/static/src | |
| parent | df52a73fc7456a8f0c401b6789e6eb06a177f756 (diff) | |
[IMP] google_docs: reviewed code. Overall cleaning of methods, better documentation, refactoring, fix of some glitches and so on...
bzr revid: qdp-launchpad@openerp.com-20120523095136-vj1n9ekukdxibzr2
Diffstat (limited to 'addons/google_docs/static/src')
| -rw-r--r-- | addons/google_docs/static/src/js/gdocs.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/addons/google_docs/static/src/js/gdocs.js b/addons/google_docs/static/src/js/gdocs.js index 6fe830d383c..8f41a9d7b21 100644 --- a/addons/google_docs/static/src/js/gdocs.js +++ b/addons/google_docs/static/src/js/gdocs.js @@ -1,31 +1,41 @@ openerp.google_docs = function(instance, m) { +var _t = instance.web._t; + instance.web.Sidebar = instance.web.Sidebar.extend({ on_attachments_loaded: function(attachments) { - self._super(attachements); + self = this + self._super(attachments); // if attachment contains a google doc url do nothing - // else - this.sidebar.add_items('other', [ - { label: _t('Google Doc'), callback: self.on_google_doc }, - ]); + // else display a button to create a google doc + var flag = false; + _.each(attachments, function(i) { + if (i.url && i.url.match('/docs.google.com/')) { flag = true; } + }); + if (! flag) { + this.add_items('files', [ + { 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) { + var ds = new instance.web.DataSet(this, 'ir.attachment', context); + ds.call('google_doc_get', [form.dataset.model, [form.datarecord.id], context], function(r) { if (r == 'False') { var params = { error: response, - message: "The user google credentials are not set yet. Contact your administrator for help." + message: _t("The user google credentials are not set yet. Contact your administrator for help.") } $(openerp.web.qweb.render("DialogWarning", params)).dialog({ - title: "User Google credentials are not yet set.", + title: _t("User Google credentials are not yet set."), modal: true, }); } - view.reload(); + form.reload(); }); - } + }) } -}; + }) +} |
