summaryrefslogtreecommitdiff
path: root/addons/share/static/src
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2012-04-27 15:12:41 +0200
committerRaphael Collet <rco@openerp.com>2012-04-27 15:12:41 +0200
commit33deda8f83dff5a510df8ef49522bbb9bb8ca7f6 (patch)
tree91705d2f6c76e06f3b1b6b81f9ba91aedc06455e /addons/share/static/src
parent1e7213e03b3572e4557f3390c4b1981b24dc1752 (diff)
parent0ba09e28c93bce54f16c02a699c7747a28406318 (diff)
[MERGE] from trunk
bzr revid: rco@openerp.com-20120427131241-6gf7x3lzhux5qnnh
Diffstat (limited to 'addons/share/static/src')
-rw-r--r--addons/share/static/src/css/share.css6
-rw-r--r--addons/share/static/src/js/share.js139
-rw-r--r--addons/share/static/src/xml/share.xml7
3 files changed, 99 insertions, 53 deletions
diff --git a/addons/share/static/src/css/share.css b/addons/share/static/src/css/share.css
index 8b137891791..2cab9c6d2f2 100644
--- a/addons/share/static/src/css/share.css
+++ b/addons/share/static/src/css/share.css
@@ -1 +1,7 @@
+button.oe-share-mail {
+ display: none;
+}
+a.oe-share_link, a.oe-share {
+ display: none;
+}
diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js
index a4dfba12e28..3563a4bb859 100644
--- a/addons/share/static/src/js/share.js
+++ b/addons/share/static/src/js/share.js
@@ -1,23 +1,29 @@
openerp.share = function(session) {
-function launch_wizard(self, view, user_type) {
+ var has_action_id = false;
+
+ function launch_wizard(self, view, user_type, invite) {
var action = view.getParent().action;
var Share = new session.web.DataSet(self, 'share.wizard', view.dataset.get_context());
var domain = new session.web.CompoundDomain(view.dataset.domain);
if (view.fields_view.type == 'form') {
domain = new session.web.CompoundDomain(domain, [['id', '=', view.datarecord.id]]);
}
+ if (view.fields_view.type == 'form') rec_name = view.datarecord.name;
+ else rec_name = '';
self.rpc('/web/session/eval_domain_and_context', {
domains: [domain],
contexts: [view.dataset.context]
}, function (result) {
Share.create({
name: action.name,
+ record_name: rec_name,
domain: result.domain,
action_id: action.id,
user_type: user_type || 'embedded',
view_type: view.fields_view.type,
+ invite: invite || false,
}, function(result) {
var share_id = result.result;
var step1 = Share.call('go_step_1', [[share_id],], function(result) {
@@ -26,63 +32,90 @@ function launch_wizard(self, view, user_type) {
});
});
});
-}
+ }
-function has_share(yes, no) {
- if (!session.connection.share_flag) {
- session.connection.share_flag = $.Deferred(function() {
- var func = new session.web.Model("share.wizard").get_func("has_share");
- func(session.connection.uid).pipe(function(res) {
- if(res) {
- session.connection.share_flag.resolve();
- } else {
- session.connection.share_flag.reject();
- }
+ function has_share(yes, no) {
+ if (!session.connection.share_flag) {
+ session.connection.share_flag = $.Deferred(function() {
+ var func = new session.web.Model("share.wizard").get_func("has_share");
+ func(session.connection.uid).pipe(function(res) {
+ if(res) {
+ session.connection.share_flag.resolve();
+ } else {
+ session.connection.share_flag.reject();
+ }
+ });
});
- });
+ }
+ session.connection.share_flag.done(yes).fail(no);
}
- session.connection.share_flag.done(yes).fail(no);
-}
-session.web.Sidebar = session.web.Sidebar.extend({
- add_default_sections: function() {
- this._super();
- var self = this;
- has_share(function() {
- self.add_items('other', [{
- label: 'Share',
- callback: self.on_sidebar_click_share,
- classname: 'oe-share',
- }]);
- });
- },
- on_sidebar_click_share: function(item) {
- var view = this.getParent()
- launch_wizard(this, view);
- },
-});
+ session.web.Sidebar = session.web.Sidebar.extend({
+ add_default_sections: function() {
+ this._super();
+ var self = this;
+ has_share(function() {
+ self.add_items('other', [{
+ label: 'Share',
+ callback: self.on_sidebar_click_share,
+ classname: 'oe-share',
+ }]);
+ });
+ },
+ on_sidebar_click_share: function(item) {
+ var view = this.getParent()
+ launch_wizard(this, view);
+ },
+ });
-session.web.ViewManagerAction.include({
- start: function() {
- var self = this;
- has_share(function() {
- self.$element.find('a.oe-share_link').click(self.on_click_share_link);
- self.$element.find('a.oe-share').click(self.on_click_share);
- }, function() {
- self.$element.find('a.oe-share_link').remove();
- self.$element.find('a.oe-share').remove();
- });
- return this._super.apply(this, arguments);
- },
- on_click_share_link: function(e) {
- e.preventDefault();
- launch_wizard(this, this.views[this.active_view].controller);
- },
- on_click_share: function(e) {
- e.preventDefault();
- launch_wizard(this, this.views[this.active_view].controller, 'emails');
- },
-});
+ session.mail.RecordThread.include( {
+ start: function() {
+ start_res = this._super.apply(this, arguments);
+ if (has_action_id) {
+ this.$element.find('button.oe-share-mail').show();
+ }
+ return start_res;
+ }
+ });
+ session.web.ViewManagerAction.include({
+ start: function() {
+ var self = this;
+ this.check_if_action_is_defined();
+ has_share(function() {
+ self.$element.find('a.oe-share_link').click(self.on_click_share_link);
+ self.$element.find('a.oe-share').click(self.on_click_share);
+ self.$element.delegate('button.oe-share-mail', 'click', self.on_click_share_mail);
+ }, function() {
+ self.$element.find('a.oe-share_link').remove();
+ self.$element.find('a.oe-share').remove();
+ });
+ return this._super.apply(this, arguments);
+ },
+
+ check_if_action_is_defined: function() {
+ if (this.action && this.action.id) {
+ has_action_id = true;
+ this.$element.find('a.oe-share_link').show();
+ this.$element.find('a.oe-share').show();
+ }
+ else {
+ has_action_id = false;
+ }
+ },
+
+ on_click_share_link: function(e) {
+ e.preventDefault();
+ launch_wizard(this, this.views[this.active_view].controller, 'embedded', false);
+ },
+ on_click_share: function(e) {
+ e.preventDefault();
+ launch_wizard(this, this.views[this.active_view].controller, 'emails', false);
+ },
+ on_click_share_mail: function(e) {
+ e.preventDefault();
+ launch_wizard(this, this.views[this.active_view].controller, 'emails', true);
+ },
+ });
};
diff --git a/addons/share/static/src/xml/share.xml b/addons/share/static/src/xml/share.xml
index 532e8c74c9d..df9cb165c36 100644
--- a/addons/share/static/src/xml/share.xml
+++ b/addons/share/static/src/xml/share.xml
@@ -10,4 +10,11 @@
</t>
</t>
+ <t t-extend="RecordThread">
+ <t t-jquery="button.oe_mail_button_unfollow" t-operation="after">
+ <button type="button" class="oe-share-mail oe_mail_button_mouseout">Invite</button>
+ </t>
+ </t>
+
+
</templates>