09-12-2017 01:56 PM
Hi i want to order member of the site on the site dashboard by the surname/name instead of the name/surname like set by default from alfresco.
i found the script site-members.js to customize for sort by surname instead name, i just change the default code:
// Sort the member list by name
items.sort(function (membership1, membership2)
{
var name1 = membership1.firstName + membership1.lastName,
name2 = membership2.firstName + membership2.lastName;
return (name1 > name2) ? 1 : (name1 < name2) ? -1 : 0;
});
....................................................................
if ((firstName !== undefined) || (lastName !== undefined))
{
name = firstName ? firstName + " " : "";
name += lastName ? lastName : "";
}
............................................................................
with this:
// Sort the member list by surname
items.sort(function (membership1, membership2)
{
var name1 = membership1.lastName + membership1.firstName,
name2 = membership2.lastName + membership2.firstName;
return (name1 > name2) ? 1 : (name1 < name2) ? -1 : 0;
});
.....................................................................
if ((firstName !== undefined) || (lastName !== undefined))
{
name = lastName ? lastName + " ": "";
name += firstName ? firstName : "";
}
...............................................................
it's work when i go to the dashlet "All Members" of the site but it's not work for the "preview" in the site dashboard, there is some other javascript i need to modify? here i put a image of the problem:
They are still order for name not surname. Someone can help me with that.
09-13-2017 02:08 AM
Hi,
You have to make following changes in colleagues.get.js file located at <alfresco_home>\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets\
You will find the following
function sortByName(membership1, membership2)
{
var name1 = membership1.authority ? membership1.authority.firstName + membership1.authority.lastName : "";
var name2 = membership2.authority ? membership2.authority.firstName + membership2.authority.lastName : "";
return (name1 > name2) ? 1 : (name1 < name2) ? -1 : 0;
}
Replace the above code with the following
function sortByName(membership1, membership2)
{
var name1 = membership1.authority ? membership1.authority.lastName + membership1.authority.firstName : "";
var name2 = membership2.authority ? membership2.authority.lastName + membership2.authority.firstName : "";
return (name1 > name2) ? 1 : (name1 < name2) ? -1 : 0;
}
Note : It is not recommended to make changes in existing alfresco files,best practice is to override the functionality by placing this <alfresco_home>\alfresco-community\tomcat\shared\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\dashlets\
Thanks,
Kalpesh
09-13-2017 02:08 AM
Hi,
You have to make following changes in colleagues.get.js file located at <alfresco_home>\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets\
You will find the following
function sortByName(membership1, membership2)
{
var name1 = membership1.authority ? membership1.authority.firstName + membership1.authority.lastName : "";
var name2 = membership2.authority ? membership2.authority.firstName + membership2.authority.lastName : "";
return (name1 > name2) ? 1 : (name1 < name2) ? -1 : 0;
}
Replace the above code with the following
function sortByName(membership1, membership2)
{
var name1 = membership1.authority ? membership1.authority.lastName + membership1.authority.firstName : "";
var name2 = membership2.authority ? membership2.authority.lastName + membership2.authority.firstName : "";
return (name1 > name2) ? 1 : (name1 < name2) ? -1 : 0;
}
Note : It is not recommended to make changes in existing alfresco files,best practice is to override the functionality by placing this <alfresco_home>\alfresco-community\tomcat\shared\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\dashlets\
Thanks,
Kalpesh
09-14-2017 09:37 AM
ty very much that is the answer, i just point out maybe you need to modify the file colleagues.get.html.ftl either, change this piece of code:
<#-- LIST - ITEM - PERSON -->
<@markup id="list-item-person">
<h3><a href="${url.context}/page/user/${m.authority.userName?url}/profile" class="theme-color-1">${m.authority.firstName?html} <#if m.authority.lastName??>${m.authority.lastName?html}</#if></a></h3>
</@markup>
into this:
<#-- LIST - ITEM - PERSON -->
<@markup id="list-item-person">
<h3><a href="${url.context}/page/user/${m.authority.userName?url}/profile" class="theme-color-1"><#if m.authority.lastName??>${m.authority.lastName?html}</#if> ${m.authority.firstName?html}</a></h3>
</@markup>
Explore our Alfresco products with the links below. Use labels to filter content by product module.