#1944 ticket.summary

This commit is contained in:
Carlos Jimenez Ruiz 2020-02-05 12:44:14 +01:00
parent dc515531c6
commit 76fc5a3311
7 changed files with 176 additions and 4 deletions

View File

@ -0,0 +1,12 @@
<vn-popover vn-id="popover">
<vn-spinner
ng-if="$ctrl.route == null"
style="padding: 1em;"
enable="true">
</vn-spinner>
<vn-route-descriptor
ng-if="$ctrl.route"
route="$ctrl.route"
quicklinks="$ctrl.quicklinks">
</vn-route-descriptor>
</vn-popover>

View File

@ -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: '<'
}
});

View File

@ -0,0 +1,9 @@
vn-route-descriptor-popover {
vn-route-descriptor {
display: block;
width: 16em;
& > vn-card{
margin: 0!important;
}
}
}

View File

@ -4,6 +4,7 @@ import './main';
import './index/';
import './search-panel';
import './descriptor';
import './descriptor-popover';
import './summary';
import './card';
import './create';

View File

@ -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"},

View File

@ -42,9 +42,11 @@
value="{{$ctrl.summary.landed | date: 'dd/MM/yyyy'}}">
</vn-label-value>
<vn-label-value label="Route">
<a ui-sref="route.card.summary({id: $ctrl.summary.routeFk})">
<span
ng-click="$ctrl.showRouteDescriptor($event)"
class="link">
{{$ctrl.summary.routeFk}}
</a>
</span>
</vn-label-value>
<vn-label-value label="Package size"
value="{{$ctrl.summary.packages}}">
@ -199,7 +201,6 @@
</span>
</vn-td>
<vn-td number>
<vn-check vn-one
ng-model="::request.isOk"
triple-state="true"
@ -213,6 +214,10 @@
</vn-auto>
</vn-horizontal>
</vn-card>
<vn-route-descriptor-popover
vn-id="route-descriptor"
quicklinks="$ctrl.routeQuicklinks">
</vn-route-descriptor-popover>
<vn-item-descriptor-popover
vn-id="descriptor"
quicklinks="$ctrl.quicklinks">

View File

@ -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: {