How to use work method in stryker-parent

Best JavaScript code snippet using stryker-parent

workItem.js

Source:workItem.js Github

copy

Full Screen

1const displayWorkItems = invoice => {2 const workItems = invoice.workItems || [];3 const existingContainer = document.querySelector("#work-items");4 if (existingContainer) {5 existingContainer.remove();6 }7 const workItemsContainer = document.createElement("div");8 workItemsContainer.classList.add("container");9 workItemsContainer.id = "work-items";10 // const workItemsTitle = document.createElement("h5");11 // workItemsTitle.textContent = `Invoice Work Items: ${workItems.length}`;12 // workItemsContainer.append(document.createElement("hr"));13 // workItemsContainer.append(workItemsTitle);14 const addWorkItemButton = displayAddWorkItemButton(invoice);15 workItemsContainer.append(addWorkItemButton);16 workItemsContainer.append(document.createElement("hr"));17 const headerRow = displayWorkItemHeader();18 workItemsContainer.append(headerRow);19 workItems.forEach(workItem => {20 const workItemRow = displayWorkItem(workItem);21 workItemsContainer.append(workItemRow);22 });23 const grandTotalRow = displayGrandTotalRow(invoice);24 workItemsContainer.append(grandTotalRow);25 return workItemsContainer;26};27const displayWorkItemHeader = () => {28 const headerContainer = document.createElement("div");29 headerContainer.classList.add("row");30 headerContainer.classList.add("header-row");31 ["Description", "Quantity", "Amount", "Sub-total"].forEach(32 (headerText, i) => {33 const headerCol = createCol();34 const header = document.createElement("h4");35 if (i !== 0) {36 header.style.textAlign = "right";37 }38 header.textContent = headerText;39 headerCol.append(header);40 headerContainer.append(headerCol);41 }42 );43 return headerContainer;44};45const displayWorkItem = workItem => {46 const workItemContainer = document.createElement("div");47 workItemContainer.id = `work-item-${workItem.id}`;48 workItemContainer.classList.add("row");49 workItemContainer.classList.add("work-item-row");50 const workItemDesc = createCol();51 workItemDesc.textContent = workItem.description;52 addEditListener(workItemDesc, event => {53 api54 .patchWorkItem(workItem.id, { description: event.target.textContent })55 .then(data => (event.target.textContent = data.description));56 });57 const workItemQuantity = createCol();58 workItemQuantity.classList.add("number-col");59 workItemQuantity.textContent = parseFloat(workItem.quantity);60 addEditListener(workItemQuantity, event => {61 if (isNaN(parseFloat(event.target.textContent))) {62 return;63 }64 api65 .patchWorkItem(workItem.id, {66 quantity: parseFloat(event.target.textContent)67 })68 .then(data => {69 event.target.textContent = parseFloat(data.quantity);70 updateWorkItemRowSubTotal(data);71 updateGrandTotalRow(workItem.invoice_id);72 });73 });74 const workItemAmount = createCol();75 workItemAmount.classList.add("number-col");76 workItemAmount.textContent = money(workItem.amount);77 addEditListener(workItemAmount, event => {78 const newAmount = parseFloat(79 String(event.target.textContent).replace(/[^0-9\.]/g, "")80 );81 api.patchWorkItem(workItem.id, { amount: newAmount }).then(data => {82 event.target.textContent = money(data.amount);83 updateWorkItemRowSubTotal(data);84 updateGrandTotalRow(workItem.invoice_id);85 });86 });87 const workItemSubTotal = createCol();88 workItemSubTotal.id = `work-item-subtotal-${workItem.id}`;89 workItemSubTotal.classList.add("number-col");90 workItemSubTotal.textContent = money(subTotalForWorkItem(workItem));91 const deleteBtn = document.createElement("delete");92 deleteBtn.classList = "btn btn-sm btn-danger d-print-none";93 deleteBtn.innerText = " X ";94 workItemContainer.append(95 workItemDesc,96 workItemQuantity,97 workItemAmount,98 workItemSubTotal,99 deleteBtn100 );101 //Delete workItem102 deleteBtn.addEventListener("click", event => {103 const workItemtoDelete = document.querySelector(104 `#work-item-${workItem.id}`105 );106 api.deleteWorkItem(workItem.id).then(() => {107 workItemtoDelete.remove();108 updateGrandTotalRow(workItem.invoice_id);109 });110 });111 return workItemContainer;112};113const subTotalForWorkItem = workItem => {114 const quantity = parseFloat(workItem.quantity);115 const amount = parseFloat(workItem.amount);116 return quantity * amount;117};118function money(amount) {119 return `£ ${parseFloat(amount).toFixed(2)}`;120}121const displayAddWorkItemButton = invoice => {122 const addWorkItemButton = document.createElement("button");123 ["btn", "btn-success", "d-print-none"].forEach(cls =>124 addWorkItemButton.classList.add(cls)125 );126 addWorkItemButton.textContent = "+ Add new work item";127 addWorkItemButton.addEventListener("click", () => {128 api129 .postWorkItem({130 invoice_id: invoice.id,131 description: "New work item",132 amount: 0.0,133 quantity: 0.0134 })135 .then(data => {136 document137 .querySelector("#work-items")138 .insertBefore(139 displayWorkItem(data),140 document.querySelector("#grand-total-row")141 );142 });143 });144 return addWorkItemButton;145};146function updateWorkItemRowSubTotal(workItem) {147 const subTotalCol = document.querySelector(148 `#work-item-subtotal-${workItem.id}`149 );150 if (!subTotalCol) {151 debugLog("Failed to find sub total col", { workItem });152 return;153 }154 subTotalCol.textContent = money(subTotalForWorkItem(workItem));155}156function displayGrandTotalRow(invoice) {157 const grandTotalRow = document.createElement("div");158 grandTotalRow.id = "grand-total-row";159 grandTotalRow.classList.add("row");160 grandTotalRow.classList.add("grand-total-row");161 const descriptionCol = createCol();162 descriptionCol.textContent = "GRAND TOTAL";163 grandTotalRow.append(descriptionCol);164 const quantityCol = createCol();165 quantityCol.id = "grand-quantity-col";166 quantityCol.classList.add("text-right");167 quantityCol.textContent = totalQuantityForInvoice(invoice);168 grandTotalRow.append(quantityCol);169 const placeHolderAmountCol = createCol();170 grandTotalRow.append(placeHolderAmountCol);171 const grandTotalCol = createCol();172 grandTotalCol.id = "grand-total-col";173 grandTotalCol.classList.add("text-right");174 grandTotalCol.textContent = money(grandTotalForInvoice(invoice));175 grandTotalRow.append(grandTotalCol);176 return grandTotalRow;177}178function updateGrandTotalRow(invoiceId) {179 api.getInvoice(invoiceId).then(data => {180 const quantityCol = document.querySelector("#grand-quantity-col");181 quantityCol.textContent = totalQuantityForInvoice(data);182 const grandTotalCol = document.querySelector("#grand-total-col");183 grandTotalCol.textContent = money(grandTotalForInvoice(data));184 });185}186function totalQuantityForInvoice(invoice) {187 return invoice.workItems.reduce((sum, workItem) => {188 return sum + parseFloat(workItem.quantity);189 }, 0.0);190}191function grandTotalForInvoice(invoice) {192 return invoice.workItems.reduce((sum, workItem) => {193 return sum + subTotalForWorkItem(workItem);194 }, 0.0);...

Full Screen

Full Screen

AddWorkScreen.js

Source:AddWorkScreen.js Github

copy

Full Screen

1/**2 *Author : www.juliocanares.com/cv3 *Email : juliocanares@gmail.com4 */5var APP = APP || {};6APP.AddWorkScreen = function () {7 APP.BaseScreen.call(this, 'addWork');8 this.work = null;9};10APP.AddWorkScreen.constructor = APP.AddWorkScreen;11APP.AddWorkScreen.prototype = Object.create(APP.BaseScreen.prototype);12APP.AddWorkScreen.prototype.setupUI = function () {13 this.workForm = $('.work-form');14 this.uploader = $('.uploader-work');15 this.name = $('input[name=name]');16 this.category = $('select[name=category]');17 this.description = $('textarea[name=description]');18 this.tags = $('input[name=tags]');19 this.tags.tagsInput({20 height: '50px',21 width: '100%',22 defaultText: '+Etiqueta'23 });24 this.send = $('.send');25 this.sendLoading = $('.send-loading');26 this.workDelete = $('.work-delete');27 this.workDeleteConfirm = $('.work-delete-confirm');28 this.workDeleteCancel = $('.work-delete-cancel');29 this.workDeleteForce = $('.work-delete-force');30 this.workPhotoPublished = $('.work-photo-published');31 this.workNamePublished = $('.work-name-published');32 this.workUserPublished = $('.work-user-published');33 this.workPublished = $('.work-published');34 this.workView = $('.work-view');35 this.workNew = $('.work-new');36 this.workEdit = $('.work-edit');37 this.uploaderImage = new APP.UploaderImage(this.uploader, this.imgComplete);38};39APP.AddWorkScreen.prototype.listeners = function () {40 APP.BaseScreen.prototype.listeners.call(this);41 this.workForm.submit(this.workFormSubmitHandler.bind(this));42 this.workDelete.click(this.deleteHandler.bind(this));43 this.workDeleteForce.click(this.workDeleteForceHandler.bind(this));44 this.workDeleteCancel.click(this.deleteCancel.bind(this));45 $('input[type=checkbox]').change(this.publicHandler);46};47APP.AddWorkScreen.prototype.publicHandler = function () {48 $(this).parent().find('.value').text((this.checked ? 'On' : 'Off'));49}50APP.AddWorkScreen.prototype.workFormSubmitHandler = function (event) {51 event.preventDefault();52 var errors = [],53 scope = this;54 console.log('okkk');55 if (!this.uploaderImage.photo) errors.push('Ingrese una foto');56 if (Validations.notBlank(this.name.val())) errors.push('Ingrese un nombre');57 if (Validations.notBlank(this.category.val())) errors.push('Ingrese una categoria');58 if (Validations.notBlank(this.description.val())) errors.push('Ingrese una descripcion');59 if (this.tags.val().split(',')[0].length < 1) errors.push('Ingrese etiquetas');60 if (errors.length > 0) return this.showFlash('error', errors);61 this.sendLoading.show();62 this.send.hide();63 var data = this.workForm.serializeArray();64 $.each(data, function (index, value) {65 if (value.name === 'photo')66 value.value = scope.uploaderImage.photo;67 if (value.name === 'nsfw' || value.name === 'public')68 value.value = (value.value === 'on');69 });70 var url = DataApp.currentUser.url + '/work/create';71 console.log(url)72 this.requestHandler(url, data, this.workCreatedComplete);73};74APP.AddWorkScreen.prototype.workCreatedComplete = function (response) {75 this.showFlash('succes', 'Su obra se subió exitosamente')76 this.work = response.data.work;77 this.workForm.hide();78 this.sendLoading.hide();79 this.send.show();80 var url = DataApp.currentUser.url + '/work/' + this.work.nameSlugify81 var photo = Utils.addImageFilter(this.work.photo, 'w_300,c_limit');82 this.workView.attr('href', url);83 this.workNew.attr('href', DataApp.currentUser.url + '/work/add');84 this.workEdit.attr('href', url + '/edit');85 this.workPhotoPublished.attr('src', photo);86 this.workNamePublished.text(this.work.name);87 this.workUserPublished.text(DataApp.currentUser.fullname);88 this.workPublished.show();89};90APP.AddWorkScreen.prototype.deleteHandler = function (event) {91 this.workDelete.hide();92 this.workDeleteConfirm.show();93};94APP.AddWorkScreen.prototype.workDeleteForceHandler = function () {95 var url = DataApp.currentUser.url + '/work/delete';96 this.requestHandler(url, {97 idWork: this.work.id98 }, this.forceComplete);99};100APP.AddWorkScreen.prototype.forceComplete = function () {101 this.showFlash('succes', 'Se elimino tu obra');102 setTimeout(function () {103 window.location.href = DataApp.currentUser.url;104 }, 1000);105};106APP.AddWorkScreen.prototype.deleteCancel = function (response) {107 this.workDelete.show();108 this.workDeleteConfirm.hide();109};110APP.AddWorkScreen.prototype.imgComplete = function (idImage) {111 this.$view.find('.upload').show();112 $('.cloudinary-fileupload').show();113 var filters = {114 width: 300,115 crop: 'limit'116 };117 $.cloudinary.image(idImage, filters).appendTo(this.$view.find('.preview'));...

Full Screen

Full Screen

EditWorkScreen.js

Source:EditWorkScreen.js Github

copy

Full Screen

1/**2 *Author : www.juliocanares.com/cv3 *Email : juliocanares@gmail.com4 */5var APP = APP || {};6APP.EditWorkScreen = function() {7 APP.BaseScreen.call(this, 'editWork');8 this.work = work;9 this.userWork = work.User;10};11APP.EditWorkScreen.constructor = APP.EditWorkScreen;12APP.EditWorkScreen.prototype = Object.create(APP.BaseScreen.prototype);13APP.EditWorkScreen.prototype.setupUI = function() {14 this.workForm = $('.work-form');15 this.uploaderImage = new APP.UploaderImage($('.uploader-work'), this.uploaderImageComplete);16 this.uploaderImage.photo = work.photo;17 this.name = $('input[name=name]');18 this.category = $('select[name=category]');19 $('select[name=category]').find('option[value=' + category.id + ']').attr('selected', true);20 $('input[name=public]').attr('checked', work.public);21 $('input[name=nsfw]').attr('checked', work.nsfw);22 this.description = $('textarea[name=description]');23 this.tags = $('input[name=tags]');24 this.tags.tagsInput({25 height: '50px',26 width: '100%',27 defaultText: '+Etiqueta'28 });29 this.send = $('.send');30 this.sendLoading = $('.send-loading');31 this.workDelete = $('.work-delete');32 this.workDeleteConfirm = $('.work-delete-confirm');33 this.workDeleteCancel = $('.work-delete-cancel');34 this.workDeleteForce = $('.work-delete-force');35};36APP.EditWorkScreen.prototype.listeners = function() {37 APP.BaseScreen.prototype.listeners.call(this);38 this.workForm.submit(this.workFormSubmitHandler.bind(this));39 this.workDelete.click(this.workDeleteHandler.bind(this));40 this.workDeleteForce.click(this.workDeleteForceHandler.bind(this));41 this.workDeleteCancel.click(this.workDeleteCancelHandler.bind(this));42 $('input[type=checkbox]').change(this.checkPublicHandler);43 $('input[type=checkbox]').change();44};45APP.EditWorkScreen.prototype.checkPublicHandler = function() {46 $(this).parent().find('.value').text((this.checked ? 'On' : 'Off'));47}48APP.EditWorkScreen.prototype.workFormSubmitHandler = function(event) {49 event.preventDefault();50 var errors = [],51 scope = this;52 if (!this.uploaderImage.photo) errors.push('Ingrese una foto');53 if (Validations.notBlank(this.name.val())) errors.push('Ingrese un nombre');54 if (Validations.notBlank(this.category.val())) errors.push('Ingrese una categoria');55 if (Validations.notBlank(this.description.val())) errors.push('Ingrese una descripcion');56 if (this.tags.val().split(',')[0].length < 1) errors.push('Ingrese etiquetas');57 if (errors.length > 0) return this.showFlash('error', errors);58 this.sendLoading.show();59 this.send.hide();60 var data = this.workForm.serializeArray();61 $.each(data, function(index, value) {62 if (value.name === 'photo')63 value.value = scope.uploaderImage.photo;64 if (value.name === 'nsfw' || value.name === 'public')65 value.value = (value.value === 'on');66 });67 var url = DataApp.currentUser.url + '/work/update';68 this.requestHandler(url, data, this.workUpdatedComplete);69};70APP.EditWorkScreen.prototype.workUpdatedComplete = function(response) {71 this.showFlash('succes', 'Su obra se actualizo exitosamente')72 this.work = response.data.work;73 this.sendLoading.hide();74 this.send.show();75 var url = '/user/' + this.userWork.username + '/work/' + this.work.nameSlugify;76 var timeout = setTimeout(function() {77 clearTimeout(timeout);78 window.location.href = url;79 }, 1000);80};81APP.EditWorkScreen.prototype.workDeleteHandler = function(event) {82 event.preventDefault();83 this.workDelete.hide();84 this.workDeleteConfirm.show();85};86APP.EditWorkScreen.prototype.workDeleteForceHandler = function() {87 var url = DataApp.currentUser.url + '/work/delete';88 this.requestHandler(url, {89 idWork: this.work.id90 }, this.workDeleteForceComplete);91};92APP.EditWorkScreen.prototype.workDeleteForceComplete = function() {93 this.showFlash('succes', 'Se elimino tu obra');94 var timeout = setTimeout(function() {95 clearTimeout(timeout);96 if (DataApp.currentUser.isAdmin)97 window.location.href = '/';98 else99 window.location.href = DataApp.currentUser.url;100 }, 1000);101};102APP.EditWorkScreen.prototype.workDeleteCancelHandler = function(response) {103 this.workDelete.show();104 this.workDeleteConfirm.hide();105};106APP.EditWorkScreen.prototype.uploaderImageComplete = function(idImage) {107 this.$view.find('.upload').show();108 $('.cloudinary-fileupload').show();109 var filters = {110 width: 300,111 crop: 'limit'112 };113 $.cloudinary.image(idImage, filters).appendTo(this.$view.find('.preview'));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.work();3var strykerParent = require('stryker-parent');4strykerParent.work();5var strykerParent = require('stryker-parent');6strykerParent.work();7var strykerParent = require('stryker-parent');8strykerParent.work();9var strykerParent = require('stryker-parent');10strykerParent.work();11var strykerParent = require('stryker-parent');12strykerParent.work();13var strykerParent = require('stryker-parent');14strykerParent.work();15var strykerParent = require('stryker-parent');16strykerParent.work();17var strykerParent = require('stryker-parent');18strykerParent.work();19var strykerParent = require('stryker-parent');20strykerParent.work();21var strykerParent = require('stryker-parent');22strykerParent.work();23var strykerParent = require('stryker-parent');24strykerParent.work();25var strykerParent = require('stryker-parent');26strykerParent.work();27var strykerParent = require('stryker-parent');28strykerParent.work();29var strykerParent = require('stry

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2strykerParent.work();3const strykerParent = require('stryker-parent');4strykerParent.work();5const strykerParent = require('stryker-parent');6strykerParent.work();7const strykerParent = require('stryker-parent');8strykerParent.work();9const strykerParent = require('stryker-parent');10strykerParent.work();11const strykerParent = require('stryker-parent');12strykerParent.work();13const strykerParent = require('stryker-parent');14strykerParent.work();15const strykerParent = require('stryker-parent');16strykerParent.work();17const strykerParent = require('stryker-parent');18strykerParent.work();19const strykerParent = require('stryker-parent');20strykerParent.work();21const strykerParent = require('stryker-parent');22strykerParent.work();23const strykerParent = require('stryker-parent');24strykerParent.work();25const strykerParent = require('stryker-parent');26strykerParent.work();27const strykerParent = require('stryker-parent');28strykerParent.work();

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.work();3var strykerChild = require('stryker-child');4strykerChild.work();5var strykerChild2 = require('stryker-child2');6strykerChild2.work();7var strykerChild3 = require('stryker-child3');8strykerChild3.work();9var strykerChild4 = require('stryker-child4');10strykerChild4.work();11var strykerChild5 = require('stryker-child5');12strykerChild5.work();13var strykerChild6 = require('stryker-child6');14strykerChild6.work();15var strykerChild7 = require('stryker-child7');16strykerChild7.work();17var strykerChild8 = require('stryker-child8');18strykerChild8.work();19var strykerChild9 = require('stryker-child9');20strykerChild9.work();21var strykerChild10 = require('stryker-child10');22strykerChild10.work();23var strykerChild11 = require('stryker-child11');24strykerChild11.work();25var strykerChild12 = require('stryker-child12');26strykerChild12.work();

Full Screen

Using AI Code Generation

copy

Full Screen

1const parent = require('stryker-parent');2parent.work();3const child = require('stryker-child');4child.work();5module.exports = require('./lib');6module.exports = {7 work: function() {8 console.log('parent working...');9 }10};11module.exports = require('./lib');12module.exports = {13 work: function() {14 console.log('child working...');15 }16};17{18 "scripts": {19 },20 "dependencies": {21 }22}23{24 "scripts": {25 },26 "dependencies": {27 }28}

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2strykerParent.work();3module.exports = {4 work() {5 console.log('working');6 }7};8{9}10{11 "dependencies": {12 }13}14{15}16{17 "dependencies": {18 }19}20const strykerParent = require('stryker-parent');21strykerParent.work();22module.exports = {23 work() {24 console.log('working');25 }26};

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.work();3module.exports = {4 work: function () {5 console.log('Working...');6 }7};8{9}10module.exports = {11 work: function () {12 console.log('Working harder...');13 }14};15{16}17module.exports = {18 work: function () {19 console.log('Working harder...');20 }21};22{23}24module.exports = {25 work: function () {26 console.log('Working harder...');27 }28};29{30}31module.exports = {32 work: function () {33 console.log('Working harder...');34 }35};36{

Full Screen

Using AI Code Generation

copy

Full Screen

1var Parent = require('stryker-parent');2var parent = new Parent();3parent.work();4function Parent() { }5Parent.prototype.work = function () {6}7module.exports = Parent;8{9}10function Api() { }11Api.prototype.doWork = function () {12}13module.exports = Api;14{15}16function Util() { }17Util.prototype.doWork = function () {18}19module.exports = Util;20{21}22function Util() { }23Util.prototype.doWork = function () {24}25module.exports = Util;26{27}

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 stryker-parent 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