({ selectStep:function(component, event, helper) { var value = event.getSource().get("v.value"); var currentStep = component.get("v.currentStep"); var processForNewStore = component.get("v.processForNewStore"); if(!processForNewStore && value != currentStep && currentStep != 'Finised'){ if(value == 'Authenticate'){ component.set("v.currentStep", "Authenticate"); $A.createComponent("c:AuthenticateOrg" , { "aura:id": "AuthenticateOrg", "hasError": component.get("v.hasError"), "siteurlparent": component.get("v.configObj.HIC_ShopifySync__Salesforce_Site_URL__c"), "Refreshtoken": component.get("v.configObj.HIC_ShopifySync__Refresh_Token__c")}, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); }); } else if(value == 'step1'){ var action = component.get("c.selectFromHeaderStep1"); $A.enqueueAction(action); } else if(value == 'step2'){ var action = component.get("c.selectFromHeaderStep2"); $A.enqueueAction(action); } if(value == 'step3'){ var action = component.get("c.selectFromHeaderStep3"); $A.enqueueAction(action); } else if(value == 'step4'){ var action = component.get("c.selectFromHeaderStep4"); $A.enqueueAction(action); } } }, authorizeStore:function(component, event, helper) { var config = component.get("v.configObj"); //console.log($A.get("$SObjectType.CurrentUser.Email")); //console.log(component.get("v.UserName")); if(config.HIC_ShopifySync__Shopify_URL__c != null && config.HIC_ShopifySync__Salesforce_Site_URL__c){ var url = 'https://connectmadeasy.com/token?shop_domain='+config.HIC_ShopifySync__Shopify_URL__c+'&sf_token_endpoint='+config.HIC_ShopifySync__Salesforce_Site_URL__c+'/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass&user_name='+component.get("v.UserName")+'&user_email='+$A.get("$SObjectType.CurrentUser.Email"); //console.log('url--',url); window.open(url); component.set("v.isAuthorized", true); component.set("v.authDone", false); } }, refreshConfig:function(component, event, helper) { helper.checkStoreToken( component, event ); }, hideModel: function(component, event, helper) { component.set("v.showWarning", false); }, saveDetails: function(component, event, helper) { component.set("v.showWarning", false); component.set("v.openstoreselection", true); }, saveDetails2: function(component, event, helper) { component.set("v.showProcessing", false); }, ContactSupport : function(component, event, helper) { try{ var action = component.get('c.Checkemaildeliverability'); action.setCallback(this,function(response){ if(response.getState() =="SUCCESS" && response.getReturnValue() !=null){ var EmailDeliverbility = response.getReturnValue(); if(EmailDeliverbility == true || EmailDeliverbility == 'true' || EmailDeliverbility == 'true'){ component.set("v.OpenMode2",EmailDeliverbility); component.set("v.ShowForm",EmailDeliverbility); }else{ window.open('mailto:support@syncmadeasy.com?Subject='+component.get("v.OrgID"),'_Top'); } } }); $A.enqueueAction(action); }catch(e){ console.log(e); } }, closeModel2 : function(component,event, helper){ component.set("v.OpenMode2",false); }, onSubmit : function(component,event, helper){ var valid = false; if(component.find('issuevalue').get("v.value") === undefined || component.find('issuevalue').get("v.value") == ''|| component.find('issuevalue').get("v.value") == null){ component.find("issuevalue").showHelpMessageIfInvalid(); }else{ valid = true; } if(valid ){ var action = component.get('c.SendingMailtoShopifySupport'); action.setParams({ "Issue":component.get("v.Issue") }); action.setCallback(this,function(response){ var returnvalue1 = response.getReturnValue(); if(response.getState() == 'SUCCESS' && returnvalue1 != null ){ component.set("v.SendingMail",returnvalue1); component.set("v.ShowForm",false); } }); $A.enqueueAction(action); component.set("v.Issue",null); //component.set("v.OpenModel",false); } }, PerformAction : function(component, event, helper) { //console.log('Batch progress'); //console.log(component.get("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c")); var batchProcessing = component.get("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c"); if(batchProcessing){ component.set("v.showProcessing",true); }else{ component.set("v.showWarning",true); } }, closeModal:function(component,event,helper){ var cmpTarget = component.find('editDialog'); var cmpBack = component.find('overlay'); $A.util.removeClass(cmpBack,'slds-backdrop--open'); $A.util.removeClass(cmpTarget, 'slds-fade-in-open'); component.set('v.openstoreselection',false); }, selectastore : function(component, event, helper){ //var sourceValue = event.getSource(); //console.log(sourceValue); var cStep = component.get("v.currentStep"); if(cStep != 'step1'){ component.set("v.OldPricebook" , component.get("v.configObj.HIC_ShopifySync__Salesforce_Pricebook__c") ); component.set("v.OldCurrencyISOCode" , component.get("v.CurrencyISOCode") ); component.set("v.currentStep", "step1"); component.set("v.mainBoolean" , false ); component.set("v.DisableButton" , false ); } var objectValue = event.getSource().get("v.name"); // console.log('Select Store Called--> '); // console.log(JSON.stringify(objectValue)); component.set("v.configObj",objectValue); //component.set("v.storeConfiguration", true); //component.set("v.storedusername",objectValue.HIC_ShopifySync__API_Key__c); component.set("v.storedpassword", objectValue.HIC_ShopifySync__Private_Key_Password__c); component.set("v.OldPricebook",objectValue.HIC_ShopifySync__Salesforce_Pricebook__c); component.set("v.processForNewStore",false); var cmpTarget = component.find('editDialog'); var cmpBack = component.find('overlay'); $A.util.removeClass(cmpBack,'slds-backdrop--open'); $A.util.removeClass(cmpTarget, 'slds-fade-in-open'); component.set('v.openstoreselection',false); /* Added UV */ // if(component.get("v.configObj.HIC_ShopifySync__Refresh_Token__c ") != null && component.get("v.configObj.HIC_ShopifySync__Refresh_Token__c ") != '' && component.get("v.configObj.HIC_ShopifySync__Refresh_Token__c ") != undefined){ // component.set("v.currentStep","step1"); // } // if(component.get("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c") == true) // { // component.set("v.currentStep",'Finised'); // } }, showAvailableStores : function(component, event, helper){ component.set("v.updateExistingStore", true); }, addNewStore : function(component, event, helper){ var config = component.get("v.configObj"); config.Id = null; config.HIC_ShopifySync__API_Key__c = null; config.HIC_ShopifySync__Private_Key_Password__c = null; config.HIC_ShopifySync__Shopify_URL__c = null; config.HIC_ShopifySync__Store__c = null; config.Name = null; //console.log(JSON.stringify(config)); component.set("v.configObj",config); //component.set("v.storeConfiguration", true); component.set("v.processForNewStore",true); helper.getConfigurations( component, event ); var cmpTarget = component.find('editDialog'); var cmpBack = component.find('overlay'); $A.util.removeClass(cmpBack,'slds-backdrop--open'); $A.util.removeClass(cmpTarget, 'slds-fade-in-open'); component.set('v.openstoreselection',false); var cStep = component.get("v.currentStep"); if(cStep != 'step1'){ component.set("v.OldPricebook" , component.get("v.configObj.HIC_ShopifySync__Salesforce_Pricebook__c") ); component.set("v.OldCurrencyISOCode" , component.get("v.CurrencyISOCode") ); component.set("v.currentStep", "step1"); component.set("v.mainBoolean" , false ); component.set("v.DisableButton" , false ); } }, removeThisStore : function(component, event, helper){ var cmpTarget = component.find('editDialog'); var cmpBack = component.find('overlay'); $A.util.removeClass(cmpBack,'slds-backdrop--open'); $A.util.removeClass(cmpTarget, 'slds-fade-in-open'); component.set('v.openstoreselection',false); var objectValue = event.getSource().get("v.name"); //console.log('Select Store Called--> '); //console.log(JSON.stringify(objectValue)); var action = component.get("c.RemoveStore"); action.setParams({ 'store' : objectValue}); action.setCallback(this, function(response) { //console.log('removing configuration'); var state = response.getState(); //console.log(state); //console.log(response.getReturnValue()); //console.log(state === "SUCCESS"); if (state === "SUCCESS" && response.getReturnValue() != null ) { helper.getConfigurations( component, event ); } else if (state === "INCOMPLETE") { }else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(action); }, acceptagreement : function(component, event, helper){ var agreecheckbox = component.find("agreement").get("v.checked"); if(agreecheckbox == true){ component.find("agreedbutton").set("v.disabled",false); }else{ component.find("agreedbutton").set("v.disabled",true); } }, closeagreementform : function(component, event, helper){ component.set("v.OpenModel",false); // component.set("v.GoDisableButton",false); }, oncurrencychange: function(component, event, helper){ var currentvalue = event.getSource().get("v.value"); } , gotocertificatepage: function(component, event, helper){ window.open('/0P1','_blank'); }, CloseSpinnerValue: function(component, event, helper){ component.set("v.Spinner",false); document.getElementById("divparent").style.display = "block"; document.getElementById("divparent").scrollTop = '0'; document.getElementById("divparent").style.pointerEvents = "all"; }, SyncAuthenticatepage: function(component, event, helper){ document.getElementById("divparent").style.display = "none"; var action = component.get("c.doInit"); component.set("v.Spinner", false); component.set("v.isOpen", false); $A.enqueueAction(action); }, OpenSliderPopupFirst: function(component, event, helper){ component.set("v.slidercurrentStep",1); component.set("v.OpenSlider",true); }, OpenSliderPopupSecond: function(component, event, helper){ component.set("v.slidercurrentStep",2); component.set("v.OpenSlider",true); }, OpenSliderPopupthird: function(component, event, helper){ component.set("v.slidercurrentStep",3); component.set("v.OpenSlider",true); }, openModal: function(component, event, helper){ document.getElementById("myModal").style.display = "block"; }, siteredirect: function(component, event, helper){ var siteurl = component.get('v.configObj.HIC_ShopifySync__Salesforce_Site_URL__c'); var sitelist = component.get("v.siteURLList"); var siteid = ''; for(var item in sitelist ){ if(sitelist[item]['siteUrl'] == siteurl ){ siteid = sitelist[item]['id']; } } if(siteid != '' && siteid !== undefined && siteurl != '' && siteurl !== undefined ){ window.open('/'+siteid,'_blank'); }else{ window.open('/0DM/o','_blank'); } }, AuthenticateErrorEventHandler: function(component, event, helper) { var hasError = event.getParam("hasError"); component.set("v.hasError",hasError); }, doInit: function(component, event, helper) { var uNaction = component.get("c.getUserName"); uNaction.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { component.set("v.UserName", response.getReturnValue()); } }); $A.enqueueAction(uNaction); var action = component.get("c.getOrgId"); action.setCallback(this,function(response){ var returnvaue = response.getReturnValue(); if(response.getState() == 'SUCCESS' && returnvaue != ''){ component.set("v.OrgID",returnvaue); } }); $A.enqueueAction(action); // helper.AuthenticateRemoteSiteCreate(component, event, helper) ; helper.getSiteURLList( component, event ); //helper.CheckingCertifiacte(component, event, helper); // helper.CheckSiteAccess(component, event, helper); var action = component.get("c.getUIThemeDescription"); action.setCallback(this,function(res){ var state = res.getState(); if(state =="SUCCESS" && res.getReturnValue() != null ){ component.set("v.viewmode",res.getReturnValue()); } }); $A.enqueueAction(action); component.set("v.Spinner",true); //document.getElementById("divparent").style.display = "none"; var emaiList = component.get("v.emaiList"); emaiList.push({ "sobjectType": "HIC_ShopifySync__Email_Addresses_to_send_error_CSV__c", "errormailfrmt": false }); try{ helper.getPricebookList( component, event ); helper.getConfigurationData( component, event ); helper.getConfigurations( component, event ); helper.getEmailErrorlist(component, event); }catch(error){ console.log('error when getting config data '+error); } }, scriptsLoaded : function(component, event, helper) { $('[data-toggle="tooltip"]').tooltip(); }, display : function(component, event, helper) { helper.toggleHelper(component, event); }, displayOut : function(component, event, helper) { helper.toggleHelper(component, event); }, onFocus: function(component, event, helper){ $A.util.addClass(component.find('helptextbody'), 'aria-described'); $A.util.removeClass(component.find('helptextbody'), 'HideHelpText'); }, onblur: function(component, event, helper){ $A.util.addClass(component.find('helptextbody'), 'HideHelpText'); $A.util.removeClass(component.find('helptextbody'), 'DisplayHelptext'); }, openModel: function(component, event, helper) { // for Display Model,set the "isOpen" attribute to "True" component.set("v.isOpen", true); }, closeModel: function(component, event, helper) { // for Hide/Close Model,set the "isOpen" attribute to "False" document.getElementById("ErrorMessage").style.display = "none"; component.set("v.isOpen", false); }, gotoURL : function (component, event, helper) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": "/apex/SalesforceAuthentication" }); urlEvent.fire(); }, selectFromHeaderStep1 : function(component,event,helper){ component.set("v.currentStep", "step1"); component.set("v.mainBoolean" , false ); }, selectFromHeaderStep2 : function(component,event,helper){ var configObj = component.get("v.configObj"); configObj.HIC_ShopifySync__Store__c = (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replace('.myshopify.com','').replace('/',''); document.getElementById("divparent").style.display = "none"; component.set("v.currentStep", "step2"); $A.createComponent("c:ConfiguarationGeneral" , { "aura:id": "ConfiguarationGeneral", "Spinner" : "true", "storeurl" : configObj.HIC_ShopifySync__Shopify_URL__c, "store" : configObj.HIC_ShopifySync__Store__c }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); }, selectFromHeaderStep3 : function(component,event,helper){ component.set("v.currentStep", "step3"); // component.set("v.Spinner",false); document.getElementById("divparent").style.display = "none"; var configObj = component.get("v.configObj"); // console.log('Congig values'); // console.log( (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','')); $A.createComponent("c:dynamicRow" , { "aura:id": "dynamicRow", "processForNewStore": component.get("v.processForNewStore"), "store" : (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','') }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); }, selectFromHeaderStep4 : function(component,event,helper){ component.set("v.currentStep", "step4"); document.getElementById("divparent").style.display = "none"; var configObj = component.get("v.configObj"); $A.createComponent("c:ConfiguarationRecordTypeMapping" , { "aura:id": "ConfiguarationRecordTypeMapping", "store" : (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','') }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); }, // function for create new object Row in Contact List addNewRow: function(component, event, helper) { // call the comman "createObjectData" helper method for add new Object Row to List helper.createObjectData(component, event); }, // function for delete the row removeDeletedRow: function(component, event, helper) { // get the selected row Index for delete, from Lightning Event Attribute var index = event.getParam("indexVar"); //console.log('index--> '+index); // get the all List (contactList attribute) and remove the Object Element Using splice method if(index != null && index != '' && index !== "undefined" ){ var AllRowsList = component.get("v.emaiList"); AllRowsList.splice(index, 1); // set the contactList after remove selected row element component.set("v.emaiList", AllRowsList); } }, gonextbutton: function(component, event, helper) { var IsChanged = false; var WarringMessage = []; var oldvalueofcurrency = component.get("v.OldCurrencyISOCode"); var currentcurrency = component.get("v.CurrencyISOCode"); var currenctpricebook = component.get("v.configObj.HIC_ShopifySync__Salesforce_Pricebook__c") var oldcurrencypricebook = component.get("v.OldPricebook"); if(oldvalueofcurrency != currentcurrency && oldvalueofcurrency != null && oldvalueofcurrency != '' && oldvalueofcurrency != undefined){ IsChanged = true; if(!WarringMessage.includes('You have changed currency.')){ WarringMessage.push('You have changed currency.'); } }else{ if(WarringMessage.includes('You have changed Currency.')){ WarringMessage.pop('You have changed Currency.'); } } if(oldcurrencypricebook !== currenctpricebook && oldcurrencypricebook != '' & oldcurrencypricebook != null && oldcurrencypricebook != undefined){ IsChanged = true; if(!WarringMessage.includes('You have changed Pricebook.')){ WarringMessage.push('You have changed Pricebook.'); } }else{ if(WarringMessage.includes('You have changed Pricebook.')){ WarringMessage.pop('You have changed Pricebook.'); } } component.set("v.IsChanged",IsChanged); if( (IsChanged && component.get('v.configObj.HIC_ShopifySync__BatchRunOnce__c')) || component.get('v.configObj.HIC_ShopifySync__IsCurrencyChanged__c') ){ component.set("v.OpenModel",true); component.set("v.warrningmessage",WarringMessage); }else{ var action = component.get("c.validationCheck"); $A.enqueueAction(action); } }, validationCheck:function(component, event, helper) { component.set("v.OpenModel",false); document.getElementById("divparent").style.pointerEvents = "none"; component.set("v.DisableButton",true); component.set("v.Spinner",true); document.getElementById("divparent").style.display = "none"; var valid = true; /* if(component.find('Pricebook').get("v.value") !== undefined && component.find('Pricebook').get("v.value") != '' && component.find('selectItem').get("v.value") !== undefined && component.find('selectItem').get("v.value") != ''){ valid = true; }else if((component.find('Pricebook').get("v.value") === undefined || component.find('Pricebook').get("v.value") == '') && (component.find('selectItem').get("v.value") === undefined || component.find('selectItem').get("v.value") == '')){ $A.util.addClass(component.find('Pricebook'), 'Pricebookcsss'); $A.util.addClass(component.find('selectItem'), 'Pricebookcsss'); }else if(component.find('Pricebook').get("v.value") === undefined || component.find('Pricebook').get("v.value") == ''){ $A.util.addClass(component.find('Pricebook'), 'Pricebookcsss'); }else if(component.find('selectItem').get("v.value") === undefined || component.find('selectItem').get("v.value") == ''){ $A.util.addClass(component.find('selectItem'), 'Pricebookcsss'); }*/ if(component.find('Pricebook').get("v.value") === undefined || component.find('Pricebook').get("v.value") == ''){ valid = false; $A.util.addClass(component.find('Pricebook'), 'Pricebookcsss'); }else{ $A.util.removeClass(component.find('Pricebook'), 'Pricebookcsss'); } if(component.find('selectItem').get("v.value") === undefined || component.find('selectItem').get("v.value") == ''){ valid = false; $A.util.addClass(component.find('selectItem'), 'Pricebookcsss'); }else{ $A.util.removeClass(component.find('selectItem'), 'Pricebookcsss'); } if(component.find('StoreURL').get("v.value") === undefined || component.find('StoreURL').get("v.value") == ''){ valid = false; $A.util.addClass(component.find('StoreURL'), 'Pricebookcsss'); }else{ $A.util.removeClass(component.find('StoreURL'), 'Pricebookcsss'); } /*if(component.find('Shopifyid').get("v.value") === undefined || component.find('Shopifyid').get("v.value") == ''){ valid = false; $A.util.addClass(component.find('Shopifyid'), 'Pricebookcsss'); }else{ $A.util.removeClass(component.find('Shopifyid'), 'Pricebookcsss'); }*/ if(component.find('secret').get("v.value") === undefined || component.find('secret').get("v.value") == ''){ valid = false; $A.util.addClass(component.find('secret'), 'Pricebookcsss'); }else{ $A.util.removeClass(component.find('secret'), 'Pricebookcsss'); } if(!valid){ //alert('please select pricebook and site'); component.set("v.DisableButton",false); // $A.util.addClass(component.find('ErrorMessage'), 'slds-show'); document.getElementById("ErrorMessage").style.display = "block"; /*component.find('notifLib').showNotice({ "variant": "error", "header": "Something has gone wrong!", "message": "Unfortunately, there was a problem updating the record.", closeCallback: function() { alert('You closed the alert!'); } });*/ var action = component.get("c.openModel"); component.set("v.Spinner", false); document.getElementById("divparent").style.display = "block"; document.getElementById("divparent").style.pointerEvents = "all"; document.getElementById("divparent").scrollTop = '0'; //$A.enqueueAction(action); }else{ // first call the helper function in if block which will return true or false. // this helper function check the "first Name" will not be blank on each row. if (helper.validateRequired(component, event)) { //if (component.find("child").ErrorMaillist()) { // call the apex class method for save the Contact Lis= // with pass the contact List attribute to method param. var action = component.get("c.saveEmailSettings"); action.setParams({ "emaiList": JSON.stringify(component.get("v.emaiList")) }); // set call back action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { // if response if success then reset/blank the 'contactList' Attribute // and call the common helper method for create a default Object Data to Contact List //component.set("v.emaiList", []); //helper.createObjectData(component, event); //alert('record Save'); //goNext(component, event, helper); component.set("v.spinner",true); helper.checksiteaccess(component, event, helper); } }); // enqueue the server side action $A.enqueueAction(action); }else{ component.set("v.DisableButton",false); } } }, checkAccess: function(component, event, helper){ var name = event.getSource().get("v.name"); if(component.get("v.AccessScopeError") != null && component.get("v.AccessScopeError").includes(name)){ alert('not Access scope for this'+ name); } }, goNext: function(component, event, helper) { var cStep = component.get("v.currentStep"); if(cStep == 'step1'){ var shopifyUrl = component.get("v.configObj").HIC_ShopifySync__Shopify_URL__c; var USER_NAME = component.get("v.configObj").HIC_ShopifySync__API_Key__c; var PASSWORD = component.get("v.configObj").HIC_ShopifySync__Private_Key_Password__c; var action1 = component.get("c.checkCreds"); action1.setParams({ 'shopifyUrl' : shopifyUrl, 'USER_NAME' : USER_NAME, 'PASSWORD' : PASSWORD }); action1.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS" ) { if(response.getReturnValue() === false){ alert('Shopify Credentials are worng please check again'); }else { var action = component.get("c.saveConfigration"); action.setParams({ 'configObj' : JSON.stringify( component.get("v.configObj")), 'check' : 'True'}); action.setCallback(this, function(response) { var configObj = component.get("v.configObj"); //console.log('configObj'+configObj.HIC_ShopifySync__Shopify_URL__c); //.replace('https://','').replace('.myshopify.com','').removeEnd('/') configObj.HIC_ShopifySync__Store__c = (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replace('.myshopify.com','').replace('/',''); //console.log('Store step 1') // console.log(configObj.HIC_ShopifySync__Store__c); debugger; var state = response.getState(); if (state === "SUCCESS" && response.getReturnValue() != null ) { document.getElementById("divparent").style.display = "none"; component.set("v.currentStep", "step2"); $A.createComponent("c:ConfiguarationGeneral" , { "aura:id": "ConfiguarationGeneral", "Spinner" : "true", "storeurl" : configObj.HIC_ShopifySync__Shopify_URL__c, "store" : configObj.HIC_ShopifySync__Store__c }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); } else if (state === "INCOMPLETE") { }else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(action); var storename = (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replace('.myshopify.com','').replace('/',''); var pricebookId = configObj.HIC_ShopifySync__Salesforce_Pricebook__c; var savePriceBookMapping = component.get("c.savePriceBookMapping"); savePriceBookMapping.setParams({ 'storename' : storename, 'pricebookId' : pricebookId}); savePriceBookMapping.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS" && response.getReturnValue() != null ) { debugger; } else if (state === "INCOMPLETE") { }else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message +" no. "+ errors[0].LineNumber); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(savePriceBookMapping); } }else{ component.set("v.Spinner",false); document.getElementById("divparent").style.pointerEvents = "all"; document.getElementById("divparent").style.display = "block"; } }); $A.enqueueAction(action1); }else if(cStep == 'step2'){ component.set("v.currentStep", "step3"); // component.set("v.Spinner",false); document.getElementById("divparent").style.display = "none"; var configObj = component.get("v.configObj"); // console.log('Congig values'); // console.log( (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','')); $A.createComponent("c:dynamicRow" , { "aura:id": "dynamicRow", "processForNewStore": component.get("v.processForNewStore"), "store" : (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','') }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); }else if(cStep == 'step3'){ component.set("v.currentStep", "step4"); // component.set("v.Spinner",false); document.getElementById("divparent").style.display = "none"; var configObj = component.get("v.configObj"); $A.createComponent("c:ConfiguarationRecordTypeMapping" , { "aura:id": "ConfiguarationRecordTypeMapping", "store" : (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','') }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); }else if(cStep == 'step4'){ // component.set("v.currentStep", "step5"); component.set("v.Spinner",false); component.set("v.currentStep", "Finised"); document.getElementById("divparent").style.pointerEvents = "all"; document.getElementById("divparent").style.display = "block"; /*$A.createComponent("c:configurationSetting" , { "aura:id": "configurationSetting" }, function(newButton, status, errorMessage){ console.log(status); console.log(errorMessage); component.set("v.body", newButton); component.set("v.mainBoolean" , true ); }); */ var configObj = component.get("v.configObj"); component.set("v.store",(configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','')); var SaveBatchisProsseTrueAction = component.get("c.syncShopify"); SaveBatchisProsseTrueAction.setParams({"store": (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','') }); SaveBatchisProsseTrueAction.setCallback(this, function(responseUpdateConfig) { var stateUpdateConfig = responseUpdateConfig.getState(); if (stateUpdateConfig === "SUCCESS"){ /*var action = component.get("c.getConfigration"); console.log('Store-->config'); console.log( component.get("v.store")); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS" && response.getReturnValue() != null ) { var configObj = JSON.parse( response.getReturnValue() ); component.set("v.configObj", configObj); component.set("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c",true); component.set("v.mainBoolean" , false ); try{ var cmpEvent = $A.get("e.c:updateStoreValue"); cmpEvent.setParams({ "store" : component.get("v.store") }) cmpEvent.fire(); }catch(e){ console.log('error --> update store event '+e); } } else if (state === "INCOMPLETE") { console.log('configuration get error'); } else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(action);*/ // alert('Process has started in the background.'); component.set("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c",true); component.set("v.mainBoolean" , false ); try{ var cmpEvent = $A.get("e.c:updateStoreValue"); cmpEvent.setParams({ "store" : component.get("v.store") }) cmpEvent.fire(); }catch(e){ console.log('error --> update store event '+e); } }else{ // alert('We have hit some error. Please Contact Admin.'); } }); $A.enqueueAction(SaveBatchisProsseTrueAction); }else if(cStep == 'step5'){ /*var action = component.get("c.getConfigration"); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS" && response.getReturnValue() != null ) { var configObj = JSON.parse( response.getReturnValue() ); component.set("v.configObj", configObj); component.set("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c",true); } else if (state === "INCOMPLETE") { console.log('configuration get error'); } else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(action); */ component.set("v.configObj.HIC_ShopifySync__Batch_Is_Processing__c",true); // console.log('configure debugging'); // console.log(component.get("v.configObj")); } }, goPrev: function(component, event, helper) { var configObj = component.get("v.configObj"); component.set("v.DisableButton",false); var cStep = component.get("v.currentStep"); if(cStep == 'step3'){ var configObj = component.get("v.configObj"); component.set("v.currentStep", "step2"); $A.createComponent("c:ConfiguarationGeneral" , { "aura:id": "ConfiguarationGeneral", "AccessScope": component.get("v.AccessScope"), "storeurl" : configObj.HIC_ShopifySync__Shopify_URL__c, "store" : configObj.HIC_ShopifySync__Store__c }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); //component.set("v.configObj",JSON.stringify( component.get("v.configObj"))); }); }else if(cStep == 'step4'){ component.set("v.currentStep", "step3"); document.getElementById("divparent").style.display = "none"; $A.createComponent("c:dynamicRow" , { "aura:id": "dynamicRow", "store" : (configObj.HIC_ShopifySync__Shopify_URL__c).replaceAll('https://','').replaceAll('.myshopify.com','').replaceAll('/','') }, function(newButton, status, errorMessage){ component.set("v.body", newButton); component.set("v.mainBoolean" , true ); component.set("v.Spinner",true); }); }else if(cStep == 'step2'){ //console.log('configuration data --'); //console.log(JSON.stringify(configObj)); component.set("v.OldPricebook" , component.get("v.configObj.HIC_ShopifySync__Salesforce_Pricebook__c") ); component.set("v.OldCurrencyISOCode" , component.get("v.CurrencyISOCode") ); component.set("v.currentStep", "step1"); component.set("v.mainBoolean" , false ); component.set("v.configObj",configObj); //console.log('3 to 2'); } }, onchangeOrderandOpportunity: function(component, event, helper){ var buttonName = event.getSource().get("v.name"); var buttonValue = event.getSource().get("v.value"); console.log(buttonName, '--', buttonValue); if(buttonName == 'DraOrderSyncButton'){ component.set("v.configObj.HIC_ShopifySync__Draft_Order_Sync__c", buttonValue); if(!buttonValue){ component.set("v.configObj.HIC_ShopifySync__Enable_Draft_Order__c", buttonValue); } console.log('draft order sync', component.get("v.configObj.HIC_ShopifySync__Draft_Order_Sync__c")); } } })