diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index e2c75597ad..cbbae3dd6a 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -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"]',
diff --git a/e2e/paths/05-ticket-module/09_ticket_weekly.spec.js b/e2e/paths/05-ticket-module/09_ticket_weekly.spec.js
index a42e6c527c..aeaac0fa82 100644
--- a/e2e/paths/05-ticket-module/09_ticket_weekly.spec.js
+++ b/e2e/paths/05-ticket-module/09_ticket_weekly.spec.js
@@ -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');
});
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index 76b1017b35..1b91254e7a 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -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"
}
\ No newline at end of file
diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html
index 95a722bd4e..4c54e07565 100644
--- a/modules/client/front/create/index.html
+++ b/modules/client/front/create/index.html
@@ -18,7 +18,7 @@
value-field="id"
where="{role: 'employee'}"
label="Salesperson">
- {{firstName}} {{name}}
+ {{firstName}} {{lastName}}
diff --git a/modules/ticket/back/models/ticket-weekly.js b/modules/ticket/back/models/ticket-weekly.js
index 8456ef49a2..733f1483a6 100644
--- a/modules/ticket/back/models/ticket-weekly.js
+++ b/modules/ticket/back/models/ticket-weekly.js
@@ -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;
+ });
};
diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js
index f9c1e9d1c6..b75398d9d8 100644
--- a/modules/ticket/front/index.js
+++ b/modules/ticket/front/index.js
@@ -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';
diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js
index 9413400cee..443857c9f6 100644
--- a/modules/ticket/front/index/index.js
+++ b/modules/ticket/front/index/index.js
@@ -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();
diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml
index dc5ed6305b..b29c7399d3 100644
--- a/modules/ticket/front/index/locale/es.yml
+++ b/modules/ticket/front/index/locale/es.yml
@@ -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...
diff --git a/modules/ticket/front/routes.json b/modules/ticket/front/routes.json
index 5332fa1cbc..cda0b75363 100644
--- a/modules/ticket/front/routes.json
+++ b/modules/ticket/front/routes.json
@@ -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",
diff --git a/modules/ticket/front/weekly/create/index.html b/modules/ticket/front/weekly/create/index.html
new file mode 100644
index 0000000000..bedd5f40c0
--- /dev/null
+++ b/modules/ticket/front/weekly/create/index.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/ticket/front/weekly/create/index.js b/modules/ticket/front/weekly/create/index.js
new file mode 100644
index 0000000000..5d8fcb2b3e
--- /dev/null
+++ b/modules/ticket/front/weekly/create/index.js
@@ -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
+});
diff --git a/modules/ticket/front/weekly/create/index.spec.js b/modules/ticket/front/weekly/create/index.spec.js
new file mode 100644
index 0000000000..1d3ae2e74c
--- /dev/null
+++ b/modules/ticket/front/weekly/create/index.spec.js
@@ -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');
+ });
+ });
+ });
+});
diff --git a/modules/ticket/front/weekly/create/locale/es.yml b/modules/ticket/front/weekly/create/locale/es.yml
new file mode 100644
index 0000000000..7d9a372bb5
--- /dev/null
+++ b/modules/ticket/front/weekly/create/locale/es.yml
@@ -0,0 +1,2 @@
+Weekday: Día de la semana
+Add weekly ticket: Añadir ticket programado
\ No newline at end of file
diff --git a/modules/ticket/front/weekly/index.html b/modules/ticket/front/weekly/index/index.html
similarity index 87%
rename from modules/ticket/front/weekly/index.html
rename to modules/ticket/front/weekly/index/index.html
index 708e15ba29..f7405ebb76 100644
--- a/modules/ticket/front/weekly/index.html
+++ b/modules/ticket/front/weekly/index/index.html
@@ -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>
-
+
Ticket ID
Client
- Turn
+ Weekday
Warehouse
Salesperson
+
@@ -66,7 +67,7 @@
{{::weekly.nickName}}
-
+
+ question="This ticket will be removed from weekly tickets! Continue anyway?"
+ message="You are going to delete this weekly ticket">
+
+
+
\ No newline at end of file
diff --git a/modules/ticket/front/weekly/index.js b/modules/ticket/front/weekly/index/index.js
similarity index 96%
rename from modules/ticket/front/weekly/index.js
rename to modules/ticket/front/weekly/index/index.js
index ddac0d1b52..4aef03c294 100644
--- a/modules/ticket/front/weekly/index.js
+++ b/modules/ticket/front/weekly/index/index.js
@@ -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
});
diff --git a/modules/ticket/front/weekly/index/locale/es.yml b/modules/ticket/front/weekly/index/locale/es.yml
new file mode 100644
index 0000000000..fa40fe96b3
--- /dev/null
+++ b/modules/ticket/front/weekly/index/locale/es.yml
@@ -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
\ No newline at end of file
diff --git a/modules/ticket/front/weekly/locale/es.yml b/modules/ticket/front/weekly/locale/es.yml
deleted file mode 100644
index e4e7ef068c..0000000000
--- a/modules/ticket/front/weekly/locale/es.yml
+++ /dev/null
@@ -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
\ No newline at end of file
diff --git a/modules/ticket/front/weekly/style.scss b/modules/ticket/front/weekly/style.scss
deleted file mode 100644
index 1d67b9cd03..0000000000
--- a/modules/ticket/front/weekly/style.scss
+++ /dev/null
@@ -1,6 +0,0 @@
-vn-ticket-weekly {
- vn-card {
- margin: auto;
- max-width: 880px;
- }
-}
\ No newline at end of file