Skip to content

Instantly share code, notes, and snippets.

View choudharymanish8585's full-sized avatar
💭
Never Settle

Manish Choudhari choudharymanish8585

💭
Never Settle
View GitHub Profile
({
/**
* Retrieve the data from server
* call prepareData function to filter out unnecessary data
* */
onInit : function(component, event, helper) {
var action = component.get("c.getRecords");
action.setStorable();
action.setCallback(this,function(response) {
var state = response.getState();
/*
* This method will call the server side action and will execute callback method
* it will also show error if generated any
* @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
* */
window.callServer = function(component, method, callback, params, setStorable) {
var action = component.get(method);
<!--Exntends Base Component in Component Definition -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="AccountController" access="global" >
<aura:attribute name="data" type="Account[]"/>
<!-- Including BaseJS script. Once loaded call fetchAccounts method -->
<ltng:require scripts="{!$Resource.BaseJS}"
afterScriptsLoaded="{!c.fetchAccounts}"/>
<aura:iteration items="{!v.data}" var="acc">
({
fetchAccounts : function(component, event, helper) {
helper.getAllAccounts(component, helper);
},
})
({
getAllAccounts : function(component, helper) {
//Calling BaseJS method to call Aura Method
callServer(component, "c.getAccounts",
function(response){
if(response){
component.set("v.data", response);
//Calling showToast method of BaseJS
showToast({
"title": "SUCCESS",
/**
* BusinessDays Class
* Use this class to operate only on business days
* and easily skip weekends and holidays from your logic
* @author - Manish Choudhari
* */
public class BusinessDays
{
public BusinessHours bHours;
/**
<!-- - **Generic Record Handler Component**
- Use this component to edit any record of any object on the same page
- The component gives you option to only view custom or standard objects or all objects
- You can view your record in read only mode or view mode
- @author - Manish Choudhari
- -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
access="global"
controller="GenericRecordHandler">
<!-- Init handler, this function will be executed on page load -->
({
/**
* This function will be called on page load
* This sets data table columns and also fetches object list
* @author - Manish Choudhari
* */
doInit : function(component, event, helper) {
component.set('v.columns', [
{label: 'Name', fieldName: 'Name', type: 'text'},
{label: 'Action', type: 'button', initialWidth: 135, typeAttributes:
({
/**
* This function gets object list
* @author - Manish Choudhari
* */
getObjectList : function(component) {
var action = component.get("c.getObjects");
action.setCallback(this,function(response) {
var state = response.getState();
if (state === "SUCCESS") {
/**
* Controller class for GenericRecordHandler Lightning Component
* Contains method to retrieve objects and records
* @author - Manish Choudhari
* */
public class GenericRecordHandler {
// This method retrieves all object list from Salesforce Org
// You can filter out object list here, as per you use case
@AuraEnabled(cacheable=true)