Skip to content

Lightning #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ node_modules
# built webapp resource bundle
resource-bundles/FullCalendar.resource/*
npm-debug.log


salesforce_marketing_calendar.sublime-project
config/.debug
config/.describe
config/.lightning
config/.local_store
config/.session
3 changes: 3 additions & 0 deletions src/aura/MarketingCalendar/MarketingCalendar.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<aura:application >
<c:calendar ></c:calendar>
</aura:application>
5 changes: 5 additions & 0 deletions src/aura/MarketingCalendar/MarketingCalendar.app-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>33.0</apiVersion>
<description>Lightning version of Marketing Calendar</description>
</AuraDefinitionBundle>
4 changes: 4 additions & 0 deletions src/aura/MarketingCalendar/MarketingCalendarController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
({
myAction : function(component, event, helper) {
}
})
63 changes: 63 additions & 0 deletions src/aura/calendar/calendar.cmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<aura:component controller="CampaignCalendar" implements="force:appHostable,flexipage:availableForAllPageTypes">
<ltng:require
styles="/resource/Fullcalendar/2.6.0/fullcalendar.min.css,
/resource/Fullcalendar/jquery.qtip.css,
/resource/Fullcalendar/select2.css"
scripts="/resource/Fullcalendar/2.6.0/lib/jquery.min.js,
/resource/Fullcalendar/2.6.0/lib/jquery-ui.custom.min.js,
/resource/Fullcalendar/2.6.0/lib/moment.min.js,
/resource/Fullcalendar/2.6.0/fullcalendar.min.js,
/resource/Fullcalendar/jquery.qtip.js,
/resource/Fullcalendar/jsrender.js,
/resource/Fullcalendar/select2.js"
afterScriptsLoaded="{!c.doInit}" />

<aura:attribute name="campaignObj" type="Campaign" default="{ sobjectType: 'Campaign' }"/>
<div>
<div class="filterBox">
<span class="filterBoxTitle">FILTERS</span>
<div style="margin-top:5px;padding:10px;">
<div id="filter-elem-1">
<b class="label">Parent Campaign</b>
<div class="filter">
<select id="parentCampaign" class="combo" style="min-width:240px">
<option value="--None--">--None--</option>
<aura:iteration items="{!v.parentCampaigns}" var="p">
<option value="{!p.Id}">{!p.Name}</option>
</aura:iteration>
</select>
</div>
</div>
<div id="filter-elem-2">
<b class="label">Campaign Type</b>
<div class="filter">
<force:inputField value="{!v.campaignObj.Type}" />
</div>
</div>
<div style="clear:both"/>
</div>
</div>
<div style="clear:both"/>
<br/>
<div id="calendarX"></div>

<div id="qtipTemplate" type="text/x-jQuery-render" style="display:none">

<table width="100%">
<aura:iteration items="{!v.MarketingCalendarPopupFields}" var="f">
<tr>
{{if '{!f.fieldPath}' == 'OwnerId'}}
<td><b>Owner</b></td>
<td>{{>Owner.Name}}</td>
{{else}}
<td><b>{!f.label}</b></td>
<td class="{!f.fieldPath}" >
{{>{!f.fieldPath}}}
</td>
{{/if}}
</tr>
</aura:iteration>
</table>
</div>
</div>
</aura:component>
5 changes: 5 additions & 0 deletions src/aura/calendar/calendar.cmp-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>33.0</apiVersion>
<description>lightning version of marketing calendar</description>
</AuraDefinitionBundle>
66 changes: 66 additions & 0 deletions src/aura/calendar/calendar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.THIS #calendarX{
background-color: #fff;
border-width: 1px;
border-color:#ddd;
padding:10px;
box-shadow: none;
border-style:solid;
border-radius: 4px 4px;
margin-top:15px;
}

.THIS .filterBox {
margin-top:5px;
background-color: #fff;
border-width: 1px;
border-color:#ddd;
padding:5px;
box-shadow: none;
border-style:solid;
border-radius: 4px 4px;
float:right;
background: linear-gradient(#E5F2F6,#CDE8F0);
-moz-box-shadow: 0 3px 5px hsla(100,0%,0%,.3);
-webkit-box-shadow: 0 3px 5px hsla(100,0%,0%,.3);
box-shadow: 0 3px 5px hsla(100,0%,0%,.3);

}

.THIS .uiInputSelect{
display: inline-block;
}

.THIS .filterBoxTitle{
position:absolute;
color:#808080;
font-weight:bold;
font-size: 12px;
}

.THIS .label{
margin-left:8px;
font-size: 13px;
margin-right:5px;
}

.THIS .combo{
margin-left:4px;
}

.THIS .filter{
float:right;
}

.THIS #filter-elem-1{
float:left;
}

.THIS #filter-elem-2{
float:right;
}

@media all and (max-width: 980px) {
.THIS #filter-elem-2{
display: block;;
}
}
9 changes: 9 additions & 0 deletions src/aura/calendar/calendarController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
({
doInit : function(component, event, helper) {
helper.doInit(helper,component);
},
reload :function(component, event, helper){
console.log('reloading');
helper.load(component,helper);
}
})
126 changes: 126 additions & 0 deletions src/aura/calendar/calendarHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
({
doInit : function(helper,component) {
var me = this;
helper.getParentCampaigns(component);
helper.describeFieldSet("MarketingCalendarPopup",component,function(r){
component.set('v.MarketingCalendarPopupFields',r.getReturnValue());
helper.load(helper,component,"","");
$('.forceInputPicklist select').removeAttr('disabled');
$('select').select2({width: 'resolve'}).on('change',function(){
helper.load(helper,component,$('#parentCampaign').val(),$('.forceInputPicklist select').val());
});
});
},
load : function(helper,component,parentCampaignId,type){
helper.fetchCalendarData(helper,component,parentCampaignId,type,function(response){
if (response.getState() === "SUCCESS") {
//component.set('v.campaigns',response.getReturnValue());
helper.initCalendar(helper,helper.parseEnteries(response.getReturnValue()));
}
else{
var error = helper.parseErrors(response.getError());
component.set("v.errors",error);
}
})
},
fetchCalendarData : function(helper,component,parentCampaignId,type,cb){
parentCampaignId = (parentCampaignId == '--None--' ? '' : parentCampaignId);
type = (type == '--None--' ? '' : type);
var action = component.get("c.getCalendarEntryAura");
action.setParams({"parentCampaignId":parentCampaignId,"type" : type});
action.setCallback(helper,cb);
$A.enqueueAction(action);
},
describeFieldSet : function(fs,component,cb){
var action = component.get("c.describeFieldSet");
action.setParams({"fieldset":fs});
action.setCallback(this,cb);
$A.enqueueAction(action);
},
parseCampaigns : function(campaigns){
var enteries = [];
for(var i =0 ;i < campaigns.length; i++){
enteries.push({
title : campaigns[i].Name,
start : campaigns[i].StartDate,
end : campaigns[i].EndDate
});
}
return enteries;
},
parseEnteries : function(results){
for(var i =0 ;i < results.length; i++){
results[i].start = new Date(results[i].startDate);
results[i].end = new Date(results[i].endDate);
}
return results;
},
initCalendar : function(helper,calendarEntries){
console.log(calendarEntries);
$('#calendarX').fullCalendar('destroy');
$('#calendarX').fullCalendar({
editable: false,
events: calendarEntries,
eventClick: function(event) {
if (event.url) {
window.open(event.url);
return false;
}
},
eventRender: function(event, element, view){
element.qtip({
position: {
my: 'top left',
at: 'bottom center'
},
style: {
width: 300,
color: 'black',
name: 'light'
},
content: $.templates(helper.decodeEntities($("#qtipTemplate").html())).render(event.campaign)
});
}
});
},
toast : function(title,message){
var toastEvent = $A.get("e.force:showToast");
if(toastEvent){
toastEvent.setParams({
"title": title,
"message": message
});

toastEvent.fire();
}
},
parseErrors : function(errorObj){
console.log('error',errorObj);
var error = [];
for(var i = 0; i < errorObj.length > 0; i ++){
if(errorObj[i].pageErrors){
error = error.concat(errorObj[i].pageErrors);
}

if(errorObj[i].fieldErrors){
for(f in errorObj[i].fieldErrors){
error = errorObj[i].fieldErrors[f].concat(errorObj[i].pageErrors);
}
}
}
return error;
},
decodeEntities : function(input) {
var y = document.createElement('textarea');
y.innerHTML = input;
return y.value;
},
getParentCampaigns : function(component){
var action = component.get("c.getActiveParentCampaignObjects");
action.setParams({});
action.setCallback(this,function(response){
component.set("v.parentCampaigns",response.getReturnValue());
});
$A.enqueueAction(action);
}
})
Loading