Changes for page Profile of XWikiUserSheet

Last modified by Ludovic Dubost on 2024/07/22 15:51

From version 4.1
edited by Ludovic Dubost
on 2015/09/01 11:46
Change comment: Install extension [org.xwiki.platform:xwiki-platform-user-profile-ui-7.1]
To version 8.1
edited by Ludovic Dubost
on 2019/05/20 19:03
Change comment: Install extension [org.xwiki.platform:xwiki-platform-user-profile-ui/11.3]

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -#set($userName="$!doc.getValue('first_name') $!doc.getValue('last_name')")#if($userName==' ')#set($userName=$doc.name)#{end}$services.localization.render('platform.core.profile.title', [$userName])
1 +#set($userName="$!doc.getValue('first_name') $!doc.getValue('last_name')")#if($userName==' ')#set($userName=$doc.documentReference.name)#{end}$services.localization.render('platform.core.profile.title', [$userName])
Content
... ... @@ -13,12 +13,20 @@
13 13  #if($isMyProfile || $hasAdmin)
14 14   #set($discard = $categories.add({'id':'preferences', 'sheet':'XWiki.XWikiUserPreferencesSheet', 'glyphicon': 'wrench'}))
15 15  #end
16 +#set($discard = $categories.add({'id':'groups', 'sheet':'XWiki.XWikiUserMembershipSheet', 'glyphicon': 'group'}))
16 16  ## TODO: add APIs to be able to display users watchlists to admins
17 17  #if($isMyProfile && $hasWatch)
18 - #set($discard = $categories.add({'id':'watchlist', 'sheet':'XWiki.XWikiUserWatchListSheet', 'glyphicon': 'eye-open'}))
19 + #set($discard = $categories.add({'id':'watchlist', 'sheet':'XWiki.XWikiUserWatchListSheet', 'glyphicon': 'eye'}))
19 19  #end
20 20  #if($isMyProfile)
21 - #set($discard = $categories.add({'id':'network', 'sheet':'XWiki.XWikiUserNetworkSheet', 'glyphicon': 'globe'}))
22 + #if ("$!services.notification.watch" != '' || $hasWatch)
23 + #set($discard = $categories.add({'id':'network', 'sheet':'XWiki.XWikiUserNetworkSheet', 'glyphicon': 'world'}))
24 + #end
25 + ## TODO: add an enhancement system instead
26 + #set($notificationsSheet = $services.model.createDocumentReference('', ['XWiki', 'Notifications', 'Code'], 'XWikiUserNotificationsSheet'))
27 + #if ($xwiki.exists($notificationsSheet))
28 + #set($discard = $categories.add({'id':'notifications', 'sheet':'XWiki.Notifications.Code.XWikiUserNotificationsSheet', 'glyphicon': 'bell'}))
29 + #end
22 22  #end
23 23  #set($userWikiSheet = 'WikiManager.UserWikiSheet')
24 24  #if($xcontext.isMainWiki() && $xwiki.exists($userWikiSheet))
... ... @@ -68,10 +68,13 @@
68 68   (((
69 69   #if($request.xpage == 'edituser')
70 70   {{html clean="false"}}
71 - #resizedUserAvatar($doc.fullName 170)
79 + #resizedUserAvatar($doc.fullName 180)
72 72   {{/html}}
73 73   #else
74 - {{attachmentSelector classname="XWiki.XWikiUsers" object="$obj.number" property="avatar" #if ($isMyProfile) savemode="direct" #end defaultValue="XWiki.XWikiUserSheet@noavatar.png" width="120" alternateText="$xwiki.getUserName($doc.fullName, false)" buttontext="$services.localization.render('platform.core.profile.changePhoto')" displayImage="true" filter="png,jpg,gif"/}}
82 + ## By specifying the image width we enable server side resizing. The width value we use is greater than the
83 + ## available space because we don't want to loose too much of the image quality (we rely on the browser to fit the
84 + ## image in the available space).
85 + {{attachmentSelector classname="XWiki.XWikiUsers" object="$obj.number" property="avatar" #if ($isMyProfile) savemode="direct" #end defaultValue="XWiki.XWikiUserSheet@noavatar.png" width="180" alternateText="$xwiki.getUserName($doc.fullName, false)" buttontext="$services.localization.render('platform.core.profile.changePhoto')" displayImage="true" filter="png,jpg,jpeg,gif"/}}
75 75   #end
76 76   )))
77 77   ##########
... ... @@ -106,10 +106,5 @@
106 106   <input type='hidden' name='category' value="$!{escapetool.xml($currentCategory)}" />
107 107   #end
108 108   <div class="clearfloats">&nbsp;</div>
109 - #if($request.get('xpage'))
110 - <script type="text/javascript">
111 - document.fire('lightbox:userprofile:loaded');
112 - </script>
113 - #end
114 114  {{/html}}
115 115  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -2,9 +2,9 @@
2 2  // Start XWiki augmentation.
3 3  Object.extend(XWiki, {
4 4   userprofile : {
5 - init : function() {
5 + init : function(container) {
6 6   this.crtCategory = '';
7 - this.tabsContainer = $('user-vertical-menu');
7 + this.tabsContainer = (container || $('body')).down('#user-vertical-menu');
8 8   if (!this.tabsContainer) {
9 9   return;
10 10   }
... ... @@ -17,6 +17,7 @@
17 17   this.tabsContainer.select('.category-tab.current').each(function (activeTab) {
18 18   this.updateCategoryFields(activeTab.id);
19 19   document.fire('xwiki:profile:switchedCategory', {'category' : activeTab.id});
20 + document.fire('xwiki:dom:refresh');
20 20   }.bind(this));
21 21   this.handleCancelAction();
22 22  
... ... @@ -47,6 +47,7 @@
47 47   this.updateURL(tabName);
48 48   }
49 49   document.fire('xwiki:profile:switchedCategory', {'category' : tab});
51 + document.fire('xwiki:dom:refresh');
50 50   },
51 51  
52 52   updateCategoryFields : function (category) {
... ... @@ -89,12 +89,14 @@
89 89   }
90 90  });
91 91  
92 -var init = function() {
93 - XWiki.userprofile.init();
94 +var init = function(event) {
95 + ((event && event.memo.elements) || [$('body')]).each(function(element) {
96 + XWiki.userprofile.init(element);
97 + });
94 94   return true;
95 95  };
96 96  (XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loaded', init);
97 -document.observe('lightbox:userprofile:loaded', init);
101 +document.observe('xwiki:dom:updated', init);
98 98  // End XWiki augmentation.
99 99  return XWiki;
100 100  }(XWiki || {}));