Bug #243 Indice de Tickets
This commit is contained in:
parent
c70154ef24
commit
592b34a879
|
@ -1,20 +1,66 @@
|
|||
<mg-ajax path="/ticket/api/Tickets/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||
<div margin-medium>
|
||||
<div class="vn-list">
|
||||
<vn-card>
|
||||
<vn-horizontal pad-medium>
|
||||
<div margin-large>
|
||||
<div>
|
||||
<vn-card pad-medium>
|
||||
<vn-title>TICKETS</vn-title>
|
||||
<vn-horizontal class="vn-list">
|
||||
<vn-searchbar vn-one
|
||||
index="index"
|
||||
on-search="$ctrl.search(index)"
|
||||
ignore-keys = "['page', 'size', 'search']">
|
||||
</vn-searchbar>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-card margin-medium-top>
|
||||
<vn-ticket-item
|
||||
ng-repeat="ticket in index.model.instances"
|
||||
ticket="ticket">
|
||||
</vn-ticket-item>
|
||||
<vn-horizontal>
|
||||
<table class="vn-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th number translate>ID Ticket</th>
|
||||
<th translate>Comercial</th>
|
||||
<th translate>Date</th>
|
||||
<th translate>Hora</th>
|
||||
<th translate>Alias</th>
|
||||
<th translate>Provincia</th>
|
||||
<th translate>Estado</th>
|
||||
<th translate>Agencia</th>
|
||||
<th translate>Almacen</th>
|
||||
<th number translate>Factura</th>
|
||||
<th number translate>Ruta</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="ticket in index.model.instances"
|
||||
class="{{::$ctrl.compareDate(ticket.shipped)}} clickable"
|
||||
ui-sref="ticket.card.summary({id: {{::ticket.id}}})">
|
||||
<td>
|
||||
<!-- <i pointer
|
||||
class="material-icons"
|
||||
vn-tooltip="delete expedition"
|
||||
ng-click="$ctrl.deleteExpedition(expedition)">warning</i> -->
|
||||
</td>
|
||||
<th number>{{::ticket.id}}</th>
|
||||
<td translate>{{::ticket.client.salesPerson.name | dashIfEmpty}}</td>
|
||||
<td translate>{{::ticket.shipped | date:'dd/MM/yyyy'}}</td>
|
||||
<td translate>{{::ticket.shipped | date:'HH:MM'}}</td>
|
||||
<td translate>{{::ticket.nickname}}</td>
|
||||
<td translate>{{::ticket.address.province.name}}</td>
|
||||
<td translate>{{::ticket.ticketTracking.state.name}}</td>
|
||||
<td translate>{{::ticket.agencyMode.name}}</td>
|
||||
<td translate>{{::ticket.warehouse.name}}</td>
|
||||
<td number translate>{{::ticket.refFk | dashIfEmpty}}</td>
|
||||
<td number translate>{{::ticket.routeFk | dashIfEmpty}}</td>
|
||||
<td>
|
||||
<vn-icon-button
|
||||
ng-click="$ctrl.preview($event, ticket)"
|
||||
vn-tooltip="Preview"
|
||||
icon="desktop_windows">
|
||||
</vn-icon-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-paging index="index" total="index.model.count"></vn-paging>
|
||||
</div>
|
||||
|
|
|
@ -8,13 +8,30 @@ export default class Controller {
|
|||
this.ticketSelected = null;
|
||||
}
|
||||
|
||||
search(index) {
|
||||
index.accept();
|
||||
compareDate(date) {
|
||||
let today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
let timeTicket = new Date(date);
|
||||
timeTicket.setHours(0, 0, 0, 0);
|
||||
|
||||
let comparation = today - timeTicket;
|
||||
|
||||
if (comparation == 0)
|
||||
return 'warning';
|
||||
|
||||
if (comparation < 0)
|
||||
return 'success';
|
||||
}
|
||||
|
||||
openSummary(ticket) {
|
||||
this.ticketSelected = ticket;
|
||||
preview(event, ticket) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
this.$scope.dialogSummaryTicket.show();
|
||||
this.ticketSelected = ticket;
|
||||
}
|
||||
|
||||
search(index) {
|
||||
index.accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
import './ticket-list.js';
|
||||
|
||||
describe('ticket', () => {
|
||||
describe('Component vnTicketList', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('ticket');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject(_$componentController_ => {
|
||||
$componentController = _$componentController_;
|
||||
controller = $componentController('vnTicketList');
|
||||
}));
|
||||
|
||||
describe('compareDate()', () => {
|
||||
it('should return warning when the date is the present', () => {
|
||||
let date = new Date();
|
||||
let result = controller.compareDate(date);
|
||||
|
||||
expect(result).toEqual('warning');
|
||||
});
|
||||
|
||||
it('should return warning when the date is in the future', () => {
|
||||
let date = '2518-05-19T00:00:00.000Z';
|
||||
let result = controller.compareDate(date);
|
||||
|
||||
expect(result).toEqual('success');
|
||||
});
|
||||
});
|
||||
|
||||
describe('preview()', () => {
|
||||
it('should call preventDefault and stopImmediatePropagation from event and show', () => {
|
||||
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopImmediatePropagation']);
|
||||
|
||||
controller.$scope = {dialogSummaryTicket: {show: () => {}}};
|
||||
spyOn(controller.$scope.dialogSummaryTicket, 'show');
|
||||
let ticket = {};
|
||||
controller.preview(event, ticket);
|
||||
|
||||
expect(event.preventDefault).toHaveBeenCalledWith();
|
||||
expect(event.stopImmediatePropagation).toHaveBeenCalledWith();
|
||||
expect(controller.$scope.dialogSummaryTicket.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -6,7 +6,53 @@ module.exports = Self => {
|
|||
where: {},
|
||||
skip: (params.page - 1) * params.size,
|
||||
limit: params.size,
|
||||
order: params.order || 'created DESC'
|
||||
order: params.order || 'created DESC',
|
||||
include: [
|
||||
{
|
||||
relation: 'address',
|
||||
scope: {
|
||||
fields: ['provinceFk'],
|
||||
include: {
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'warehouse',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}, {
|
||||
relation: 'agencyMode',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}, {
|
||||
relation: 'ticketTracking',
|
||||
scope: {
|
||||
fields: ['stateFk'],
|
||||
include: {
|
||||
relation: 'state',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['salesPersonFk'],
|
||||
include: {
|
||||
relation: 'salesPerson',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
delete params.page;
|
||||
|
|
Loading…
Reference in New Issue