Skip to content

Instantly share code, notes, and snippets.

@mhamzas
Created November 18, 2019 14:17
Show Gist options
  • Save mhamzas/0fabc166b0198ff7a840382cf03f78ba to your computer and use it in GitHub Desktop.
Save mhamzas/0fabc166b0198ff7a840382cf03f78ba to your computer and use it in GitHub Desktop.
Contact Support Custom AURA - Clearbanc
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
<aura:attribute name="SubmitBtnLabel" Type="String" default="Submit" />
<aura:attribute name="CreateCaseBtnLbl" Type="String" default="Create Case" />
<aura:registerEvent name="appEvent" type="selfService:caseCreateFieldChange"/>
<lightning:recordEditForm aura:id="recordEditForm"
objectApiName="Case" onsuccess="{!c.handleSuccess}">
<lightning:messages />
<lightning:inputField fieldName="Category__c" onchange="{!c.showchild}"/>
<lightning:inputField aura:id="child1" required="true" fieldName="Sub_Category__c" onchange="{!c.changeSubject}"/>
<lightning:inputField aura:id="name" class="slds-hide" required="true" fieldName="SuppliedName" value="{!v.subject}" />
<lightning:inputField aura:id="email" class="slds-hide" required="true" fieldName="SuppliedEmail" value="{!v.subject}" />
<lightning:inputField aura:id="phone" class="slds-hide" required="true" fieldName="SuppliedPhone" value="{!v.subject}" />
<lightning:inputField aura:id="subject" class="slds-hide" required="true" fieldName="Subject" value="{!v.subject}"/>
<lightning:inputField aura:id="description" class="slds-hide" required="true" fieldName="Description" />
<lightning:button variant="brand" aura:id="showbutton" class="slds-hide slds-hide slds-m-top_small" type="button" label="{!v.CreateCaseBtnLbl}" onclick="{!c.toggle}" />
<lightning:button variant="brand" aura:id="submitbutton" class="slds-hide slds-m-top_small" type="submit" label="{!v.SubmitBtnLabel}" />
</lightning:recordEditForm>
</aura:component>
({
handleSuccess : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({"title": "Success!","message": "Case has been created.","type": "success"});toastEvent.fire();
var recordEditForm = component.find("recordEditForm");
$A.util.toggleClass(recordEditForm, "slds-hide");
},
handleCancel : function(component, event, helper) {
helper.showHide(component);
event.preventDefault();
},
changeSubject : function(component, event, helper) {
console.log(event.getSource().get("v.value"));
var showbutton = component.find("showbutton");
console.log(showbutton);
if(event.getSource().get("v.value") == ''){
console.log('yes');
$A.util.addClass(showbutton, "slds-hide");
} else {
console.log('yes1');
$A.util.removeClass(showbutton, "slds-hide");
$A.util.removeClass(showbutton, "slds-hide");
}
//component.set('v.subject',event.getSource().get("v.value"));
var appEvent = $A.get("e.selfService:caseCreateFieldChange");
appEvent.setParams({
"modifiedField": "Subject",
"modifiedFieldValue": event.getSource().get("v.value")
});
appEvent.fire();
},
toggle : function(component, event, helper) {
helper.showHide(component);
},
showchild : function(component, event, helper) {
if(event.getSource().get("v.value") == ''){
var child = component.find("child1");
$A.util.addClass(child, "slds-hide");
} else {
var child = component.find("child1");
$A.util.removeClass(child, "slds-hide");
}
}
})
({
showHide : function(component) {
var subject = component.find("subject");
$A.util.toggleClass(subject, "slds-hide");
var name = component.find("name");
$A.util.toggleClass(name, "slds-hide");
var email = component.find("email");
$A.util.toggleClass(email, "slds-hide");
var phone = component.find("phone");
$A.util.toggleClass(phone, "slds-hide");
var description = component.find("description");
$A.util.toggleClass(description, "slds-hide");
var submitbutton = component.find("submitbutton");
$A.util.toggleClass(submitbutton, "slds-hide");
var showbutton = component.find("showbutton");
$A.util.toggleClass(showbutton, "slds-hide");
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment