Changes for page Profile of XWikiUserSheet

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

From version 5.1
edited by Ludovic Dubost
on 2017/02/07 23:57
Change comment: Install extension [org.xwiki.platform:xwiki-platform-user-profile-ui-8.4.4]
To version 12.1
edited by Ludovic Dubost
on 2024/07/22 15:51
Change comment: Install extension [org.xwiki.platform:xwiki-platform-user-profile-ui/16.5.0]

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
... ... @@ -8,30 +8,21 @@
8 8  ## Setting categories
9 9  #########################
10 10  #set($categories = [])
11 -#set($discard = $categories.add({'id':'profile', 'sheet':'XWiki.XWikiUserProfileSheet', 'glyphicon': 'user'}))
12 -#set($isMyProfile = ($services.model.resolveDocument($xcontext.user) == $doc.documentReference))
13 -#if($isMyProfile || $hasAdmin)
14 - #set($discard = $categories.add({'id':'preferences', 'sheet':'XWiki.XWikiUserPreferencesSheet', 'glyphicon': 'wrench'}))
11 +
12 +## load the user menu from the 'org.xwiki.plaftorm.user.profile.menu' UIXP.
13 +#foreach ($uix in $services.uix.getExtensions('org.xwiki.plaftorm.user.profile.menu', {'sortByParameter': 'priority'}))
14 + #if(!$uix.parameters.containsKey('isActive') || $uix.parameters.get('isActive') != 'false')
15 + #if (!$uix.parameters.containsKey('id'))
16 + ## when no id is explicitly provided, we use the id of the UIX.
17 + #set ($discard = $uix.parameters.put('id', $uix.id))
18 + #end
19 + #if ($uix.parameters.containsKey('icon'))
20 + #set ($discard = $uix.parameters.put('glyphicon', $uix.parameters.get('icon')))
21 + #end
22 + #set ($discard = $uix.parameters.put('uix', $uix))
23 + #set($discard = $categories.add($uix.parameters))
24 + #end
15 15  #end
16 -## TODO: add APIs to be able to display users watchlists to admins
17 -#if($isMyProfile && $hasWatch)
18 - #set($discard = $categories.add({'id':'watchlist', 'sheet':'XWiki.XWikiUserWatchListSheet', 'glyphicon': 'eye-open'}))
19 -#end
20 -#if($isMyProfile)
21 - #set($discard = $categories.add({'id':'network', 'sheet':'XWiki.XWikiUserNetworkSheet', 'glyphicon': 'globe'}))
22 -#end
23 -#set($userWikiSheet = 'WikiManager.UserWikiSheet')
24 -#if($xcontext.isMainWiki() && $xwiki.exists($userWikiSheet))
25 - #set($discard = $categories.add({
26 - 'id': 'wikis',
27 - 'name': $services.localization.render('platform.wiki.menu.userwikis'),
28 - 'sheet': $userWikiSheet,
29 - 'glyphicon': 'list'
30 - }))
31 -#end
32 -#if($isMyProfile && $hasDashboard)
33 - #set($discard = $categories.add({'id':'dashboard', 'sheet':'Dashboard.XWikiUserDashboardSheet', 'glyphicon': 'th'}))
34 -#end
35 35  #########################
36 36  ## Current category
37 37  #########################
... ... @@ -74,7 +74,7 @@
74 74   ## By specifying the image width we enable server side resizing. The width value we use is greater than the
75 75   ## available space because we don't want to loose too much of the image quality (we rely on the browser to fit the
76 76   ## image in the available space).
77 - {{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,gif"/}}
68 + {{attachmentSelector classname="XWiki.XWikiUsers" object="$obj.number" property="avatar" #if ($hasEdit) 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"/}}
78 78   #end
79 79   )))
80 80   ##########
... ... @@ -95,8 +95,7 @@
95 95   #set($tabKey = $subcategory.get('id'))
96 96   (% id="${tabKey}Pane" class="user-page-pane#if($tabKey != $currentCategory) hidden#end" %)
97 97   (((
98 - #set($tabInclude = $subcategory.get('sheet'))
99 - {{include reference="${tabInclude}" /}}
89 + {{html}}$services.rendering.render($subcategory.uix.execute(), 'html/5.0'){{/html}}
100 100   )))
101 101   #end
102 102   #end
... ... @@ -109,10 +109,5 @@
109 109   <input type='hidden' name='category' value="$!{escapetool.xml($currentCategory)}" />
110 110   #end
111 111   <div class="clearfloats">&nbsp;</div>
112 - #if($request.get('xpage'))
113 - <script type="text/javascript">
114 - document.fire('lightbox:userprofile:loaded');
115 - </script>
116 - #end
117 117  {{/html}}
118 118  {{/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) {
... ... @@ -61,7 +61,7 @@
61 61   if (history.pushState) {
62 62   var params = window.location.search.toQueryParams();
63 63   params.category = category;
64 - newQueryString = Object.toQueryString(params);
66 + var newQueryString = Object.toQueryString(params);
65 65  
66 66   var newURL = window.location.protocol + '//' + window.location.host + window.location.pathname + '?' + newQueryString;
67 67   window.history.pushState({category : category}, '', newURL);
... ... @@ -70,7 +70,7 @@
70 70  
71 71   updateField : function (fieldName, value) {
72 72   var element = $$('input[name=' + fieldName + ']');
73 - if (element && element.size() > 0) {
75 + if (element && element.length) {
74 74   element[0].value = value;
75 75   }
76 76   },
... ... @@ -77,7 +77,7 @@
77 77  
78 78   handleCancelAction : function() {
79 79   var elements = $$('form .buttons input[type=submit][name=action_cancel]');
80 - if (elements && elements.size() > 0) {
82 + if (elements && elements.length) {
81 81   var button = elements[0];
82 82   Event.stopObserving(button, 'click');
83 83   button.observe('click', function(event){
... ... @@ -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 || {}));
XWiki.StyleSheetExtension[0]
Code
... ... @@ -12,7 +12,7 @@
12 12  
13 13  #avatar img {
14 14   border: 1px solid $theme.borderColor;
15 - border-radius: 5px 5px 5px 5px;
15 + border-radius: 8px 8px 8px 8px;
16 16   box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
17 17   margin: 0 auto;
18 18   padding: 0.3em;
... ... @@ -72,13 +72,13 @@
72 72   margin-left: 14em;
73 73  }
74 74  
75 -.column h1 {
76 - font-weight:bold;
77 - font-size:115%;
78 - margin:10px 0;
75 +.column h1, .column h2 {
76 + font-weight: bold;
77 + font-size: 115%;
78 + margin: 10px 0;
79 79  }
80 80  
81 -.column h2 {
81 +.column h3 {
82 82   font-size: 110%;
83 83  }
84 84  
... ... @@ -96,7 +96,7 @@
96 96  
97 97  /* ----- Profile ----- */
98 98  td.recentChangesLeft, .recentChangesMoreActions {
99 - display:none;
99 + display: none;
100 100  }
101 101  
102 102  td.recentChangesRight {
... ... @@ -115,10 +115,6 @@
115 115   background-color: $theme.backgroundSecondaryColor;
116 116  }
117 117  
118 -.userInfo {
119 - -ms-word-break: break-all; /* IE8, IE9 */
120 -}
121 -
122 122  .userInfo a {
123 123   word-wrap: break-word;
124 124  }
... ... @@ -126,21 +126,21 @@
126 126  .userInfo img {
127 127   max-width: 100%;
128 128  }
129 -
125 +
126 +.userInfo h2 {
127 + font-size: larger;
128 + font-weight: bolder;
129 + margin-top: 10px;
130 +}
131 +
130 130  div.userInfo input[type="text"], div.userInfo input[type="password"], div.userInfo textarea, div.userInfo select, div.userPreferences select {
131 131   width: 100%;
132 132  }
133 133  
134 134  div.editProfileCategory {
135 - float:right;
137 + float: right;
136 136  }
137 137  
138 -div.editProfileCategory a {
139 - display:block;
140 - width: 16px;
141 - height: 16px;
142 - background: url("$xwiki.getSkinFile('icons/silk/pencil.png')") no-repeat;
143 -}
144 144  
145 145  /* Watchlist */
146 146  
... ... @@ -151,9 +151,9 @@
151 151  }
152 152  
153 153  span#avatarUpload {
154 - display:block;
155 - width:$tabswidth;
156 - position:absolute;
150 + display: block;
151 + width: $tabswidth;
152 + position: absolute;
157 157   font-size: 10px;
158 158   font-weight: bold;
159 159   background-color: white;
... ... @@ -168,28 +168,35 @@
168 168   margin: 0;
169 169   padding: 0;
170 170  }
167 +
171 171  #networkPane .following li {
172 172   padding: 2px 20px 2px 2px;
173 173  }
171 +
174 174  #networkPane .following li:hover {
175 175   background-color: $theme.highlightColor;
176 176  }
175 +
177 177  #networkPane .following img {
178 178   float: left;
179 179   margin-right: 5px;
180 180  }
180 +
181 181  #networkPane .following .user-info {
182 182   float: left;
183 183  }
184 +
184 184  #networkPane .following .user-id {
185 185   font-size: .8em;
186 186   font-weight: 900;
187 187  }
189 +
188 188  #networkPane .following .unfollow {
189 189   float: right;
190 190   margin-right: -16px;
191 191   padding: 0;
192 192  }
195 +
193 193  ## --------------------------------------
194 194  ## Picker style
195 195  .attachment-picker {
... ... @@ -197,6 +197,7 @@
197 197   margin: auto;
198 198   width: 100%;
199 199  }
203 +
200 200  .attachment-picker p {
201 201   padding: 0;
202 202   margin: 0;
... ... @@ -205,6 +205,7 @@
205 205  .attachment-picker .picture {
206 206   z-index: -1;
207 207  }
212 +
208 208  .attachment-picker .buttonwrapper {
209 209   margin: 0;
210 210  }
Content Type
... ... @@ -1,0 +1,1 @@
1 +LESS