How to use customList method in tracetest

Best JavaScript code snippet using tracetest

CreateOuote_YETIController.js

Source:CreateOuote_YETIController.js Github

copy

Full Screen

1({2 doInit: function(component, event, helper) {3 try {4 5 var action = component.get("c.getQuoteDetails"); 6 action.setParams({7 recId : component.get("v.quoteID")8 });9 action.setCallback(this, function(response) {10 console.log(response.getReturnValue());11 var results = response.getReturnValue();12 component.set("v.QuoteObj",results.QuoteObj);13 component.set("v.AccId",results.QuoteObj.Account__c);14 console.log(component.get("v.AccId"));15 component.set("v.OppId",results.QuoteObj.Opportunity__c);16 console.log(component.get("v.OppId"));17 component.set("v.quoteID",results.QuoteObj.Id);18 console.log(component.get("v.quoteID"));19 if(results.QuoteObj.ItemNumberToCapture__c != null || results.QuoteObj.ItemNumberToCapture__c != undefined ){20 console.log("-->"+results.QuoteObj.ItemNumberToCapture__c);21 component.set("v.itemnumber",results.QuoteObj.ItemNumberToCapture__c); 22 }else{23 let itmnum = 0;24 component.set("v.itemnumber",itmnum);25 console.log(component.get("v.itemnumber"));26 }27 28 29 component.set("v.Access", results.Accessble);30 //console.log(component.get("v.Access"));31 var lineitemList = JSON.parse(results.lineList);32 if(lineitemList.length > 0 ){33 34 console.log(lineitemList);35 var stockList = [];36 var customlist = [];37 var customhardcoolers = [];38 39 for (let i = 0; i < lineitemList.length; i++) {40 if (lineitemList[i].category__c == "Stock") {41 stockList.push(lineitemList[i]);42 component.set("v.Coolerslist", stockList);43 } else if (lineitemList[i].category__c == "Custom") {44 customlist.push(lineitemList[i]);45 component.set("v.Customlist", customlist);46 } else if (lineitemList[i].category__c == "NonCustom") {47 customhardcoolers.push(lineitemList[i]);48 component.set("v.NotCustomlist", customhardcoolers);49 }50 }51 }52 });53 $A.enqueueAction(action);54 55 window.addEventListener("message", function(event) {56 // console.log(event.data);57 var jsndata = event.data58 if (jsndata.includes("isEdit")) {59 // console.log("testforow" + event.data);60 var edata = JSON.parse(jsndata);61 // console.log(edata);62 var itno = component.get("v.CitemNumber");63 // console.log(itno);64 var side = component.get("v.side");65 // console.log(side);66 var evdata = edata.editdata;67 // console.log(evdata);68 var v = evdata.toString();69 var m = v.replace(' "{ ', "{");70 var o = m.replace('"{', '{');71 var n = o.replace(/\\/g, "");72 // console.log("n");73 // console.log(n);74 var jsn = "[" + n + "]"75 76 var custmizerList = JSON.parse(jsn);77 // console.log(custmizerList);78 var cusList = component.get("v.Customlist");79 // console.log(component.get("v.Customlist"));80 for (var i = 0; i < cusList.length; i++) {81 if (cusList[i].itemnumber == itno) {82 for (var j = 0; j < cusList[i].jsondata.length; j++) {83 // cusList[i].jsondata = custmizerList;84 // console.log(cusList[i].jsondata[j].ramsideloc);85 if (cusList[i].jsondata[j].ramsideloc != side) {86 //cusList[i].jsondata.splice(j, 1);87 custmizerList.push(cusList[i].jsondata[j]);88 89 // console.log(cusList[i].jsondata[j]);90 // console.log(custmizerList);91 }92 // }else{93 // custmizerList.push(cusList[i].jsondata[j]);94 // }95 }96 cusList[i].jsondata = custmizerList;97 }98 // cusList[i].jsondata = custmizerList;99 }100 //console.log(custmizerList);101 component.set("v.Customlist", cusList);102 // console.log(component.get("v.Customlist"));103 // component.set("v.CitemNumber",null); 104 } else {105 // console.log(component.get("v.Coolerslist"));106 // console.log(component.get("v.Customlist"));107 // console.log(component.get("v.customProductId"));108 var v = event.data.toString();109 var m = v.replace(' "{ ', "{");110 var o = m.replace('"{', '{');111 var n = o.replace(/\\/g, "");112 var jsn = "[" + n + "]"113 114 var custmizerList = JSON.parse(jsn);115 // console.log(custmizerList);116 var cusList = component.get("v.Customlist");117 var StockList = component.get("v.Coolerslist");118 // console.log(cusList);119 // console.log(StockList);120 if(StockList.length > 0){121 for (var i = 0; i < StockList.length; i++) {122 // console.log(StockList[i]);123 if (StockList[i].itemnumber == component.get("v.customProductId")) {124 StockList[i].jsondata = custmizerList;125 StockList[i].category__c = 'Custom';126 cusList.push(StockList[i]);127 StockList.splice(i, 1);128 }129 }130 //console.log(cusList);131 // console.log(StockList);132 component.set("v.Customlist", cusList);133 component.set("v.Coolerslist", StockList);134 //console.log(component.get("v.Customlist"));135 //console.log(component.get("v.Coolerslist"));136 //console.log(component.get("v.insertList")); 137 }138 139 }140 }, false);141 } catch (e) {142 if (e instanceof MyCustomError) {143 // Specific message for MyCustomError144 console.error(e.name + ' (code ' + e.code + '): ' + e.message);145 helper.showToast(component, e.name, "Error", e.message);146 } else {147 // Generic message for other types of error148 // (unreachable code in this sample)149 console.error(e.message);150 helper.showToast(component, "Error", "Error", e.message);151 }152 }153 },154 changeicon: function(component, event, helper) {155 try {156 helper.showsection(component, event);157 } catch (e) {158 console.error(e.message);159 helper.showToast(component, "Error", "Error", e.message);160 }161 },162 changeicon1: function(component, event, helper) {163 try {164 helper.showsectioncustom(component, event);165 } catch (e) {166 console.error(e.message);167 helper.showToast(component, "Error", "Error", e.message);168 }169 },170 changeicon2: function(component, event, helper) {171 try {172 helper.showsectionnoncustom(component, event);173 } catch (e) {174 console.error(e.message);175 helper.showToast(component, "Error", "Error", e.message);176 }177 },178 ToggleTopProducts: function(component, event, helper) {179 try {180 helper.showsectionnonTopProducts(component, event);181 } catch (e) {182 console.error(e.message);183 helper.showToast(component, "Error", "Error", e.message);184 }185 },186 handleComponentEvent: function(cmp, event, helper) {187 try {188 helper.recordsFromSearchbar(cmp, event);189 } catch (e) {190 console.error(e.message);191 helper.showToast(cmp, "Error", "Error", e.message);192 }193 },194 handleTopProductevent: function(cmp, event, helper) {195 try {196 helper.recordsFromTopList(cmp, event);197 } catch (e) {198 console.error(e.message);199 helper.showToast(component, "Error", "Error", e.message);200 }201 },202 showAll: function(cmp, event, helper) {203 cmp.set("v.cooler", true);204 cmp.set("v.custom", true);205 cmp.set("v.noncustom", true);206 },207 showCoolers: function(cmp, event, helper) {208 cmp.set("v.cooler", true);209 cmp.set("v.custom", false);210 cmp.set("v.noncustom", false);211 },212 showCustom: function(cmp, event, helper) {213 cmp.set("v.cooler", false);214 cmp.set("v.custom", true);215 cmp.set("v.noncustom", false);216 },217 showNonCustom: function(cmp, event, helper) {218 cmp.set("v.cooler", false);219 cmp.set("v.custom", false);220 cmp.set("v.noncustom", true);221 },222 AddEmblishment: function(component, event, helper) {223 var productkey = event.getSource().get("v.name");224 var n = productkey.lastIndexOf('/');225 var HvItemId = productkey.substring(n + 1);226 var UPK = productkey.substring(0, n);227 component.set("v.customProductId", HvItemId);228 var modalBody;229 $A.createComponent("c:ModalContent", {230 "UPK": UPK231 },232 function(content, status) {233 if (status === "SUCCESS") {234 modalBody = content;235 component.find('overlayLib').showCustomModal({236 header: "ADD EMBELLISHMENT",237 body: modalBody,238 showCloseButton: true,239 cssClass: "slds-modal_large",240 closeCallback: function() {241 // alert('You closed the alert!');242 }243 }).then(function(overlay) {244 component.set('v.overlay', overlay);245 });246 }247 });248 },249 removeLine: function(component, event, helper) {250 console.log(event.target.name);251 console.log(event.target.id);252 if (event.target.name == "Custom") {253 let customlist = component.get("v.Customlist");254 let insrtlist = component.get("v.insertList");255 for (var i = 0; i < customlist.length; i++) {256 if (customlist[i].itemnumber == event.target.id) {257 customlist.splice(i, 1);258 component.set("v.Customlist", customlist);259 }260 }261 for (var i = 0; i < insrtlist.length; i++) {262 if (insrtlist[i].itemnumber == event.target.id) {263 insrtlist.splice(i, 1);264 component.set("v.insertList", insrtlist);265 }266 }267 } else if (event.target.name == "Stock") {268 let Stocklist = component.get("v.Coolerslist");269 let insrtlist = component.get("v.insertList");270 for (var i = 0; i < Stocklist.length; i++) {271 if (Stocklist[i].itemnumber == event.target.id) {272 Stocklist.splice(i, 1);273 component.set("v.Coolerslist", Stocklist);274 }275 }276 for (var i = 0; i < insrtlist.length; i++) {277 if (insrtlist[i].itemnumber == event.target.id) {278 insrtlist.splice(i, 1);279 component.set("v.insertList", insrtlist);280 }281 }282 } else if(event.target.name == "NonCustom"){283 let nonCustomlist = component.get("v.NotCustomlist");284 console.log("list");285 console.log(nonCustomlist)286 for (var i = 0; i < nonCustomlist.length; i++) {287 if (nonCustomlist[i].itemnumber == event.target.id) {288 console.log(nonCustomlist[i].Id);289 nonCustomlist.splice(i, 1);290 component.set("v.NotCustomlist", nonCustomlist);291 }292 }293 }294 },295 saveQuoteHeader: function(component, event, helper) {296 try {297 var issave = true;298 helper.saveandcreate(component, event,helper, issave);299 } catch (e) {300 console.error(e.message);301 helper.showToast(component, "Error", "Error", e.message);302 }303 },304 saveandContinueQuoteDetails: function(component, event, helper) {305 try {306 var issave = false;307 helper.saveandcreate(component, event,helper, issave);308 } catch (e) {309 console.error(e.message);310 helper.showToast(component, "Error", "Error", e.message);311 }312 },313 deleteItem: function(component, event, helper) {314 console.log(event.target.id);315 console.log(event.target.name);316 if (event.target.name == "Custom") {317 console.log("name");318 let customlist = component.get("v.Customlist");319 console.log(customlist)320 for (var i = 0; i < customlist.length; i++) {321 if (customlist[i].Id == event.target.id) {322 console.log(customlist[i].Id);323 customlist.splice(i, 1);324 component.set("v.Customlist", customlist);325 }326 }327 }else if(event.target.name == "NonCustom"){328 let nonCustomlist = component.get("v.NotCustomlist");329 console.log("list");330 console.log(nonCustomlist)331 for (var i = 0; i < nonCustomlist.length; i++) {332 if (nonCustomlist[i].Id == event.target.id) {333 console.log(nonCustomlist[i].Id);334 nonCustomlist.splice(i, 1);335 component.set("v.NotCustomlist", nonCustomlist);336 }337 }338 339 } 340 341 else {342 let Stock = component.get("v.Coolerslist");343 console.log("list");344 console.log(Stock)345 for (var i = 0; i < Stock.length; i++) {346 if (Stock[i].Id == event.target.id) {347 console.log(Stock[i].Id);348 Stock.splice(i, 1);349 component.set("v.Coolerslist", Stock);350 }351 }352 }353 },354 removeCustomArt: function(component, event, helper) {355 var cusList = component.get("v.Customlist");356 for (var i = 0; i < cusList.length; i++) {357 if (cusList[i].itemnumber == event.target.id) {358 for (var j = 0; j < cusList[i].jsondata.length; j++) {359 console.log(cusList[i].jsondata[j].ramsideloc);360 if (cusList[i].jsondata[j].ramsideloc == event.target.name) {361 cusList[i].jsondata.splice(j, 1);362 }363 }364 }365 }366 component.set("v.Customlist", cusList);367 },368 editCustomizer: function(component, event, helper) {369 console.log(event.target.name);370 let itmnumber = event.target.id;371 component.set("v.CitemNumber", itmnumber);372 var customList = component.get("v.Customlist");373 var json = [];374 var upk;375 var side = event.target.name;376 component.set("v.side", side);377 for (var i = 0; i < customList.length; i++) {378 if (customList[i].itemnumber == itmnumber) {379 upk = customList[i].UPK__c;380 for (var j = 0; j < customList[i].jsondata.length; j++) {381 if (customList[i].jsondata[j].ramsideloc == event.target.name) {382 json.push(customList[i].jsondata[j]);383 }384 }385 }386 }387 var modalBody;388 $A.createComponent("c:ModalContent", {389 "UPK": upk,390 "jsonData": json,391 "isEdit": "true"392 },393 function(content, status) {394 if (status === "SUCCESS") {395 modalBody = content;396 component.find('overlayLib').showCustomModal({397 header: "ADD EMBELLISHMENT",398 body: modalBody,399 showCloseButton: true,400 cssClass: "slds-modal_large",401 closeCallback: function() {402 //alert('You closed the alert!');403 }404 }).then(function(overlay) {405 component.set('v.overlay', overlay);406 });407 }408 });409 console.log(json);410 },411 handleCloseEvent: function(component, event, helper) {412 var cmpEvent = event.getParam("eventtoclose");413 console.log("hai there ");414 console.log(cmpEvent);415 // component.find("overlayLib").notifyClose(); 416 },417 handleSapOrgDetails: function(component, event, helper) {418 console.log(event.getParam("sapOrgstr"));419 var prodId = event.getParam("sapOrgstr");420 console.log('this is a handler--->');421 console.log(prodId);422 component.set("v.SapOrgJson", prodId);423 },424 /* getPricing: function(cmp, event, helper) {425 cmp.set("v.loaded", true);426 var stock = cmp.get("v.Coolerslist");427 var custom = cmp.get("v.Customlist");428 var noncustom = cmp.get("v.NotCustomlist");429 var lineItems = [];430 var stockList = [];431 // cmp.set("v.Coolerslist",stockList);432 var customlist = [];433 var customhardcoolers = [];434 cmp.set("v.insertList", lineItems);435 for (let i in stock) {436 lineItems.push(stock[i])437 }438 for (let i in custom) {439 lineItems.push(custom[i])440 }441 for (let i in noncustom) {442 lineItems.push(noncustom[i])443 }444 if ( cmp.get("v.SapOrgJson") != null && cmp.get("v.SapOrgJson") != "" ){445 446 var OrgObj = JSON.parse(cmp.get("v.SapOrgJson"));447 console.log(OrgObj);448 OrgObj.productMaterial = lineItems;449 console.log(JSON.stringify(OrgObj));450 451 console.log(OrgObj); 452 } else{453 var OrgObj = {454 "salesOrg":"",455 "distribution":"",456 "division":"",457 "companycode":"",458 "salesoffice":"",459 "salesgrp":""460 };461 OrgObj.productMaterial = lineItems;462 463 464 }465 466 var getPricing = cmp.get("c.getProductPricing");467 getPricing.setParams({468 productjson: JSON.stringify(OrgObj)469 });470 getPricing.setCallback(this, function(response) {471 var state = response.getState();472 if (state === "SUCCESS") {473 console.log(response.getReturnValue());474 var result = JSON.parse(response.getReturnValue());475 console.log(result);476 if(result.MESSAGE != null){477 console.log(result.MESSAGE);478 479 var toastEvent = $A.get("e.force:showToast");480 toastEvent.setParams({481 title : 'Info Message',482 message: result.MESSAGE,483 mode: 'pester'484 });485 toastEvent.fire();486 cmp.set("v.loaded", false); 487 }else{488 489 490 for (let i = 0; i < result.length; i++) {491 for (let j = 0; j < lineItems.length; j++) {492 if (lineItems[j].itemnumber == parseInt(result[i].ITM_NUMBER)) {493 console.log(parseInt(result[i].ITM_NUMBER));494 for (let k = 0; k < result[i].PricingList.length; k++) {495 console.log("1");496 if (result[i].PricingList[k].COND_DESC == "Price") {497 console.log(result[i].PricingList[k].COND_VALUE);498 lineItems[j].unitprice = result[i].PricingList[k].COND_VALUE;499 }500 if (result[i].PricingList[k].COND_TYPE == "LTAX") {501 lineItems[j].Tax = result[i].PricingList[k].COND_VALUE;502 }503 if (result[i].PricingList[k].COND_TYPE == "LTOT") {504 lineItems[j].Total = result[i].PricingList[k].COND_VALUE;505 }506 if (result[i].PricingList[k].COND_TYPE == "ZD01") {507 let d = result[i].PricingList[k].CONDVALUE;508 509 let dis = Math.abs(d); 510 lineItems[j].Discount = dis.toFixed(2); ;511 }512 }513 }514 }515 }516 for (let i = 0; i < lineItems.length; i++) {517 if (lineItems[i].category__c == "Stock") {518 stockList.push(lineItems[i]);519 cmp.set("v.Coolerslist", stockList);520 } else if (lineItems[i].category__c == "Custom") {521 customlist.push(lineItems[i]);522 cmp.set("v.Customlist", customlist);523 } else if (lineItems[i].category__c == "NonCustom") {524 customhardcoolers.push(lineItems[i]);525 cmp.set("v.NotCustomlist", customhardcoolers);526 }527 }528 console.log(lineItems);529 cmp.set("v.insertList", lineItems);530 console.log(cmp.get("v.insertList"));531 console.log(cmp.get("v.Coolerslist"));532 cmp.set("v.loaded", false);533 }534 } else if (state === "INCOMPLETE") {535 // do something536 } else if (state === "ERROR") {537 var errors = response.getError();538 if (errors) {539 if (errors[0] && errors[0].message) {540 console.log("Error message: " +541 errors[0].message);542 }543 } else {544 console.log("Unknown error");545 }546 }547 });548 $A.enqueueAction(getPricing);549 },*/550 551 getPricing: function(cmp, event, helper) {552 cmp.set("v.loaded", true);553 var stock = cmp.get("v.Coolerslist");554 var custom = cmp.get("v.Customlist");555 var noncustom = cmp.get("v.NotCustomlist");556 var lineItems = [];557 var stockList = [];558 var customlist = [];559 var customhardcoolers = [];560 cmp.set("v.insertList", lineItems);561 for (let i in stock) {562 lineItems.push(stock[i])563 }564 for (let i in custom) {565 lineItems.push(custom[i])566 }567 for (let i in noncustom) {568 lineItems.push(noncustom[i])569 }570 if (cmp.get("v.SapOrgJson") != null && cmp.get("v.SapOrgJson") != "") {571 var OrgObj = JSON.parse(cmp.get("v.SapOrgJson"));572 OrgObj.productMaterial = lineItems;573 } else {574 var OrgObj = {575 "salesOrg": "",576 "distribution": "",577 "division": "",578 "companycode": "",579 "salesoffice": "",580 "salesgrp": ""581 };582 OrgObj.productMaterial = lineItems;583 }584 var getPricing = cmp.get("c.getProductPricing");585 getPricing.setParams({586 productjson: JSON.stringify(OrgObj)587 });588 getPricing.setCallback(this, function(response) {589 var state = response.getState();590 if (state === "SUCCESS") {591 console.log(response.getReturnValue());592 if(response.getReturnValue() == null || response.getReturnValue() == undefined ){ 593 cmp.set("v.loaded", false);594 helper.showToast(cmp, "Error!", "Error", "Callout Error!" );595 } else if(response.getReturnValue().includes("MESSAGE") && response.getReturnValue() != "" ) {596 var result = JSON.parse(response.getReturnValue());597 if(result.MESSAGE != " " || result.MESSAGE != null){598 cmp.set("v.loaded", false);599 helper.showToast(cmp, "Error!", "Error", result.MESSAGE ); 600 601 }else{602 cmp.set("v.loaded", false); 603 helper.showToast(cmp, "Error!", "Error", "Callout Error!" ); 604 }605 606 } else{607 608 var result = JSON.parse(response.getReturnValue());609 console.log(result);610 611 result.forEach(result1 => {612 // console.log(result1.PricingList);613 lineItems.forEach(item => {614 if (item.itemnumber == parseInt(result1.ITM_NUMBER) ) {615 (result1.PricingList).forEach(priceitem => {616 console.log("test");617 if (priceitem.COND_DESC == "Price") {618 item.unitprice = priceitem.COND_VALUE;619 console.log(item.unitprice);620 }621 else if (priceitem.COND_TYPE == "LTAX" ) {622 item.Tax = priceitem.COND_VALUE;623 console.log(item.Tax);624 }625 else if (priceitem.COND_TYPE == "LTOT" ) {626 item.Total = priceitem.COND_VALUE;627 console.log(item.Total);628 }629 else if (priceitem.COND_TYPE == "ZD01" ) {630 let d = priceitem.CONDVALUE;631 let dis = Math.abs(d);632 item.Discount = dis.toFixed(2);633 console.log(item.Discount);634 }635 });636 }637 });638 });639 console.log(lineItems);640 lineItems.forEach(item1 => {641 if (item1.category__c == "Stock") {642 console.log(item1);643 stockList.push(item1);644 } else if (item1.category__c == "Custom") {645 console.log(item1);646 customlist.push(item1);647 } else if (item1.category__c == "NonCustom") {648 console.log(item1);649 customhardcoolers.push(item1);650 }651 });652 if (stockList.length > 0) {653 cmp.set("v.Coolerslist", stockList);654 }655 if (customlist.length > 0) {656 cmp.set("v.Customlist", customlist);657 }658 if (customhardcoolers.length > 0) {659 cmp.set("v.NotCustomlist", customhardcoolers);660 }661 if (lineItems.length > 0) {662 cmp.set("v.insertList", lineItems);663 }664 // console.log(cmp.get("v.insertList"));665 console.log(cmp.get("v.Coolerslist"));666 cmp.set("v.loaded", false);667 668 }669 } else if (state === "INCOMPLETE") {670 // do something671 cmp.set("v.loaded", false);672 helper.showToast(cmp, "Error!", "Error", "transaction is in complete" );673 } else if (state === "ERROR") {674 var errors = response.getError();675 if (errors) {676 if (errors[0] && errors[0].message) {677 console.log("Error message: " +678 errors[0].message);679 cmp.set("v.loaded", false);680 helper.showToast(cmp, "Error!", "Error", errors[0].message );681 }682 } else {683 console.log("Unknown error");684 cmp.set("v.loaded", false);685 helper.showToast(cmp, "Error!", "Error", "Unknown error");686 }687 }688 });689 $A.enqueueAction(getPricing);690 },691 onQuantityChange: function(component, event, helper) {692 console.log(event.target.name);693 console.log(event.target.id);694 console.log(event.target.value);695 if (event.target.name == 'Stock') {696 var Stocklist = component.get("v.Coolerslist");697 for (var i = 0; i < Stocklist.length; i++) {698 if (Stocklist[i].itemnumber == event.target.id) {699 console.log(Stocklist[i].itemnumber);700 Stocklist[i].Quantity = event.target.value;701 }702 }703 console.log(Stocklist);704 component.set("v.Coolerslist", Stocklist);705 console.log(component.get("v.Coolerslist"));706 } else if (event.target.name == 'Custom') {707 var CustomList = component.get("v.Customlist");708 for (let i = 0; i < CustomList.length; i++) {709 if (CustomList[i].itemnumber == event.target.id) {710 CustomList[i].Quantity = event.target.value;711 }712 }713 component.set("v.Customlist", CustomList);714 console.log(component.get("v.Customlist"));715 }716 else if(event.target.name == 'NonCustom') {717 var nonCustomList = component.get("v.NotCustomlist");718 for (let i = 0; i < nonCustomList.length; i++) {719 if (nonCustomList[i].itemnumber == event.target.id) {720 nonCustomList[i].Quantity = event.target.value;721 }722 }723 component.set("v.NotCustomlist", nonCustomList);724 console.log(component.get("v.NotCustomlist"));725 }726 },727 onDiscountChange: function(component, event, helper) {728 console.log(event.target.name);729 console.log(event.target.id);730 console.log(event.target.value);731 if (event.target.name == 'Stock') {732 var Stocklist = component.get("v.Coolerslist");733 for (var i = 0; i < Stocklist.length; i++) {734 if (Stocklist[i].itemnumber == event.target.id) {735 console.log(Stocklist[i].itemnumber);736 Stocklist[i].Discount = event.target.value;737 }738 }739 console.log(Stocklist);740 component.set("v.Coolerslist", Stocklist);741 console.log(component.get("v.Coolerslist"));742 } else if (event.target.name == 'Custom') {743 var CustomList = component.get("v.Customlist");744 for (let i = 0; i < CustomList.length; i++) {745 if (CustomList[i].itemnumber == event.target.id) {746 CustomList[i].Discount = event.target.value;747 }748 }749 component.set("v.Customlist", CustomList);750 console.log(component.get("v.Customlist"));751 }752 else if (event.target.name == 'NonCustom') {753 var nonCustomList = component.get("v.NotCustomlist");754 for (let i = 0; i < nonCustomList.length; i++) {755 if (nonCustomList[i].itemnumber == event.target.id) {756 nonCustomList[i].Discount = event.target.value;757 }758 }759 component.set("v.NotCustomlist", nonCustomList);760 console.log(component.get("v.NotCustomlist"));761 }762 },763 changeMeasures: function(component, event, helper) {764 var key = event.target.name;765 var n = key.lastIndexOf('/');766 var category = key.substring(0, n);767 var measures = key.substring(n + 1);768 if (category == 'Stock') {769 var StockList = component.get("v.Coolerslist");770 for (let i = 0; i < StockList.length; i++) {771 if (StockList[i].itemnumber == event.target.id) {772 StockList[i].measure = measures;773 }774 }775 component.set("v.Coolerslist", StockList);776 console.log(component.get("v.Coolerslist"));777 } else if (category == 'Custom') {778 var CustomList = component.get("v.Customlist");779 for (let i = 0; i < CustomList.length; i++) {780 if (CustomList[i].itemnumber == event.target.id) {781 CustomList[i].measure = measures;782 }783 }784 component.set("v.Customlist", CustomList);785 console.log(component.get("v.Customlist"));786 }787 788 else {789 var nonCustomList = component.get("v.NotCustomlist");790 for (let i = 0; i < nonCustomList.length; i++) {791 if (nonCustomList[i].itemnumber == event.target.id) {792 nonCustomList[i].measure = measures;793 }794 }795 component.set("v.NotCustomlist", nonCustomList);796 console.log(component.get("v.NotCustomlist"));797 }798 },799 changeDiscount: function(component, event, helper) {800 801 var key = event.target.name;802 var n = key.lastIndexOf('/');803 var category = key.substring(0, n);804 var discount = key.substring(n + 1);805 console.log(category);806 if (category == 'Stock') {807 var StockList = component.get("v.Coolerslist");808 for (let i = 0; i < StockList.length; i++) {809 if (StockList[i].itemnumber == event.target.id) {810 StockList[i].Discountmeasure = discount;811 }812 }813 component.set("v.Coolerslist", StockList);814 console.log(component.get("v.Coolerslist"));815 } else if (category == 'Custom') {816 var CustomList = component.get("v.Customlist");817 for (let i = 0; i < CustomList.length; i++) {818 if (CustomList[i].itemnumber == event.target.id) {819 CustomList[i].Discountmeasure = discount;820 }821 }822 component.set("v.Customlist", CustomList);823 console.log(component.get("v.Customlist"));824 }825 else {826 console.log("entered");827 var nonCustomList = component.get("v.NotCustomlist");828 for (let i = 0; i < nonCustomList.length; i++) {829 if (nonCustomList[i].itemnumber == event.target.id) {830 nonCustomList[i].Discountmeasure = discount;831 }832 }833 component.set("v.NotCustomlist", nonCustomList);834 console.log(component.get("v.NotCustomlist"));835 }836 },837 838 handlecancle : function (cmp,event,helper){839 //helper.saveandcreate(component, event);840 helper.navigatetoobject(cmp, event, cmp.get("v.AccId")); 841 842 }...

Full Screen

Full Screen

EditQuoteScreenController.js

Source:EditQuoteScreenController.js Github

copy

Full Screen

1({2 doInit: function(component, event, helper) {3 try {4 5 var action = component.get("c.getQuoteDetails"); 6 action.setParams({7 recId : component.get("v.quoteID")8 });9 action.setCallback(this, function(response) {10 console.log(response.getReturnValue());11 var results = response.getReturnValue();12 component.set("v.QuoteObj",results.QuoteObj);13 component.set("v.AccId",results.QuoteObj.Account__c);14 console.log(component.get("v.AccId"));15 component.set("v.OppId",results.QuoteObj.Opportunity__c);16 console.log(component.get("v.OppId"));17 component.set("v.quoteID",results.QuoteObj.Id);18 console.log(component.get("v.quoteID"));19 component.set("v.itemnumber",results.QuoteObj.ItemNumberToCapture__c);20 component.set("v.Access",results.Accessble);21 console.log(component.get("v.Access"));22 var lineitemList = JSON.parse(results.lineList);23 24 25 if(lineitemList.length > 0){26 var stockList = [];27 var customlist = [];28 var customhardcoolers = [];29 30 for (let i = 0; i < lineitemList.length; i++) {31 if (lineitemList[i].category__c == "Stock") {32 stockList.push(lineitemList[i]);33 component.set("v.Coolerslist", stockList);34 } else if (lineitemList[i].category__c == "Custom") {35 customlist.push(lineitemList[i]);36 component.set("v.Customlist", customlist);37 } else if (lineitemList[i].category__c == "NonCustom") {38 customhardcoolers.push(lineitemList[i]);39 component.set("v.NotCustomlist", customhardcoolers);40 }41 } 42 }43 44 });45 $A.enqueueAction(action);46 47 window.addEventListener("message", function(event) {48 // console.log(event.data);49 var jsndata = event.data50 if (jsndata.includes("isEdit")) {51 52 // console.log("testforow" + event.data);53 var edata = JSON.parse(jsndata);54 // console.log(edata);55 var itno = component.get("v.CitemNumber");56 // console.log(itno);57 var side = component.get("v.side");58 // console.log(side);59 var evdata = edata.editdata;60 //console.log(evdata);61 var v = evdata.toString();62 var m = v.replace(' "{ ', "{");63 var o = m.replace('"{', '{');64 var n = o.replace(/\\/g, "");65 // console.log("n");66 // console.log(n);67 var jsn = "[" + n + "]"68 // var custmizerList = [];69 var custmizerList = JSON.parse(jsn);70 console.log(custmizerList);71 var cusList = component.get("v.Customlist");72 console.log(component.get("v.Customlist"));73 for (var i = 0; i < cusList.length; i++) {74 if (cusList[i].itemnumber == itno) {75 for (var j = 0; j < cusList[i].jsondata.length; j++) {76 // cusList[i].jsondata = custmizerList;77 // console.log(cusList[i].jsondata[j].ramsideloc);78 if (cusList[i].jsondata[j].ramsideloc != side) {79 //cusList[i].jsondata.splice(j, 1);80 custmizerList.push(cusList[i].jsondata[j]);81 82 // console.log(cusList[i].jsondata[j]);83 // console.log(custmizerList);84 }85 // }else{86 // custmizerList.push(cusList[i].jsondata[j]);87 // }88 }89 cusList[i].jsondata = custmizerList;90 }91 // cusList[i].jsondata = custmizerList;92 }93 // console.log(custmizerList);94 component.set("v.Customlist", cusList);95 //console.log(component.get("v.Customlist"));96 // component.set("v.CitemNumber",null); 97 } else {98 //console.log(component.get("v.Coolerslist"));99 //console.log(component.get("v.Customlist"));100 //console.log(component.get("v.customProductId"));101 var v = event.data.toString();102 var m = v.replace(' "{ ', "{");103 var o = m.replace('"{', '{');104 var n = o.replace(/\\/g, "");105 var jsn = "[" + n + "]"106 107 var custmizerList = JSON.parse(jsn);108 console.log(custmizerList);109 var cusList = component.get("v.Customlist");110 var StockList = component.get("v.Coolerslist");111 //console.log(cusList);112 // console.log(StockList);113 if(StockList.length > 0){114 for (var i = 0; i < StockList.length; i++) {115 // console.log(StockList[i]);116 if (StockList[i].itemnumber == component.get("v.customProductId")) {117 StockList[i].jsondata = custmizerList;118 StockList[i].category__c = 'Custom';119 cusList.push(StockList[i]);120 StockList.splice(i, 1);121 }122 }123 //console.log(cusList);124 //console.log(StockList);125 component.set("v.Customlist", cusList);126 component.set("v.Coolerslist", StockList);127 //console.log(component.get("v.Customlist"));128 //console.log(component.get("v.Coolerslist"));129 //console.log(component.get("v.insertList"));130 }131 132 }133 }, false);134 } catch (e) {135 if (e instanceof MyCustomError) {136 // Specific message for MyCustomError137 console.error(e.name + ' (code ' + e.code + '): ' + e.message);138 helper.showToast(component, e.name, "Error", e.message);139 } else {140 // Generic message for other types of error141 // (unreachable code in this sample)142 console.error(e.message);143 helper.showToast(component, "Error", "Error", e.message);144 }145 }146 },147 changeicon: function(component, event, helper) {148 try {149 helper.showsection(component, event);150 } catch (e) {151 console.error(e.message);152 helper.showToast(component, "Error", "Error", e.message);153 }154 },155 changeicon1: function(component, event, helper) {156 try {157 helper.showsectioncustom(component, event);158 } catch (e) {159 console.error(e.message);160 helper.showToast(component, "Error", "Error", e.message);161 }162 },163 changeicon2: function(component, event, helper) {164 try {165 helper.showsectionnoncustom(component, event);166 } catch (e) {167 console.error(e.message);168 helper.showToast(component, "Error", "Error", e.message);169 }170 },171 ToggleTopProducts: function(component, event, helper) {172 try {173 helper.showsectionnonTopProducts(component, event);174 } catch (e) {175 console.error(e.message);176 helper.showToast(component, "Error", "Error", e.message);177 }178 },179 handleComponentEvent: function(cmp, event, helper) {180 try {181 helper.recordsFromSearchbar(cmp, event);182 } catch (e) {183 console.error(e.message);184 helper.showToast(cmp, "Error", "Error", e.message);185 }186 },187 handleTopProductevent: function(cmp, event, helper) {188 try {189 helper.recordsFromTopList(cmp, event);190 } catch (e) {191 console.error(e.message);192 helper.showToast(component, "Error", "Error", e.message);193 }194 },195 showAll: function(cmp, event, helper) {196 cmp.set("v.cooler", true);197 cmp.set("v.custom", true);198 cmp.set("v.noncustom", true);199 },200 showCoolers: function(cmp, event, helper) {201 cmp.set("v.cooler", true);202 cmp.set("v.custom", false);203 cmp.set("v.noncustom", false);204 },205 showCustom: function(cmp, event, helper) {206 cmp.set("v.cooler", false);207 cmp.set("v.custom", true);208 cmp.set("v.noncustom", false);209 },210 showNonCustom: function(cmp, event, helper) {211 cmp.set("v.cooler", false);212 cmp.set("v.custom", false);213 cmp.set("v.noncustom", true);214 },215 AddEmblishment: function(component, event, helper) {216 var productkey = event.getSource().get("v.name");217 var n = productkey.lastIndexOf('/');218 var HvItemId = productkey.substring(n + 1);219 var UPK = productkey.substring(0, n);220 component.set("v.customProductId", HvItemId);221 var modalBody;222 $A.createComponent("c:ModalContent", {223 "UPK": UPK224 },225 function(content, status) {226 if (status === "SUCCESS") {227 modalBody = content;228 component.find('overlayLib').showCustomModal({229 header: "ADD EMBELLISHMENT",230 body: modalBody,231 showCloseButton: true,232 cssClass: "slds-modal_large",233 closeCallback: function() {234 // alert('You closed the alert!');235 }236 }).then(function(overlay) {237 component.set('v.overlay', overlay);238 });239 }240 });241 },242 removeLine: function(component, event, helper) {243 console.log(event.target.name);244 console.log(event.target.id);245 if (event.target.name == "Custom") {246 let customlist = component.get("v.Customlist");247 let insrtlist = component.get("v.insertList");248 for (var i = 0; i < customlist.length; i++) {249 if (customlist[i].itemnumber == event.target.id) {250 customlist.splice(i, 1);251 component.set("v.Customlist", customlist);252 }253 }254 for (var i = 0; i < insrtlist.length; i++) {255 if (insrtlist[i].itemnumber == event.target.id) {256 insrtlist.splice(i, 1);257 component.set("v.insertList", insrtlist);258 }259 }260 } else if (event.target.name == "Stock") {261 let Stocklist = component.get("v.Coolerslist");262 let insrtlist = component.get("v.insertList");263 for (var i = 0; i < Stocklist.length; i++) {264 if (Stocklist[i].itemnumber == event.target.id) {265 Stocklist.splice(i, 1);266 component.set("v.Coolerslist", Stocklist);267 }268 }269 for (var i = 0; i < insrtlist.length; i++) {270 if (insrtlist[i].itemnumber == event.target.id) {271 insrtlist.splice(i, 1);272 component.set("v.insertList", insrtlist);273 }274 }275 } else if(event.target.name == "NonCustom"){276 let nonCustomlist = component.get("v.NotCustomlist");277 console.log("list");278 console.log(nonCustomlist)279 for (var i = 0; i < nonCustomlist.length; i++) {280 if (nonCustomlist[i].itemnumber == event.target.id) {281 console.log(nonCustomlist[i].Id);282 nonCustomlist.splice(i, 1);283 component.set("v.NotCustomlist", nonCustomlist);284 }285 }286 }287 },288 saveQuoteHeader: function(component, event, helper) {289 try {290 var issave = true;291 helper.saveandcreate(component, event, helper, issave);292 } catch (e) {293 console.error(e.message);294 helper.showToast(component, "Error", "Error", e.message);295 }296 },297 saveandContinueQuoteDetails: function(component, event, helper) {298 try {299 var issave = false;300 helper.saveandcreate(component, event, helper, issave);301 } catch (e) {302 console.error(e.message);303 helper.showToast(component, "Error", "Error", e.message);304 }305 },306 deleteItem: function(component, event, helper) {307 console.log(event.target.id);308 console.log(event.target.name);309 if (event.target.name == "Custom") {310 console.log("name");311 let customlist = component.get("v.Customlist");312 console.log(customlist)313 for (var i = 0; i < customlist.length; i++) {314 if (customlist[i].Id == event.target.id) {315 console.log(customlist[i].Id);316 customlist.splice(i, 1);317 component.set("v.Customlist", customlist);318 }319 }320 }else if(event.target.name == "NonCustom"){321 let nonCustomlist = component.get("v.NotCustomlist");322 console.log("list");323 console.log(nonCustomlist)324 for (var i = 0; i < nonCustomlist.length; i++) {325 if (nonCustomlist[i].Id == event.target.id) {326 console.log(nonCustomlist[i].Id);327 nonCustomlist.splice(i, 1);328 component.set("v.NotCustomlist", nonCustomlist);329 }330 }331 332 } 333 334 else {335 let Stock = component.get("v.Coolerslist");336 console.log("list");337 console.log(Stock)338 for (var i = 0; i < Stock.length; i++) {339 if (Stock[i].Id == event.target.id) {340 console.log(Stock[i].Id);341 Stock.splice(i, 1);342 component.set("v.Coolerslist", Stock);343 }344 }345 }346 },347 removeCustomArt: function(component, event, helper) {348 var cusList = component.get("v.Customlist");349 for (var i = 0; i < cusList.length; i++) {350 if (cusList[i].itemnumber == event.target.id) {351 for (var j = 0; j < cusList[i].jsondata.length; j++) {352 console.log(cusList[i].jsondata[j].ramsideloc);353 if (cusList[i].jsondata[j].ramsideloc == event.target.name) {354 cusList[i].jsondata.splice(j, 1);355 }356 }357 }358 }359 component.set("v.Customlist", cusList);360 },361 editCustomizer: function(component, event, helper) {362 console.log(event.target.name);363 let itmnumber = event.target.id;364 component.set("v.CitemNumber", itmnumber);365 var customList = component.get("v.Customlist");366 var json = [];367 var upk;368 var side = event.target.name;369 component.set("v.side", side);370 for (var i = 0; i < customList.length; i++) {371 if (customList[i].itemnumber == itmnumber) {372 upk = customList[i].UPK__c;373 for (var j = 0; j < customList[i].jsondata.length; j++) {374 if (customList[i].jsondata[j].ramsideloc == event.target.name) {375 json.push(customList[i].jsondata[j]);376 }377 }378 }379 }380 var modalBody;381 $A.createComponent("c:ModalContent", {382 "UPK": upk,383 "jsonData": json,384 "isEdit": "true"385 },386 function(content, status) {387 if (status === "SUCCESS") {388 modalBody = content;389 component.find('overlayLib').showCustomModal({390 header: "ADD EMBELLISHMENT",391 body: modalBody,392 showCloseButton: true,393 cssClass: "slds-modal_large",394 closeCallback: function() {395 //alert('You closed the alert!');396 }397 }).then(function(overlay) {398 component.set('v.overlay', overlay);399 });400 }401 });402 console.log(json);403 },404 handleCloseEvent: function(component, event, helper) {405 var cmpEvent = event.getParam("eventtoclose");406 console.log("hai there ");407 console.log(cmpEvent);408 // component.find("overlayLib").notifyClose(); 409 },410 handleSapOrgDetails: function(component, event, helper) {411 console.log(event.getParam("sapOrgstr"));412 var prodId = event.getParam("sapOrgstr");413 console.log('this is a handler--->');414 console.log(prodId);415 component.set("v.SapOrgJson", prodId);416 },417 getPricing: function(cmp, event, helper) {418 cmp.set("v.loaded", true);419 var stock = cmp.get("v.Coolerslist");420 var custom = cmp.get("v.Customlist");421 var noncustom = cmp.get("v.NotCustomlist");422 var lineItems = [];423 var stockList = [];424 var customlist = [];425 var customhardcoolers = [];426 cmp.set("v.insertList", lineItems);427 for (let i in stock) {428 lineItems.push(stock[i])429 }430 for (let i in custom) {431 lineItems.push(custom[i])432 }433 for (let i in noncustom) {434 lineItems.push(noncustom[i])435 }436 if (cmp.get("v.SapOrgJson") != null && cmp.get("v.SapOrgJson") != "") {437 var OrgObj = JSON.parse(cmp.get("v.SapOrgJson"));438 OrgObj.productMaterial = lineItems;439 } else {440 var OrgObj = {441 "salesOrg": "",442 "distribution": "",443 "division": "",444 "companycode": "",445 "salesoffice": "",446 "salesgrp": ""447 };448 OrgObj.productMaterial = lineItems;449 }450 var getPricing = cmp.get("c.getProductPricing");451 getPricing.setParams({452 productjson: JSON.stringify(OrgObj)453 });454 getPricing.setCallback(this, function(response) {455 var state = response.getState();456 if (state === "SUCCESS") {457 console.log(response.getReturnValue());458 if(response.getReturnValue() == null || response.getReturnValue() == undefined ){ 459 cmp.set("v.loaded", false);460 helper.showToast(cmp, "Error!", "Error", "Callout Error!" );461 } else if(response.getReturnValue().includes("MESSAGE") && response.getReturnValue() != "" ) {462 var result = JSON.parse(response.getReturnValue());463 if(result.MESSAGE != " " || result.MESSAGE != null){464 cmp.set("v.loaded", false);465 helper.showToast(cmp, "Error!", "Error", result.MESSAGE ); 466 467 }else{468 cmp.set("v.loaded", false); 469 helper.showToast(cmp, "Error!", "Error", "Callout Error!" ); 470 }471 472 } else{473 474 var result = JSON.parse(response.getReturnValue());475 console.log(result);476 477 result.forEach(result1 => {478 // console.log(result1.PricingList);479 lineItems.forEach(item => {480 if (item.itemnumber == parseInt(result1.ITM_NUMBER) ) {481 (result1.PricingList).forEach(priceitem => {482 console.log("test");483 if (priceitem.COND_DESC == "Price") {484 item.unitprice = priceitem.COND_VALUE;485 console.log(item.unitprice);486 }487 else if (priceitem.COND_TYPE == "LTAX" ) {488 item.Tax = priceitem.COND_VALUE;489 console.log(item.Tax);490 }491 else if (priceitem.COND_TYPE == "LTOT" ) {492 item.Total = priceitem.COND_VALUE;493 console.log(item.Total);494 }495 else if (priceitem.COND_TYPE == "ZD01" ) {496 let d = priceitem.CONDVALUE;497 let dis = Math.abs(d);498 item.Discount = dis.toFixed(2);499 console.log(item.Discount);500 }501 });502 }503 });504 });505 console.log(lineItems);506 lineItems.forEach(item1 => {507 if (item1.category__c == "Stock") {508 console.log(item1);509 stockList.push(item1);510 } else if (item1.category__c == "Custom") {511 console.log(item1);512 customlist.push(item1);513 } else if (item1.category__c == "NonCustom") {514 console.log(item1);515 customhardcoolers.push(item1);516 }517 });518 if (stockList.length > 0) {519 cmp.set("v.Coolerslist", stockList);520 }521 if (customlist.length > 0) {522 cmp.set("v.Customlist", customlist);523 }524 if (customhardcoolers.length > 0) {525 cmp.set("v.NotCustomlist", customhardcoolers);526 }527 if (lineItems.length > 0) {528 cmp.set("v.insertList", lineItems);529 }530 // console.log(cmp.get("v.insertList"));531 console.log(cmp.get("v.Coolerslist"));532 cmp.set("v.loaded", false);533 534 }535 } else if (state === "INCOMPLETE") {536 // do something537 cmp.set("v.loaded", false);538 helper.showToast(cmp, "Error!", "Error", "transaction is in complete" );539 } else if (state === "ERROR") {540 var errors = response.getError();541 if (errors) {542 if (errors[0] && errors[0].message) {543 console.log("Error message: " +544 errors[0].message);545 cmp.set("v.loaded", false);546 helper.showToast(cmp, "Error!", "Error", errors[0].message );547 }548 } else {549 console.log("Unknown error");550 cmp.set("v.loaded", false);551 helper.showToast(cmp, "Error!", "Error", "Unknown error");552 }553 }554 });555 $A.enqueueAction(getPricing);556 },557 onQuantityChange: function(component, event, helper) {558 console.log(event.target.name);559 console.log(event.target.id);560 console.log(event.target.value);561 if (event.target.name == 'Stock') {562 var Stocklist = component.get("v.Coolerslist");563 for (var i = 0; i < Stocklist.length; i++) {564 if (Stocklist[i].itemnumber == event.target.id) {565 console.log(Stocklist[i].itemnumber);566 Stocklist[i].Quantity = event.target.value;567 }568 }569 console.log(Stocklist);570 component.set("v.Coolerslist", Stocklist);571 console.log(component.get("v.Coolerslist"));572 } else if (event.target.name == 'Custom') {573 var CustomList = component.get("v.Customlist");574 for (let i = 0; i < CustomList.length; i++) {575 if (CustomList[i].itemnumber == event.target.id) {576 CustomList[i].Quantity = event.target.value;577 }578 }579 component.set("v.Customlist", CustomList);580 console.log(component.get("v.Customlist"));581 }582 else if(event.target.name == 'NonCustom') {583 var nonCustomList = component.get("v.NotCustomlist");584 for (let i = 0; i < nonCustomList.length; i++) {585 if (nonCustomList[i].itemnumber == event.target.id) {586 nonCustomList[i].Quantity = event.target.value;587 }588 }589 component.set("v.NotCustomlist", nonCustomList);590 console.log(component.get("v.NotCustomlist"));591 }592 },593 onDiscountChange: function(component, event, helper) {594 console.log(event.target.name);595 console.log(event.target.id);596 console.log(event.target.value);597 if (event.target.name == 'Stock') {598 var Stocklist = component.get("v.Coolerslist");599 for (var i = 0; i < Stocklist.length; i++) {600 if (Stocklist[i].itemnumber == event.target.id) {601 console.log(Stocklist[i].itemnumber);602 Stocklist[i].Discount = event.target.value;603 }604 }605 console.log(Stocklist);606 component.set("v.Coolerslist", Stocklist);607 console.log(component.get("v.Coolerslist"));608 } else if (event.target.name == 'Custom') {609 var CustomList = component.get("v.Customlist");610 for (let i = 0; i < CustomList.length; i++) {611 if (CustomList[i].itemnumber == event.target.id) {612 CustomList[i].Discount = event.target.value;613 }614 }615 component.set("v.Customlist", CustomList);616 console.log(component.get("v.Customlist"));617 }618 else if (event.target.name == 'NonCustom') {619 var nonCustomList = component.get("v.NotCustomlist");620 for (let i = 0; i < nonCustomList.length; i++) {621 if (nonCustomList[i].itemnumber == event.target.id) {622 nonCustomList[i].Discount = event.target.value;623 }624 }625 component.set("v.NotCustomlist", nonCustomList);626 console.log(component.get("v.NotCustomlist"));627 }628 },629 changeMeasures: function(component, event, helper) {630 var key = event.target.name;631 var n = key.lastIndexOf('/');632 var category = key.substring(0, n);633 var measures = key.substring(n + 1);634 if (category == 'Stock') {635 var StockList = component.get("v.Coolerslist");636 for (let i = 0; i < StockList.length; i++) {637 if (StockList[i].itemnumber == event.target.id) {638 StockList[i].measure = measures;639 }640 }641 component.set("v.Coolerslist", StockList);642 console.log(component.get("v.Coolerslist"));643 } else if (category == 'Custom') {644 var CustomList = component.get("v.Customlist");645 for (let i = 0; i < CustomList.length; i++) {646 if (CustomList[i].itemnumber == event.target.id) {647 CustomList[i].measure = measures;648 }649 }650 component.set("v.Customlist", CustomList);651 console.log(component.get("v.Customlist"));652 }653 654 else {655 var nonCustomList = component.get("v.NotCustomlist");656 for (let i = 0; i < nonCustomList.length; i++) {657 if (nonCustomList[i].itemnumber == event.target.id) {658 nonCustomList[i].measure = measures;659 }660 }661 component.set("v.NotCustomlist", nonCustomList);662 console.log(component.get("v.NotCustomlist"));663 }664 },665 changeDiscount: function(component, event, helper) {666 667 var key = event.target.name;668 var n = key.lastIndexOf('/');669 var category = key.substring(0, n);670 var discount = key.substring(n + 1);671 console.log(category);672 if (category == 'Stock') {673 var StockList = component.get("v.Coolerslist");674 for (let i = 0; i < StockList.length; i++) {675 if (StockList[i].itemnumber == event.target.id) {676 StockList[i].Discountmeasure = discount;677 }678 }679 component.set("v.Coolerslist", StockList);680 console.log(component.get("v.Coolerslist"));681 } else if (category == 'Custom') {682 var CustomList = component.get("v.Customlist");683 for (let i = 0; i < CustomList.length; i++) {684 if (CustomList[i].itemnumber == event.target.id) {685 CustomList[i].Discountmeasure = discount;686 }687 }688 component.set("v.Customlist", CustomList);689 console.log(component.get("v.Customlist"));690 }691 else {692 console.log("entered");693 var nonCustomList = component.get("v.NotCustomlist");694 for (let i = 0; i < nonCustomList.length; i++) {695 if (nonCustomList[i].itemnumber == event.target.id) {696 nonCustomList[i].Discountmeasure = discount;697 }698 }699 component.set("v.NotCustomlist", nonCustomList);700 console.log(component.get("v.NotCustomlist"));701 }702 },703 704 navigatetoobject: function(component, event, helper) {705 console.log("test");706 try {707 var navEvt = $A.get("e.force:navigateToSObject");708 navEvt.setParams({709 "recordId": component.get("v.quoteID")710 711 });712 navEvt.fire();713 } catch (Err) {714 console.log(Err);715 }716 },717 ...

Full Screen

Full Screen

customList.js

Source:customList.js Github

copy

Full Screen

1Meteor.publishComposite("customList", function(_id, limit) {2 // We only want to publish normally if either privacy is false, or the current user is the author of the list3 var customList = CustomLists.findOne({_id: _id});4 if (customList.privacy === false || (customList.privacy === true && this.userId === customList.userId)) {5 return {6 find: function() {7 return CustomLists.find({_id: _id});8 },9 children: [{10 find: function(customList) {11 var ids = _.pluck(customList.entries, 'contentId');12 switch (customList.type) {13 case "anime":14 return Anime.find({_id: {$in: ids}});15 case "characters":16 return Characters.find({_id: {$in: ids}});17 case "people":18 return People.find({_id: {$in: ids}});19 }20 }21 },22 {23 find: function(customList) {24 return Meteor.users.find({_id: customList.userId}, {fields: requireCollectionFields.user.defaultFields});25 }26 },27 {28 find: function(customList) {29 return Comments.find({contentId: customList._id}, {sort: {createdAt: -1}, limit: limit});30 },31 children: [{32 find: function(comment, customList) {33 // Only publish the users that haven't already been published (everone except current user, and author in this case)34 if (comment.userId !== this.userId && comment.userId !== customList.userId) {35 return Meteor.users.find({_id: comment.userId}, {fields: requireCollectionFields.user.defaultFields});36 }37 }38 }]39 }]40 };41 } else {42 return {43 find : function() {44 return CustomLists.find({_id: _id}, {fields: {privacy: 1}});45 }46 }47 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest');2tracetest.customList();3var list = ['a', 'b', 'c'];4exports.customList = function() {5 console.log(list);6};

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('./tracetest');2tracetest.customList();3exports.customList = function() {4 console.log("customList");5}6exports.customList = function() {7 console.log("customList");8}9exports.customList = function() {10 console.log("customList");11}12To import the tracetest module, add the following code to a file named test.js :13var tracetest = require('./tracetest');14tracetest.customList();

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest');2var list = tracetest.customList();3console.log(list);4var customList = function () {5 return [1, 2, 3];6};7module.exports.customList = customList;8var tracetest = require('tracetest');9var list = tracetest.customList();10console.log(list);11var customList = function () {12 return [1, 2, 3];13};14module.exports.customList = customList;15describe("Test customList method", function () {16 it("should return a list", function () {17 var list = customList();18 expect(list.length).toBeGreaterThan(0);19 });20});21var tracetest = require('tracetest');22var list = tracetest.customList();23console.log(list);24var customList = function () {25 return [1, 2, 3];26};27module.exports.customList = customList;28describe("Test customList method", function () {29 it("should return a list", function () {30 var list = tracetest.customList();31 expect(list.length).toBeGreaterThan(0);32 });33});

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest');2tracetest.customList();3exports.customList = function() {4 console.log('customList() called');5};6customList() called7customList() called8In the above code, we are using the customList() method from the tracetest modu

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest');2tracetest.customList('test');3exports.customList = function (name) {4 console.log('customList: ' + name);5};6var tracetest = require('tracetest');7tracetest.customList('test');8exports.customList = function (name) {9 console.log('customList: ' + name);10};11var tracetest = require('tracetest');12tracetest.customList('test');13exports.customList = function (name) {14 console.log('customList: ' + name);15};16var tracetest = require('tracetest');17tracetest.customList('test');18exports.customList = function (name) {19 console.log('customList: ' + name);20};21var tracetest = require('tracetest');22tracetest.customList('test');23exports.customList = function (name) {24 console.log('customList: ' + name);25};26var tracetest = require('tracetest');27tracetest.customList('test');28exports.customList = function (name) {29 console.log('customList: ' + name);30};31var tracetest = require('tracetest');32tracetest.customList('test

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tracetest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful