cancel
Showing results for 
Search instead for 
Did you mean: 

Sort Site Members by Surname not name on site dashboard

4535992
Star Collaborator
Star Collaborator

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.

1 ACCEPTED ANSWER

kalpesh_c2
Star Collaborator
Star Collaborator

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

ContCentric

View answer in original post

2 REPLIES 2

kalpesh_c2
Star Collaborator
Star Collaborator

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

ContCentric

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>