Guest User

Untitled

a guest
Jul 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. <aura:application extends="force:slds">
  2. <c:AccountMainScreen/>
  3. </aura:application>
  4.  
  5. <aura:component controller="AccountController">
  6. <aura:attribute name="allaccounts" type="List" description="All Products" />
  7. <aura:handler name="init" value="{!this}" action="{!c.fillAccount}"/>
  8. <div class="container">
  9. <div style="font-weight: bold;">Filter by Billing City</div><br/>
  10. <div>Bangalore</div><br/>
  11. <div>Mountain View</div><br/>
  12. <div>Singapore</div><br/>
  13. <div>
  14. <div style="background-color: #7f7e8a;height: 20px;"></div>
  15. <aura:iteration items="{!v.allaccounts}" var="account">
  16. <article class="slds-card">
  17. <div class="slds-card__header slds-grid">
  18. <header class="slds-media slds-media--center slds-has-flexi-truncate">
  19. <div class="slds-media__body slds-truncate">
  20. <h2>
  21. <a href="javascript:void(0);" class="slds-text-link--reset">
  22. <span class="slds-text-heading--small">{!account.Name}</span>
  23. </a>
  24. </h2>
  25. </div>
  26. </header>
  27. </div>
  28. <div class="slds-card__body">{!account.BillingCity}</div>
  29.  
  30. </article>
  31. </aura:iteration>
  32. </div>
  33.  
  34. </div>
  35.  
  36. </aura:component>
  37.  
  38. public class AccountController {
  39.  
  40. @AuraEnabled
  41. public static List<Account> getAllAccounts()
  42. {
  43.  
  44. List<Account> lstacc=[select Name,BillingCity from Account where BillingCity != null];
  45. return lstacc;
  46.  
  47. }
  48.  
  49. }
  50.  
  51. ({ fillAccount : function(component, event, helper) {
  52. helper.getAccountsfromSF(component, event) } })
  53.  
  54. ({
  55. getAccountsfromSF : function(component, event) {
  56.  
  57. var action = component.get('c.getAllAccounts');
  58. action.setCallback(this,function(actionResult){
  59. component.set('v.allaccounts', actionResult.getReturnValue());
  60. });
  61. $A.enqueueAction(action);
  62.  
  63. }
  64. })
  65.  
  66. <aura:iteration var="a" items="{!v.AccountList}" indexVar="indx">
  67. <ui:inputCheckbox aura:id="pick" text="{!a.BillingCity}" name="{!indx}" label="{!a.BillingCity}" change="{!c.selectoptionvalue}"/>
  68. </aura:iteration>
  69.  
  70. <aura:iteration items="{!v.selectedvalues}" var="account">
  71. <article class="slds-card">
  72. <div class="slds-card__header slds-grid">
  73. <header class="slds-media slds-media--center slds-has-flexi-truncate">
  74. <div class="slds-media__body slds-truncate">
  75. <h2>
  76. <a href="javascript:void(0);" class="slds-text-link--reset">
  77. <span class="slds-text-heading--small">{!account.Name}</span>
  78. </a>
  79. </h2>
  80. </div>
  81. </header>
  82. </div>
  83. <div class="slds-card__body">{!account.BillingCity}</div>
  84.  
  85. </article>
  86. </aura:iteration>
  87.  
  88. ({
  89.  
  90. initmethod : function(component,event,helper){
  91. var action = component.get("c.getAccountList");
  92. action.setCallback(this,function(a){
  93. var state=a.getState();
  94. if(state == "SUCCESS"){
  95. component.set("v.AccountList",a.getReturnValue());
  96. }
  97.  
  98. });
  99. $A.enqueueAction(action);
  100. },
  101.  
  102. selectoptionvalue :function(component,event,helper){
  103. var temp=component.get("v.selectedvalues");
  104. var selectedcity=component.get("v.SelectedCity");
  105. var accountdetails = component.get("v.AccountList");
  106. temp = [];//empty when while changing Picklist value
  107. if(event.getSource().get("v.value")){
  108. selectedcity.push({'ids':event.getSource().get("v.name"),'name':event.getSource().get("v.text"),'value':event.getSource().get("v.value")});
  109. }
  110. if(event.getSource().get("v.value") == false){
  111. for(var j=0;j<selectedcity.length;j++){
  112. if(selectedcity[j].ids == event.getSource().get("v.name")){
  113. var index = j;
  114. }
  115. }
  116. selectedcity.splice(index,1);
  117. }
  118. component.set("v.SelectedCity",selectedcity);
  119. var accountdetails = component.get("v.AccountList");
  120. for(var i=0;i<accountdetails.length;i++){
  121. for(var k=0;k<selectedcity.length;k++){
  122. if(accountdetails[i].BillingCity == selectedcity[k].name){
  123. temp.push(accountdetails[i]);
  124. }
  125. }
  126. }
  127.  
  128. component.set("v.selectedvalues",temp);
  129. }
  130.  
  131. public class valuesget {
  132. @AuraEnabled
  133. public static List<Account> getAccountList(){
  134. return [Select Id,Name,BillingCity From Account where BillingCity != null];
  135. }
  136. }
Add Comment
Please, Sign In to add comment