How to use isCoreComponent method in Playwright Internal

Best JavaScript code snippet using playwright-internal

review.controller.js

Source:review.controller.js Github

copy

Full Screen

1(function () {2'use strict';3 angular.module('hrTool.review')4 .controller('hrTool.review', ['hrTool.review.dataservice', '$log', 'hrTool.events', '$rootScope', '$state', '$stateParams', 'config', 'hrTool.widgets.dataservice', 'hrTool.storage', ReviewController]);5 function ReviewController(service, logger, hrToolEvents, $rootScope, $state, $stateParams, config, widgetsDataService, hrToolStorage) {6 var vm = this;7 vm.currentEmployee = {8 currentRole: {}, performanceHeaderText: "", reviewQuestions: [], salary: {effectiveDate: new Date()}, goals: "", overallScore: 0,9 supervisorReviewDate: new Date(), deptHeadReviewDate: new Date(), adminReviewDate: new Date(), employeeReviewDate: new Date(),10 signatureUrl1: "", signatureUrl2: "", signatureUrl3: "", signatureUrl4: "", state: "",11 signatureLabel1: "", signatureLabel2: "", signatureLabel3: "", signatureLabel4: "", subsequentReview: 012 };13 vm.currentNav = '';14 // Progress Bars15 vm.progressBarCurrent = 1;16 vm.progressBarMax = 0;17 vm.overallProgressBarCurrent = 1;18 vm.overallProgressBarMax = 3;19 vm.progressBarNonCoreIndex = 0;20 vm.coreComponentsPrefaceText = "Core Components of the job directly reflects the employee\'s understanding of their position, and how to accomplish the essential functions of that position. Miller\'s goal is to train and develop all employees in a manor that aides them in the accomplishment of this goal.";21 vm.isSigning = false;22 vm.isFinalizing = false; //state for department heads and location admin putting the final touches on it.23 var pdfMargins = {24 top: 0.5,25 bottom: 0.5,26 left: 0.5,27 width: 7.528 };29 var defaultSignaturePenColor = "rgb(255,250,250)";30 var defaultReviewRoute = 'review.start';31 var defaultHomeRedirect = 'home.myInfo';32 $rootScope.$on("$stateChangeSuccess", function(event, next, current) {33// console.log("$stateChangeSuccess")34 if ($state.current.name=='review'){35 $state.go(defaultReviewRoute);36 }37 loadCurrentReviewPageData($state.current.name);38 vm.currentNav = $state.current.name;39 });40 activate();41 // #region Implementation42 function activate() {43 vm.startCore = startCore;44 vm.startQuestions = startQuestions;45 vm.signatureStart = signatureStart;46 vm.signatureClear = signatureClear;47 vm.signatureAccept = signatureAccept;48 vm.reviewFinalize= reviewFinalize;49 vm.reviewDone= reviewDone;50 vm.printSalary = printSalary;51 vm.printReview = printReview;52 vm.completeGoals = completeGoals;53 vm.storeLocalChanges = storeLocalChanges;54 vm.loadReviewData = loadReviewData;55 vm.submitReview = submitReview;56 vm.nextQuestion = nextQuestion;57 vm.hardResetReview = hardResetReview;58// var currentReviewData = localStorageService.get("currentReview");59 var currentReviewData = service.getReviewData();60 if (currentReviewData==null){61 $state.go(defaultHomeRedirect);62 }63 else{64 vm.currentEmployee = angular.copy(currentReviewData);65 if (!vm.currentEmployee.hasOwnProperty('currentRole')) {66// Placeholder Until Data Retrieved67 vm.currentEmployee.lastReviewDate = new Date();68 vm.currentEmployee.nextReviewDate = new Date();69 vm.currentEmployee.actualReviewDate = new Date();70 vm.loadReviewData();71 }72 else{73// console.log("has Current ROle")74// console.log(vm.currentEmployee)75// console.log(vm.currentEmployee.actualReviewDate )76// console.log(typeof vm.currentEmployee.actualReviewDate )77// console.log(typeof (new Date(vm.currentEmployee.actualReviewDate )) );78 //TODO - if date nothing, if string convert, if int conver79 if (vm.currentEmployee.hasOwnProperty('actualReviewDate')) {80 vm.currentEmployee.actualReviewDate = new Date(vm.currentEmployee.actualReviewDate);81 }82 if (vm.currentEmployee.hasOwnProperty('nextReviewDate')) {83 vm.currentEmployee.nextReviewDate = new Date(vm.currentEmployee.nextReviewDate);84 }85 if (vm.currentEmployee.hasOwnProperty('lastReviewDate')) {86 vm.currentEmployee.lastReviewDate = new Date(vm.currentEmployee.lastReviewDate);87 }88 if (vm.currentEmployee.hasOwnProperty('salary')) {89 if (vm.currentEmployee.salary.hasOwnProperty('effectiveDate')) {90 vm.currentEmployee.salary.effectiveDate = new Date(vm.currentEmployee.salary.effectiveDate);91 }92 else{93 vm.currentEmployee.salary.effectiveDate = new Date();94 }95 }96 else{97 vm.currentEmployee.salary = {effectiveDate: new Date()};98 }99// console.log('supervisorReviewDate')100// console.log(vm.currentEmployee.supervisorReviewDate)101 if (vm.currentEmployee.hasOwnProperty('supervisorReviewDate')) {102 vm.currentEmployee.supervisorReviewDate = new Date(vm.currentEmployee.supervisorReviewDate);103 vm.currentEmployee.deptHeadReviewDate = new Date(vm.currentEmployee.deptHeadReviewDate);104 vm.currentEmployee.adminReviewDate = new Date(vm.currentEmployee.adminReviewDate);105 vm.currentEmployee.employeeReviewDate = new Date(vm.currentEmployee.employeeReviewDate);106 }107 if (vm.currentEmployee.hasOwnProperty('reviewQuestions')) {108// console.log("has review questions "+ vm.currentEmployee.reviewQuestions.length)109 // vm.progressBarMax = vm.currentEmployee.reviewQuestions.length;110 var nonCoreQuestionIndex = [];111 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {112 if (!aQuest.isCoreComponent){113 vm.progressBarMax ++;114 nonCoreQuestionIndex.push(ind);115 }116 });117 vm.progressBarNonCoreIndex = nonCoreQuestionIndex[vm.progressBarCurrent - 1];118 }119 }120 if (vm.currentEmployee.hasOwnProperty('state')) {121 var state = vm.currentEmployee.state;122// console.log('state ' + state);123// console.log('review.isFinalizing ' + vm.isFinalizing);124 if (state=='Completed'){125 vm.isFinalizing = true;126 }127 }128 if ($state.current.name=='review'){129 $state.go(defaultReviewRoute);130 }131 loadCurrentReviewPageData($state.current.name);132 vm.currentNav = $state.current.name;133 }134 }135 function loadCurrentReviewPageData(currentReviewRoute){136// console.log(currentReviewRoute + " || state: " + vm.currentEmployee.state);137 switch(currentReviewRoute) {138 case 'review.print':139 break;140 case 'review.core':141 vm.overallProgressBarCurrent = 1;142 break;143 case 'review.questions':144// console.log('admin questions');145 if (vm.currentEmployee.hasOwnProperty('reviewQuestions')) {146// console.log("has review questions "+ vm.currentEmployee.reviewQuestions.length)147 // vm.progressBarMax = vm.currentEmployee.reviewQuestions.length;148 var nonCoreQuestionIndex = [];149 vm.progressBarMax = 0;150 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {151 if (!aQuest.isCoreComponent){152 vm.progressBarMax ++;153 nonCoreQuestionIndex.push(ind);154 }155 });156 vm.progressBarNonCoreIndex = nonCoreQuestionIndex[vm.progressBarCurrent - 1];157 }158 var q = $state.params.qId159 if (q == null || q <= 0){160// $location.search('q', null)161// var q = $state.params.qId162 vm.progressBarCurrent = 1;163 }164 else if(q >= vm.progressBarMax){165// $location.search('q', vm.progressBarMax)166 vm.progressBarCurrent = vm.progressBarMax;167 }168 else{169 vm.progressBarCurrent = Number(q);170 }171 var nonCoreQuestionIndex = [];172 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {173 if (!aQuest.isCoreComponent){174 nonCoreQuestionIndex.push(ind);175 }176 });177 vm.progressBarNonCoreIndex = nonCoreQuestionIndex[vm.progressBarCurrent -1];178 vm.overallProgressBarCurrent = 1;179// if (vm.currentEmployee.hasOwnProperty('reviewQuestions')) {180// console.log("has review questions "+ vm.currentEmployee.reviewQuestions.length)181// // vm.progressBarMax = vm.currentEmployee.reviewQuestions.length;182// var nonCoreQuestionIndex = [];183// angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {184// if (!aQuest.isCoreComponent){185// vm.progressBarMax ++;186// nonCoreQuestionIndex.push(ind);187// }188// });189// vm.progressBarNonCoreIndex = nonCoreQuestionIndex[vm.progressBarCurrent - 1];190// }191 break;192 case 'review.goals':193 vm.overallProgressBarCurrent = 2;194 break;195 case 'review.salary':196 vm.overallProgressBarCurrent = 3;197 break;198 case 'review.start':199 //loadStart();200// console.log("loadStart")201// console.log(vm.currentEmployee.state)202 break;203 default:204// console.log("review default break")205 }206 }207 function nextQuestion(){208 //console.log("nextQuestion");209 var nonCoreQuestionIndex = [];210 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {211 if (!aQuest.isCoreComponent){212 nonCoreQuestionIndex.push(ind);213 }214 });215 //if (!vm.currentEmployee.reviewQuestions[vm.progressBarCurrent - 1].score){216 if (!vm.currentEmployee.reviewQuestions[vm.progressBarNonCoreIndex].score){217 hrToolEvents.broadcastAlertWarning("Please enter a score for the question."); //TODO Use events218 }219 else{220 storeLocalChanges();221// console.log(vm.progressBarMax)222// console.log(vm.progressBarCurrent)223 if ((vm.progressBarCurrent + 1) > vm.progressBarMax){224// //console.log("last question jump to goals")225// $location.search('q', null);226// $location.search('v', 'reviewGoals');227// vm.currentNav = 'reviewGoals';228// vm.overallProgressBarCurrent = 2;229// //vm.navClick('reviewGoals');230 $state.go('review.goals');231 }232 else{233 vm.progressBarCurrent = (vm.progressBarCurrent + 1);234 vm.progressBarNonCoreIndex = nonCoreQuestionIndex[vm.progressBarCurrent -1 ];235 $state.go('review.questions', {qId: vm.progressBarCurrent});236// $location.search('q', vm.progressBarCurrent);237 }238 }239 };240 function storeLocalChanges(){241// console.log("storeLocalChanges");242 var currentScore = 0;243 if (vm.currentEmployee.hasOwnProperty('reviewQuestions') && (typeof vm.currentEmployee.reviewQuestions != 'undefined')){244 for(var i = 0; i < vm.currentEmployee.reviewQuestions.length; i++){245 var aQuestion = vm.currentEmployee.reviewQuestions[i];246 if (angular.isNumber(aQuestion.score)){247 currentScore += aQuestion.score;248 }249 }250 }251 vm.currentEmployee.overallScore = currentScore;252 // console.log("overallScore " + vm.currentEmployee.overallScore)253 service.updateReviewData(angular.copy(vm.currentEmployee));254 //console.log("storing data to database");255 var reviewPayload = angular.copy(vm.currentEmployee);256 reviewPayload.lastReviewDate = new Date(reviewPayload.lastReviewDate).getTime();257 reviewPayload.nextReviewDate = new Date(reviewPayload.nextReviewDate).getTime();258 reviewPayload.actualReviewDate = new Date(reviewPayload.actualReviewDate).getTime();259 reviewPayload.supervisorReviewDate = new Date(reviewPayload.supervisorReviewDate).getTime();260 reviewPayload.deptHeadReviewDate = new Date(reviewPayload.deptHeadReviewDate).getTime();261 reviewPayload.adminReviewDate = new Date(reviewPayload.adminReviewDate).getTime();262 reviewPayload.employeeReviewDate = new Date(reviewPayload.employeeReviewDate).getTime();263 if (vm.currentEmployee.hasOwnProperty('salary')) {264 if (vm.currentEmployee.salary.hasOwnProperty('effectiveDate')) {265 reviewPayload.salary.effectiveDate = new Date(reviewPayload.salary.effectiveDate).getTime();266 }267 else{268 reviewPayload.salary.effectiveDate = new Date().getTime();269 }270 }271 else{272 reviewPayload.salary = {effectiveDate: new Date().getTime()};273 }274 //console.log("reviewEmployeeId: " + reviewEmployeeId)275 //console.log(reviewPayload)276 delete reviewPayload._id;277 service.saveReviewData(reviewPayload).then(function(data) {278 if (data){279 //console.log("stored data to database");280 }281 else{282 //console.log("failed to store database");283 }284 });285 }286 function startCore() {287 storeLocalChanges();288 if (vm.currentEmployee.currentRole.hasCoreComponentsQuestion){289 // console.log("hasCoreComponentsQuestion");290// vm.navClick('reviewCore');291 $state.go('review.core');292 }293 else{294// vm.navClick('reviewQuestions');295 $state.go('review.questions');296 }297 }298 function startQuestions(){299 // console.log("startQuestions");300 storeLocalChanges();301 // set index to first core components question302 var foundNonCoreQuestion = false;303 var nonCoreQuestionIndex = [];304 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {305 if (!aQuest.isCoreComponent){306 if (!foundNonCoreQuestion){307 //console.log("START QUESTOIN INDEX FOUND - " + ind);308 //console.log(JSON.stringify(aQuest));309 vm.progressBarNonCoreIndex = ind;310 foundNonCoreQuestion = true;311 }312 nonCoreQuestionIndex.push(ind);313 }314 });315 $state.go('review.questions');316 // console.log("START QUESTOIN nonCoreQuestionIndex - " + nonCoreQuestionIndex);317 // console.log("progressBarNonCoreIndexprogressBarNonCoreIndexprogressBarNonCoreIndex - " + vm.progressBarNonCoreIndex);318 };319 function submitReview(){320 // if (vm.currentEmployee.salary.employeeComments.length==0){321 // hrToolEvents.broadcastAlertWarning("Please enter a comment for the Salary section.");322 // }323 // else{324 storeLocalChanges();325 $state.go('review.print');326 // }327 };328 function completeGoals(){329 if (vm.currentEmployee.goals.length==0 || vm.currentEmployee.education.length==0 || vm.currentEmployee.growthOpportunities.length==0){330 hrToolEvents.broadcastAlertWarning("Please enter a comment for each of the three section.");331 }332 else{333 storeLocalChanges();334 $state.go('review.salary')335 }336 };337 function signatureStart (){338 // console.log("signatureStart");339 vm.isSigning = true;340 var canvas = $('#signatureCanvas').get(0);341 var canvas2 = $('#signatureCanvas2').get(0);342 var canvas3 = $('#signatureCanvas3').get(0);343 var canvas4 = $('#signatureCanvas4').get(0);344 var ctx=canvas.getContext("2d");345 var ctx2=canvas2.getContext("2d");346 var ctx3=canvas3.getContext("2d");347 var ctx4=canvas4.getContext("2d");348 var signaturePad = new SignaturePad(canvas);349 var signaturePad2 = new SignaturePad(canvas2);350 var signaturePad3 = new SignaturePad(canvas3);351 var signaturePad4 = new SignaturePad(canvas4);352 signaturePad.penColor=defaultSignaturePenColor;353 signaturePad2.penColor=defaultSignaturePenColor;354 signaturePad3.penColor=defaultSignaturePenColor;355 signaturePad4.penColor=defaultSignaturePenColor;356 if (vm.currentEmployee.signatureUrl1.length>0){357 var img = new Image;358 img.onload = function(){359 ctx.drawImage(img,0,0);360 };361 img.src = vm.currentEmployee.signatureUrl1;362 }363 if (vm.currentEmployee.signatureUrl2.length>0){364 var img2 = new Image;365 img2.onload = function(){366 ctx2.drawImage(img2,0,0);367 }368 img2.src = vm.currentEmployee.signatureUrl2;369 }370 if (vm.currentEmployee.signatureUrl3.length>0){371 var img3 = new Image;372 img3.onload = function(){373 ctx3.drawImage(img3,0,0);374 };375 img3.src = vm.currentEmployee.signatureUrl3;376 }377 if (vm.currentEmployee.signatureUrl4.length>0){378 var img4 = new Image;379 img4.onload = function(){380 ctx4.drawImage(img4,0,0);381 };382 img4.src = vm.currentEmployee.signatureUrl4;383 }384 };385 function signatureClear(signaturePadInt){386 if (signaturePadInt === undefined){387 signaturePadInt = '';388 }389 var canvasStringName = '#signatureCanvas' + signaturePadInt;390 // console.log("signatureClear " + canvasStringName);391 var canvas = $(canvasStringName).get(0);392 var ctx=canvas.getContext("2d");393 ctx.clearRect(0,0, canvas.width, canvas.height);394 };395 function signatureAccept(signaturePadInt){396 if (signaturePadInt === undefined){397 signaturePadInt = '';398 }399 var canvasStringName = '#signatureCanvas' + signaturePadInt;400 // console.log("signatureClear " + canvasStringName);401 var canvas = $(canvasStringName).get(0);402 var ctx=canvas.getContext("2d");403 var imgData=ctx.getImageData(0,0,canvas.width, canvas.height);404 var dataURL = canvas.toDataURL("image/jpeg", 1.0);405 // console.log(dataURL);406 if (signaturePadInt == '2'){407 vm.currentEmployee.signatureUrl2 = dataURL;408 }409 else if (signaturePadInt == '3'){410 vm.currentEmployee.signatureUrl3 = dataURL;411 }412 else if (signaturePadInt == '4'){413 vm.currentEmployee.signatureUrl4 = dataURL;414 }415 else{416 vm.currentEmployee.signatureUrl1 = dataURL;417 }418 //vm.isSigning = false;419 storeLocalChanges();420 hrToolEvents.broadcastAlertSuccess("Signature saved.");421 };422 function reviewFinalize(){423 //console.log("reviewFinalize");424 vm.currentEmployee.state = "Finalized";425 storeLocalChanges();426 hrToolEvents.broadcastAlertSuccess("Review Finalized.");427 $state.go(defaultHomeRedirect)428 };429 function reviewDone(){430 // console.log("reviewDone");431 vm.currentEmployee.state = "Completed";432 // console.log("reviewDone " + vm.currentEmployee.state );433 storeLocalChanges();434 hrToolEvents.broadcastAlertSuccess("Review Completed.");435// vm.redirectDefault();436 $state.go(defaultHomeRedirect)437 };438 //TODO: Move Print Review Here439 function printReview(){440// console.log("printRev")441 $rootScope.$broadcast("printReviewEvent", vm.currentEmployee);442 //hrToolEvents.printReviewEvent(vm.currentReview);443// var aReview = vm.currentReview;444////445//// vm.currentReview.salary.effectiveDate = new Date(vm.currentReview.salary.effectiveDate).toLocaleString();446//// vm.currentReview.supervisorReviewDate = new Date(vm.currentReview.supervisorReviewDate).toLocaleString();447//// vm.currentReview.deptHeadReviewDate = new Date(vm.currentReview.deptHeadReviewDate).toLocaleString();448//// vm.currentReview.adminReviewDate = new Date(vm.currentReview.adminReviewDate).toLocaleString();449//// vm.currentReview.employeeReviewDate = new Date(vm.currentReview.employeeReviewDate).toLocaleString();450//451//// hrToolEvents.printReviewEvent(vm.currentReview);452 }453 function hardResetReview(){454 //console.log('hardResetReview')455 return service.hardResetReview(vm.currentEmployee).then(function(data) {456// console.log("hardResetReview ctrl");457// console.log(data.performanceHeaderText);458// console.log(vm.currentEmployee.currentRole.performanceHeaderText);459 if (data){460 var newReviewData = data;461// console.log(data);462 // Overwrite New Data463 var userData = widgetsDataService.getLocalUserData();464// console.log("subsequent review")465// vm.currentEmployee = newReviewData;466 vm.isFinalizing = false;467 //newReviewData.performanceHeaderText = vm.performanceHeaderText;468 newReviewData.subsequentReview = userData.subsequentReview;469// newReviewData.state = 'Started';470 vm.currentEmployee.currentRole = newReviewData;471 vm.currentEmployee.reviewEmployeeId = data.reviewEmployeeId;472 vm.currentEmployee.reviewId = data.reviewId;473 //vm.currentEmployee.currentRole = $sce.trustAsHtml(vm.currentEmployee.currentRole.performanceHeaderText);474 vm.currentEmployee.reviewQuestions = angular.copy(vm.currentEmployee.currentRole.questions);475 vm.currentEmployee.lastReviewDate = new Date(vm.currentEmployee.lastReviewDate);476 vm.currentEmployee.nextReviewDate = new Date(vm.currentEmployee.nextReviewDate);477 // vm.currentEmployee.scheduledReviewDate = new Date(vm.currentEmployee.scheduledReviewDate);478 vm.currentEmployee.actualReviewDate = new Date();479 vm.currentEmployee.overallScore = 0;480 //vm.progressBarMax = vm.currentEmployee.reviewQuestions.length;481 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {482 if (!aQuest.isCoreComponent){483 vm.progressBarMax ++;484 }485 });486 vm.currentEmployee.salary = {487 currentRateOfPay: null,488 currentSalaryGrade: null,489 yearsOfService: null, //TODO: AUTO SET?490 proposedRateOfPay: null,491 proposedSalaryGrade: null,492 effectiveDate: new Date().getTime(),493 followsFacilityWageApproval: null,494 explanation: "",495 employeeComments: ""496 };497 vm.currentEmployee.signatureUrl1 = "";498 vm.currentEmployee.signatureUrl2 = "";499 vm.currentEmployee.signatureUrl3 = "";500 vm.currentEmployee.signatureUrl4 = "";501 vm.currentEmployee.signatureLabel1 = "";502 vm.currentEmployee.signatureLabel2 = "";503 vm.currentEmployee.signatureLabel3 = "";504 vm.currentEmployee.signatureLabel4 = "";505 vm.currentEmployee.supervisorReviewDate = new Date().getTime();506 vm.currentEmployee.deptHeadReviewDate = new Date().getTime();507 vm.currentEmployee.adminReviewDate = new Date().getTime();508 vm.currentEmployee.employeeReviewDate = new Date().getTime();509 vm.currentEmployee.goals = "";510 vm.currentEmployee.state = "Started";511 //vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;512//513// if (vm.currentEmployee.hasOwnProperty('currentRole')){514// if (vm.currentEmployee.currentRole.hasOwnProperty('subsequentReview')){515// vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;516// }517// }518 hrToolStorage.setStorage(config.review_info_path, newReviewData);519 //service.createReview(currentReviewData);520 hrToolEvents.broadcastAlertSuccess("The review has been reset."); //TODO Use events521// $state.go(defaultReviewRoute)522 }523 });524 }525 function printSalary(){526// console.log("printSalary");527 var reportName = 'Salary Report ' + new Date().toLocaleString();528 var reportExt = '.pdf';529 var reportFileName = reportName + reportExt;530 var pdfDoc = new jsPDF('p', 'in', 'letter');531 var source = $('#printReviewHTML').first();532 var specialElementHandlers = {533 '#bypassme': function(element, renderer) {534 return true;535 }536 };537 pdfDoc.page = 1;538 var roleTitleAndEmployeeName = vm.currentEmployee.roleName + ' - ' + vm.currentEmployee.employeeName;539 pdfDoc.text(0.25, 0.5, roleTitleAndEmployeeName);540 pdfDoc.fromHTML(541 $('#printReviewHTMLPage5').get(0),542 pdfMargins.left, // x coord543 pdfMargins.top, // y coord544 {545 'width': pdfMargins.width, // max width of content on PDF546 'elementHandlers': specialElementHandlers547 }548 );549 pdfDoc.save(reportFileName);550 };551 function loadReviewData(){552// console.log("loadReviewData");553// console.log(vm.currentEmployee)554 // Placeholder Until Data Retrieved555// if ()556// vm.currentEmployee.lastReviewDate = new Date(vm.currentEmployee.lastReviewDate);557// vm.currentEmployee.nextReviewDate = new Date(vm.currentEmployee.nextReviewDate);558// vm.currentEmployee.actualReviewDate = new Date();559 var currentRoleId = vm.currentEmployee.role;560 var reviewEmployeeId = vm.currentEmployee._id;561 var currentEmployee = vm.currentEmployee.employeeName;562 var reviewDataPayload = {roleId: currentRoleId, reviewEmployeeId: reviewEmployeeId, employeeName: currentEmployee};563// console.log(reviewDataPayload)564 return service.loadReviewData(reviewDataPayload).then(function(data) {565// console.log("loadReviewData ctrl");566// console.log(data);s567// console.log(data.state);568// console.log(vm.currentEmployee.currentRole.performanceHeaderText);569 if (data){570 if (!data.isNew){571// console.log("not new");572// console.log(vm.currentEmployee.employeeReviewDate);573 var empName = vm.currentEmployee.employeeName;574 vm.currentEmployee = data;575 vm.currentEmployee.employeeName = empName;576 vm.currentEmployee.lastReviewDate = new Date(vm.currentEmployee.lastReviewDate);577 vm.currentEmployee.nextReviewDate = new Date(vm.currentEmployee.nextReviewDate);578 vm.currentEmployee.actualReviewDate = new Date(vm.currentEmployee.actualReviewDate);579 vm.currentEmployee.supervisorReviewDate = new Date(vm.currentEmployee.supervisorReviewDate);580 vm.currentEmployee.deptHeadReviewDate = new Date(vm.currentEmployee.deptHeadReviewDate);581 vm.currentEmployee.adminReviewDate = new Date(vm.currentEmployee.adminReviewDate);582 vm.currentEmployee.employeeReviewDate = new Date(vm.currentEmployee.employeeReviewDate);583 //vm.currentEmployee.effectiveDate = new Date(vm.currentEmployee.employeeReviewDate);584 if (vm.currentEmployee.hasOwnProperty('salary')){585 if (vm.currentEmployee.salary.hasOwnProperty('effectiveDate')){586 vm.currentEmployee.salary.effectiveDate = new Date(vm.currentEmployee.salary.effectiveDate);587 }588 else{589 vm.currentEmployee.salary.effectiveDate = new Date();590 }591 }592 else{593 vm.currentEmployee.salary = {effectiveDate: new Date()};594 }595 if (vm.currentEmployee.hasOwnProperty('currentRole')){596 if (vm.currentEmployee.currentRole.hasOwnProperty('subsequentReview')){597 vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;598 }599 }600 vm.currentEmployee.reviewId = vm.currentEmployee._id;601// vm.currentEmployee.state= vm.currentEmployee.state;602// vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;603 //TODO: Validate Below Change604// if (vm.currentEmployee.hasOwnProperty('currentRole')){605// if (vm.currentEmployee.currentRole.hasOwnProperty('subsequentReview')){606// vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;607// }608// }609// console.log(vm.currentEmployee.salary);610// console.log(vm.currentEmployee.state);611 }612 else{613// console.log("new");614// console.log(data);615// console.log(data.effectiveDate);616 vm.currentEmployee.currentRole = data;617 vm.currentEmployee.reviewEmployeeId = data.reviewEmployeeId;618 vm.currentEmployee.reviewId = data.reviewId;619 //vm.currentEmployee.currentRole = $sce.trustAsHtml(vm.currentEmployee.currentRole.performanceHeaderText);620 vm.currentEmployee.reviewQuestions = angular.copy(vm.currentEmployee.currentRole.questions);621 vm.currentEmployee.lastReviewDate = new Date(vm.currentEmployee.lastReviewDate);622 vm.currentEmployee.nextReviewDate = new Date(vm.currentEmployee.nextReviewDate);623// vm.currentEmployee.scheduledReviewDate = new Date(vm.currentEmployee.scheduledReviewDate);624 vm.currentEmployee.actualReviewDate = new Date();625 vm.currentEmployee.overallScore = 0;626 //vm.progressBarMax = vm.currentEmployee.reviewQuestions.length;627 angular.forEach(vm.currentEmployee.reviewQuestions, function(aQuest, ind) {628 if (!aQuest.isCoreComponent){629 vm.progressBarMax ++;630 }631 });632 vm.currentEmployee.salary = {633 currentRateOfPay: null,634 currentSalaryGrade: null,635 yearsOfService: null, //TODO: AUTO SET?636 proposedRateOfPay: null,637 proposedSalaryGrade: null,638 effectiveDate: new Date().getTime(),639 followsFacilityWageApproval: null,640 explanation: "",641 employeeComments: ""642 };643 vm.currentEmployee.signatureUrl1 = "";644 vm.currentEmployee.signatureUrl2 = "";645 vm.currentEmployee.signatureUrl3 = "";646 vm.currentEmployee.signatureUrl4 = "";647 vm.currentEmployee.signatureLabel1 = "";648 vm.currentEmployee.signatureLabel2 = "";649 vm.currentEmployee.signatureLabel3 = "";650 vm.currentEmployee.signatureLabel4 = "";651 vm.currentEmployee.supervisorReviewDate = new Date().getTime();652 vm.currentEmployee.deptHeadReviewDate = new Date().getTime();653 vm.currentEmployee.adminReviewDate = new Date().getTime();654 vm.currentEmployee.employeeReviewDate = new Date().getTime();655 vm.currentEmployee.goals = "";656 vm.currentEmployee.state = "Started";657 //vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;658 if (vm.currentEmployee.hasOwnProperty('currentRole')){659 if (vm.currentEmployee.currentRole.hasOwnProperty('subsequentReview')){660 vm.currentEmployee.subsequentReview = vm.currentEmployee.currentRole.subsequentReview;661 }662 }663// console.log(vm.currentEmployee.state);664 }665 var state = vm.currentEmployee.state;666 if (state=='Completed'){667 vm.isFinalizing = true;668 }669 vm.storeLocalChanges();670 }671 });672 };673 function printReview2 (){674// console.log("printReview");675 var reportName = 'Report ' + new Date().toLocaleString();676 var reportExt = '.pdf';677 var reportFileName = reportName + reportExt;678 var pdfDoc = new jsPDF('p', 'in', 'letter');679 var source = $('#printReviewHTML').first();680 var specialElementHandlers = {681 '#bypassme': function(element, renderer) {682 return true;683 }684 };685 pdfDoc.page = 1;686 pdfDoc.fromHTML(687 $('#printReviewHTMLPage1').get(0),688 pdfMargins.left, // x coord689 pdfMargins.top, // y coord690 {691 'width': pdfMargins.width, // max width of content on PDF692 'elementHandlers': specialElementHandlers693 }694 );695 var numberOfPages = 6;696 var i = 2;697 for (i = 2; i <= numberOfPages; i++) {698 //pdfDoc.page = i;699 var pageHTMLContent ='#printReviewHTMLPage' + i;700// console.log(pageHTMLContent)701// console.log(i)702 if (i==2){703 var corePageHeader = true;704 var corePageHeaderText = '<h3>Core Components</h3><div style="padding-bottom: 10px;">' + vm.coreComponentsPrefaceText + '</div><h4>Core Components of Job:</h4>';705 angular.forEach(vm.currentEmployee.reviewQuestions, function(question) {706 if (question.isCoreComponent) {707 var coreComponentScore = "Not Met";708 if (question.score==1){709 coreComponentScore = "Met";710 }711 var nextQuestionDiv = '<div><span>'+coreComponentScore+'</span> <hr> <b>'+question.title+'</b> <hr> <p> <i>Comments: </i>'+question.comments+'</p></div>';712 if (corePageHeader){713 nextQuestionDiv = corePageHeaderText + ' ' + nextQuestionDiv;714 corePageHeader = false;715 }716 pdfDoc.page ++;717 pdfDoc.addPage();718 pdfDoc.fromHTML(719 nextQuestionDiv,720 0.5, // x coord721 0.5, // y coord722 {723 'width': 7.5, // max width of content on PDF724 'elementHandlers': specialElementHandlers725 }726 );727 }728 });729 }730 else if (i==3){731 //console.log("currentpage is Review Questions + iterate over quesitons and print them")732 //console.log(pdfDoc.page)733 //console.log(vm.currentReview.reviewQuestions);734 var nonCorePageHeader = true;735 var nonCorePageHeaderText = '<h3>Review Questions</h3>';736 angular.forEach(vm.currentEmployee.reviewQuestions, function(question) {737 if (!question.isCoreComponent) {738 var nextQuestionDiv = '<div style="padding-bottom: 3px;"><div class="row"><div class="col-md-12"><h5>' + question.title + '</h5> <h5>Score: '+question.score+'</h5>'+question.text+'</div><p></br> </br> <i>Comments: </i>'+question.comments+'</p></div><p>----------------</p></div>';739 if (nonCorePageHeader){740 nextQuestionDiv = nonCorePageHeaderText + ' ' + nextQuestionDiv;741 nonCorePageHeader = false;742 }743 pdfDoc.page ++;744 pdfDoc.addPage();745 pdfDoc.fromHTML(746 nextQuestionDiv,747 0.5, // x coord748 0.5, // y coord749 {750 'width': 7.5, // max width of content on PDF751 'elementHandlers': specialElementHandlers752 }753 );754 }755 });756 }757 else{758 pdfDoc.page ++;759 pdfDoc.addPage();760 pdfDoc.fromHTML(761 $(pageHTMLContent).get(0),762 0.5, // x coord763 0.5, // y coord764 {765 'width': 7.5, // max width of content on PDF766 'elementHandlers': specialElementHandlers767 }768 );769 }770 }771 pdfDoc.page = (numberOfPages + 1);772 pdfDoc.addPage();773 if (vm.currentEmployee.hasOwnProperty('signatureUrl1')){774 var imageDataUrl = vm.currentEmployee.signatureUrl1 ;775 if (imageDataUrl.length>0){776// console.log("save PDF - has signatureUrl1")777 pdfDoc.text(0.25, 0.4, vm.currentEmployee.signatureLabel1);778 //pdfDoc.addImage(imageDataUrl, 'JPEG', 15, 40, 180, 45)779 pdfDoc.addImage(imageDataUrl, 'JPEG', 0.25, 0.5, 8, 3)780 }781 }782 if (vm.currentEmployee.hasOwnProperty('signatureUrl2')){783 var imageDataUrl = vm.currentEmployee.signatureUrl2 ;784 if (imageDataUrl.length>0){785// console.log("save PDF - has signatureUrl2")786 pdfDoc.text(0.25, 3.85, vm.currentEmployee.signatureLabel2);787 //pdfDoc.addImage(imageDataUrl, 'JPEG', 15, 40, 180, 45)788 pdfDoc.addImage(imageDataUrl, 'JPEG', 0.25, 4.15, 8, 3)789 }790 }791 if (vm.currentEmployee.hasOwnProperty('signatureUrl3')){792 var imageDataUrl = vm.currentEmployee.signatureUrl3;793 if (imageDataUrl.length>0){794// console.log("save PDF - has signatureUrl3")795 pdfDoc.text(0.25, 7.65, vm.currentEmployee.signatureLabel3);796 //pdfDoc.addImage(imageDataUrl, 'JPEG', 15, 40, 180, 45)797 pdfDoc.addImage(imageDataUrl, 'JPEG', 0.25, 7.85, 8, 3)798 }799 }800 if (vm.currentEmployee.hasOwnProperty('signatureUrl4')){801 pdfDoc.page = (numberOfPages + 1);802 pdfDoc.addPage();803 var imageDataUrl = vm.currentEmployee.signatureUrl4 ;804 if (imageDataUrl.length>0){805// console.log("save PDF - has signatureUrl4")806 pdfDoc.text(0.25, 0.4, vm.currentEmployee.signatureLabel4);807 //pdfDoc.addImage(imageDataUrl, 'JPEG', 15, 40, 180, 45);808 pdfDoc.addImage(imageDataUrl, 'JPEG', 0.25, 0.5, 8, 3);809 }810 }811 pdfDoc.save(reportFileName);812 //pdfDoc.output('dataurl');813 };814 // #endregion815 }...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1const fs = require("fs");2const path = require('path');3const reAssets = [4 /<(img|script|input)\s+(?:[^>]*?)src=((["']?)(.*?)\3)/ig,5 /<(link)\s+(?:[^>]*?)href=((["']?)(.*?)\3)/ig,6 /(url)\s*\(\s*((["']?)([^)]*)\3)\s*\)/ig7];8const reDuplicateAttributes = /([A-Za-z0-9-:]+?)\s*=\s*(["'])([^"']*?)\2([^>]*)\1\s*=\s*(["'])([^"]*)\5/;9const colouriseErrors = () => {10 // See https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color11 const originalError = console.error;12 const originalWarn = console.warn;13 console.error = (args) => {14 process.stdout.write("\x1b[31m"); // red15 originalError(args);16 process.stdout.write("\x1b[0m"); // reset17 }18 console.warn = (args) => {19 process.stdout.write("\x1b[33m"); // yellow20 originalWarn(args);21 process.stdout.write("\x1b[0m"); // reset22 }23};24const getPaths = (origin, url, alternativePrefixes = []) => {25 if (!Array.isArray(alternativePrefixes)) alternativePrefixes = [alternativePrefixes];26 const filename = path.basename(url);27 const root = getRoot();28 let filepath = "";29 let alternativePaths = [];30 if (url.indexOf("/") === 0) {31 filepath = path.join(root, url);32 alternativePaths = alternativePrefixes.map(prefix => path.join(root, prefix, url));33 } else if (url.indexOf("~/") === 0 || url.indexOf("@/") === 0) {34 filepath = path.join(root, url.substr(1));35 alternativePaths = alternativePrefixes.map(prefix => path.join(root, prefix, url.substr(1)));36 } else {37 filepath = path.resolve(path.dirname(origin), url);38 alternativePaths = alternativePrefixes.map(prefix => path.join(path.dirname(origin), prefix, url));39 }40 let folder = path.dirname(filepath).substr(root.length + 1).replace(/\\/g, "/") + "/";41 if (folder === "/") folder = "";42 return {43 path: filepath,44 folder: folder,45 filename: filename,46 alternativePaths47 };48};49const getRecursive = function(dir, extns, excludes = []) {50 if (!Array.isArray(extns)) extns = [extns];51 if (!Array.isArray(excludes)) excludes = [excludes];52 excludes = excludes.map(exclude => path.resolve(dir, exclude).replace(/\\/g, "/"));53 var results = [];54 extns.forEach(function(extn) {55 if (extn.substr(0,1) !== ".") extn = "." + extn;56 var list = fs.readdirSync(dir);57 list.forEach(function(file) {58 if (file !== "node_modules") {59 file = dir + '/' + file;60 if (!excludes.some(exclude => exclude.length > 0 && exclude.slice(0, file.length) === file.replace(/\\/g, "/"))) {61 var stat = fs.statSync(file);62 if (stat && stat.isDirectory()) { 63 results = results.concat(getRecursive(file, extn));64 } else { 65 if (file.slice(extn.length * -1) === extn) {66 results.push(file);67 }68 }69 }70 }71 });72 });73 return results;74}75const isCoreComponent = (type) => {76 return ["code","color","date","document","href","image","src","text","video","wysiwyg"].indexOf((type || "").toLowerCase()) >= 0;77};78const replaceAssets = (file, content, cssParser, isComponent = false, alternativePathPrefixes = []) => {79 if (!Array.isArray(alternativePathPrefixes)) alternativePathPrefixes = [alternativePathPrefixes];80 let result = content;81 let uploads = [];82 var matches;83 for (var i = 0, len = reAssets.length; i < len; i++) {84 while (matches = reAssets[i].exec(result)) {85 if (matches && matches.length > 4) {86 let url = matches[4];87 if (url && url.indexOf("http") < 0 && url.indexOf("//") < 0) {88 //console.log(`Found candidate ${url}`);89 let { path: filepath, folder: dir, filename, alternativePaths } = getPaths(file, url, alternativePathPrefixes);90 let prefix = "";91 let fileExists = fs.existsSync(filepath);92 if (!fileExists) {93 const alternateIndex = alternativePaths.findIndex(p => fs.existsSync(p));94 if (alternateIndex >= 0) {95 const alternate = alternativePaths[alternateIndex];96 prefix = alternativePathPrefixes[alternateIndex] + "/";97 fileExists = true;98 filepath = alternate;99 }100 }101 if (fileExists) {102 let replacement = isComponent103 ? `"/cpt_internal/${dir}${filename}"`104 : `"<%= Asset.Load(Asset.GetSiteRoot(asset).AssetPath + \"/${dir}${filename}\").GetLink(LinkType.Include) %>"`;105 //console.log(`Replacement is ${replacement}`);106 result = replaceAll(result, matches[2], replacement);107 if (matches[1] === "link" && fs.lstatSync(filepath).isFile()) {108 // If this is CSS, it needs to be parsed separately109 const result = cssParser.parse(filepath, fs.readFileSync(filepath, "utf8"), "", prefix);110 if (result.content && result.uploads && result.uploads.length) {111 uploads.push({source: filepath, name: filename, destination: dir, content: result.content});112 uploads = uploads.concat(result.uploads);113 } else {114 uploads.push({source: filepath, name: filename, destination: dir});115 }116 } else {117 uploads.push({source: filepath, name: filename, destination: dir});118 }119 }120 }121 }122 }123 }124 return { content: result, uploads: uploads };125};126const getRoot = function() {127 return process.cwd();128};129const replaceAll = (source, original, replacement) => {130 if (!source || !source.replace) return source;131 let result = source;132 let index = result.indexOf(original);133 while (index >= 0) {134 result = result.substr(0, index) + replacement + result.substr(index + original.length);135 index = result.indexOf(original, index + replacement.length - original.length);136 }137 return result;138};139let replacements = null;140const replaceMarkup = (source, temporaryReplacements = null) => {141 if (!source || typeof(source) !== "string") return source;142 if (temporaryReplacements) {143 replacements = temporaryReplacements;144 }145 if (!replacements) {146 const cwd = process.env.INIT_CWD || path.resolve('.');147 if (fs.existsSync(`${cwd}/.cpscaffold.json`)) {148 const file = JSON.parse(fs.readFileSync(`${cwd}/.cpscaffold.json`));149 if (file && file.replacements) {150 replacements = file.replacements;151 }152 }153 if (!replacements) replacements = {};154 }155 let result = source;156 const keys = Object.keys(replacements);157 for (let key of keys) {158 const replacement = replacements[key];159 const keyMatch = key.match(/^<([A-Za-z0-9.:-]+)>$/);160 const replacementMatch = replacement.match(/^<.*?>$/);161 if (keyMatch && replacementMatch) {162 // Start tag plus attributes163 result = result.replace(new RegExp(key.substr(0, key.length - 1) + "(.*?)" + ">", "g"), replacement.substr(0, replacement.length - 1) + "$1" + ">");164 // Combine duplicate attributes165 let match = result.match(reDuplicateAttributes);166 while (match) {167 result = result.replace(match[0], `${match[1]}="${match[3]} ${match[6]}"${match[4].trimEnd()}`);168 match = result.match(reDuplicateAttributes);169 }170 } else {171 // Simple replacement172 result = result.replace(new RegExp(key, "g"), replacement);173 }174 }175 if (temporaryReplacements) replacements = null;176 return result;177}178module.exports = {179 colouriseErrors: colouriseErrors,180 colorizeErrors: colouriseErrors,181 getPaths: getPaths,182 getRecursive: getRecursive,183 isCoreComponent: isCoreComponent,184 replaceAssets: replaceAssets,185 replaceMarkup: replaceMarkup...

Full Screen

Full Screen

questions.js

Source:questions.js Github

copy

Full Screen

1// questions.js2// added comment - change for 3rd branch3var winston = require('winston');4module.exports = function(config, db, logger, router, aws) {5 logger.info('Questions.js');6 var Questions = db.models.Location;7 var Roles = db.models.Role;8 logger.add(winston.transports.File, {9 name: 'questions', filename: config.logging.filePath + 'routes.data.questions.log',10 maxsize: config.logging.maxsize, maxFiles: config.logging.maxFiles, colorize: 'true', timestamp: true11 }12 );13 router.post('/questions/save', function (req, res) {14 try{15 var roleId = req.body.roleId;16 logger.info('Saving Question Data for Role-Id: (%s).', roleId);17 var updateQuestion = {};18 var updateQuestionId = req.body._id;19 updateQuestion._id = req.body._id;20 updateQuestion.active = req.body.active;21 //updateQuestion.title = req.body.title;22 updateQuestion.title = req.body.title;23 updateQuestion.order = req.body.order;24 //updateQuestion.text = req.body.text;25 updateQuestion.text = req.body.text;26 updateQuestion.isCoreComponent = req.body.isCoreComponent;27 var questionsUpdateQuery = {_id: roleId, "questions._id": updateQuestionId};28 var questionsUpdateData = { $set: {"questions.$": updateQuestion}};29 Roles.findOneAndUpdate(questionsUpdateQuery, questionsUpdateData, function callback (err, saveRes) {30 if (err) {31 logger.error("Error saving question: " + err);32 res.status(500).send(config.responses.serverError);33 //throw new Error('Error saving question. ' + err);34 }35 else{36 logger.info("Saved question '%s' for Role-Id: (%s).", updateQuestionId, roleId);37 if (!saveRes){38 logger.error("No question found with id %s.", updateQuestionId);39 res.status(404).send(config.responses.dataError);40 }41 else{42 res.send({results: true});43 }44 }45 });46 }47 catch (questionsSaveEx){48 logger.error("/questions/save - questionsSaveEx: " + questionsSaveEx);49 res.status(500).send(config.responses.serverError);50 }51 });52 router.post('/questions/new', function (req, res) {53 try{54 var roleId = req.body.roleId;55 logger.info('Creating a new Admin Question for Role-Id: (%s).', roleId);56 var newQuestion = {};57 newQuestion.active = req.body.active;58 newQuestion.title = req.body.title;59 newQuestion.order = req.body.order;60 newQuestion.text = req.body.text;61 newQuestion.isCoreComponent = req.body.isCoreComponent;62// logger.debug('New Question: %s', JSON.stringify(newQuestion));63 var roleQuery = {_id: roleId};64 Roles.findById(roleQuery, function (err, aRole) {65 if (err) {66 logger.error("Error creating new question: " + err);67 throw new Error('Error finding creating question. ' + err);68 }69 else{70 if (typeof aRole !== 'undefined' && aRole){71 logger.info('Role Found (%s) | %s.', roleId);72// logger.info('Role Found (%s) | %s.', roleId, JSON.stringify(aRole));73 aRole.questions.push(newQuestion);74 aRole.save(function (err, saveRes) {75 if(err){76 logger.error("Error creating new question: " + err);77 throw new Error('Error saving new question. ' + err);78 }79 else{80 var aNewQuestion = saveRes.questions[saveRes.questions.length -1]81 logger.info('Created new Question-Id: (%s).', aNewQuestion._id);82 res.send({results: aNewQuestion});83 }84 })85 }86 else{87 logger.error("Error creating new question. No role found with id: %s", roleId);88 res.status(404).send(config.responses.dataError);89 }90 }91 });92 }93 catch (rolesEx){94 logger.error("/roles/new - rolesEx: " + rolesEx);95 res.status(500).send(config.responses.serverError);96 }97 });98 return router;...

Full Screen

Full Screen

Preferences.js

Source:Preferences.js Github

copy

Full Screen

...57 }58 if (opts.type !== 'radio' || (opts.type === 'radio' && opts.setter !== 'on')) {59 opts.scope.logger.debug('Undefined model setter', opts);60 // Toggle method core component <=> widget content61 const method = opts.scope.controller.isCoreComponent() ?62 '_setItemInfoPreferences' : 'setPrefs';63 /**64 * Define setter65 * @type {Function}66 */67 setter = LibFunction.create({68 name: opts.setter,69 params: name,70 body: `this.${method}("${name}", ${name});${opts.scope.controller.getCustomPublisher(opts.name)}`,71 scope: opts.scope.model.constructor.prototype72 });73 opts.scope.logger.debug('Define model setter', setter, opts);74 _validateCallback();75 }...

Full Screen

Full Screen

pa11yci.config.js

Source:pa11yci.config.js Github

copy

Full Screen

...14 const hasExplicitDisable = (s) =>15 s.parameters == null || s.parameters.pa11y == null || s.parameters.pa11y.disable !== true;16 return Promise.resolve(17 stories18 .filter((s) => hasPa11ySet(s) || isCoreComponent(s))19 .filter(hasExplicitDisable)20 .filter((s) => filter == null || s.id.includes(filter.toLowerCase()))21 .map((s) => ({22 url: url + "?id=" + s.id,23 ...s.parameters.pa11y,24 }))25 );26}27module.exports = (async () => {28 const browser = await puppeteer.launch({29 ignoreHTTPSErrors: true,30 args: ["--no-sandbox", "--disable-setuid-sandbox"],31 });32 const page = await browser.newPage();...

Full Screen

Full Screen

coreCheckHealth.js

Source:coreCheckHealth.js Github

copy

Full Screen

1/*2 * This code file belongs to Mantra Framework project (www.mantrajs.com)3 * in the scope of MIT license. More info at support@mantrajs.com. Enjoy :-)4 */ 5"use strict";6const MantraConsole = global.gimport("mantraconsole");7const ComponentsIterator = global.gimport("componentsiterator");8const CoreConstants = global.gimport("coreconstants");9module.exports = {10 checkHealth: async (MantraAPI) => {11 await checkComponentSchemas(MantraAPI);12 }13}14async function checkComponentSchemas(MantraAPI) {15 const AssetsLocations = MantraAPI.GetAssetsLocations();16 MantraConsole.info("Checking entities for components and database connectivity...", false);17 await ComponentsIterator( async (cmpInstance, componentName) => { 18 if ( !CoreConstants.IsCoreComponent(componentName) ) {19 const schemaLocation = AssetsLocations.GetSchemaLocation( componentName );20 const existsSchemaFile = await MantraAPI.Utils.FileExists( schemaLocation );21 22 if ( existsSchemaFile ) {23 try {24 const componentDb = MantraAPI.ComponentEntities(componentName);25 const existsSchema = await componentDb.ExistsSchema();26 if ( !existsSchema ) {27 MantraConsole.warning(`Unable to access schema for component ${componentName}. Check if it installed or database connectivity.`, false)28 }29 } catch(err) {30 MantraConsole.warning(`Unable to access schema for component ${componentName}. Check if it installed or database connectivity.`, false)31 }32 }33 }34 });...

Full Screen

Full Screen

coreconstants.tests.js

Source:coreconstants.tests.js Github

copy

Full Screen

1const assert = require("chai").assert;2const CronValidator = require("cron-validator");3const TestsHelper = require("./testshelper");4require("gimport").initm( process.cwd() );5const CoreConstants = global.gimport("coreconstants");6describe( 'CoreComponents tests', () => {7 it( '# Check default modules', () => {8 for( const coreComponent of CoreConstants.CORE_COMPONENTS ) {9 assert.isTrue( CoreConstants.IsCoreComponent(coreComponent) );10 }11 });12 it( '# Check cron aliases names', () => {13 for( const cronAlias of Object.keys(CoreConstants.CRONALIASES) ) {14 assert.isTrue( typeof cronAlias == 'string' );15 }16 });17 it( '# Check cron aliases values', () => {18 for( const cronAlias of Object.keys(CoreConstants.CRONALIASES) ) {19 const cronConfig = CoreConstants.CRONALIASES[cronAlias];20 assert.isTrue( CronValidator.isValidCron(cronConfig, { seconds: true }));21 }22 });23 it( '# Check node versions supported', () => {24 for( const nodeVersion of CoreConstants.NODESUPPORTEDVERSIONS ) {25 assert.isNumber( nodeVersion );26 assert.isTrue( nodeVersion >= 12 );27 }28 });29 it( '# Check Mantra web site constant', () => {30 assert.isTrue( TestsHelper.isValidUrl(CoreConstants.MANTRAWEBSITE) );31 });32 it( '# Check Mantra api endpoint constant', () => {33 assert.isTrue( TestsHelper.isValidUrl(CoreConstants.APIMANTRAWEBSITEENDPOINT) );34 });35 it( '# Check Mantra support mail constant', () => {36 assert.isTrue( TestsHelper.isValidMail(CoreConstants.MANTRASUPPORTMAIL) );37 });...

Full Screen

Full Screen

Question.js

Source:Question.js Github

copy

Full Screen

1var mongoose = require("mongoose");2// This is a dedicated sub-document. There is no collection associated to it.3var QuestionsSchema = new mongoose.Schema({4 //_id: String,5 title: String,6 order: Number,7 active: Boolean,8 text: String,9 createDate: Date,10 isCoreComponent: Boolean11});12//var Question = mongoose.model('Question', QuestionsSchema);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isCoreComponent } = require('@playwright/test/lib/utils/utils');2const { test } = require('@playwright/test');3test('isCoreComponent', async ({ page }) => {4 expect(isCoreComponent(page, 'div')).toBe(true);5 expect(isCoreComponent(page, 'div', 'text=Get started')).toBe(false);6});7 › Object.<anonymous> (test.js:11:5)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isCoreComponent } = require('playwright/lib/server/frames');2console.log(isCoreComponent('button'));3const { isCoreComponent } = require('playwright/lib/server/frames');4console.log(isCoreComponent('button'));5const { isCoreComponent } = require('playwright/lib/server/frames');6console.log(isCoreComponent('button'));7const { isCoreComponent } = require('playwright/lib/server/frames');8console.log(isCoreComponent('button'));9const { isCoreComponent } = require('playwright/lib/server/frames');10console.log(isCoreComponent('button'));11const { isCoreComponent } = require('playwright/lib/server/frames');12console.log(isCoreComponent('button'));13const { isCoreComponent } = require('playwright/lib/server/frames');14console.log(isCoreComponent('button'));15const { isCoreComponent } = require('playwright/lib/server/frames');16console.log(isCoreComponent('button'));17const { isCoreComponent } = require('playwright/lib/server/frames');18console.log(isCoreComponent('button'));19const { isCoreComponent } = require('playwright/lib/server/frames');20console.log(isCoreComponent('button'));21const { isCoreComponent } = require('playwright/lib/server/frames');22console.log(isCoreComponent('button'));23const { isCoreComponent } = require('playwright/lib/server/frames');24console.log(isCoreComponent('button'));25const { isCoreComponent } = require('playwright/lib/server/frames');26console.log(isCoreComponent('button'));27const { is

Full Screen

Using AI Code Generation

copy

Full Screen

1const isCoreComponent = require('playwright/lib/server/supplements/utils/isCoreComponent');2(async () => {3 const isCore = await isCoreComponent('playwright');4 console.log('Is Core', isCore);5})();6If we import the package from the source, the output will be:

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');2console.log(isCoreComponent('div'));3const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');4console.log(isCoreComponent('div'));5const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');6console.log(isCoreComponent('div'));7const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');8console.log(isCoreComponent('div'));9const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');10console.log(isCoreComponent('div'));11const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');12console.log(isCoreComponent('div'));13const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');14console.log(isCoreComponent('div'));15const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');16console.log(isCoreComponent('div'));17const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');18console.log(isCoreComponent('div'));19const { isCoreComponent } = require('playwright/lib/server/supplements/recorder/recorderUtils');20console.log(isCoreComponent('div'));21const { isCoreComponent } =

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isCoreComponent } = require('playwright/lib/server/dom.js');2const isCore = isCoreComponent('div');3console.log(isCore);4const { isCoreComponent } = require('playwright/lib/server/dom.js');5const isCore = isCoreComponent('div');6console.log(isCore);7const { isCoreComponent } = require('playwright/lib/server/dom.js');8const isCore = isCoreComponent('div');9console.log(isCore);10const { isCoreComponent } = require('playwright/lib/server/dom.js');11const isCore = isCoreComponent('div');12console.log(isCore);13const { isCoreComponent } = require('playwright/lib/server/dom.js');14const isCore = isCoreComponent('div');15console.log(isCore);16const { isCoreComponent } = require('playwright/lib/server/dom.js');17const isCore = isCoreComponent('div');18console.log(isCore);19const { isCoreComponent } = require('playwright/lib/server/dom.js');20const isCore = isCoreComponent('div');21console.log(isCore);22const { isCoreComponent } = require('playwright/lib/server/dom.js');23const isCore = isCoreComponent('div');24console.log(isCore);25const { isCoreComponent } = require('playwright/lib/server/dom.js');26const isCore = isCoreComponent('div');27console.log(isCore);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isCoreComponent } = require('@playwright/test/lib/server/frames');2const isCore = isCoreComponent('div');3console.log(isCore);4const { chromium } = require('playwright');5(async () => {6 const browser = await chromium.launch({ headless: false });7 const page = await browser.newPage();8 const input = await page.$('input');9 const value = await input.getAttribute('value');10 console.log(value);11 await browser.close();12})();13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch({ headless: false });16 const page = await browser.newPage();17 const input = await page.$('input');18 const value = await input.getAttribute('value');19 console.log(value);20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch({ headless: false });25 const page = await browser.newPage();26 const input = await page.$('input');27 const value = await input.getAttribute('value');28 console.log(value);29 await browser.close();30})();31const { chromium } = require('playwright');32(async () => {33 const browser = await chromium.launch({ headless: false });34 const page = await browser.newPage();35 const input = await page.$('input');36 const value = await input.getAttribute('

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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