changeset 8e0f3d778fc5 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=8e0f3d778fc5
description:
        Add support for avatar

        issue10085
        review343561002
diffstat:

 src/sao.js   |  17 ++++++++++++++++-
 src/sao.less |  17 ++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diffs (64 lines):

diff -r 1c860c6af056 -r 8e0f3d778fc5 src/sao.js
--- a/src/sao.js        Sun Mar 28 16:24:52 2021 +0200
+++ b/src/sao.js        Sun Mar 28 19:20:37 2021 +0200
@@ -679,6 +679,14 @@
     };
 
     Sao.user_menu = function(preferences) {
+        var avatar_url = preferences.avatar_url || '';
+        if (avatar_url) {
+            avatar_url += '?s=30';
+        }
+        var avatar_badge_url = preferences.avatar_badge_url || '';
+        if (avatar_badge_url){
+            avatar_badge_url += '?s=15';
+        }
         jQuery('#user-preferences').empty();
         jQuery('#user-favorites').empty();
         jQuery('#user-preferences').append(jQuery('<a/>', {
@@ -687,7 +695,14 @@
         }).click(function(evt) {
             evt.preventDefault();
             Sao.preferences();
-        }).text(preferences.status_bar));
+        }).text(preferences.status_bar)
+            .prepend(jQuery('<img/>', {
+                'src': avatar_badge_url,
+                'class': 'img-circle img-badge',
+            })).prepend(jQuery('<img/>', {
+                'src': avatar_url,
+                'class': 'img-circle',
+            })));
         var title = Sao.i18n.gettext("Logout");
         jQuery('#user-logout > a')
             .attr('title', title)
diff -r 1c860c6af056 -r 8e0f3d778fc5 src/sao.less
--- a/src/sao.less      Sun Mar 28 16:24:52 2021 +0200
+++ b/src/sao.less      Sun Mar 28 19:20:37 2021 +0200
@@ -154,10 +154,25 @@
 }
 
 #user-preferences > a {
-    max-width: 20em;
+    max-width: 30em;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
+
+    > img {
+        margin: -5px 5px;
+        width: 30px;
+
+        &[src=''] {
+            width: 0;
+        }
+
+        &.img-badge {
+            margin-left: -15px;
+            margin-bottom: -25px;
+            width: 15px;
+        }
+    }
 }
 
 .list-group-item-variant(selected; @state-selected-bg; @state-selected-text);

Reply via email to