This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component controller="CarTypeSearch" | |
| implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId"> | |
| <!-- Attribute to controle visibility of New button --> | |
| <aura:attribute name="showNew" type="boolean" /> | |
| <aura:attribute name="carTypes" type="Car_Type__c[]"/> | |
| <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> | |
| <!-- This event will be fired when user will click on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| doInit : function(component, event, helper) { | |
| var createBoatRecord = $A.get("e.force:createRecord"); | |
| if(createBoatRecord){ //check if this event is available or not | |
| component.set("v.showNew", true); | |
| } else{ | |
| component.set("v.showNew", false); | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| getCarType : function(component, helper) { | |
| var action = component.get("c.getCarTypes"); | |
| action.setCallback(this, function(data) { | |
| component.set("v.carTypes", data.getReturnValue()); | |
| }); | |
| $A.enqueueAction(action); | |
| }, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| /* | |
| * This method will call the server side action and will execute callback method | |
| * it will also show error if generated any | |
| * @param component (required) - Calling component | |
| * @param method (required) - Server side methos name | |
| * @param callback (required) - Callback function to be executed on server response | |
| * @param params (optional) - parameter values to pass to server | |
| * @param setStorable(optional) - if true, action response will be stored in cache | |
| * */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component abstract="true"> | |
| {!v.body} | |
| </aura:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component controller="CarTypeSearch" | |
| implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId" | |
| extends="c:Base"> | |
| <!-- Attribute to controle visibility of New button --> | |
| <aura:attribute name="showNew" type="boolean" /> | |
| <aura:attribute name="carTypes" type="Car_Type__c[]"/> | |
| <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| doInit : function(component, event, helper) { | |
| var createBoatRecord = $A.get("e.force:createRecord"); | |
| if(createBoatRecord){ //check if this event is available or not | |
| component.set("v.showNew", true); | |
| } else{ | |
| component.set("v.showNew", false); | |
| } | |
| helper.getCarType(component, helper); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| getCarType : function(component, helper) { | |
| /* | |
| * Below line of code uses inheritance to | |
| * call server side controller from | |
| * base component's helper method | |
| * */ | |
| helper.callServer(component, "c.getCarTypes", | |
| function(response){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"> | |
| <!-- searchFormSubmit event handler to call aura method 'searchCars' of | |
| CarSearchResult component --> | |
| <aura:handler name="searchFormSubmit" event="c:SearchFormSubmitEvent" action="{!c.doFormSubmit}" /> | |
| <!-- Top CarSeachForm Component --> | |
| <lightning:card title="Search Your Car" class="bottom_margin"> | |
| <c:CarSearchForm /> | |
| </lightning:card> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| doFormSubmit : function(component, event, helper) { | |
| //fetching carTypeId attribute value from event | |
| var carTypeId = event.getParam('carTypeId'); | |
| var carSearchResultComp = component.find("carSearchResult"); | |
| // call the aura:method in the child component | |
| var carSearchCmpResult = carSearchResultComp.searchCars(carTypeId); | |
| console.log("auraMethodResult: " + carSearchCmpResult); |