diff options
| author | sgo@tinyerp.com <> | 2013-07-01 14:39:59 +0530 |
|---|---|---|
| committer | sgo@tinyerp.com <> | 2013-07-01 14:39:59 +0530 |
| commit | daec1fa0117348e91dffa0d2d7c669c9673ec5c4 (patch) | |
| tree | c8a1f9e2889cf81007efd1e2862e7f6fc73d2840 /addons/google_drive/static/src | |
| parent | ff73b066ed6adee1cd00b70241a17394d55f7436 (diff) | |
| parent | 447895839fd22fa610079a5b30f977b5b89b277d (diff) | |
[MERGE]sync with trunk
bzr revid: sgo@tinyerp.com-20130701090959-ddkktnp3asn6qqj1
Diffstat (limited to 'addons/google_drive/static/src')
| -rw-r--r-- | addons/google_drive/static/src/img/drive_icon.png | bin | 0 -> 2148 bytes | |||
| -rw-r--r-- | addons/google_drive/static/src/img/drive_icon_mono.png | bin | 0 -> 479 bytes | |||
| -rw-r--r-- | addons/google_drive/static/src/js/gdrive.js | 71 | ||||
| -rw-r--r-- | addons/google_drive/static/src/xml/gdocs.xml | 8 |
4 files changed, 79 insertions, 0 deletions
diff --git a/addons/google_drive/static/src/img/drive_icon.png b/addons/google_drive/static/src/img/drive_icon.png Binary files differnew file mode 100644 index 00000000000..590dde867f4 --- /dev/null +++ b/addons/google_drive/static/src/img/drive_icon.png diff --git a/addons/google_drive/static/src/img/drive_icon_mono.png b/addons/google_drive/static/src/img/drive_icon_mono.png Binary files differnew file mode 100644 index 00000000000..9fd836b6988 --- /dev/null +++ b/addons/google_drive/static/src/img/drive_icon_mono.png diff --git a/addons/google_drive/static/src/js/gdrive.js b/addons/google_drive/static/src/js/gdrive.js new file mode 100644 index 00000000000..3267487b4e3 --- /dev/null +++ b/addons/google_drive/static/src/js/gdrive.js @@ -0,0 +1,71 @@ +openerp.google_drive = function (instance, m) { + var _t = instance.web._t, + QWeb = instance.web.qweb; + + instance.web.Sidebar.include({ + start: function () { + var self = this; + var ids + this._super.apply(this, arguments); + var view = self.getParent(); + var result; + if (view.fields_view.type == "form") { + ids = [] + view.on("load_record", self, function (r) { + ids = [r.id] + self.add_gdoc_items(view, r.id) + }); + } + }, + add_gdoc_items: function (view, res_id) { + var self = this; + var gdoc_item = _.indexOf(_.pluck(self.items.other, 'classname'), 'oe_share_gdoc'); + if (gdoc_item !== -1) { + self.items.other.splice(gdoc_item, 1); + } + if (res_id) { + view.sidebar_eval_context().done(function (context) { + var ds = new instance.web.DataSet(this, 'google.drive.config', context); + ds.call('get_google_drive_config', [view.dataset.model, res_id, context]).done(function (r) { + if (!_.isEmpty(r)) { + _.each(r, function (res) { + var g_item = _.indexOf(_.pluck(self.items.other, 'label'), res.name); + if (g_item !== -1) { + self.items.other.splice(g_item, 1); + } + self.add_items('other', [{ + label: res.name+ '<img style="position:absolute;right:5px;height:20px;width:20px;" title="Google Drive" src="google_drive/static/src/img/drive_icon.png"/>', + config_id: res.id, + res_id: res_id, + res_model: view.dataset.model, + callback: self.on_google_doc, + classname: 'oe_share_gdoc' + }, + ]); + }) + } + }); + }); + } + }, + + fetch: function (model, fields, domain, ctx) { + return new instance.web.Model(model).query(fields).filter(domain).context(ctx).all() + }, + + on_google_doc: function (doc_item) { + var self = this; + self.config = doc_item; + var loaded = self.fetch('google.drive.config', ['google_drive_resource_id', 'google_drive_client_id'], [['id', '=', doc_item.config_id]]) + .then(function (configs) { + var ds = new instance.web.DataSet(self, 'google.drive.config'); + ds.call('get_google_drive_url', [doc_item.config_id, doc_item.res_id,configs[0].google_drive_resource_id]).done(function (url) { + if (url){ + window.open(url, '_blank'); + } + }); + }); + }, + + }); +};
\ No newline at end of file diff --git a/addons/google_drive/static/src/xml/gdocs.xml b/addons/google_drive/static/src/xml/gdocs.xml new file mode 100644 index 00000000000..0c8d9c3b01f --- /dev/null +++ b/addons/google_drive/static/src/xml/gdocs.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- vim:fdl=1: +--> +<templates id="template" xml:space="preserve"> +<t t-name="AddGoogleDocumentItem"> + <li class="oe_sidebar_add_google_doc"><span><b>Add Google Doc...</b></span></li> +</t> +</templates> |
