Bug #571 usuario con privilegios cambia el estado de un ticket bloqueado
This commit is contained in:
parent
b6cc14065e
commit
49ea108771
|
@ -114,7 +114,7 @@ class Controller {
|
||||||
|
|
||||||
onStateChange(value) {
|
onStateChange(value) {
|
||||||
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
||||||
this.$http.post(`/ticket/api/TicketTrackings`, params).then(() => {
|
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
|
||||||
this.card.reload();
|
this.card.reload();
|
||||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
|
@ -265,6 +265,7 @@ class Controller {
|
||||||
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
|
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
|
||||||
this.sale.price = this.edit.price;
|
this.sale.price = this.edit.price;
|
||||||
this.$scope.model.refresh();
|
this.$scope.model.refresh();
|
||||||
|
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.$scope.editPricePopover.hide();
|
this.$scope.editPricePopover.hide();
|
||||||
|
@ -303,8 +304,6 @@ class Controller {
|
||||||
updateQuantity(id, quantity) {
|
updateQuantity(id, quantity) {
|
||||||
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
|
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
|
||||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||||
}).catch(e => {
|
|
||||||
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
|
||||||
});
|
});
|
||||||
this.$scope.model.refresh();
|
this.$scope.model.refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
|
||||||
describe('Ticket', () => {
|
fdescribe('Ticket', () => {
|
||||||
describe('Component vnTicketSale', () => {
|
describe('Component vnTicketSale', () => {
|
||||||
let $componentController;
|
let $componentController;
|
||||||
let controller;
|
let controller;
|
||||||
|
@ -20,9 +20,7 @@ describe('Ticket', () => {
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
$state.params.id = 1;
|
$state.params.id = 1;
|
||||||
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
|
$scope.model = {data: [
|
||||||
controller.ticket = {id: 1};
|
|
||||||
controller.$scope = {model: {data: [
|
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
quantity: 5,
|
quantity: 5,
|
||||||
|
@ -37,11 +35,10 @@ describe('Ticket', () => {
|
||||||
discount: 0,
|
discount: 0,
|
||||||
checked: true
|
checked: true
|
||||||
}
|
}
|
||||||
]}, accept: () => {
|
]};
|
||||||
return {
|
$scope.addTurn = {show: () => {}};
|
||||||
then: () => {}
|
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
|
||||||
};
|
controller.ticket = {id: 1};
|
||||||
}};
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('getSales()', () => {
|
describe('getSales()', () => {
|
||||||
|
@ -148,19 +145,22 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
xdescribe('addTurn(day)', () => {
|
describe('addTurn(day)', () => {
|
||||||
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
|
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
|
||||||
controller.$scope.addTurn = {hide: () => {}};
|
controller.$scope.addTurn = {hide: () => {}};
|
||||||
spyOn(controller.$scope.addTurn, 'hide');
|
spyOn(controller.$scope.addTurn, 'hide');
|
||||||
controller.showAddTurnDialog();
|
|
||||||
|
|
||||||
expect(controller.$scope.addTurn.show).toHaveBeenCalledWith();
|
$httpBackend.expectPATCH(`/ticket/api/TicketWeeklies`).respond();
|
||||||
|
controller.addTurn(1);
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.$scope.addTurn.hide).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onStateChange()', () => {
|
describe('onStateChange()', () => {
|
||||||
it('should perform a POST', () => {
|
it('should perform a post and then call a function', () => {
|
||||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings`).respond();
|
$httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond();
|
||||||
controller.card = {reload: () => {}};
|
controller.card = {reload: () => {}};
|
||||||
controller.onStateChange(3);
|
controller.onStateChange(3);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
|
@ -22,6 +22,9 @@ module.exports = Self => {
|
||||||
Self.isEditable = async ticketFk => {
|
Self.isEditable = async ticketFk => {
|
||||||
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'});
|
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'});
|
||||||
let exists = await Self.app.models.Ticket.findOne({where: {id: ticketFk}, fields: 'isDeleted'});
|
let exists = await Self.app.models.Ticket.findOne({where: {id: ticketFk}, fields: 'isDeleted'});
|
||||||
return (exists && state == null && exists.isDeleted == 0) || (exists.isDeleted == 0 && state.alertLevel == 0);
|
if (!exists || exists.isDeleted == 1 || state.alertLevel > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.changeState = async (params, ctx) => {
|
Self.changeState = async params => {
|
||||||
let isEditable = await Self.app.models.Ticket.isEditable(params.ticketFk);
|
let isEditable = await Self.app.models.Ticket.isEditable(params.ticketFk);
|
||||||
if (isEditable)
|
if (isEditable)
|
||||||
return await Self.app.models.TicketTracking.create(params);
|
return await Self.app.models.TicketTracking.create(params);
|
||||||
|
|
Loading…
Reference in New Issue