• Neerudu Priyanka
  • NEWBIE
  • 25 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
<aura:application extends="force:slds">
    <c:MyWRAPPER/>
</aura:application>
 
<aura:component access="global" controller="AllAccount_ApexClass">
    <aura:handler name="init" value="{!this}" action="{!c.myaction}"/>
    <aura:attribute name="accounts" type="sObject[]"/>
    <aura:attribute name="isSelectAll" type="boolean" default="false"/>
    <div>
        <!--Header-->
        <lightning:layout horizontalAlign="spread" multipleRows="true">
            <lightning:layoutItem flexibility="grow" >
                <h1 class="modal-header slds-modal__header"  align="center">Accounts Detail</h1>
            </lightning:layoutItem>
        </lightning:layout>
        <!--/Header-->
        
        <table class="slds-table slds-table_bordered slds-table_resizable-cols slds-table_fixed-layout" role="grid">
            <thead>
                <tr class="slds-text-title--caps">
                    <!--Header checkBox-->
                    <th>
                        <div class="slds-m-left_medium">
                            <!--header checkbox for select all-->
                            <ui:inputCheckbox aura:id="box3" change="{!c.selectAll}"/>
                            SELECT ALL
                        </div>
                    </th>
                    <!--/Header checkBox-->
                    <th aria-sort="none"  scope="col">Account Name</th>
                    <th aria-sort="none" scope="col">Account Id</th>
                    <th aria-sort="none" scope="col">Account Phone</th>
                    <th aria-sort="none" scope="col">Account Fax</th>
                    
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.accounts}" var="acct">
                    <tr class="slds-text-title--caps">
                        <!--Body checkBox-->
                        <td>
                            <div class=" slds-m-left_x-small">
                                <ui:inputCheckbox text="{!acct.Id}" aura:id="boxPack" value="" />
                            </div>
                        </td>  
                        <!--/Body checkBox-->
                        <td class="slds-truncate">{!acct.accName}</td>
                        <td class="slds-truncate">{!acct.accId}</td>
                        <td class="slds-truncate">{!acct.Phone}</td>
                        <td class="slds-truncate">{!acct.Fax}</td>
                       
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </div>
</aura:component>
 
({
	myaction : function(c,e,h) {
		 console.log('saveData');
        h.myAction_helper(c,e,h);
    },
     selectAll: function(c,e,h) {
  //get the header checkbox value  
  var selectedHeaderCheck = e.getSource().get("v.value");
         var selectedCount ='';
         var getAllId = c.find("boxPack");
          if(! Array.isArray(getAllId)){
       if(selectedHeaderCheck == true){ 
          c.find("boxPack").set("v.value", true);
       }else{
           c.find("boxPack").set("v.value", false);
       }
     }else{
      if (selectedHeaderCheck == true) {
        for (var i = 0; i < getAllId.length; i++) {
      c.find("boxPack")[i].set("v.value", true);
            
      //call apex class get accounts method to list account for selected id...
        }
        } else {
          for (var i = 0; i < getAllId.length; i++) {
      c.find("boxPack")[i].set("v.value", false);
      // c.set("v.selectedCount", 0);
       }
       } 
     }  
 
 },
})
 
({
    myAction_helper : function(c,e,h) {
        console.log('PRIYANKA------');
        var action = c.get("c.myAction");
        action.setCallback(this, function (response) {
            if(response.getState() === 'SUCCESS') {
                var storedResponse = response.getReturnValue();
                console.log('storedResponse:');
                console.log(storedResponse);
                c.set("v.accounts",storedResponse);
                
            } else {
                console.log('ERROR');
                console.log(response.getError());
            }
        });
        $A.enqueueAction(action); 
    }
})

 
<aura:component controller="BoatSearchResults">
    
    <aura:handler name="init" action="{!c.doSearch}" value="{!this}"/>
	<aura:attribute name="boats" type="Boat__c[]" />

 <lightning:layout horizontalAlign="center" verticalAlign="center">
            <lightning:layoutItem flexibility="grow"  class="slds-m-right_small" >   
    			<aura:iteration items="{!v.boats}" var="boatVar">
                	<c:BoatTile boat="{!boatVar}"/>
                </aura:iteration>
    		
               
                <aura:renderIf isTrue="{!v.boats.length==1}">
                    <div style="margin-left: 50%;">
                    <ui:outputText value="No boats found" />
                        </div>
                </aura:renderIf>
     </lightning:layoutItem>
    </lightning:layout>
</aura:component>
 
({
    onSearch : function(component, event, helper) {
        console.log('In Helper');
        var action=component.get('c.getBoats');
         action.setParam({"boatTypeId":''});
        action.setCallback(this,function(response) {
            if(response.getState() === 'SUCCESS')
            {
                var boatslist = response.getReturnValue();
                component.set("v.boats",boatslist);
            }
        });
        $A.enqueueAction(action);
    }
})
 
({
    doSearch: function(component, event, helper) {
          helper.onSearch(cmp);
    }
})
 
public with sharing class BoatSearchResults {

    @Auraenabled
    public static List<Boat__c> getBoats(String boatTypeId)
    {
       if(boatTypeId != '')
       {
       return ([Select Id,Name, BoatType__c , Contact__r.Name , Description__c,Geolocation__c,Length__c,Price__c,Year_Built__c
               from Boat__c Where Id = :boatTypeId]); 
       }
       else
       {
           return ([SELECT Id, BoatType__c, picture__c, name,contact__r.Name from Boat__c]);
       }
    }
}

 
<aura:component controller="ContactControllerlightning">
	<aura:attribute name="contactObj" type="Contact" default="{'sobjectType':'Contact',
                                                              'FirstName':'' ,
                                                              'LastName':'' ,
                                                              'phone':''}"/>
    <aura:attribute name="contactId" type="String"/>
 
    <lightning:input value="{!v.contactObj.FirstName}" label="First Name" placeholder="Enter FirstName"/>
    <lightning:input vlaue="{!v.contactObj.LastName}" label="Last Name" placeholder="Enter LastName"/>
    <lightning:input value="{!v.contactObj.phone}" label="Phone" placeholder="Enter Phone"/>
        <lightning:button variant="brand" label="Save" title="Save" onclick="{!c.dosave}"/>

  

    
    
    
</aura:component>
 
({
	dosave : function(component, event, helper) {
        var action = component.get("c.createContact");
        
        action.setParams({'contObj':component.get('v.contactObj')});
        
        action.setCallback(this,function(data){
         component.set('v.contactId',data.getReturnValue())
        });
		$A.enqueueAction(action);
	}
})

 
<aura:component controller="ContactControllerlightning">
	<aura:attribute name="contactObj" type="Contact" default="{'sobjectType':'Contact',
                                                              'FirstName':'' ,
                                                              'LastName':'' ,
                                                              'phone':''}"/>
    <aura:attribute name="contactId" type="String"/>
 
    <lightning:input value="{!v.contactObj.FirstName}" label="First Name" placeholder="Enter FirstName"/>
    <lightning:input vlaue="{!v.contactObj.LastName}" label="Last Name" placeholder="Enter LastName"/>
    <lightning:input value="{!v.contactObj.phone}" label="Phone" placeholder="Enter Phone"/>
        <lightning:button variant="brand" label="Save" title="Save" onclick="{!c.dosave}"/>

  

    
    
    
</aura:component>
 
({
	dosave : function(component, event, helper) {
        var action = component.get("c.createContact");
        
        action.setParams({'contObj':component.get('v.contactObj')});
        
        action.setCallback(this,function(data){
         component.set('v.contactId',data.getReturnValue())
        });
		$A.enqueueAction(action);
	}
})