[ADD] Allow admin to edit the company logo
authorFabien Meghazi <fme@openerp.com>
Tue, 18 Dec 2012 11:17:34 +0000 (12:17 +0100)
committerFabien Meghazi <fme@openerp.com>
Tue, 18 Dec 2012 11:17:34 +0000 (12:17 +0100)
bzr revid: fme@openerp.com-20121218111734-wu02xaifqyqz1g20

addons/web/static/src/css/base.css
addons/web/static/src/css/base.sass
addons/web/static/src/js/chrome.js
addons/web/static/src/xml/base.xml

index c76403a..39bb5d8 100644 (file)
   padding-bottom: 16px;
 }
 .openerp a.oe_logo {
+  position: relative;
   width: 220px;
   display: block;
   text-align: center;
   margin: 14px 0;
   border: 0;
 }
+.openerp a.oe_logo .oe_logo_edit {
+  margin: 14px 0;
+  position: absolute;
+  top: 1px;
+  padding: 4px;
+  width: 100%;
+  display: none;
+  text-align: center;
+  color: #eeeeee;
+  background: rgba(37, 37, 37, 0.9);
+  -webkit-box-sizing: border-box;
+  -moz-box-sizing: border-box;
+  -ms-box-sizing: border-box;
+  box-sizing: border-box;
+}
+.openerp a.oe_logo:hover .oe_logo_edit_admin {
+  display: block;
+}
 .openerp .oe_footer {
   position: fixed;
   bottom: 0;
index bf0ff4c..eab40a5 100644 (file)
@@ -958,12 +958,26 @@ $sheet-padding: 16px
         text-shadow: 0 1px 1px white
         padding-bottom: 16px
     a.oe_logo
+        position: relative
         width: 220px
         display: block
         text-align: center
         img
             margin: 14px 0
             border: 0
+        .oe_logo_edit
+            margin: 14px 0
+            position: absolute
+            top: 1px
+            padding: 4px
+            width: 100%
+            display: none
+            text-align: center
+            color: #eee
+            background: rgba(37,37,37,0.9)
+            @include box-sizing(border)
+        &:hover .oe_logo_edit_admin
+            display: block
     .oe_footer
         position: fixed
         bottom: 0
index 9e5a593..4ad159e 100644 (file)
@@ -1118,6 +1118,9 @@ instance.web.Client = instance.web.Widget.extend({
 
 instance.web.WebClient = instance.web.Client.extend({
     _template: 'WebClient',
+    events: {
+        'click .oe_logo_edit_admin': 'logo_edit'
+    },
     init: function(parent) {
         this._super(parent);
         this._current_state = null;
@@ -1188,7 +1191,29 @@ instance.web.WebClient = instance.web.Client.extend({
     },
     update_logo: function() {
         var img = this.session.url('/web/binary/company_logo');
-        this.$el.find('.oe_logo img').attr('src', '').attr('src', img);
+        this.$('.oe_logo img').attr('src', '').attr('src', img);
+        this.$('.oe_logo_edit').toggleClass('oe_logo_edit_admin', this.session.uid === 1);
+    },
+    logo_edit: function(ev) {
+        var self = this;
+        new instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"]).then(function(res) {
+            self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) {
+                result.res_id = res['company_id'][0];
+                result.target = "new";
+                result.views = [[false, 'form']];
+                result.flags = {
+                    action_buttons: true,
+                };
+                self.action_manager.do_action(result);
+                var form = self.action_manager.dialog_widget.views.form.controller;
+                form.on("on_button_cancel", self.action_manager.dialog, self.action_manager.dialog.close);
+                form.on('record_saved', self, function() {
+                    self.action_manager.dialog.close();
+                    self.update_logo();
+                });
+            });
+        });
+        return false;
     },
     check_timezone: function() {
         var self = this;
index dc31a24..5afadae 100644 (file)
         <tr>
             <td class="oe_leftbar" valign="top">
                 <t t-set="debug" t-value="__debug__ ? '&amp;debug' : ''"/>
-                <a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}"><img t-att-src='widget.session.url("/web/binary/company_logo")'/></a>
+                <a class="oe_logo" t-attf-href="/?ts=#{Date.now()}#{debug}">
+                    <span class="oe_logo_edit">Edit Company data</span>
+                    <img t-att-src='widget.session.url("/web/binary/company_logo")'/>
+                </a>
                 <div class="oe_secondary_menus_container"/>
                 <div class="oe_footer">
                     Powered by <a href="http://www.openerp.com" target="_blank"><span>OpenERP</span></a>