• Amrita Panda 2
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies
requirements - 
on mouse over the "manager" column should show an manager column along with an arrow.

component-

<th class="slds-is-sortable slds-text-title--caps" scope="col" onmouseover="{!c.arrowshow}" onclick="{!c.sortManager}"><div class="slds-truncate slds-cell-fixed" style="width: 980px;padding-left: 10px;padding-top: 10px;" title="Manager">Manager
                                    <aura:if isTrue="{! and(v.arrowDirection == 'arrowdown', v.selectedTabsoft == 'Manager') }">&nbsp; &#8595;  </aura:if>  
                                    <aura:if isTrue="{! and(v.arrowDirection != 'arrowdown', v.selectedTabsoft == 'Manager') }"> &nbsp; &#8593;  </aura:if>   
                                    </div></th>

controller.js-

  sortManager: function(component, event, helper) {
          try {
                   component.set("v.selectedTabsoft", 'Manager');
                 helper.sortManagerHelper(component, event, 'Manager');
          }
          catch(Err){
            helper.showToast(component, 'Error',"Error Occured While Loading Component", "Error");
        }
    },
     arrowshow: function(component, event, helper) {
           var arw = component.find('Manager');
          $A.util.addClass(arw,'arrowdown');

    },

helper-

sortManagerHelper: function(component, event, sortField,isAsc) { 
        try {
            var currentDir = component.get("v.arrowDirection");
            if (currentDir == 'arrowdown') {
                component.set("v.arrowDirection", 'arrowup');
                component.set("v.isAsc", true);
                component.set("v.isSort", true);
            } else {
                component.set("v.arrowDirection", 'arrowdown');
                component.set("v.isAsc", false);
                component.set("v.isSort", true);
            }
            this.doinitHelper(component, event);
        }
        catch(Err){
            helper.showToast(component, 'Error',"Error Occured While Loading Component", "Error");
        }
    },
  @AuraEnabled
    public static List <User> fetchSearchQueueUser(String SearchUserKeyword, String grpId) {
        try{
            string searchkey = '%'+ SearchUserKeyword + '%';
            List <User> returnList = new List <User> ();
            List <User> lstOfUser;
            String sortField ;
            boolean isAsc;
            List <String> lstOfSubGroup= new List <String> ();
            List <String> lstOfUserIds = new List <String> ();
            set <String> lstOfGrpIds = new set <String> ();
            List <GroupMember> lstOfGroupMember;
            List <GroupMember> lstOfSubGroupMember;
            Set<id> idGroup = new Set<id>();
            //To get subgroup:
            lstOfSubGroupMember =  [SELECT UserOrGroupId,Group.Name from GroupMember WHERE GroupId=: grpId LIMIT 500];
            for(GroupMember gm : lstOfSubGroupMember){
                if(String.Valueof(gm.UserOrGroupId).startsWith('00G')){
                    idGroup.add(gm.UserOrGroupId);
                }
            }
            lstOfGroupMember =  [SELECT Id,UserOrGroupId,GroupId from GroupMember WHERE GroupId  IN: idGroup LIMIT 500];
            for(GroupMember gm : lstOfGroupMember){
                lstOfUserIds.add(gm.UserOrGroupId);
            }
            system.debug(searchkey);
            if(string.isBlank(searchKey)){
              lstOfUser = [select id,name,federationIdentifier,userrole.name,Manager.name,profile.name from user where Id IN: lstOfUserIds and profile.name in ('Service Agent','Work Order Approver') order by name asc LIMIT 500];
                if (sortField != '') {
                     lstOfUser += ' order by ' + sortField; ---------------------------------------------------->error
                  // if isAsc is equal tp ture then set 'asc' order otherwise set 'desc' order.
                 if (isAsc) {
                    lstOfUser += ' asc';                            ---------------------------------------------------->error
                 } else {
                    lstOfUser += ' desc';                          ---------------------------------------------------->error
         }
      }
            }
            else{
                    lstOfUser = [select id,name, federationIdentifier,userrole.name,Manager.name,profile.name from user where Id IN: lstOfUserIds and (federationIdentifier like: searchkey or name like: searchkey)  and profile.name in ('Service Agent','Work Order Approver') order by name asc LIMIT 500];        
                
            }
            system.debug(lstOfUser);     
            return lstOfUser;
        }
        catch(Exception e)
        {
            System.debug('The following exception has occurred: ' + e.getMessage());
            return null;
        }
  1.     }