[IMP] separate embed and email actions
authorAntony Lesuisse <al@openerp.com>
Sun, 18 Dec 2011 15:43:32 +0000 (16:43 +0100)
committerAntony Lesuisse <al@openerp.com>
Sun, 18 Dec 2011 15:43:32 +0000 (16:43 +0100)
bzr revid: al@openerp.com-20111218154332-28ecj6xek6dixthp

addons/share/static/src/css/share.css
addons/share/static/src/js/share.js
addons/share/static/src/xml/share.xml
addons/share/wizard/share_wizard.py
addons/share/wizard/share_wizard_view.xml

index 4bd4f1d..8b13789 100644 (file)
@@ -1,14 +1 @@
 
-.openerp li.oe-share {
-    background: url(../img/share.png) no-repeat 0 60%;
-    padding-left: 20px;
-}
-
-.openerp a.oe-share {
-    background: url(../img/share.png) no-repeat center center;
-    display: block;
-    float: left;
-    width: 20px;
-    height: 20px;
-    margin-top: 3px;
-}
index 8fbcf06..b084e82 100644 (file)
@@ -1,7 +1,8 @@
 
 openerp.share = function(instance) {
 
-function launch_wizard(self, view) {
+function launch_wizard(self, view, button) {
+        var button = button || 'go_step_1';
         var action = view.widget_parent.action;
         var Share = new instance.web.DataSet(self, 'share.wizard', view.dataset.get_context());
         var domain = new instance.web.CompoundDomain(view.dataset.domain);
@@ -19,7 +20,7 @@ function launch_wizard(self, view) {
                 view_type: view.fields_view.type,
             }, function(result) {
                 var share_id = result.result;
-                var step1 = Share.call('go_step_1', [[share_id],], function(result) {
+                var step1 = Share.call(button, [[share_id],], function(result) {
                     var action = result;
                     self.do_action(action);
                 });
@@ -46,9 +47,14 @@ instance.web.Sidebar = instance.web.Sidebar.extend({
 instance.web.ViewManagerAction.include({
     start: function() {
         var self = this;
+        self.$element.find('a.oe-share_link').click(self.on_click_share_link);
         self.$element.find('a.oe-share').click(self.on_click_share);
         return this._super.apply(this, arguments);
     },
+    on_click_share_link: function(e) {
+        e.preventDefault();
+        launch_wizard(this, this.views[this.active_view].controller,'go_step_1_link');
+    },
     on_click_share: function(e) {
         e.preventDefault();
         launch_wizard(this, this.views[this.active_view].controller);
index 9a13638..d8d3ab5 100644 (file)
@@ -5,9 +5,8 @@
 
     <t t-extend="ViewManagerAction">
         <t t-jquery=".oe-shortcut-toggle" t-operation="after">
-            <a class="oe-share" href="#share" title="Share this in 2 clicks...">
-                <!--<img src="/share/static/src/img/share.png"/>-->
-            </a>
+            <a class="oe-share_link" href="#share_link" title="Link or embed"><img src="/share/static/src/img/share.png"/></a>
+            <a class="oe-share" href="#share" title="Share by email"><img src="/share/static/src/img/share.png"/></a>
         </t>
     </t>
 
index f4cb46b..e115cab 100644 (file)
@@ -176,10 +176,24 @@ class share_wizard(osv.osv_memory):
         'embed_option_search': True,
     }
 
+    def go_step_1_link(self, cr, uid, ids, context=None):
+        dummy, step1_form_view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'share', 'share_step1_form_link')
+        return {
+            'name': _('Link or embed your documents'),
+            'view_type': 'form',
+            'view_mode': 'form',
+            'res_model': 'share.wizard',
+            'view_id': False,
+            'res_id': ids[0],
+            'views': [(step1_form_view_id, 'form')],
+            'type': 'ir.actions.act_window',
+            'target': 'new'
+        }
+
     def go_step_1(self, cr, uid, ids, context=None):
         dummy, step1_form_view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'share', 'share_step1_form')
         return {
-            'name': _('Grant instant access to your documents'),
+            'name': _('Share your documents by email'),
             'view_type': 'form',
             'view_mode': 'form',
             'res_model': 'share.wizard',
index b47b5e8..3e5840c 100644 (file)
             </field>
         </record>
 
+        <record id="share_step1_form_link" model="ir.ui.view">
+            <field name="name">share.step1.form.link</field>
+            <field name="model">share.wizard</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Link or embed your documents">
+                    <field name="user_type" invisible="1"/>
+                    <separator colspan="4" string="Sharing Options"/>
+                    <group colspan="4" col="4">
+                        <field name="name" colspan="4"/>
+                        <field name="access_mode" colspan="4"/>
+                    </group>
+                    <separator colspan="4"/>
+                    <group colspan="4">
+                        <button special="cancel" string="Cancel" icon='gtk-cancel'/>
+                        <button name="go_step_2" string="Share" colspan="1" type="object" icon="gtk-go-forward"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
         <record id="share_step1_form" model="ir.ui.view">
             <field name="name">share.step1.form</field>
             <field name="model">share.wizard</field>
             <field name="type">form</field>
             <field name="arch" type="xml">
-                <form string="Grant instant access to your documents">
-                    <group name="groups_group" colspan="4" col="4">
-                        <separator colspan="4" string="How do you want to share it ?"/>
-                        <field name="user_type" />
-                    </group>
-                    <group colspan="4" name="emails_group" attrs="{'invisible':[('user_type','!=','emails')]}">
+                <form string="Share by email your documents">
+                    <field name="user_type" invisible="1"/>
+                    <group colspan="4" name="emails_group">
                         <separator colspan="4" string="Share with these people (one e-mail per line)"/>
                         <field colspan="4" nolabel="1" name="new_users" attrs="{'required':[('user_type','=','emails')]}"/>
                     </group>
-                    <group colspan="4" col="4" attrs="{'invisible':[('user_type','=','embedded')]}">
-                       <separator colspan="4" string="Optional: include a personal message"/>
+                    <group colspan="4" col="4">
+                        <separator colspan="4" string="Optional: include a personal message"/>
                         <field name="message" colspan="4" nolabel="1"/>
                     </group>
-                    <separator colspan="4" string="Extra Options"/>
+                    <separator colspan="4" string="Sharing Options"/>
                     <group colspan="4" col="4">
                         <field name="name" colspan="4"/>
                         <field name="access_mode" colspan="4"/>
                     - 'domain' (string expression for full domain to apply as sent to server, 
                                with dynamic data like 'uid' replaced by actual value (i.e. after eval)!)
          -->
+        <record id="action_share_wizard_step1_link" model="ir.actions.act_window">
+            <field name="name">Share Wizard</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">share.wizard</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="view_id" ref="share_step1_form_link"/>
+            <field name="target">new</field>
+            <field name="context">{'default_user_type':'embedded'}</field>
+        </record>
+
         <record id="action_share_wizard_step1" model="ir.actions.act_window">
             <field name="name">Share Wizard</field>
             <field name="type">ir.actions.act_window</field>