Skip to content

Instantly share code, notes, and snippets.

View dhaniksahni's full-sized avatar

Dhanik Lal Sahni dhaniksahni

View GitHub Profile
@dhaniksahni
dhaniksahni / DataDisplayController.cls
Created May 16, 2018 13:53 — forked from toanshulverma/DataDisplayController.cls
Sample Code to Generate PDF from Lightning components with in-memory data
public class DataDisplayController {
public String PDFData {get; set;}
public DataDisplayController(){
PDFData = '';
}
public PageReference downloadPDF(){
System.PageReference pageRef = new System.PageReference('/apex/PDFGenerator');
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.SignaturePad=e()}(this,function(){"use strict";function t(t,e,i){this.x=t,this.y=e,this.time=i||(new Date).getTime()}function e(t,e,i,o){this.startPoint=t,this.control1=e,this.control2=i,this.endPoint=o}function i(t,e,i){var o,n,s,r=null,h=0;i||(i={});var a=function(){h=!1===i.leading?0:Date.now(),r=null,s=t.apply(o,n),r||(o=n=null)};return function(){var c=Date.now();h||!1!==i.leading||(h=c);var d=e-(c-h);return o=this,n=arguments,d<=0||d>e?(r&&(clearTimeout(r),r=null),h=c,s=t.apply(o,n),r||(o=n=null)):r||!1===i.trailing||(r=setTimeout(a,d)),s}}function o(t,e){var n=this,s=e||{};this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.throttle?this._strokeMoveUpdate=i(o.prototype._strokeUpdate,this.throttle):this._strokeMo
@dhaniksahni
dhaniksahni / WhatsAppSender.cmp
Created September 6, 2019 15:33
Send WhatsApp Message using Lightning Component
<aura:component controller="WhatsAppMessageService" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
<lightning:notificationsLibrary aura:id="notifLib"/>
<div class="row">
<lightning:input aura:id="mobileNumber" name="mobileNumber" label="Mobile Number" />
<lightning:input aura:id="message" name="message" label="Message" />
</div>
<div class="row">
<lightning:button variant="brand" label="Send Message" title="Send Message" onclick="{! c.handleClick }" />
</div>
public class StackExchangeAccess {
@AuraEnabled
public static StackExchangeUserWrapper getUsers(integer pageNumber,integer pageSize,string sortdirection, string sortName, string sitename)
{
string url='page='+pageNumber+'&pagesize='+ pageSize+'&order='+sortdirection+'&sort='+sortName+'&site='+sitename;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.stackexchange.com/2.2/users?'+url);
request.setMethod('GET');
HttpResponse response = http.send(request);
public class StackExchangeUserWrapper {
@AuraEnabled
public List<Items> items;
@AuraEnabled
public Boolean has_more;
@AuraEnabled
public Integer quota_max;
@AuraEnabled
public Integer quota_remaining;
@dhaniksahni
dhaniksahni / stackoverflowExplorer.css
Created October 2, 2019 13:37
Salesforce Stack Exchange Explorer
.divcenter {
text-align: center;
font-weight: bold;
font-size: 15px;
}
@dhaniksahni
dhaniksahni / paginator.html
Created October 2, 2019 13:40
Paginator Lightning Web Component
<template>
<lightning-layout>
<lightning-layout-item>
<lightning-button label="Previous" icon-name="utility:chevronleft" onclick={previousHandler}></lightning-button>
</lightning-layout-item>
<lightning-layout-item flexibility="grow"></lightning-layout-item>
<lightning-layout-item>
<lightning-button label="Next" icon-name="utility:chevronright" icon-position="right" onclick={nextHandler}></lightning-button>
</lightning-layout-item>
</lightning-layout>
@dhaniksahni
dhaniksahni / imageControl.css
Created October 10, 2019 04:01
Custom Data Type for Image in Lightning Web Component
.image
{
height: 30px;
width: 30px;
}
@dhaniksahni
dhaniksahni / imageTableControl.html
Created October 10, 2019 04:10
Extend Lightning Web Component Data Table
<template>
<c-image-control url={value}
alt-text="Image Not Found">
</c-image-control>
</template>
@dhaniksahni
dhaniksahni / showProfile.html
Created October 10, 2019 04:37
Use Extended Data Table in Lightning Web Component
<template>
<c-salesforce-codex-data-table
                key-field="id"
                data={data}
                show-row-number-column="false"
                hide-checkbox-column="false"
                columns={columns}>
 </c-salesforce-codex-data-table>
</template>