feat: add tFront
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
deb8a00dfb
commit
bb26fa6502
|
@ -2,16 +2,6 @@ import ngModule from '../module';
|
|||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
onDialogAccept(id) {
|
||||
return this.$http.delete(`Expeditions/${id}`)
|
||||
.then(() => this.$.model.refresh());
|
||||
}
|
||||
|
||||
showLog(expedition) {
|
||||
this.expedition = expedition;
|
||||
this.$.statusLog.show();
|
||||
}
|
||||
|
||||
get checked() {
|
||||
const rows = this.$.model.data || [];
|
||||
const checkedRows = [];
|
||||
|
@ -27,13 +17,23 @@ class Controller extends Section {
|
|||
return this.checked.length;
|
||||
}
|
||||
|
||||
onDialogAccept(id) {
|
||||
return this.$http.delete(`Expeditions/${id}`)
|
||||
.then(() => this.$.model.refresh());
|
||||
}
|
||||
|
||||
showLog(expedition) {
|
||||
this.expedition = expedition;
|
||||
this.$.statusLog.show();
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
const params = {expeditionsIds: this.checked};
|
||||
const query = `Expeditions/deleteExpeditions`;
|
||||
this.$http.post(query, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Expedition removed'));
|
||||
this.$state.reload();
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,6 @@ class Controller extends Section {
|
|||
const query = `Tickets/new`;
|
||||
this.$http.post(query, ticketParams).then(res => {
|
||||
if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk});
|
||||
|
||||
const params = {
|
||||
expeditionsIds: this.checked,
|
||||
ticketId: res.data.id
|
||||
|
|
|
@ -17,6 +17,14 @@ describe('Ticket', () => {
|
|||
refresh: () => {}
|
||||
};
|
||||
controller = $componentController('vnTicketExpedition', {$element: null, $scope});
|
||||
controller.$.model.data = [
|
||||
{id: 1},
|
||||
{id: 2},
|
||||
{id: 3}
|
||||
];
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
}));
|
||||
|
||||
describe('onDialogAccept()', () => {
|
||||
|
@ -50,5 +58,55 @@ describe('Ticket', () => {
|
|||
expect(controller.$.statusLog.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onRemove()', () => {
|
||||
it('should make a query and then call to the model refresh() method', () => {
|
||||
jest.spyOn($scope.model, 'refresh');
|
||||
|
||||
const expectedParams = {expeditionsIds: [1, 2]};
|
||||
$httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200);
|
||||
controller.onRemove();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($scope.model.refresh).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('createTicket()', () => {
|
||||
it('should make a query and then call to the $state go() method', () => {
|
||||
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
||||
|
||||
const ticket = {
|
||||
clientFk: 1101,
|
||||
landed: new Date(),
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
warehouseFk: 1
|
||||
};
|
||||
controller.ticket = ticket;
|
||||
|
||||
const expectedTicket = {
|
||||
clientId: 1101,
|
||||
landed: new Date(),
|
||||
addressId: 121,
|
||||
agencyModeId: 1,
|
||||
warehouseId: 1
|
||||
};
|
||||
|
||||
const ticketIdToTransfer = 28;
|
||||
const expectedResponse = {id: ticketIdToTransfer};
|
||||
|
||||
const expectedParams = {
|
||||
expeditionsIds: [1, 2],
|
||||
ticketId: 28
|
||||
};
|
||||
$httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse);
|
||||
$httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(200);
|
||||
controller.createTicket();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketIdToTransfer});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue