-
-
Save shrutis22/0b6f2e8f0c4d5324328cfa10c6eda52b 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
( { | |
init : function( component, event, helper ) { | |
var action = component.get( "c.initialize" ); | |
component.set( "v.scriptsLoaded", true ); | |
action.setCallback( this, function( response ) { | |
var state = response.getState(); | |
if ( state === "SUCCESS" ) { | |
var result = response.getReturnValue(); | |
var cols = {}; | |
result.columns.forEach( | |
function( col ) { | |
cols[col.label] = col; | |
} | |
); | |
var rows = []; | |
for( var key in result.rows ) { | |
rows.push( { value: result.rows[key], key: cols[key] } ); | |
} | |
component.set( "v.rows", rows ); | |
component.set( "v.columns", result.columns ); | |
helper.hideSpinner( component ); | |
} | |
else { | |
helper.showToast( | |
{ | |
"title" : "Error", | |
"message" : "Error: " + JSON.stringify( response.getError() ) + ", State: " + state, | |
"isSuccess" : "error" | |
} | |
); | |
} | |
} ); | |
$A.enqueueAction( action ); | |
}, | |
applySortable : function( component, event, helper ) { | |
var sortableApplied = component.get( "v.sortableApplied" ); | |
var scriptsLoaded = component.get( "v.scriptsLoaded" ); | |
/** | |
* Apply the jQuery Sortable | |
* when the DOM is ready and | |
* the Scripts have been loaded. | |
*/ | |
if( scriptsLoaded && | |
!sortableApplied && | |
jQuery( ".slds-lane" ).length > 0 | |
) { | |
component.set( "v.sortableApplied", true ); | |
helper.applySortable( component ); | |
} | |
}, | |
logACall : function( component, event, helper ) { | |
var createRecordEvent = $A.get( "e.force:createRecord" ); | |
createRecordEvent.setParams( | |
{ | |
"entityApiName" : "Task", | |
"defaultFieldValues": { | |
"WhoId" : event.getSource().get( "v.name" ), | |
"Subject" : "Log A Call" | |
} | |
} | |
); | |
createRecordEvent.fire(); | |
}, | |
logAMeeting : function( component, event, helper ) { | |
var createRecordEvent = $A.get( "e.force:createRecord" ); | |
createRecordEvent.setParams( | |
{ | |
"entityApiName" : "Event", | |
"defaultFieldValues": { | |
"WhoId" : event.getSource().get( "v.name" ), | |
"Subject" : "Log A Meeting" | |
} | |
} | |
); | |
createRecordEvent.fire(); | |
} | |
} ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment