Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. ***Controller****
  2. public with sharing class Inquiry_Todo_Controller {
  3.  
  4. @AuraEnabled(cacheable=true)
  5. public static List<Inquiry_Todos__c> getInquiryTodos(String sRecId){
  6. System.debug('@@record ID:'+sRecId);
  7. Map<String,Inquiry_Todos__c> todoMap = new Map<String,Inquiry_Todos__c>();
  8. List<Inquiry_Todos__c> todoLst = new List<Inquiry_Todos__c>();
  9. String insType = [SELECT Insurance_Type__c FROM Inquiry__c WHERE Id =: sRecId].Insurance_Type__c;
  10. for (Inquiry_Todos__c setting : Inquiry_Todos__c.getAll().values()){
  11. if(setting.Insurance_Type__c == insType)
  12. todoLst.add(setting);
  13. }
  14. return todoLst;
  15. }
  16.  
  17. }
  18.  
  19. ***Component****
  20. <aura:component description="ToDoItem" implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName"
  21. controller="Inquiry_Todo_Controller">
  22. <aura:attribute name="options" type="List" />
  23. <aura:attribute name="value" type="List" />
  24. <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
  25.  
  26. <div class="slds-box slds-theme_default">
  27. <span class="title slds-path__title" style="font-weight: bold;color:#FF9033;" >
  28. <lightning:icon iconName="standard:task" title="Inquiry TODO's" size="medium" alternativeText="To Do's"/>
  29. TO-DO
  30. </span>
  31. <lightning:checkboxGroup
  32. aura:id="todo"
  33. name="InqTODO"
  34. options="{! v.options }"
  35. value="{! v.value }"
  36. onchange="{!c.handleChange}"
  37. required="false" />
  38. </div>
  39. </aura:component>
  40.  
  41. ***JS Controller****
  42.  
  43. doInit: function(component,event,helper){
  44. helper.getTodoList(component);
  45. },
  46.  
  47. handleChange: function(component,event,helper){
  48. console.log('@@@options:::'+component.get("v.options"));
  49. console.log('@@@options JSON:::'+JSON.stringify(component.get("v.options")));
  50. var selectedValue = component.find("todo").get("v.value");
  51. if(selectedValue.length != 0){
  52. var lastSelectedValue = selectedValue[selectedValue.length - 1];
  53. console.log('@@@lastSelectedValue@@@'+lastSelectedValue);
  54. }
  55. }
  56.  
  57. ****Helper****
  58. ({
  59. getTodoList: function(component){
  60. var res;
  61. var action = component.get("c.getInquiryTodos");
  62. action.setParams({
  63. "sRecId" : component.get("v.recordId")
  64. });
  65. action.setCallback(this,function(response){
  66. console.log('response object::'+JSON.stringify(response.getReturnValue()));
  67. var state = response.getState();
  68. if(state == "SUCCESS"){
  69. var res = response.getReturnValue();
  70. var labels= [];
  71. for(var key in res){
  72. labels.push({ label: res[key].Todo_Value__c,
  73. value: res[key].Name });
  74. }
  75. component.set("v.options", labels);
  76. }
  77. });
  78. $A.enqueueAction(action);
  79. },
  80.  
  81. createToDoTask: function(var1){
  82. }
  83. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement