Guest User

Untitled

a guest
Oct 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. <lightning:overlayLibrary aura:id="overlayLib"/>
  2. <lightning:button name="modal" label="Create Pet" onclick="{!c.handleShowModal}"/>
  3.  
  4. handleShowModal : function (component, event, helper) {
  5. var modalBody;
  6. var modalFooter;
  7. $A.createComponents([
  8. ["c:IFBPetCreate", {"record": component.get("v.newPet"),
  9. "needsOwner": component.get("v.missingPetOwner"),
  10. "isEU": component.get("v.isEuUser"),
  11. "contList": component.get("v.contList"),
  12. "isLead": component.get("v.isLead")}],
  13.  
  14. ["c:ModalFooter", {"recordId": component.get("v.recordId"),
  15. "newPet": component.get("v.newPet")}]
  16. ],
  17. function(components, status){
  18. if (status === "SUCCESS") {
  19. modalBody = components[0];
  20. modalFooter = components[1];
  21. component.find('overlayLib').showCustomModal({
  22. header: "New Pet",
  23. body: modalBody,
  24. footer: modalFooter,
  25. showCloseButton: false,
  26. cssClass: "my-modal,my-custom-class,my-other-class",
  27. closeCallback: function() {
  28. //alert('You closed the alert!');
  29. }
  30. })
  31. }
  32. }
  33. );
  34. },
  35.  
  36. <aura:component implements="force:hasRecordId" controller="CasePetList_Controller">
  37.  
  38. <aura:attribute name="recordId" type="String" />
  39. <aura:attribute name="newPet" type="Pet__c" default="{'sobjectType':'Pet__c', 'Active__c':true}" />
  40.  
  41. <lightning:overlayLibrary aura:id="overlayLib"/>
  42. <lightning:button name="cancel" label="Cancel" onclick="{!c.handleCancel}"/>
  43. <lightning:button name="save" label="Save" variant="brand" onclick="{!c.handleSave}"/>
  44.  
  45. </aura:component>
  46.  
  47. handleCancel : function(component, event, helper) {
  48. component.find("overlayLib").notifyClose();
  49. console.log('handleCancel: component: '+component);
  50. var action = component.get("c.setNewPet");
  51. console.log('handleCancel: action: '+action);
  52. action.setParams({
  53. recId: component.get("v.recordId")
  54. });
  55. action.setCallback(this, function(response) {
  56. var state = response.getState();
  57. if(state === "SUCCESS") {
  58. component.set("v.newPet", response.getReturnValue());
  59. }else{
  60. console.log('Problem getting new pet, response state: ' + state);
  61. }
  62. });
  63. $A.enqueueAction(action);
  64. },
Add Comment
Please, Sign In to add comment