diff options
| author | Divyesh Makwana (Open ERP) <mdi@tinyerp.com> | 2012-07-03 14:28:16 +0530 |
|---|---|---|
| committer | Divyesh Makwana (Open ERP) <mdi@tinyerp.com> | 2012-07-03 14:28:16 +0530 |
| commit | f28cfcfe8a16e77acd7e390e25fff2793e4e6548 (patch) | |
| tree | fe3fad1ad3f95ff11a34638ea5c7f325cecfa25c /addons/share | |
| parent | 9ce0d57fbe8357e00e72123e7e4c07326b26b261 (diff) | |
| parent | 1e123ce0c86060be9ad66fa8962912b14597c699 (diff) | |
[Merge] Merge with main addons.
bzr revid: mdi@tinyerp.com-20120703043709-c8o4k6hjfw5v8gn0
bzr revid: mdi@tinyerp.com-20120703085816-mc75d3ukecz03m79
Diffstat (limited to 'addons/share')
| -rw-r--r-- | addons/share/static/src/css/share.css | 7 | ||||
| -rw-r--r-- | addons/share/static/src/js/share.js | 58 | ||||
| -rw-r--r-- | addons/share/static/src/xml/share.xml | 13 | ||||
| -rw-r--r-- | addons/share/wizard/share_wizard.py | 16 | ||||
| -rw-r--r-- | addons/share/wizard/share_wizard_view.xml | 32 |
5 files changed, 64 insertions, 62 deletions
diff --git a/addons/share/static/src/css/share.css b/addons/share/static/src/css/share.css index 997c070fe54..dbbb8bea943 100644 --- a/addons/share/static/src/css/share.css +++ b/addons/share/static/src/css/share.css @@ -1,7 +1,4 @@ -button.oe_share_mail { - display: none; -} - -a.oe_share_link, a.oe_share { +/* Added invite button, hidden by default */ +button.oe_share_invite { display: none; } diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js index e88616546a3..33aa3d1aab9 100644 --- a/addons/share/static/src/js/share.js +++ b/addons/share/static/src/js/share.js @@ -50,29 +50,46 @@ openerp.share = function(session) { session.connection.share_flag.done(yes).fail(no); } + /* Extend the Sidebar to add Share and Embed links in the 'More' menu */ session.web.Sidebar = session.web.Sidebar.extend({ - add_default_sections: function() { - this._super(); + + start: function() { var self = this; + this._super(this); has_share(function() { - self.add_items('other', [{ - label: 'Share', - callback: self.on_sidebar_click_share, - classname: 'oe_share', - }]); + self.add_items('other', [ + { label: 'Share', + callback: self.on_click_share, + classname: 'oe_share' }, + { label: 'Embed', + callback: self.on_click_share_link, + classname: 'oe_share' }, + ]); }); }, - on_sidebar_click_share: function(item) { + + on_click_share: function(item) { + var view = this.getParent() + launch_wizard(this, view, 'emails', false); + }, + + on_click_share_link: function(item) { var view = this.getParent() - launch_wizard(this, view); + launch_wizard(this, view, 'embedded', false); }, }); + /** + * Extends mail (Chatter widget) + * - show the 'invite' button' only we came on the form view through + * an action. We do this because 'invite' is based on the share + * mechanism, and it tries to share an action. + */ 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(); + this.$element.find('button.oe_share_invite').show(); } return start_res; } @@ -83,12 +100,7 @@ openerp.share = function(session) { 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(); + self.$element.delegate('button.oe_share_invite', 'click', self.on_click_share_invite); }); return this._super.apply(this, arguments); }, @@ -96,23 +108,13 @@ openerp.share = function(session) { 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) { + + on_click_share_invite: 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 e51dc135c0b..1d9bc987afc 100644 --- a/addons/share/static/src/xml/share.xml +++ b/addons/share/static/src/xml/share.xml @@ -3,18 +3,11 @@ --> <templates id="template" xml:space="preserve"> - <t t-extend="ViewManagerAction"> - <t t-jquery=".oe_shortcuts_toggle" t-operation="after"> - <a class="oe_share_link" href="#share_link" title="Link or embed..."><img t-att-src='_s + "/share/static/src/img/share.png"'/></a> - <a class="oe_share" href="#share" title="Share with..."><img t-att-src='_s + "/share/static/src/img/share.png"'/></a> - </t> - </t> - - <t t-extend="RecordThread"> + <!-- Extends Chatter widget in form view to add the invite button --> + <t t-extend="mail.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> + <button type="button" class="oe_share_invite">Invite</button> </t> </t> - </templates> diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 55d43453775..41871480f45 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -48,7 +48,7 @@ RANDOM_PASS_CHARACTERS = 'aaaabcdeeeefghjkmnpqrstuvwxyzAAAABCDEEEEFGHJKLMNPQRSTU def generate_random_pass(): return ''.join(random.sample(RANDOM_PASS_CHARACTERS,10)) -class share_wizard(osv.osv_memory): +class share_wizard(osv.TransientModel): _name = 'share.wizard' _description = 'Share Wizard' @@ -177,9 +177,10 @@ class share_wizard(osv.osv_memory): 'name': fields.char('Share Title', size=64, required=True, help="Title for the share (displayed to users as menu and shortcut name)"), 'record_name': fields.char('Record name', size=128, help="Name of the shared record, if sharing a precise record"), 'message': fields.text("Personal Message", help="An optional personal message, to be included in the email notification."), - - 'embed_code': fields.function(_embed_code, type='text'), - 'embed_option_title': fields.boolean("Display title"), + 'embed_code': fields.function(_embed_code, type='text', string='Code', + help="Embed this code in your documents to provide a link to the "\ + "shared document."), + 'embed_option_title': fields.boolean('Display title'), 'embed_option_search': fields.boolean('Display search view'), 'embed_url': fields.function(_embed_url, string='Share URL', type='char', size=512, readonly=True), } @@ -903,8 +904,11 @@ class share_result_line(osv.osv_memory): def _share_url(self, cr, uid, ids, _fieldname, _args, context=None): result = dict.fromkeys(ids, '') for this in self.browse(cr, uid, ids, context=context): - data = dict(dbname=cr.dbname, login=this.login, password='') - result[this.id] = this.share_wizard_id.share_url_template() % data + data = dict(dbname=cr.dbname, login=this.login, password=this.password) + if this.share_wizard_id and this.share_wizard_id.action_id: + data['action_id'] = this.share_wizard_id.action_id.id + ctx = dict(context, share_url_template_hash_arguments=['action_id']) + result[this.id] = this.share_wizard_id.share_url_template(context=ctx) % data return result _columns = { diff --git a/addons/share/wizard/share_wizard_view.xml b/addons/share/wizard/share_wizard_view.xml index ee5d4dd23b9..58734caa25b 100644 --- a/addons/share/wizard/share_wizard_view.xml +++ b/addons/share/wizard/share_wizard_view.xml @@ -39,17 +39,20 @@ <group> <field name="user_type" invisible="1"/> <field name="invite" invisible="1"/> - </group> + </group> <group> - <group name="emails_group" attrs="{'invisible':['|', ('user_type', '!=', 'emails'), ('invite', '=', True)]}" string="Share with these People (one email per line)"> - <field colspan="2" nolabel="1" name="new_users" attrs="{'required':[('user_type','=','emails'), ('invite', '!=', True)]}"/> + <group colspan="4" name="emails_group" attrs="{'invisible':['|', ('user_type', '!=', 'emails'), ('invite', '=', True)]}" + string="Share with these People (one email per line)"> + <field nolabel="1" name="new_users" attrs="{'required':[('user_type','=','emails'), ('invite', '!=', True)]}"/> </group> - <group name="email_lines" attrs="{'invisible':[('invite', '!=', True)]}" string="Share with these People (one email per line)"> + <group colspan="4" name="email_lines" attrs="{'invisible':['|', ('invite', '!=', True), ('user_type', '!=', 'emails')]}" + string="Share with these People (one email per line)"> <field name="email_1"/> <field name="email_2"/> <field name="email_3"/> </group> - <group attrs="{'invisible':[('user_type', '=', 'embedded')]}" string="Include an Optional Personal Message"> + <group colspan="4" attrs="{'invisible':[('user_type', '=', 'embedded')]}" + string="Include an Optional Personal Message"> <field name="message" colspan="2" nolabel="1"/> </group> <group attrs="{'invisible':[('invite', '=', True)]}" string="Sharing Options"> @@ -71,8 +74,8 @@ <field name="user_type" invisible="1"/> <field name="access_mode" invisible="1"/> </header> - <group attrs="{'invisible':[('user_type','=','embedded')]}"> - <separator string="An email notification with instructions has been sent to the following people:"/> + <group attrs="{'invisible':[('user_type','=','embedded')]}" + string="An email notification with instructions has been sent to the following people:"> <field name="result_line_ids" nolabel="1" mode="tree"> <tree string="Summary"> <field name="login"/> @@ -85,14 +88,17 @@ </field> </group> <group colspan="4" col="1" attrs="{'invisible':[('user_type','!=','embedded')]}"> - <separator string="Use this Link"/> - <field name="embed_url"/> - <separator string="Or insert the following code where you want to embed your documents"/> - <group string="Options"> - <field name="embed_option_title" on_change="onchange_embed_options(embed_option_title, embed_option_search)"/> - <field name="embed_option_search" on_change="onchange_embed_options(embed_option_title, embed_option_search)" attrs="{'invisible':[('access_mode','=','readonly')]}"/> + <group string="Use this link"> + <field name="embed_url"/> + </group> + <group string="Or insert the following code where you want to embed your documents"> <field name="embed_code"/> </group> + <group string="Embedded code options"> + <field name="embed_option_title" on_change="onchange_embed_options(embed_option_title, embed_option_search)"/> + <field name="embed_option_search" on_change="onchange_embed_options(embed_option_title, embed_option_search)" + attrs="{'invisible':[('access_mode','=','readonly')]}"/> + </group> </group> </form> |
