diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 03225f8d8..0399f7b17 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -314,7 +314,7 @@ export default {
ticketSummary: {
header: 'vn-ticket-summary > vn-card > h5',
state: 'vn-ticket-summary vn-label-value[label="State"] > section > span',
- route: 'vn-ticket-summary vn-label-value[label="Route"] > section > span > a',
+ route: 'vn-ticket-summary vn-label-value[label="Route"] > section > span > span',
total: 'vn-ticket-summary vn-one.taxes > p:nth-child(3) > strong',
sale: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr',
firstSaleItemId: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > span',
diff --git a/modules/route/front/descriptor-popover/index.html b/modules/route/front/descriptor-popover/index.html
new file mode 100644
index 000000000..a0295c138
--- /dev/null
+++ b/modules/route/front/descriptor-popover/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/route/front/descriptor-popover/index.js b/modules/route/front/descriptor-popover/index.js
new file mode 100644
index 000000000..7d5cd3d91
--- /dev/null
+++ b/modules/route/front/descriptor-popover/index.js
@@ -0,0 +1,130 @@
+import ngModule from '../module';
+import Component from 'core/lib/component';
+import './style.scss';
+
+class Controller extends Component {
+ constructor($element, $scope, $http, $timeout, $q) {
+ super($element, $scope);
+ this.$timeout = $timeout;
+ this.$http = $http;
+ this.$q = $q;
+ this.route = null;
+ this._quicklinks = {};
+ }
+
+ set routeFk(id) {
+ if (id == this._routeFk) return;
+
+ this._routeFk = id;
+ this.route = null;
+ this.getCard();
+ }
+
+ get routeFk() {
+ return this._routeFk;
+ }
+
+ set route(value) {
+ this._route = value;
+ this.$timeout(() => this.$.popover.relocate());
+ }
+
+ get route() {
+ return this._route;
+ }
+
+ get quicklinks() {
+ return this._quicklinks;
+ }
+
+ set quicklinks(value = {}) {
+ Object.keys(value).forEach(key => {
+ this._quicklinks[key] = value[key];
+ });
+ }
+
+ show() {
+ this.$.popover.parent = this.parent;
+ this.$.popover.show();
+ }
+
+ getCard() {
+ if (this.canceler)
+ this.canceler.resolve();
+
+ this.canceler = this.$q.defer();
+
+ let query = 'Routes/findOne';
+
+ let filter = {
+ fields: [
+ 'id',
+ 'workerFk',
+ 'agencyModeFk',
+ 'created',
+ 'm3',
+ 'warehouseFk',
+ 'description',
+ 'vehicleFk',
+ 'kmStart',
+ 'kmEnd',
+ 'started',
+ 'finished',
+ 'cost',
+ 'zoneFk'
+ ],
+ include: [
+ {
+ relation: 'agencyMode',
+ scope: {
+ fields: ['id', 'name']
+ }
+ }, {
+ relation: 'vehicle',
+ scope: {
+ fields: ['id', 'm3']
+ }
+ }, {
+ relation: 'zone',
+ scope: {
+ fields: ['id', 'name']
+ }
+ },
+ {
+ relation: 'worker',
+ scope: {
+ fields: ['userFk'],
+ include: {
+ relation: 'user',
+ scope: {
+ fields: ['id'],
+ include: {
+ relation: 'emailUser',
+ scope: {
+ fields: ['email']
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ };
+ this.$http.get(query, {params: {filter}}).then(res => {
+ this.route = res.data;
+ this.$.$applyAsync(() => {
+ this.$.popover.relocate();
+ });
+ });
+ }
+}
+Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
+
+ngModule.component('vnRouteDescriptorPopover', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ routeFk: '<',
+ quicklinks: '<'
+ }
+});
diff --git a/modules/route/front/descriptor-popover/index.spec.js b/modules/route/front/descriptor-popover/index.spec.js
new file mode 100644
index 000000000..be33d366d
--- /dev/null
+++ b/modules/route/front/descriptor-popover/index.spec.js
@@ -0,0 +1,77 @@
+import './index';
+
+describe('vnRouteDescriptorPopover', () => {
+ let $httpBackend;
+ let $scope;
+ let controller;
+ let $element;
+ let $timeout;
+
+ beforeEach(ngModule('route'));
+
+ beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => {
+ $httpBackend = _$httpBackend_;
+ $timeout = _$timeout_;
+ $element = angular.element(`
`);
+ $scope = $rootScope.$new();
+ $scope.popover = {relocate: () => {}, show: () => {}};
+ controller = $componentController('vnRouteDescriptorPopover', {$scope, $element});
+ }));
+
+ describe('routeFk()', () => {
+ it(`should do nothing if the received id isn't a new one`, () => {
+ controller.route = 'I exist!';
+ controller._routeFk = 1;
+ spyOn(controller, 'getCard');
+ controller.routeFk = 1;
+
+ expect(controller.route).toEqual('I exist!');
+ expect(controller._routeFk).toEqual(1);
+ expect(controller.getCard).not.toHaveBeenCalled();
+ });
+
+ it(`should set the received id, set the route null and then call getCard()`, () => {
+ controller.route = `Please don't`;
+ controller._routeFk = 1;
+ spyOn(controller, 'getCard');
+ controller.routeFk = 999;
+
+ expect(controller.route).toBeNull();
+ expect(controller._routeFk).toEqual(999);
+ expect(controller.getCard).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('route()', () => {
+ it(`should save the client on the controller and then call relocate()`, () => {
+ spyOn(controller.$.popover, 'relocate');
+ let route = `i'm the route!`;
+ controller.route = route;
+ $timeout.flush();
+
+ expect(controller.route).toEqual(route);
+ expect(controller.$.popover.relocate).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('show()', () => {
+ it(`should call the popover show() method`, () => {
+ spyOn(controller.$.popover, 'show');
+ controller.show();
+
+ expect(controller.$.popover.show).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('getCard()', () => {
+ it(`should perform a get query to store the client data into the controller`, () => {
+ let response = {the: 'route'};
+
+ $httpBackend.whenRoute('GET', 'Routes/findOne').respond(response);
+ controller.routeFk = 1;
+ $httpBackend.flush();
+
+ expect(controller.route).toEqual(response);
+ });
+ });
+});
diff --git a/modules/route/front/descriptor-popover/style.scss b/modules/route/front/descriptor-popover/style.scss
new file mode 100644
index 000000000..0c84ff2fe
--- /dev/null
+++ b/modules/route/front/descriptor-popover/style.scss
@@ -0,0 +1,9 @@
+vn-route-descriptor-popover {
+ vn-route-descriptor {
+ display: block;
+ width: 16em;
+ & > vn-card{
+ margin: 0!important;
+ }
+ }
+}
diff --git a/modules/route/front/index.js b/modules/route/front/index.js
index ce8e80e95..7c2a17483 100644
--- a/modules/route/front/index.js
+++ b/modules/route/front/index.js
@@ -4,6 +4,7 @@ import './main';
import './index/';
import './search-panel';
import './descriptor';
+import './descriptor-popover';
import './summary';
import './card';
import './create';
diff --git a/modules/ticket/front/routes.json b/modules/ticket/front/routes.json
index be142a2ac..af0683ee1 100644
--- a/modules/ticket/front/routes.json
+++ b/modules/ticket/front/routes.json
@@ -3,7 +3,7 @@
"name": "Tickets",
"icon": "icon-ticket",
"validations": true,
- "dependencies": ["worker", "item", "client"],
+ "dependencies": ["worker", "item", "client", "route"],
"menus": {
"main": [
{"state": "ticket.index", "icon": "icon-ticket"},
diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html
index 7bbff4f28..decb01023 100644
--- a/modules/ticket/front/summary/index.html
+++ b/modules/ticket/front/summary/index.html
@@ -42,9 +42,11 @@
value="{{$ctrl.summary.landed | date: 'dd/MM/yyyy'}}">
-
+
{{$ctrl.summary.routeFk}}
-
+
@@ -199,7 +201,6 @@
-
+
+
diff --git a/modules/ticket/front/summary/index.js b/modules/ticket/front/summary/index.js
index 0cfa5614f..010110340 100644
--- a/modules/ticket/front/summary/index.js
+++ b/modules/ticket/front/summary/index.js
@@ -36,6 +36,21 @@ class Controller {
});
}
+ showRouteDescriptor(event) {
+ this.routeQuicklinks = {
+ btnThree: {
+ icon: 'icon-delivery',
+ state: `route.card.summary({
+ id: ${this.summary.routeFk},
+ })`,
+ tooltip: 'Route summary'
+ }
+ };
+ this.$scope.routeDescriptor.routeFk = this.summary.routeFk;
+ this.$scope.routeDescriptor.parent = event.target;
+ this.$scope.routeDescriptor.show();
+ }
+
showDescriptor(event, itemFk) {
this.quicklinks = {
btnThree: {