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,10 +204,9 @@ 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) {
Object.assign(this.data, json.data); Object.assign(this.data, json.data);
@ -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');