This commit is contained in:
parent
772095fc1e
commit
07af2271c2
|
@ -325,11 +325,11 @@ export default {
|
|||
advancedSearchButton: 'vn-ticket-index vn-searchbar > vn-popover vn-ticket-search-panel vn-submit[label="Search"] input',
|
||||
searchButton: 'vn-ticket-index vn-searchbar vn-icon[icon="search"]',
|
||||
moreMenu: 'vn-ticket-index vn-icon-menu[vn-id="more-button"] > div > vn-icon',
|
||||
moreMenuTurns: 'vn-ticket-index vn-icon-menu vn-drop-down > vn-popover li:nth-child(2)',
|
||||
sixthWeeklyTicketTurn: 'vn-ticket-weekly vn-table vn-tr:nth-child(6) vn-autocomplete[field="weekly.weekDay"] input',
|
||||
weeklyTicket: 'vn-ticket-weekly vn-table > div > vn-tbody > vn-tr',
|
||||
sixthWeeklyTicketDeleteIcon: 'vn-ticket-weekly vn-tr:nth-child(6) vn-icon-button[icon="delete"]',
|
||||
acceptDeleteTurn: 'vn-ticket-weekly > vn-confirm[vn-id="deleteWeekly"] button[response="ACCEPT"]'
|
||||
moreMenuWeeklyTickets: 'vn-ticket-index vn-icon-menu vn-drop-down > vn-popover li:nth-child(2)',
|
||||
sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) vn-autocomplete[field="weekly.weekDay"] input',
|
||||
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
|
||||
sixthWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(6) vn-icon-button[icon="delete"]',
|
||||
acceptDeleteTurn: 'vn-ticket-weekly-index > vn-confirm[vn-id="deleteWeekly"] button[response="ACCEPT"]'
|
||||
},
|
||||
createTicketView: {
|
||||
clientAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.clientFk"]',
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Ticket descriptor path', () => {
|
|||
it('should count the mount of tickets in the turns section', async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick(selectors.ticketsIndex.moreMenu)
|
||||
.waitToClick(selectors.ticketsIndex.moreMenuTurns)
|
||||
.waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets)
|
||||
.wait(selectors.ticketsIndex.weeklyTicket)
|
||||
.countElement(selectors.ticketsIndex.weeklyTicket);
|
||||
|
||||
|
@ -73,8 +73,8 @@ describe('Ticket descriptor path', () => {
|
|||
it('should confirm the ticket 11 was added on thursday', async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick(selectors.ticketsIndex.moreMenu)
|
||||
.waitToClick(selectors.ticketsIndex.moreMenuTurns)
|
||||
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
|
||||
.waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets)
|
||||
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
|
||||
|
||||
expect(result).toEqual('Thursday');
|
||||
});
|
||||
|
@ -133,8 +133,8 @@ describe('Ticket descriptor path', () => {
|
|||
it('should confirm the ticket 11 was added on saturday', async() => {
|
||||
const result = await nightmare
|
||||
.waitToClick(selectors.ticketsIndex.moreMenu)
|
||||
.waitToClick(selectors.ticketsIndex.moreMenuTurns)
|
||||
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
|
||||
.waitToClick(selectors.ticketsIndex.moreMenuWeeklyTickets)
|
||||
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
|
||||
|
||||
expect(result).toEqual('Saturday');
|
||||
});
|
||||
|
|
|
@ -97,5 +97,8 @@
|
|||
"This postcode already exists": "Este código postal ya existe",
|
||||
"Concept cannot be blank": "El concepto no puede quedar en blanco",
|
||||
"File doesn't exists": "El archivo no existe",
|
||||
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona"
|
||||
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona",
|
||||
"This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
|
||||
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
|
||||
"Weekday cannot be blank": "El día de la semana no puede quedar en blanco"
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
label="Salesperson">
|
||||
<tpl-item>{{firstName}} {{name}}</tpl-item>
|
||||
<tpl-item>{{firstName}} {{lastName}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
require('../methods/ticket-weekly/filter')(Self);
|
||||
|
||||
Self.validatesPresenceOf('ticketFk', {
|
||||
message: `Ticket id cannot be blank`
|
||||
});
|
||||
|
||||
Self.validatesPresenceOf('weekDay', {
|
||||
message: `Weekday cannot be blank`
|
||||
});
|
||||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`This ticket is already on weekly tickets`);
|
||||
return err;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -30,7 +30,8 @@ import './picture';
|
|||
import './request/index';
|
||||
import './request/create';
|
||||
import './log';
|
||||
import './weekly';
|
||||
import './weekly/index';
|
||||
import './weekly/create';
|
||||
import './dms/index';
|
||||
import './dms/create';
|
||||
import './dms/edit';
|
||||
|
|
|
@ -11,8 +11,8 @@ export default class Controller {
|
|||
this.selectedTicket = null;
|
||||
this.moreOptions = [
|
||||
{callback: () => {
|
||||
this.$state.go('ticket.weekly');
|
||||
}, name: 'Turns', always: true},
|
||||
this.$state.go('ticket.weekly.index');
|
||||
}, name: 'Weekly tickets', always: true},
|
||||
{callback: () => {
|
||||
this.setBalanceCreateDialog();
|
||||
this.$.balanceCreateDialog.show();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Turns: Turnos
|
||||
Weekly tickets: Tickets programados
|
||||
Go to lines: Ir a lineas
|
||||
Not available: No disponible
|
||||
Payment on account...: Pago a cuenta...
|
||||
|
|
|
@ -181,10 +181,21 @@
|
|||
"component": "vn-ticket-log",
|
||||
"description": "Log"
|
||||
}, {
|
||||
"url" : "/weekly?q",
|
||||
"url": "/weekly",
|
||||
"state": "ticket.weekly",
|
||||
"component": "vn-ticket-weekly",
|
||||
"abstract": true,
|
||||
"component": "ui-view",
|
||||
"description": "Weekly"
|
||||
}, {
|
||||
"url": "/index?q",
|
||||
"state": "ticket.weekly.index",
|
||||
"component": "vn-ticket-weekly-index",
|
||||
"description": "Weekly tickets"
|
||||
}, {
|
||||
"url": "/create",
|
||||
"state": "ticket.weekly.create",
|
||||
"component": "vn-ticket-weekly-create",
|
||||
"description": "Add weekly ticket"
|
||||
}, {
|
||||
"url": "/request",
|
||||
"state": "ticket.card.request",
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<mg-ajax path="/api/ticketWeeklies" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.ticketWeekly"
|
||||
form="form"
|
||||
save="post">
|
||||
</vn-watcher>
|
||||
<div class="content-block">
|
||||
<form name="form" vn-http-submit="$ctrl.onSubmit()" compact>
|
||||
<vn-card pad-large>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one vn-id="ticket"
|
||||
url="/api/tickets"
|
||||
field="$ctrl.ticketWeekly.ticketFk"
|
||||
fields="['id', 'nickname', 'clientFk', 'warehouseFk']"
|
||||
search-function="{nickname: $search}"
|
||||
show-field="id"
|
||||
value-field="id"
|
||||
label="Ticket"
|
||||
on-change="$ctrl.onChangeTicket(ticket.selection)">
|
||||
<tpl-item>#{{id}} - {{nickname}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one label="Weekday"
|
||||
field="$ctrl.ticketWeekly.weekDay"
|
||||
data="$ctrl.weekdays"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
translate-fields="['name']"
|
||||
order="id">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="client" vn-one disabled="true"
|
||||
url="/api/clients"
|
||||
fields="['id', 'name', 'salesPersonFk']"
|
||||
field="$ctrl.ticketWeekly.clientFk"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Client"
|
||||
selection="$ctrl.clientSelection">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one disabled="true"
|
||||
field="$ctrl.ticketWeekly.warehouseFk"
|
||||
url="/api/warehouses"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Warehouse">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one disabled="true"
|
||||
field="$ctrl.ticketWeekly.salesPersonFk"
|
||||
url="/api/clients/activeWorkersWithRole"
|
||||
search-function="{firstName: $search}"
|
||||
show-field="firstName"
|
||||
value-field="id"
|
||||
where="{role: 'employee'}"
|
||||
label="Salesperson">
|
||||
<tpl-item>{{firstName}} {{lastName}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Create"></vn-submit>
|
||||
<vn-button ui-sref="ticket.weekly.index" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
||||
<!-- New postcode dialog -->
|
||||
<vn-client-postcode vn-id="postcode"
|
||||
on-response="$ctrl.onResponse(response)">
|
||||
</vn-client-postcode>
|
||||
</div>
|
|
@ -0,0 +1,49 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
export default class Controller {
|
||||
constructor($scope, $state, $http, $translate, vnApp) {
|
||||
this.$ = $scope;
|
||||
this.$state = $state;
|
||||
this.$http = $http;
|
||||
this.$translate = $translate;
|
||||
this.vnApp = vnApp;
|
||||
this.ticketWeekly = {};
|
||||
this.weekdays = [
|
||||
{id: 0, name: 'Monday'},
|
||||
{id: 1, name: 'Tuesday'},
|
||||
{id: 2, name: 'Wednesday'},
|
||||
{id: 3, name: 'Thursday'},
|
||||
{id: 4, name: 'Friday'},
|
||||
{id: 5, name: 'Saturday'},
|
||||
{id: 6, name: 'Sunday'}
|
||||
];
|
||||
}
|
||||
|
||||
onChangeTicket(ticket) {
|
||||
this.ticketWeekly.clientFk = ticket.clientFk;
|
||||
this.ticketWeekly.warehouseFk = ticket.warehouseFk;
|
||||
}
|
||||
|
||||
get clientSelection() {
|
||||
return this._clientSelection;
|
||||
}
|
||||
|
||||
set clientSelection(value) {
|
||||
this._clientSelection = value;
|
||||
|
||||
if (value)
|
||||
this.ticketWeekly.salesPersonFk = value.salesPersonFk;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
return this.$.watcher.submit().then(
|
||||
json => this.$state.go('ticket.weekly.index')
|
||||
);
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp'];
|
||||
|
||||
ngModule.component('vnTicketWeeklyCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,58 @@
|
|||
import './index';
|
||||
|
||||
fdescribe('Client', () => {
|
||||
describe('Component vnTicketWeeklyCreate', () => {
|
||||
let $componentController;
|
||||
let $scope;
|
||||
let $state;
|
||||
let controller;
|
||||
|
||||
beforeEach(ngModule('ticket'));
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_) => {
|
||||
$componentController = _$componentController_;
|
||||
$scope = $rootScope.$new();
|
||||
$state = _$state_;
|
||||
$scope.watcher = {
|
||||
submit: () => {
|
||||
return {
|
||||
then: callback => {
|
||||
callback({data: {id: '1234'}});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
controller = $componentController('vnTicketWeeklyCreate', {$scope, $state});
|
||||
}));
|
||||
|
||||
describe('onChangeTicket() setter', () => {
|
||||
it(`should define clientFk and warehouseFk properties on ticketWeekly object`, () => {
|
||||
controller.onChangeTicket({clientFk: 101, warehouseFk: 1});
|
||||
|
||||
expect(controller.ticketWeekly.clientFk).toEqual(101);
|
||||
expect(controller.ticketWeekly.warehouseFk).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('clientSelection() setter', () => {
|
||||
it(`should define salesPersonFk property on ticketWeekly object`, () => {
|
||||
controller.clientSelection = {clientFk: 101, salesPersonFk: 106};
|
||||
|
||||
expect(controller.ticketWeekly.salesPersonFk).toEqual(106);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||
spyOn(controller.$state, 'go');
|
||||
controller.ticketWeekly = {
|
||||
ticketFk: 11,
|
||||
weekDay: 0
|
||||
};
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('ticket.weekly.index');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
Weekday: Día de la semana
|
||||
Add weekly ticket: Añadir ticket programado
|
|
@ -14,22 +14,23 @@
|
|||
vn-id="turnSearchbar"
|
||||
style="width: 100%"
|
||||
on-search="$ctrl.onSearch($params)"
|
||||
info="Search turns by id or client id"
|
||||
info="Search weekly ticket by id or client id"
|
||||
vn-focus>
|
||||
</vn-searchbar>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
</div>
|
||||
<div margin-medium>
|
||||
<vn-card margin-medium-v pad-medium>
|
||||
<vn-card margin-medium-v pad-medium compact>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th number field="ticketFk">Ticket ID</vn-th>
|
||||
<vn-th field="weekDay">Client</vn-th>
|
||||
<vn-th>Turn</vn-th>
|
||||
<vn-th>Weekday</vn-th>
|
||||
<vn-th>Warehouse</vn-th>
|
||||
<vn-th>Salesperson</vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
|
@ -66,7 +67,7 @@
|
|||
{{::weekly.nickName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-icon-button
|
||||
icon="delete"
|
||||
ng-click="$ctrl.deleteWeekly($index)"
|
||||
|
@ -90,6 +91,9 @@
|
|||
<vn-confirm
|
||||
vn-id="deleteWeekly"
|
||||
on-response="$ctrl.returnDialog(response)"
|
||||
question="You are going to delete this turn"
|
||||
message="This turn will be removed! Continue anyway?">
|
||||
question="This ticket will be removed from weekly tickets! Continue anyway?"
|
||||
message="You are going to delete this weekly ticket">
|
||||
</vn-confirm>
|
||||
<a ui-sref="ticket.weekly.create" vn-tooltip="Add weekly ticket" vn-bind="+" fixed-bottom-right>
|
||||
<vn-float-button icon="person_add"></vn-float-button>
|
||||
</a>
|
|
@ -1,5 +1,4 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
import ngModule from '../../module';
|
||||
|
||||
export default class Controller {
|
||||
constructor($scope, vnApp, $translate, $http) {
|
||||
|
@ -89,7 +88,7 @@ export default class Controller {
|
|||
|
||||
Controller.$inject = ['$scope', 'vnApp', '$translate', '$http'];
|
||||
|
||||
ngModule.component('vnTicketWeekly', {
|
||||
ngModule.component('vnTicketWeeklyIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
Ticket ID: ID Ticket
|
||||
Weekly tickets: Tickets programados
|
||||
You are going to delete this weekly ticket: Vas a eliminar este ticket programado
|
||||
This ticket will be removed from weekly tickets! Continue anyway?: Este ticket se eliminará de tickets programados! ¿Continuar de todas formas?
|
||||
Search weekly ticket by id or client id: Busca tickets programados por el identificador o el identificador del cliente
|
|
@ -1,6 +0,0 @@
|
|||
Turn: Turno
|
||||
Ticket ID: ID Ticket
|
||||
Weekly: Turnos
|
||||
You are going to delete this turn: Vas a eliminar este turno
|
||||
This turn will be removed! Continue anyway?: Se eliminará este turno! ¿Continuar de todas formas?
|
||||
Search turns by id or client id: Busca turnos por el identificador o el identificador del cliente
|
|
@ -1,6 +0,0 @@
|
|||
vn-ticket-weekly {
|
||||
vn-card {
|
||||
margin: auto;
|
||||
max-width: 880px;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue