linter errors

This commit is contained in:
Carlos Jimenez 2018-11-06 13:59:16 +01:00
parent d85a4da1ab
commit 1ad44f22b4
6 changed files with 29 additions and 25 deletions

View File

@ -155,6 +155,7 @@ export default class Watcher extends Component {
}); });
} }
return this.$q((resolve, reject) => { return this.$q((resolve, reject) => {
this.$http.post(this.url, changedData).then( this.$http.post(this.url, changedData).then(
json => this.writeData(json, resolve), json => this.writeData(json, resolve),
@ -203,9 +204,8 @@ export default class Watcher extends Component {
if (this.data) if (this.data)
Object.assign(this.data, this.orgData); Object.assign(this.data, this.orgData);
this.$state.go(this.state); this.$state.go(this.state);
} else { } else
this.state = null; this.state = null;
}
} }
writeData(json, resolve) { writeData(json, resolve) {
@ -236,6 +236,7 @@ export default class Watcher extends Component {
} }
); );
} }
return newCopy; return newCopy;
} }
} }

View File

@ -12,8 +12,8 @@ class Controller {
this.deletable = false; this.deletable = false;
this.edit = {}; this.edit = {};
this.moreOptions = [ this.moreOptions = [
{callback: this.showAddTurnDialog, name: "Add turn", always: true}, {callback: this.showAddTurnDialog, name: 'Add turn', always: true},
{callback: this.showDeleteTicketDialog, name: "Delete ticket", always: true}, {callback: this.showDeleteTicketDialog, name: 'Delete ticket', always: true},
{callback: this.markAsReserved, name: 'Mark as reserved'}, {callback: this.markAsReserved, name: 'Mark as reserved'},
{callback: this.unmarkAsReserved, name: 'Unmark as reserved'}, {callback: this.unmarkAsReserved, name: 'Unmark as reserved'},
{callback: this.showEditDialog, name: 'Update discount'}, {callback: this.showEditDialog, name: 'Update discount'},
@ -77,9 +77,10 @@ class Controller {
} }
get isChecked() { get isChecked() {
if (this.sales) if (this.sales) {
for (let instance of this.sales) for (let instance of this.sales)
if (instance.checked) return true; if (instance.checked) return true;
}
return false; return false;
} }
@ -87,16 +88,18 @@ class Controller {
getCheckedLines() { getCheckedLines() {
let lines = []; let lines = [];
let data = this.sales; let data = this.sales;
if (data) if (data) {
for (let i = 0; i < data.length; i++) for (let i = 0; i < data.length; i++) {
if (data[i].checked) if (data[i].checked)
lines.push({id: data[i].id, instance: i}); lines.push({id: data[i].id, instance: i});
}
}
return lines; return lines;
} }
// Change State // Change State
onStateOkClick() { onStateOkClick() {
let filter = {where: {code: "OK"}, fields: ["id"]}; let filter = {where: {code: 'OK'}, fields: ['id']};
let json = encodeURIComponent(JSON.stringify(filter)); let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/ticket/api/States?filter=${json}`).then(res => { this.$http.get(`/ticket/api/States?filter=${json}`).then(res => {
this.onStateChange(res.data[0].id); this.onStateChange(res.data[0].id);
@ -197,7 +200,7 @@ class Controller {
let sales = this.getCheckedLines(); let sales = this.getCheckedLines();
this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => { this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => {
let url = this.$state.href("ticket.card.sale", {id: res.data.id}, {absolute: true}); let url = this.$state.href('ticket.card.sale', {id: res.data.id}, {absolute: true});
window.open(url, '_blank'); window.open(url, '_blank');
this.$scope.transfer.hide(); this.$scope.transfer.hide();
this.$scope.model.refresh(); this.$scope.model.refresh();
@ -215,13 +218,12 @@ class Controller {
for (let i = 0; i < sales.length; i++) for (let i = 0; i < sales.length; i++)
sales[i].quantity = this.sales[sales[i].instance].quantity; sales[i].quantity = this.sales[sales[i].instance].quantity;
this.$http.post(`claim/api/Claims/createFromSales`, {claim: claim, sales: sales}).then(res => { this.$http.post(`claim/api/Claims/createFromSales`, {claim: claim, sales: sales}).then(res => {
let url = this.$state.href("claim.card.basicData", {id: res.data.id}, {absolute: true}); this.$state.go('claim.card.basicData', {id: res.data.id});
window.open(url, '_blank');
}); });
} }
goToTicket(ticketID) { goToTicket(ticketID) {
this.$state.go("ticket.card.sale", {id: ticketID}); this.$state.go('ticket.card.sale', {id: ticketID});
} }
// Focus First Input // Focus First Input
@ -288,6 +290,7 @@ class Controller {
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}); });
} }
this.$scope.editPricePopover.hide(); this.$scope.editPricePopover.hide();
} }

View File

@ -1,7 +1,7 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('sale getClaimableFromTicket()', () => { describe('sale getClaimableFromTicket()', () => {
it('should throw an error if the ticket is not editable', async() => { it('should return the claimable sales of a given ticket', async () => {
let claimableFromTicket = await app.models.Sale.getClaimableFromTicket(16); let claimableFromTicket = await app.models.Sale.getClaimableFromTicket(16);
expect(claimableFromTicket[0].concept).toBe('Gem of Time'); expect(claimableFromTicket[0].concept).toBe('Gem of Time');

View File

@ -1,7 +1,7 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('sale moveToTicket()', () => { describe('sale moveToTicket()', () => {
it('should throw an error if the ticket is not editable', async() => { it('should throw an error if the ticket is not editable', async () => {
let error; let error;
let params = {actualTicketFk: 10}; let params = {actualTicketFk: 10};
@ -15,7 +15,7 @@ describe('sale moveToTicket()', () => {
expect(error).toBeDefined(); expect(error).toBeDefined();
}); });
it('should throw an error if the receiving ticket is not editable', async() => { it('should throw an error if the receiving ticket is not editable', async () => {
let error; let error;
let params = {actualTicketFk: 1, newTicketFk: 10}; let params = {actualTicketFk: 1, newTicketFk: 10};
@ -29,7 +29,7 @@ describe('sale moveToTicket()', () => {
expect(error).toBeDefined(); expect(error).toBeDefined();
}); });
it('should transfer the sales from one ticket to another', async() => { it('should transfer the sales from one ticket to another', async () => {
let senderTicketSales = await app.models.Ticket.getSales(11); let senderTicketSales = await app.models.Ticket.getSales(11);
let receiverTicketSales = await app.models.Ticket.getSales(13); let receiverTicketSales = await app.models.Ticket.getSales(13);
@ -53,7 +53,7 @@ describe('sale moveToTicket()', () => {
expect(receiverTicketSales.length).toEqual(2); expect(receiverTicketSales.length).toEqual(2);
}); });
it('should transfers back the sales', async() => { it('should transfers back the sales', async () => {
let senderTicketSales = await app.models.Ticket.getSales(13); let senderTicketSales = await app.models.Ticket.getSales(13);
let receiverTicketSales = await app.models.Ticket.getSales(11); let receiverTicketSales = await app.models.Ticket.getSales(11);

View File

@ -3,17 +3,17 @@ const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket changeState()', () => { describe('ticket changeState()', () => {
let ticket; let ticket;
beforeAll(async() => { beforeAll(async () => {
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}}); let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
originalTicket.id = null; originalTicket.id = null;
ticket = await app.models.Ticket.create(originalTicket); ticket = await app.models.Ticket.create(originalTicket);
}); });
afterAll(async() => { afterAll(async () => {
await app.models.Ticket.destroyById(ticket.id); await app.models.Ticket.destroyById(ticket.id);
}); });
it('should throw an error if the ticket is not editable and the user isnt production', async() => { it('should throw an error if the ticket is not editable and the user isnt production', async () => {
let ctx = {req: {accessToken: {userId: 110}}}; let ctx = {req: {accessToken: {userId: 110}}};
let params = {ticketFk: 2, stateFk: 3}; let params = {ticketFk: 2, stateFk: 3};
let error; let error;
@ -26,7 +26,7 @@ describe('ticket changeState()', () => {
expect(error).toEqual(new Error(`You don't have enough privileges to change the state of this ticket`)); expect(error).toEqual(new Error(`You don't have enough privileges to change the state of this ticket`));
}); });
it('should be able to create a ticket tracking line for a not editable ticket if the user has the production role', async() => { it('should be able to create a ticket tracking line for a not editable ticket if the user has the production role', async () => {
let ctx = {req: {accessToken: {userId: 50}}}; let ctx = {req: {accessToken: {userId: 50}}};
let params = {ticketFk: 20, stateFk: 3}; let params = {ticketFk: 20, stateFk: 3};
@ -38,7 +38,7 @@ describe('ticket changeState()', () => {
expect(res.__data.id).toBeDefined(); expect(res.__data.id).toBeDefined();
}); });
it('return an array with the created ticket tracking line', async() => { it('return an array with the created ticket tracking line', async () => {
let ctx = {req: {accessToken: {userId: 108}}}; let ctx = {req: {accessToken: {userId: 108}}};
let params = {ticketFk: ticket.id, stateFk: 3}; let params = {ticketFk: ticket.id, stateFk: 3};
let res = await app.models.TicketTracking.changeState(ctx, params); let res = await app.models.TicketTracking.changeState(ctx, params);

View File

@ -11,7 +11,7 @@ describe('ticket componentUpdate()', () => {
const today = new Date(); const today = new Date();
let ticketId = 11; let ticketId = 11;
beforeAll(async() => { beforeAll(async () => {
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven); [componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
firstvalueBeforeChange = componentValue.value; firstvalueBeforeChange = componentValue.value;
@ -19,7 +19,7 @@ describe('ticket componentUpdate()', () => {
secondvalueBeforeChange = componentValue.value; secondvalueBeforeChange = componentValue.value;
}); });
it('should change the agencyMode to modify the sale components value', async() => { it('should change the agencyMode to modify the sale components value', async () => {
let data = { let data = {
clientFk: 101, clientFk: 101,
agencyModeFk: 8, agencyModeFk: 8,
@ -46,7 +46,7 @@ describe('ticket componentUpdate()', () => {
expect(secondvalueBeforeChange).not.toEqual(secondvalueAfterChange); expect(secondvalueBeforeChange).not.toEqual(secondvalueAfterChange);
}); });
it('should change the agencyMode to go back to the originals sale components value', async() => { it('should change the agencyMode to go back to the originals sale components value', async () => {
let data = { let data = {
clientFk: 101, clientFk: 101,
agencyModeFk: 7, agencyModeFk: 7,