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..2458a94ac --- /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/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: {