Last active
May 5, 2018 10:39
-
-
Save veeranjik/9f4966c8a41a65ad91eb6fd60959de0c to your computer and use it in GitHub Desktop.
This file contains 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
({ | |
getReasource: function(component,event){ | |
var action = component.get("c.getReasource"); | |
var self = this; | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (component.isValid() && state === "SUCCESS") { | |
var eventArr = response.getReturnValue(); | |
self.jsLoaded(component,eventArr); | |
component.set("v.Resources", response.getReturnValue()); | |
} | |
}); | |
$A.enqueueAction(action); | |
}, | |
jsLoaded : function(component,events){ | |
$(document).ready(function(){ | |
(function($) { | |
var tempR = events; | |
var jsnResourcesArray = []; | |
var jsnEventsArray = []; | |
for(var i = 0;i < tempR.length;i++){ | |
jsnResourcesArray.push({ | |
'title':tempR[i].Name, | |
'id':i | |
}); | |
for(var k=0;k < tempR[i].Reservations__r.length ; k++){ | |
jsnEventsArray.push({ | |
'resourceId': i, | |
'id': tempR[i].id, | |
'start': tempR[i].Reservations__r[k].Check_in__c, | |
'end': tempR[i].Reservations__r[k].Check_out__c, | |
'color' : myEventColor(tempR[i].Reservations__r[k].Status__c) | |
}); | |
} | |
} | |
$('#calendar').fullCalendar({ | |
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source', | |
defaultView: 'timelineMonth', | |
locale: 'en', | |
resourceAreaWidth: '12%', | |
resourceLabelText: 'My Hotel Rooms', | |
views: { | |
}, | |
resources:jsnResourcesArray, | |
events: jsnEventsArray | |
}); | |
})(jQuery); | |
}); | |
function myEventColor(status) { | |
if(status === 'Inquired'){ | |
return 'BlueViolet'; | |
} | |
else if (status === 'Hold') { | |
return 'YellowGreen'; | |
} else if (status === 'Confirmed') { | |
return '#54ff9f'; | |
} else { //Cancelled | |
return '#ff0000'; | |
} | |
} | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment