Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. <aura:attribute name="recordId" type="Id" />
  2. <aura:attribute name="pageType" type="String" />
  3. <aura:attribute name="ActivityObjects" type="sObject" />
  4. <aura:attribute name="sobjectType" type="String" default="{!v.sObjectName}"/>
  5. <aura:attribute name="sobjectView" type="String" />
  6.  
  7. <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  8. <aura:handler event="force:showToast" action="{!c.refreshRecords}" />
  9.  
  10.  
  11. <article class="slds-card slds-p-around_x-small">
  12. <div class="bgColor">
  13. <div class="slds-section__title slds-m-bottom--x-small">
  14. <h2 class="slds-align-middle slds-truncate">History</h2>
  15. <div class="slds-p-left_small"/>
  16.  
  17. <lightning:buttonMenu alternativeText="Filter Activity" variant="bare" onselect="{!c.handleMenuSelect}" iconName="utility:down">
  18. <lightning:menuItem label="Views" value="Views" />
  19. <lightning:menuItem label="Cases" value="Cases" />
  20. <lightning:menuItem label="Tasks" value="Tasks"/>
  21. <lightning:menuItem label="Events" value="Events" />
  22.  
  23. <lightning:menuItem label="All" value="All" />
  24. </lightning:buttonMenu>
  25. <div class="slds-p-left_small">
  26. <ui:outputText value="{!v.sobjectView}"/>
  27. </div>
  28. </div>
  29. <ul>
  30. <aura:iteration items="{!v.ActivityObjects}" var="ActivityObj">
  31. <li>
  32. <c:Activity_DisplayComponent item="{!ActivityObj}" />
  33.  
  34. </li>
  35.  
  36. </aura:iteration>
  37. </ul>
  38.  
  39. </div>
  40. </article>
  41.  
  42. ({
  43. doInit: function(cmp, evt, helper) {
  44. helper.getActivity(cmp, event)
  45. },
  46.  
  47. handleMenuSelect: function(cmp, event, helper) {
  48. helper.getReActivity(cmp,event)
  49. },
  50.  
  51. refreshRecords: function(cmp, event, helper) {
  52. helper.getReRefreshActivityHelper(cmp, event)
  53. }
  54. })
  55.  
  56. // this helper method for without filtering it will display all toegther
  57. related object in activity page
  58.  
  59. ({
  60. getActivity : function(cmp) {
  61. // we having apex controller that fetch the getActivityActivity for filtering
  62. with soql queries.- that working fine
  63. const getActivity = cmp.get("c.getActivityActivity")// we having apex controller that fetch the getActivityActivity for filtering with soql queries.
  64. getActivity.setParams({ recordId : cmp.get("v.recordId"), objectName :
  65. cmp.get("v.sObjectName")})
  66.  
  67. getActivity.setCallback(this, function(response) {
  68. const state = response.getState()
  69. if (cmp.isValid() && state === "SUCCESS") {
  70. cmp.set("v.ActivityObjects", response.getReturnValue())
  71. $A.get('e.force:refreshView').fire()
  72. }
  73. })
  74. $A.enqueueAction(getActivity)
  75.  
  76. },
  77.  
  78. // this helper method for with filtering it will display all toegther related object in activity page
  79. getReActivity : function(cmp,event){
  80. // we having apex controller that fetch the ("c.getReRefreshHistoryActivity")for filtering with soql queries.- that working fine
  81. const getReRefreshActivity = cmp.get("c.getReRefreshHistoryActivity")
  82.  
  83. //category : event.getParam("value") - this category here, it will fetch the activity listed object eg : we have case, event, audit record object.
  84.  
  85. getReActivity.setParams({ recordId : cmp.get("v.recordId"), category : event.getParam("value") , objectName : cmp.get("v.sObjectName")})
  86.  
  87. const sobjectActivityDisplay=event.getParam("value")
  88. cmp.set("v.sobjectView", sobjectActivityDisplay)
  89.  
  90. getReActivity.setCallback(this, function(response) {
  91. const state = response.getState()
  92. if (cmp.isValid() && state === "SUCCESS") {
  93. cmp.set("v.ActivityObjects", response.getReturnValue())
  94. $A.get('e.force:refreshView').fire()
  95. }
  96. })
  97. $A.enqueueAction(getReRefreshActivity)
  98.  
  99. },
  100. -------------------------------------------------------
  101. // Refresh method helper here its working but when i use any filter any activity then filtering its not working
  102. // this one is same method but
  103.  
  104. //
  105. getReRefreshActivityHelper : function(cmp, event){
  106.  
  107. ({
  108. getReRefreshActivityHelper : function(cmp) {
  109. const getReRefreshActivityHelper= cmp.get("c.getActivityActivity")
  110. // i need to fetch the category value to filter, so that i able to
  111. category : event.getParam("value"), at the moment its throwing null values, bcz above method is used with menu item values that will fetch the category but here refreshing method thats why throwing null values
  112.  
  113. getReActivity.setParams({ recordId : cmp.get("v.recordId"), category : event.getParam("value") , objectName : cmp.get("v.sObjectName")})
  114.  
  115. getReRefreshActivityHelper.setCallback(this, function(response) {
  116. const state = response.getState()
  117. if (cmp.isValid() && state === "SUCCESS") {
  118. cmp.set("v.ActivityObjects", response.getReturnValue())
  119. $A.get('e.force:refreshView').fire()
  120. }
  121. })
  122. $A.enqueueAction(getReRefreshActivityHelper)
  123.  
  124. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement