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
global class FullCalendarDemo{
@RemoteAction
global static List<User_Calendar__c> getEvents() {
String userId = UserInfo.getUserId() ;
List<User_Calendar__c> userCalendar = [SELECT Id, Name, User__r.Name,
Event__c, Event__r.Name, Event__r.Start_Time__c, Event__r.End_Time__c
FROM User_Calendar__c
WHERE User__c=:userId];
if(userCalendar.size()>0){
/**
* Initializing fullcalendar with appropriate option and handlers
* using Singleton Pattern
* */
const CalendarSingleton = (function(){
let calendarInstance;
function createCalendar(){
//Initialize Full Calender
//and render inside 'calendar' div
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="message" type="String"/>
<aura:attribute name="visualforceDomain" type="String"
default="manish-winter19-dev-ed--c.visualforce.com"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:card title="Post Message Demo">
<lightning:layout multipleRows="true">
<lightning:layoutItem padding="around-large">
({
doInit : function(component) {
var visualforceDomain = "https://" + component.get("v.visualforceDomain");
/**
* Adding a new event listner on window object
* to listen for message event
**/
window.addEventListener("message", function(event) {
//Check if origin is not your org's my domain url, in this case, simply return out of function
if (visualforceDomain.indexOf(event.origin) == -1) {
<apex:page lightningStylesheets="true">
<html>
<head>
<style>
.vf-header {
padding-left: 20px;
background-color: lightgrey;
padding-top: 5px;
padding-bottom: 5px;
font-weight: bold;
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
controller="LightningMapDemoController"
access="global" >
<!-- datatable component attribute -->
<aura:attribute name="data" type="Object"/>
<aura:attribute name="columns" type="List"/>
<aura:attribute name="selectedRowsCount" type="Integer" default="0"/>
<aura:attribute name="maxRowSelection" type="Integer" default="5"/>
({
/**
* Fetch car list on component initialization and
* generate datatable columns
* */
doInit : function(component, event, helper) {
component.set('v.columns', [
{label: 'Name', fieldName: 'Name', type: 'text'},
{label: 'Build Year', fieldName: 'BuildYear', type: 'number'},
{label: 'Rent/Day', fieldName: 'PerDayRent', type: 'currency',
({
/**
* Get all cars from server
* */
getCars : function(component, helper) {
//Call server action to get events
var action = component.get("c.getAllCars");
action.setCallback(this, function(response) {
var state = response.getState();
public class LightningMapDemoController {
@AuraEnabled(cacheable=true)
public static List<CarWrapper> getAllCars(){
List<Car__c> cars = [SELECT Id, Name, Available_For_Rent__c, Build_Year__c,
Mileage__c, Per_Day_Rent__c,
(SELECT Id, Name, City__c,Coordinates__Latitude__s, Coordinates__Longitude__s,
Country__c, Pin_Code__c, State__c, Street__c FROM Address__r)
FROM Car__c Limit 100];
<aura:component access="global">
<!-- ChannelName, which needs to subscribed -->
<aura:attribute name="channelName" type="String" required="true"/>
<!-- Save the reference of current subscription, which can be unsubscribe later on -->
<aura:attribute name="subscription" type="Object"/>
<!-- This event is fired when a component is destroyed.
Handle this event if you need to do custom cleanup when a component is destroyed.-->
<aura:handler name="destroy" value="{!this}" action="{!c.unsubscribe}"/>