Skip to content

Commit b0c8262

Browse files
committed
Enable the user avatars in realtime applications by default
1 parent 4f6504b commit b0c8262

File tree

7 files changed

+67
-12
lines changed

7 files changed

+67
-12
lines changed

src/classes/RTFrontend.ConfigurationClass.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ XClass(function (xcl, XWiki) {
77
xcl.setDefaultWeb("");
88
xcl.setNameField("");
99
xcl.setValidationScript("");
10+
xcl.addProp("useGlobalConfig", props.XBoolean.create({
11+
"customDisplay": "",
12+
"defaultValue": "",
13+
"displayFormType": "checkbox",
14+
"displayType": "",
15+
"prettyName": "Use the main wiki configuration",
16+
"validationMessage": "",
17+
"validationRegExp": ""
18+
}));
1019
xcl.addProp("toolbarUserlist", props.StaticList.create({
1120
"customDisplay": "",
1221
"picker": "0",

src/xwiki/RTFrontend/LoadEditors/objects/XWiki.JavaScriptExtension_0/code.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ define(['jquery', 'xwiki-meta'], function($, xm) {
100100
#end
101101
var userAvatarUrl = '$avatarUrl';
102102

103-
## Configurable values
104-
#set ($webhomeRef = $services.model.resolveDocument("RTFrontend.WebHome"))
105-
#set ($configObj = $!xwiki.getDocument($webhomeRef).getObject('RTFrontend.ConfigurationClass'))
106-
107-
#set ($toolbarValue = $configObj.getProperty('toolbarUserlist').value)
108-
var configToolbarUserlist = module.toolbarUserlist = "$!toolbarValue";
109-
#set ($marginValue = $configObj.getProperty('marginAvatar').value)
110-
var configMarginAvatar = module.marginAvatar = "$!marginValue";
111-
112103
// END_VELOCITY
113104

114105
if (!WEBSOCKET_URL) {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
XWikiObj(function (obj) {
2-
obj.setMarginAvatar("0");
3-
obj.setToolbarUserlist("name");
2+
obj.setUseGlobalConfig("1");
3+
obj.setMarginAvatar("1");
4+
obj.setToolbarUserlist("both");
45
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{html clean='false'}}
2+
<script>
3+
require(['jquery'], function (jQuery) {
4+
var isMainWiki = $xcontext.isMainWiki();
5+
var form = document.getElementById('realtime editors_RTFrontend.WebHome');
6+
if (isMainWiki) {
7+
jQuery(form).find('dt:first').hide();
8+
return;
9+
}
10+
var useGlobalCheckbox = document.getElementById('RTFrontend.WebHome_RTFrontend.ConfigurationClass_1_useGlobalConfig');
11+
var useGlobal = jQuery(useGlobalCheckbox).is(':checked');
12+
var onChange = function (value) {
13+
if (value) {
14+
jQuery(form).find('input:visible, textarea:visible, select:visible').attr('disabled', 'disabled');
15+
jQuery(useGlobalCheckbox).removeAttr('disabled');
16+
}
17+
else {
18+
jQuery(form).find('input:visible, textarea:visible, select:visible').removeAttr('disabled');
19+
}
20+
};
21+
onChange(useGlobal);
22+
jQuery(useGlobalCheckbox).change(function() {
23+
onChange(jQuery(this).is(':checked'));
24+
});
25+
});
26+
</script>
27+
{{/html}}
28+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
XWikiObj(function (obj) {
2+
obj.setCategoryIcon("");
3+
obj.setConfigurationClass("RTFrontend.ConfigurationClass");
4+
obj.setConfigureGlobally("1");
5+
obj.setDisplayBeforeCategory("");
6+
obj.setDisplayInCategory("");
7+
obj.setDisplayInSection("Realtime Editors");
8+
obj.setHeading("Commons");
9+
obj.setIconAttachment("");
10+
obj.setLinkPrefix("");
11+
obj.setPropertiesToShow("");
12+
obj.setSectionOrder("");
13+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{velocity}}
2+
{{html clean=false}}
3+
#set ($data = {"version" : "$!tdoc.version", "locale" : "$!tdoc.locale"})
4+
#set ($webhomeRef = $services.model.resolveDocument("RTFrontend.WebHome"))
5+
#set ($configObj = $xwiki.getDocument($webhomeRef).getObject('RTFrontend.ConfigurationClass'))
6+
#if ("$!configObj.getProperty('useGlobalConfig').value" != "0")
7+
#set ($mainWebhomeRef = $services.model.createDocumentReference($xcontext.getMainWikiName(), "RTFrontend", "WebHome"))
8+
#set ($configObj = $!xwiki.getDocument($mainWebhomeRef).getObject('RTFrontend.ConfigurationClass'))
9+
#end
10+
#set ($dataConfig = {"toolbarUserlist" : "$!{configObj.getProperty('toolbarUserlist').value}", "marginAvatar" : "$!{configObj.getProperty('marginAvatar').value}"})
11+
<div style="display:none" id="realtime-frontend-getversion">$jsontool.serialize($data)</div>
12+
<div style="display:none" id="realtime-frontend-getconfig">$jsontool.serialize($dataConfig)</div>
13+
{{/html}}
14+
{{/velocity}}

src/xwiki/RTFrontend/WebHome/objects/XWiki.UIExtensionClass_0/this.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
XWikiObj(function (obj) {
2-
obj.setContent("{{velocity}}\r\n{{html clean=false}}\r\n#set ($data = {\"version\" : \"$!tdoc.version\", \"locale\" : \"$!tdoc.locale\"})\r\n#set ($webhomeRef = $services.model.resolveDocument(\"RTFrontend.WebHome\"))\r\n#set ($configObj = $xwiki.getDocument($webhomeRef).getObject('RTFrontend.ConfigurationClass'))\r\n#set ($dataConfig = {\"toolbarUserlist\" : \"$!{configObj.getProperty('toolbarUserlist').value}\", \"marginAvatar\" : \"$!{configObj.getProperty('marginAvatar').value}\"})\r\n<div style=\"display:none\" id=\"realtime-frontend-getversion\">$jsontool.serialize($data)</div>\r\n<div style=\"display:none\" id=\"realtime-frontend-getconfig\">$jsontool.serialize($dataConfig)</div>\r\n{{/html}}\r\n{{/velocity}}");
32
obj.setExtensionPointId("org.xwiki.platform.template.header.after");
43
obj.setName("header.rtfrontend.getVersion");
54
obj.setParameters("");

0 commit comments

Comments
 (0)