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) {
|
||||
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.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.sale.price = this.edit.price;
|
||||
this.$scope.model.refresh();
|
||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||
});
|
||||
}
|
||||
this.$scope.editPricePopover.hide();
|
||||
|
@ -303,8 +304,6 @@ class Controller {
|
|||
updateQuantity(id, quantity) {
|
||||
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
|
||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||
}).catch(e => {
|
||||
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
||||
});
|
||||
this.$scope.model.refresh();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './index.js';
|
||||
|
||||
describe('Ticket', () => {
|
||||
fdescribe('Ticket', () => {
|
||||
describe('Component vnTicketSale', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
|
@ -20,9 +20,7 @@ describe('Ticket', () => {
|
|||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$state.params.id = 1;
|
||||
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
|
||||
controller.ticket = {id: 1};
|
||||
controller.$scope = {model: {data: [
|
||||
$scope.model = {data: [
|
||||
{
|
||||
id: 1,
|
||||
quantity: 5,
|
||||
|
@ -37,11 +35,10 @@ describe('Ticket', () => {
|
|||
discount: 0,
|
||||
checked: true
|
||||
}
|
||||
]}, accept: () => {
|
||||
return {
|
||||
then: () => {}
|
||||
};
|
||||
}};
|
||||
]};
|
||||
$scope.addTurn = {show: () => {}};
|
||||
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
|
||||
controller.ticket = {id: 1};
|
||||
}));
|
||||
|
||||
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()', () => {
|
||||
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()', () => {
|
||||
it('should perform a POST', () => {
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings`).respond();
|
||||
it('should perform a post and then call a function', () => {
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond();
|
||||
controller.card = {reload: () => {}};
|
||||
controller.onStateChange(3);
|
||||
$httpBackend.flush();
|
||||
|
|
|
@ -22,6 +22,9 @@ module.exports = Self => {
|
|||
Self.isEditable = async ticketFk => {
|
||||
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'});
|
||||
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);
|
||||
if (isEditable)
|
||||
return await Self.app.models.TicketTracking.create(params);
|
||||
|
|
Loading…
Reference in New Issue