This commit is contained in:
Carlos Jimenez Ruiz 2019-03-21 13:46:14 +01:00
parent 504dc954d0
commit 92347cd9c4
10 changed files with 261 additions and 14 deletions

View File

@ -353,15 +353,15 @@ INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassification`, `credit`, `crea
(2, 2 , 6000, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL),
(3, 3, 10000 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL);
INSERT INTO `vn`.`route`(`id`, `created`, `workerFk`, `vehicleFk`, `isOk`, `description`)
INSERT INTO `vn`.`route`(`id`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`)
VALUES
(1, CURDATE(), 56, 1, 0, 'first route' ),
(2, CURDATE(), 56, 1, 0, 'second route' ),
(3, CURDATE(), 56, 2, 0, 'third route' ),
(4, CURDATE(), 56, 3, 0, 'fourth route' ),
(5, CURDATE(), 56, 4, 0, 'fifth route' ),
(6, CURDATE(), 57, 5, 0, 'sixth route' ),
(7, CURDATE(), 57, 6, 0, 'seventh route');
(1, 56, CURDATE(), 1, 1, 'first route', null),
(2, 56, CURDATE(), 1, 1, 'second route', 4.2),
(3, 56, CURDATE(), 2, 7, 'third route', 5.3),
(4, 56, CURDATE(), 3, 7, 'fourth route', 6.4),
(5, 56, CURDATE(), 4, 8, 'fifth route', 7.5),
(6, 57, CURDATE(), 5, 8, 'sixth route', 8.6),
(7, 57, CURDATE(), 6, null, 'seventh route', 9.7);
INSERT INTO `vn2008`.`empresa_grupo`(`empresa_grupo_id`, `grupo`)
VALUES
@ -1188,7 +1188,7 @@ INSERT INTO `postgresql`.`person`(`person_id`, `name`, `nickname`, `nif`, `first
VALUES
(1, 'Haller', 'DavidCharlesHaller', '53136686Q', 'David Charles', 106 ),
(2, 'Pym', 'HankPym', '09854837G', 'Hank', 107),
(3, 'VERDNATURA EVANTE SL', 'VNL', 'B78945612', NULL, NULL);
(3, 'VERDNATURA LEVANTE SL', 'VNL', 'B78945612', NULL, NULL);
INSERT INTO `postgresql`.`profile`(`profile_id`, `person_id`, `profile_type_id`)
VALUES

View File

@ -1,6 +1,6 @@
export default function moduleImport(moduleName) {
// FIXME: Webpack watches module backend files when using dynamic import
// TODO: Webpack watches module backend files when using dynamic import
//return import(
// /* webpackInclude: /modules\/[a-z0-9-]+\/front\/index.js$/ */
// '../modules/'+ moduleName +'/front/index.js'
@ -16,5 +16,6 @@ export default function moduleImport(moduleName) {
case 'travel' : return import('travel/front');
case 'worker' : return import('worker/front');
case 'invoice' : return import('invoice/front');
case 'route' : return import('route/front');
}
}

View File

@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
"table": "route"
"table": "route"
}
},
"properties": {
@ -18,9 +18,6 @@
"time": {
"type": "date"
},
"isOk": {
"type": "Number"
},
"kmStart": {
"type": "Number"
},

View File

@ -0,0 +1,4 @@
export * from './module';
import './index/';
import './search-panel';

View File

@ -0,0 +1,75 @@
<vn-crud-model
vn-id="model"
url="/api/Routes"
filter="::$ctrl.filter"
limit="20"
data="routes"
order="id ASC">
</vn-crud-model>
<div class="content-block">
<div class="vn-list">
<vn-card pad-medium-h>
<vn-searchbar
panel="vn-route-search-panel"
model="model"
expr-builder="$ctrl.exprBuilder(param, value)"
auto-load="true"
vn-focus>
</vn-searchbar>
</vn-card>
</div>
<vn-card margin-medium-v compact>
<vn-table model="model" auto-load="false">
<vn-thead>
<vn-tr>
<vn-th field="id" number>id</vn-th>
<vn-th th-id="worker">Worker</vn-th>
<vn-th th-id="agency">Agency</vn-th>
<vn-th th-id="vehicle">Vehicle</vn-th>
<vn-th th-id="created">Created</vn-th>
<vn-th th-id="m3" number></vn-th>
<vn-th th-id="description">Description</vn-th>
<vn-th></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<a ng-repeat="route in routes"
class="clickable vn-tr searchResult"
ui-sref="route.card.summary({id: {{::route.id}}})">
<vn-td number>{{::route.id | dashIfEmpty}}</vn-td>
<vn-td expand>
<span
class="link"
ng-click="$ctrl.showWorkerDescriptor($event, route.worker.id)">
{{::route.worker.user.nickname}}
</span>
</vn-td>
<vn-td>{{::route.agencyMode.name | dashIfEmpty}}</vn-td>
<vn-td>{{::route.vehicle.numberPlate | dashIfEmpty}}</vn-td>
<vn-td>{{::route.created | dateTime:'dd/MM/yyyy' | dashIfEmpty}}</vn-td>
<vn-td number>{{::route.m3 | dashIfEmpty}}</vn-td>
<vn-td>{{::route.description | dashIfEmpty}}</vn-td>
<vn-td>
<vn-icon-button
ng-click="$ctrl.preview($event, route)"
vn-tooltip="Preview"
icon="desktop_windows">
</vn-icon-button>
</vn-td>
</a>
</vn-tbody>
</vn-table>
</vn-card>
<vn-pagination model="model"></vn-pagination>
</div>
<vn-dialog
vn-id="summary"
class="dialog-summary">
<tpl-body>
<vn-route-summary route="$ctrl.selectedRoute"></vn-route-summary>
</tpl-body>
</vn-dialog>
<vn-worker-descriptor-popover
vn-id="workerDescriptor"
user-id="$ctrl.selectedWorker">
</vn-worker-descriptor-popover>

View File

@ -0,0 +1,80 @@
import ngModule from '../module';
export default class Controller {
constructor($scope, vnToken) {
this.accessToken = vnToken.token;
this.$ = $scope;
this.ticketSelected = null;
this.filter = {
include: [
{
relation: 'agencyMode',
scope: {
fields: ['name']
}
},
{
relation: 'vehicle',
scope: {
fields: ['numberPlate']
}
},
{
relation: 'worker',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
},
]
};
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return {id: value};
case 'from':
return {created: {gte: value}};
case 'to':
return {created: {lte: value}};
case 'workerFk':
case 'vehicleFk':
case 'agencyModeFk':
case 'm3':
case 'description':
return {[param]: value};
}
}
showWorkerDescriptor(event, userId) {
if (event.defaultPrevented) return;
event.preventDefault();
event.stopPropagation();
this.selectedWorker = userId;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
preview(event, route) {
this.routeSelected = route;
this.$.dialogSummaryClaim.show();
event.preventDefault();
event.stopImmediatePropagation();
}
}
Controller.$inject = ['$scope', 'vnToken'];
ngModule.component('vnRouteIndex', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,3 @@
import {ng} from 'core/vendor';
export default ng.module('route', ['vnCore']);

View File

@ -0,0 +1,23 @@
{
"module": "route",
"name": "Routes",
"icon": "icon-delivery",
"validations" : true,
"dependencies": ["client", "worker"],
"routes": [
{
"url": "/route",
"state": "route",
"abstract": true,
"component": "ui-view",
"description": "Routes",
"acl": ["employee"]
},
{
"url": "/index?q",
"state": "route.index",
"component": "vn-route-index",
"description": "Routes"
}
]
}

View File

@ -0,0 +1,57 @@
<div class="search-panel">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="General search"
model="filter.search"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
field="filter.workerFk"
url="/client/api/Clients/activeWorkersWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Worker">
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Agency"
field="filter.agencyModeFk"
url="/agency/api/AgencyModes/isActive"
show-field="name"
value-field="id">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
label="Vehicle"
field="filter.vehicleFk"
url="/route/api/Vehicles"
show-field="numberPlate"
value-field="id">
</vn-autocomplete>
<vn-textfield
vn-one
label="m³"
model="filter.m3">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Description"
model="filter.description">
</vn-textfield>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -0,0 +1,7 @@
import ngModule from '../module';
import SearchPanel from 'core/components/searchbar/search-panel';
ngModule.component('vnRouteSearchPanel', {
template: require('./index.html'),
controller: SearchPanel
});