Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. ({
  2. doInit : function(component, event){
  3. var action = component.get("c.getStatus");
  4. var currentId = component.get("v.recordId");
  5. action.setParams({
  6. recordId : currentId
  7. });
  8. console.log(currentId);
  9.  
  10. action.setCallback(this, function(response){
  11. var state = response.getState();
  12. if (component.isValid() && state === "SUCCESS"){
  13. $A.log(response);
  14. component.set("v.currentStep", response.getReturnValue());
  15. }
  16. else {
  17. console.log("Failed with state" + state);
  18. }
  19. })
  20. $A.enqueueAction(action);
  21. },
  22.  
  23. onStepChange : function(component, event) {
  24. var action = component.get("c.saveStatus");
  25.  
  26. var currentId = component.get("v.recordId");
  27. action.setParams({
  28. recordId : currentId
  29. });
  30.  
  31. action.setCallback(this, function(response){
  32. var state = response.getState();
  33.  
  34. if(component.isValid() && state === "SUCCESS"){
  35. var currentStep = component.get("v.currentStep");
  36. component.set(currentStep, response.getReturnValue());
  37. }
  38. else {
  39. console.log("Failed with state" + state);
  40. }
  41. })
  42. $A.enqueueAction(action)
  43. }})
  44.  
  45. public with sharing class ApexController {
  46.  
  47. @AuraEnabled
  48. public static list<Object__c> getStatus(Id recordId){
  49.  
  50. return[SELECT Id, status__c FROM Object__c WHERE Id=:recordId];
  51. }
  52.  
  53. @AuraEnabled
  54. public static Object__c saveStatus(Object__c newStatus){
  55. upsert newStatus;
  56. return newStatus;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement