From c74517990f1bec61e52e455be4ec12b6135015a6 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 26 Jun 2013 11:30:19 +0200 Subject: [RENAME]google_docs => google_drive bzr revid: dle@openerp.com-20130626093019-krwt5eamagmd5amu --- addons/google_drive/static/src/img/drive_icon.png | Bin 0 -> 2148 bytes .../static/src/img/drive_icon_mono.png | Bin 0 -> 479 bytes addons/google_drive/static/src/img/icon.png | Bin 0 -> 19252 bytes addons/google_drive/static/src/js/gdrive.js | 76 +++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 addons/google_drive/static/src/img/drive_icon.png create mode 100644 addons/google_drive/static/src/img/drive_icon_mono.png create mode 100644 addons/google_drive/static/src/img/icon.png create mode 100644 addons/google_drive/static/src/js/gdrive.js (limited to 'addons/google_drive/static/src') diff --git a/addons/google_drive/static/src/img/drive_icon.png b/addons/google_drive/static/src/img/drive_icon.png new file mode 100644 index 00000000000..590dde867f4 Binary files /dev/null and b/addons/google_drive/static/src/img/drive_icon.png differ diff --git a/addons/google_drive/static/src/img/drive_icon_mono.png b/addons/google_drive/static/src/img/drive_icon_mono.png new file mode 100644 index 00000000000..9fd836b6988 Binary files /dev/null and b/addons/google_drive/static/src/img/drive_icon_mono.png differ diff --git a/addons/google_drive/static/src/img/icon.png b/addons/google_drive/static/src/img/icon.png new file mode 100644 index 00000000000..3989ab57b30 Binary files /dev/null and b/addons/google_drive/static/src/img/icon.png differ 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..1bfcc603d51 --- /dev/null +++ b/addons/google_drive/static/src/js/gdrive.js @@ -0,0 +1,76 @@ +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+ '', + 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_doc_name', [[doc_item.config_id], doc_item.res_id,configs[0].google_drive_resource_id]).done(function (r) { + if (!_.isEmpty(r)) { + _.each(r, function (res) { + if(res.url) + { + window.open(res.url, '_blank'); + } + }); + } + }); + }); + }, + + }); +}; \ No newline at end of file -- cgit v1.2.3 From fc70550ca2a8d34c07b05b465f342f6248da10ed Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 28 Jun 2013 12:04:41 +0200 Subject: [IMP] move html module description and icon bzr revid: al@openerp.com-20130628100441-swpanf2jwcojygh4 --- addons/google_drive/static/src/img/icon.png | Bin 19252 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 addons/google_drive/static/src/img/icon.png (limited to 'addons/google_drive/static/src') diff --git a/addons/google_drive/static/src/img/icon.png b/addons/google_drive/static/src/img/icon.png deleted file mode 100644 index 3989ab57b30..00000000000 Binary files a/addons/google_drive/static/src/img/icon.png and /dev/null differ -- cgit v1.2.3 From d69046f327b5fc0590a0f6274248107d3e04d62c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 23 Jul 2013 15:30:55 +0200 Subject: [FIX]google_drive: add in more menu duplicate when clicking on form switch button bzr revid: dle@openerp.com-20130723133055-evcyunmih9uma3k4 --- addons/google_drive/static/src/js/gdrive.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'addons/google_drive/static/src') diff --git a/addons/google_drive/static/src/js/gdrive.js b/addons/google_drive/static/src/js/gdrive.js index 3267487b4e3..dbbe50d0794 100644 --- a/addons/google_drive/static/src/js/gdrive.js +++ b/addons/google_drive/static/src/js/gdrive.js @@ -29,19 +29,24 @@ openerp.google_drive = function (instance, m) { 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); + var already_there = false; + for (var i = 0;i < self.items.other.length;i++){ + if (self.items.other[i].classname === "oe_share_gdoc" && self.items.other[i].label.indexOf(res.name) > -1){ + already_there = true; + break; + } + } + if (!already_there){ + self.add_items('other', [{ + label: res.name+ '', + config_id: res.id, + res_id: res_id, + res_model: view.dataset.model, + callback: self.on_google_doc, + classname: 'oe_share_gdoc' + }, + ]); } - self.add_items('other', [{ - label: res.name+ '', - config_id: res.id, - res_id: res_id, - res_model: view.dataset.model, - callback: self.on_google_doc, - classname: 'oe_share_gdoc' - }, - ]); }) } }); -- cgit v1.2.3