Compare commits
24 Commits
dev
...
4770-route
Author | SHA1 | Date |
---|---|---|
Vicent Llopis | c667c67f36 | |
Vicent Llopis | 854e07cfae | |
Vicent Llopis | d44418ecea | |
Vicent Llopis | aa6e5a7ca0 | |
Vicent Llopis | eddb5a506f | |
Vicent Llopis | 19f9501b44 | |
Vicent Llopis | 593cacaaab | |
Vicent Llopis | b27c5ced61 | |
Vicent Llopis | c9e3e77869 | |
Vicent Llopis | af1c080e0c | |
Vicent Llopis | 2ba333e714 | |
Vicent Llopis | 4788d5d3f7 | |
Vicent Llopis | a98d987896 | |
Vicent Llopis | 7f5c5b91fa | |
Vicent Llopis | 16ca2416d1 | |
Vicent Llopis | eda58eb099 | |
Vicent Llopis | 05b87dbff2 | |
Vicent Llopis | 6ac12187c5 | |
Vicent Llopis | 5d40b5615d | |
Vicent Llopis | cf37dda044 | |
Vicent Llopis | 057151eda0 | |
Vicent Llopis | c8d21e1ef3 | |
Vicent Llopis | a8e2f90539 | |
Vicent Llopis | 9d2ec4a223 |
|
@ -0,0 +1,10 @@
|
|||
ALTER TABLE `vn`.`roadmap` COMMENT='Troncales diarios que se contratan';
|
||||
ALTER TABLE `vn`.`roadmap` ADD price decimal(10,2) NULL;
|
||||
ALTER TABLE `vn`.`roadmap` ADD driverName varchar(45) NULL;
|
||||
ALTER TABLE `vn`.`roadmap` ADD name varchar(45) NOT NULL;
|
||||
ALTER TABLE `vn`.`roadmap` CHANGE name name varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL AFTER id;
|
||||
ALTER TABLE `vn`.`roadmap` MODIFY COLUMN etd datetime NOT NULL;
|
||||
|
||||
ALTER TABLE `vn`.`expeditionTruck` COMMENT='Distintas paradas que hacen los trocales';
|
||||
ALTER TABLE `vn`.`expeditionTruck` DROP FOREIGN KEY expeditionTruck_FK_2;
|
||||
ALTER TABLE `vn`.`expeditionTruck` ADD CONSTRAINT expeditionTruck_FK_2 FOREIGN KEY (roadmapFk) REFERENCES vn.roadmap(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Roadmap', '*', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ExpeditionTruck', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -2593,7 +2593,7 @@ UPDATE `vn`.`ticket`
|
|||
|
||||
UPDATE `vn`.`ticket`
|
||||
SET refFk = 'A1111111'
|
||||
WHERE id = 6;
|
||||
WHERE id = 6;
|
||||
|
||||
INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
|
||||
VALUES
|
||||
|
@ -2602,9 +2602,18 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
|
|||
(3, 6, 5),
|
||||
(4, 7, 1);
|
||||
|
||||
INSERT INTO `vn`.`expeditionTruck` (`id`, `eta`, `description`)
|
||||
INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`)
|
||||
VALUES
|
||||
(1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet');
|
||||
(1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
|
||||
(2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
|
||||
(3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
|
||||
|
||||
INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`)
|
||||
VALUES
|
||||
(1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1),
|
||||
(2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1),
|
||||
(3, 1, 3, DATE_ADD(util.VN_NOW(), INTERVAL '1 4' DAY_HOUR), 'Third truck in fleet', 1),
|
||||
(4, 2, 1, DATE_ADD(util.VN_NOW(), INTERVAL 3 DAY), 'Truck red', 1);
|
||||
|
||||
INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`)
|
||||
VALUES
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-trailer:before {
|
||||
content: "\e967";
|
||||
}
|
||||
.icon-grafana:before {
|
||||
content: "\e965";
|
||||
}
|
||||
.icon-trolley:before {
|
||||
content: "\e95c";
|
||||
}
|
||||
.icon-agency-term:before {
|
||||
content: "\e950";
|
||||
}
|
||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 173 KiB |
Binary file not shown.
Binary file not shown.
|
@ -8,7 +8,7 @@ vn-client-summary .summary {
|
|||
}
|
||||
|
||||
vn-horizontal h4 .grafana:after {
|
||||
content: 'contact_support';
|
||||
font-size: 17px;
|
||||
font-family: 'salixfont' !important;
|
||||
content: "\e965";;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
|
||||
vn-entry-buy-index vn-card {
|
||||
max-width: $width-xl;
|
||||
|
||||
|
||||
.dark-row {
|
||||
background-color: lighten($color-marginal, 10%);
|
||||
}
|
||||
|
||||
thead tr {
|
||||
border-left: 1px solid white;
|
||||
border-right: 1px solid white;
|
||||
border: 1px solid white;;
|
||||
}
|
||||
|
||||
tbody tr:nth-child(1),
|
||||
|
@ -22,7 +21,7 @@ vn-entry-buy-index vn-card {
|
|||
tbody tr:nth-child(2) {
|
||||
border-bottom: 1px solid $color-spacer;
|
||||
}
|
||||
|
||||
|
||||
tbody{
|
||||
border-bottom: 1px solid $color-spacer;
|
||||
}
|
||||
|
@ -40,4 +39,4 @@ vn-entry-buy-index vn-card {
|
|||
}
|
||||
}
|
||||
|
||||
$color-font-link-medium: lighten($color-font-link, 20%)
|
||||
$color-font-link-medium: lighten($color-font-link, 20%)
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('clone', {
|
||||
description: 'Clones the selected routes',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'ids',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The routes ids to clone'
|
||||
},
|
||||
{
|
||||
arg: 'etd',
|
||||
type: 'date',
|
||||
required: true,
|
||||
description: 'The estimated time of departure for all roadmaps'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['Object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/clone`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.clone = async(ids, etd) => {
|
||||
const tx = await Self.beginTransaction({});
|
||||
try {
|
||||
const models = Self.app.models;
|
||||
const options = {transaction: tx};
|
||||
const originalRoadmaps = await models.Roadmap.find({
|
||||
where: {id: {inq: ids}},
|
||||
fields: [
|
||||
'id',
|
||||
'name',
|
||||
'tractorPlate',
|
||||
'trailerPlate',
|
||||
'phone',
|
||||
'supplierFk',
|
||||
'etd',
|
||||
'observations',
|
||||
'price'],
|
||||
include: [{
|
||||
relation: 'expeditionTruck',
|
||||
scope: {
|
||||
fields: ['roadmapFk', 'warehouseFk', 'eta', 'description']
|
||||
}
|
||||
}]
|
||||
|
||||
}, options);
|
||||
|
||||
if (ids.length != originalRoadmaps.length)
|
||||
throw new UserError(`The amount of roadmaps found don't match`);
|
||||
|
||||
for (const roadmap of originalRoadmaps) {
|
||||
roadmap.id = undefined;
|
||||
roadmap.etd = etd;
|
||||
|
||||
const clone = await models.Roadmap.create(roadmap, options);
|
||||
|
||||
const expeditionTrucks = roadmap.expeditionTruck();
|
||||
expeditionTrucks.map(expeditionTruck => {
|
||||
expeditionTruck.roadmapFk = clone.id;
|
||||
return expeditionTruck;
|
||||
});
|
||||
await models.ExpeditionTruck.create(expeditionTrucks, options);
|
||||
}
|
||||
|
||||
await tx.commit();
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,47 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('route clone()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
|
||||
const createdDate = Date.vnNew();
|
||||
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
|
||||
const ids = [996, 997, 998, 999];
|
||||
|
||||
let error;
|
||||
|
||||
try {
|
||||
await app.models.Route.clone(ids, createdDate);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toEqual(`The amount of routes found don't match`);
|
||||
});
|
||||
|
||||
it('should clone two routes', async() => {
|
||||
const ids = [1, 2];
|
||||
|
||||
const clones = await app.models.Route.clone(ids, createdDate);
|
||||
|
||||
expect(clones.length).toEqual(2);
|
||||
|
||||
// restores
|
||||
for (const clone of clones)
|
||||
await app.models.Route.destroyById(clone.id);
|
||||
});
|
||||
});
|
|
@ -5,18 +5,22 @@
|
|||
"AgencyTermConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Route": {
|
||||
"DeliveryPoint": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Vehicle": {
|
||||
"ExpeditionTruck": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Roadmap": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Route": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"RouteLog": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"DeliveryPoint": {
|
||||
"Vehicle": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "ExpeditionTruck",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "expeditionTruck"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"roadmapFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"warehouseFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"eta": {
|
||||
"type": "date"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"roadmap": {
|
||||
"type": "belongsTo",
|
||||
"model": "Roadmap",
|
||||
"foreignKey": "roadmapFk"
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
"model": "Warehouse",
|
||||
"foreignKey": "warehouseFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/roadmap/clone')(Self);
|
||||
};
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"name": "Roadmap",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "roadmap"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tractorPlate": {
|
||||
"type": "string"
|
||||
},
|
||||
"trailerPlate": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
"supplierFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"etd": {
|
||||
"type": "date"
|
||||
},
|
||||
"observations": {
|
||||
"type": "string"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"price": {
|
||||
"type": "number"
|
||||
},
|
||||
"driverName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "userFk"
|
||||
},
|
||||
"supplier": {
|
||||
"type": "belongsTo",
|
||||
"model": "Supplier",
|
||||
"foreignKey": "supplierFk"
|
||||
},
|
||||
"expeditionTruck": {
|
||||
"type": "hasMany",
|
||||
"model": "ExpeditionTruck",
|
||||
"foreignKey": "roadmapFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,3 +16,4 @@ import './agency-term/createInvoiceIn';
|
|||
import './agency-term-search-panel';
|
||||
import './ticket-popup';
|
||||
import './sms';
|
||||
import './roadmap';
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<mg-ajax path="Roadmaps/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.roadmap"
|
||||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-focus
|
||||
vn-one
|
||||
label="Roadmap"
|
||||
ng-model="$ctrl.roadmap.name"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="ETD date"
|
||||
ng-model="$ctrl.roadmap.etd">
|
||||
</vn-date-picker>
|
||||
<vn-input-time
|
||||
vn-one
|
||||
label="ETD hour"
|
||||
ng-model="$ctrl.roadmap.etd">
|
||||
</vn-input-time>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Tractor plate"
|
||||
ng-model="$ctrl.roadmap.tractorPlate"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Trailer plate"
|
||||
ng-model="$ctrl.roadmap.trailerPlate"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.roadmap.supplierFk"
|
||||
url="Suppliers"
|
||||
show-field="nickname"
|
||||
search-function="{or: [{id: $search}, {nickname: {like: '%'+ $search +'%'}}]}"
|
||||
value-field="id"
|
||||
order="nickname"
|
||||
label="Carrier">
|
||||
<tpl-item>
|
||||
{{::id}} - {{::nickname}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
vn-one
|
||||
label="Price"
|
||||
ng-model="$ctrl.roadmap.price"
|
||||
rule>
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Driver name"
|
||||
ng-model="$ctrl.roadmap.driverName"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Phone"
|
||||
ng-model="$ctrl.roadmap.phone"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textArea
|
||||
vn-one
|
||||
label="Observations"
|
||||
ng-model="$ctrl.roadmap.observations"
|
||||
rule>
|
||||
</vn-textArea>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Undo changes"
|
||||
disabled="!watcher.dataChanged()"
|
||||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,16 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
onSubmit() {
|
||||
this.$.watcher.submit();
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnRoadmapBasicData', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
roadmap: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
<vn-portal slot="menu">
|
||||
<vn-roadmap-descriptor roadmap="$ctrl.roadmap"></vn-roadmap-descriptor>
|
||||
<vn-left-menu source="roadmap"></vn-left-menu>
|
||||
</vn-portal>
|
||||
<ui-view></ui-view>
|
|
@ -0,0 +1,19 @@
|
|||
import ngModule from '../../module';
|
||||
import ModuleCard from 'salix/components/module-card';
|
||||
|
||||
class Controller extends ModuleCard {
|
||||
reload() {
|
||||
const filter = {
|
||||
include: [
|
||||
{relation: 'supplier'}
|
||||
]
|
||||
};
|
||||
this.$http.get(`Roadmaps/${this.$params.id}`, {filter})
|
||||
.then(res => this.roadmap = res.data);
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnRoadmapCard', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
import './index';
|
||||
|
||||
describe('component vnItemTypeCard', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('item'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnItemTypeCard', {$element: null});
|
||||
}));
|
||||
|
||||
describe('reload()', () => {
|
||||
it('should reload the controller data', () => {
|
||||
controller.$params.id = 1;
|
||||
|
||||
const itemType = {id: 1};
|
||||
|
||||
$httpBackend.expectGET('ItemTypes/1').respond(itemType);
|
||||
controller.reload();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.itemType).toEqual(itemType);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,37 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="Roadmaps"
|
||||
data="$ctrl.roadmap"
|
||||
insert-mode="true"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
label="Roadmap"
|
||||
ng-model="$ctrl.roadmap.name"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-date-picker
|
||||
label="ETD date"
|
||||
ng-model="$ctrl.roadmap.etd">
|
||||
</vn-date-picker>
|
||||
<vn-input-time
|
||||
label="ETD hour"
|
||||
ng-model="$ctrl.roadmap.etd">
|
||||
</vn-input-time>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Create">
|
||||
</vn-submit>
|
||||
<vn-button
|
||||
class="cancel"
|
||||
label="Cancel"
|
||||
ui-sref="roadmap.index">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,23 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $, $transclude, vnReport, vnEmail) {
|
||||
super($element, $, $transclude);
|
||||
this.roadmap = {etd: Date.vnNew()};
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(
|
||||
res => this.$state.go('route.roadmap.card.summary', {id: res.data.id})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
||||
ngModule.vnComponent('vnRoadmapCreate', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,107 @@
|
|||
import './index';
|
||||
import watcher from 'core/mocks/watcher.js';
|
||||
|
||||
describe('AgencyTerm', () => {
|
||||
describe('Component vnAgencyTermCreateInvoiceIn', () => {
|
||||
let controller;
|
||||
let $scope;
|
||||
let $httpBackend;
|
||||
let $httpParamSerializer;
|
||||
|
||||
beforeEach(ngModule('route'));
|
||||
|
||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
||||
$scope = $rootScope.$new();
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpParamSerializer = _$httpParamSerializer_;
|
||||
const $element = angular.element('<vn-agency-term-create-invoice-in></vn-agency-term-create-invoice-in>');
|
||||
controller = $componentController('vnAgencyTermCreateInvoiceIn', {$element});
|
||||
controller._route = {
|
||||
id: 1
|
||||
};
|
||||
}));
|
||||
|
||||
describe('$onChanges()', () => {
|
||||
it('should update the params data when $params.q is defined', () => {
|
||||
controller.$params = {q: '{"supplierName": "Plants SL","rows": null}'};
|
||||
|
||||
const params = {q: '{"supplierName": "Plants SL", "rows": null}'};
|
||||
const json = JSON.parse(params.q);
|
||||
|
||||
controller.$onChanges();
|
||||
|
||||
expect(controller.params).toEqual(json);
|
||||
});
|
||||
});
|
||||
|
||||
describe('route() setter', () => {
|
||||
it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||
jest.spyOn(controller, 'setDefaultParams');
|
||||
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||
controller.route = {
|
||||
id: 1
|
||||
};
|
||||
|
||||
expect(controller.route).toBeDefined();
|
||||
expect(controller.setDefaultParams).toHaveBeenCalledWith();
|
||||
expect(controller.getAllowedContentTypes).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAllowedContentTypes()', () => {
|
||||
it('should make an HTTP GET request to get the allowed content types', () => {
|
||||
const expectedResponse = ['image/png', 'image/jpg'];
|
||||
$httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse);
|
||||
controller.getAllowedContentTypes();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.allowedContentTypes).toBeDefined();
|
||||
expect(controller.allowedContentTypes).toEqual('image/png, image/jpg');
|
||||
});
|
||||
});
|
||||
|
||||
describe('setDefaultParams()', () => {
|
||||
it('should perform a GET query and define the dms property on controller', () => {
|
||||
const params = {filter: {
|
||||
where: {code: 'invoiceIn'}
|
||||
}};
|
||||
const serializedParams = $httpParamSerializer(params);
|
||||
$httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 1, code: 'invoiceIn'});
|
||||
controller.params = {supplierName: 'Plants SL'};
|
||||
controller.setDefaultParams();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.dms).toBeDefined();
|
||||
expect(controller.dms.dmsTypeId).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should make an HTTP POST request to save the form data', () => {
|
||||
controller.$.watcher = watcher;
|
||||
|
||||
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
||||
const files = [{id: 1, name: 'MyFile'}];
|
||||
controller.dms = {files};
|
||||
const serializedParams = $httpParamSerializer(controller.dms);
|
||||
const query = `dms/uploadFile?${serializedParams}`;
|
||||
controller.params = {rows: null};
|
||||
|
||||
$httpBackend.expect('POST', query).respond({});
|
||||
$httpBackend.expect('POST', 'AgencyTerms/createInvoiceIn').respond({});
|
||||
controller.onSubmit();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onFileChange()', () => {
|
||||
it('should set dms hasFileAttached property to true if has any files', () => {
|
||||
const files = [{id: 1, name: 'MyFile'}];
|
||||
controller.onFileChange(files);
|
||||
$scope.$apply();
|
||||
|
||||
expect(controller.dms.hasFileAttached).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,7 @@
|
|||
vn-ticket-request {
|
||||
.vn-textfield {
|
||||
margin: 0!important;
|
||||
max-width: 100px;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<vn-descriptor-content
|
||||
module="route"
|
||||
base-state="route.roadmap"
|
||||
description="$ctrl.roadmap.name">
|
||||
<slot-menu>
|
||||
<vn-item
|
||||
ng-click="deleteRoadmap.show()"
|
||||
name="deleteRoadmap"
|
||||
translate>
|
||||
Delete roadmap
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
<div class="attributes">
|
||||
<vn-label-value
|
||||
label="Roadmap"
|
||||
value="{{$ctrl.roadmap.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="ETD"
|
||||
value="{{$ctrl.roadmap.etd | date:'dd/MM/yyyy HH:mm'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Carrier">
|
||||
<span ng-click="supplierDescriptor.show($event, $ctrl.roadmap.supplier.id)" class="link">
|
||||
{{$ctrl.roadmap.supplier.nickname}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</slot-body>
|
||||
</vn-descriptor-content>
|
||||
<vn-confirm
|
||||
vn-id="deleteRoadmap"
|
||||
on-accept="$ctrl.onDelete()"
|
||||
question="Are you sure you want to continue?"
|
||||
message="The roadmap will be removed">
|
||||
</vn-confirm>
|
||||
<vn-supplier-descriptor-popover
|
||||
vn-id="supplierDescriptor">
|
||||
</vn-supplier-descriptor-popover>
|
|
@ -0,0 +1,26 @@
|
|||
import ngModule from '../../module';
|
||||
import Descriptor from 'salix/components/descriptor';
|
||||
|
||||
class Controller extends Descriptor {
|
||||
get roadmap() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
set roadmap(value) {
|
||||
this.entity = value;
|
||||
}
|
||||
|
||||
onDelete() {
|
||||
return this.$http.delete(`Roadmaps/${this.roadmap.id}`)
|
||||
.then(() => this.$state.go('route.roadmap'))
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Roadmap removed')));
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnRoadmapDescriptor', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
roadmap: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
Delete roadmap: Eliminar troncal
|
||||
The roadmap will be removed: La troncal será eliminada
|
||||
Roadmap removed: Troncal eliminada
|
|
@ -0,0 +1,9 @@
|
|||
import './main';
|
||||
import './index/';
|
||||
import './summary';
|
||||
import './card';
|
||||
import './descriptor';
|
||||
import './create';
|
||||
import './basic-data';
|
||||
import './search-panel';
|
||||
import './stops';
|
|
@ -0,0 +1,112 @@
|
|||
<vn-auto-search
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-lg">
|
||||
<vn-card class="vn-pa-md vn-w-lg">
|
||||
<vn-tool-bar class="vn-ma-md">
|
||||
<vn-button
|
||||
disabled="$ctrl.totalChecked == 0"
|
||||
ng-click="$ctrl.openClonationDialog()"
|
||||
icon="icon-clone"
|
||||
vn-tooltip="Clone selected roadmaps">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
disabled="$ctrl.totalChecked == 0"
|
||||
ng-click="deleteRoadmaps.show()"
|
||||
vn-tooltip="Delete roadmap(s)"
|
||||
icon="delete">
|
||||
</vn-button>
|
||||
</vn-tool-bar>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="description">Roadmap</vn-th>
|
||||
<vn-th field="etd" expand date>ETD</vn-th>
|
||||
<vn-th field="supplierFk">Carrier</vn-th>
|
||||
<vn-th field="plate">Plate</vn-th>
|
||||
<vn-th field="price">Price</vn-th>
|
||||
<vn-th field="observations" expand>Observations</vn-th>
|
||||
<vn-th></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="roadmap in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="route.roadmap.card.summary({id: {{::roadmap.id}}})">
|
||||
<vn-td>
|
||||
<vn-check
|
||||
ng-model="roadmap.checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td>{{::roadmap.name}}</vn-td>
|
||||
<vn-td expand date>{{::roadmap.etd | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
<vn-td expand>
|
||||
<span
|
||||
class="link"
|
||||
vn-click-stop="supplierDescriptor.show($event, roadmap.supplierFk)">
|
||||
{{::roadmap.supplier.nickname}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{::roadmap.tractorPlate | dashIfEmpty}}</vn-td>
|
||||
<vn-td expand>{{::roadmap.price | currency: 'EUR':2 | dashIfEmpty}}</vn-td>
|
||||
<vn-td expand>{{::roadmap.observations | dashIfEmpty}}</vn-td>
|
||||
<vn-td shrink>
|
||||
<vn-icon-button
|
||||
vn-click-stop="$ctrl.preview(roadmap)"
|
||||
vn-tooltip="Preview"
|
||||
icon="preview">
|
||||
</vn-icon-button>
|
||||
</vn-td>
|
||||
</a>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<a
|
||||
ui-sref="route.roadmap.create"
|
||||
vn-tooltip="Create roadmap"
|
||||
vn-bind="+"
|
||||
fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
||||
<vn-popup vn-id="summary">
|
||||
<vn-roadmap-summary
|
||||
roadmap="$ctrl.roadmapSelected">
|
||||
</vn-roadmap-summary>
|
||||
</vn-popup>
|
||||
<vn-supplier-descriptor-popover
|
||||
vn-id="supplierDescriptor">
|
||||
</vn-supplier-descriptor-popover>
|
||||
|
||||
<!-- Clonation dialog -->
|
||||
<vn-dialog class="edit"
|
||||
vn-id="clonationDialog"
|
||||
on-accept="$ctrl.cloneSelectedRoadmaps()"
|
||||
message="Select the estimated time of departure (ETD)">
|
||||
<tpl-body>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
label="ETD"
|
||||
ng-model="$ctrl.etd">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Clone</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
<vn-confirm
|
||||
vn-id="deleteRoadmaps"
|
||||
question="Are you sure you want to continue?"
|
||||
message="Selected roadmaps will be removed"
|
||||
on-accept="$ctrl.deleteRoadmaps()">
|
||||
</vn-confirm>
|
|
@ -0,0 +1,62 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
get checked() {
|
||||
const roadmaps = this.$.model.data || [];
|
||||
const checkedRoadmap = [];
|
||||
for (let roadmap of roadmaps) {
|
||||
if (roadmap.checked)
|
||||
checkedRoadmap.push(roadmap);
|
||||
}
|
||||
|
||||
return checkedRoadmap;
|
||||
}
|
||||
|
||||
get totalChecked() {
|
||||
return this.checked.length;
|
||||
}
|
||||
|
||||
preview(roadmap) {
|
||||
this.roadmapSelected = roadmap;
|
||||
this.$.summary.show();
|
||||
}
|
||||
|
||||
openClonationDialog() {
|
||||
this.$.clonationDialog.show();
|
||||
this.etd = Date.vnNew();
|
||||
}
|
||||
|
||||
cloneSelectedRoadmaps() {
|
||||
try {
|
||||
if (!this.etd)
|
||||
throw new Error(`The date can't be empty`);
|
||||
|
||||
const roadmapsIds = [];
|
||||
for (let roadmap of this.checked)
|
||||
roadmapsIds.push(roadmap.id);
|
||||
|
||||
return this.$http.post('Roadmaps/clone', {ids: roadmapsIds, etd: this.etd}).then(() => {
|
||||
this.$.model.refresh();
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
}
|
||||
}
|
||||
|
||||
deleteRoadmaps() {
|
||||
console.log(this.checked);
|
||||
|
||||
for (const roadmap of this.checked) {
|
||||
this.$http.delete(`Roadmaps/${roadmap.id}`)
|
||||
.then(() => this.$.model.refresh())
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Roadmaps removed')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnRoadmapIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,94 @@
|
|||
import './index.js';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('AgencyTerm', () => {
|
||||
describe('Component vnAgencyTermIndex', () => {
|
||||
let controller;
|
||||
let $window;
|
||||
|
||||
beforeEach(ngModule('route'));
|
||||
|
||||
beforeEach(inject(($componentController, _$window_) => {
|
||||
$window = _$window_;
|
||||
const $element = angular.element('<vn-agency-term-index></vn-agency-term-index>');
|
||||
controller = $componentController('vnAgencyTermIndex', {$element});
|
||||
controller.$.model = crudModel;
|
||||
controller.$.model.data = [
|
||||
{supplierFk: 1, totalPrice: null},
|
||||
{supplierFk: 1},
|
||||
{supplierFk: 2}
|
||||
];
|
||||
}));
|
||||
|
||||
describe('checked() getter', () => {
|
||||
it('should return the checked lines', () => {
|
||||
const data = controller.$.model.data;
|
||||
data[0].checked = true;
|
||||
|
||||
const checkedRows = controller.checked;
|
||||
|
||||
const firstCheckedRow = checkedRows[0];
|
||||
|
||||
expect(firstCheckedRow.supplierFk).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('totalCheked() getter', () => {
|
||||
it('should return the total checked lines', () => {
|
||||
const data = controller.$.model.data;
|
||||
data[0].checked = true;
|
||||
|
||||
const checkedRows = controller.totalChecked;
|
||||
|
||||
expect(checkedRows).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('preview()', () => {
|
||||
it('should show the summary dialog', () => {
|
||||
controller.$.summary = {show: () => {}};
|
||||
jest.spyOn(controller.$.summary, 'show');
|
||||
|
||||
let event = new MouseEvent('click', {
|
||||
view: $window,
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
const route = {id: 1};
|
||||
|
||||
controller.preview(event, route);
|
||||
|
||||
expect(controller.$.summary.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('createInvoiceIn()', () => {
|
||||
it('should throw an error if more than one autonomous are checked', () => {
|
||||
jest.spyOn(controller.vnApp, 'showError');
|
||||
const data = controller.$.model.data;
|
||||
data[0].checked = true;
|
||||
data[2].checked = true;
|
||||
|
||||
controller.createInvoiceIn();
|
||||
|
||||
expect(controller.vnApp.showError).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call the function go() on $state to go to the file management', () => {
|
||||
jest.spyOn(controller.$state, 'go');
|
||||
const data = controller.$.model.data;
|
||||
data[0].checked = true;
|
||||
|
||||
controller.createInvoiceIn();
|
||||
|
||||
delete data[0].checked;
|
||||
const params = JSON.stringify({
|
||||
supplierName: data[0].supplierName,
|
||||
rows: [data[0]]
|
||||
});
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('route.agencyTerm.createInvoiceIn', {q: params});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
Delete roadmap(s): Eliminar troncal(es)
|
||||
Selected roadmaps will be removed: Los troncales seleccionados serán eliminados
|
||||
Roadmaps removed: Troncales eliminados
|
|
@ -0,0 +1,14 @@
|
|||
Roadmaps: Troncales
|
||||
Roadmap: Troncal
|
||||
Driver name: Nombre conductor
|
||||
Plate: Matrícula
|
||||
Price: Precio
|
||||
Observations: Observaciones
|
||||
Clone selected roadmaps: Clonar troncales seleccionadas
|
||||
Select the estimated time of departure (ETD): Seleccione la hora estimada de salida (ETD)
|
||||
Create roadmap: Crear troncal
|
||||
Tractor plate: Matrícula tractor
|
||||
Trailer plate: Matrícula trailer
|
||||
Carrier: Transportista
|
||||
ETD date: Fecha ETD
|
||||
ETD hour: Hora ETD
|
|
@ -0,0 +1,20 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Roadmaps"
|
||||
include="$ctrl.include"
|
||||
auto-load="true"
|
||||
limit="20">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
info="Search roadmap by id or trunk"
|
||||
panel="vn-roadmap-search-panel"
|
||||
model="model"
|
||||
filter="$ctrl.filterParams"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
base-state="route.roadmap">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<ui-view>
|
||||
<vn-roadmap-index></vn-roadmap-index>
|
||||
</ui-view>
|
|
@ -0,0 +1,61 @@
|
|||
import ngModule from '../../module';
|
||||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Roadmap extends ModuleMain {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.include = {
|
||||
relation: 'supplier',
|
||||
scope: {
|
||||
fields: ['nickname']
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$postLink() {
|
||||
const from = Date.vnNew();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
||||
const to = Date.vnNew();
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
this.filterParams = {
|
||||
from: from,
|
||||
to: to
|
||||
};
|
||||
|
||||
this.$.model.addFilter({where: {
|
||||
and: [
|
||||
{etd: {gte: from}},
|
||||
{etd: {lte: to}}
|
||||
]
|
||||
}});
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {id: value}
|
||||
: {name: {like: `%${value}%`}};
|
||||
case 'from':
|
||||
return {etd: {gte: value}};
|
||||
case 'to':
|
||||
return {etd: {lte: value}};
|
||||
case 'supplierFk':
|
||||
case 'price':
|
||||
return {[param]: value};
|
||||
case 'tractorPlate':
|
||||
case 'trailerPlate':
|
||||
case 'phone':
|
||||
case 'driverName':
|
||||
return {[param]: {like: `%${value}%`}};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnRoadmap', {
|
||||
controller: Roadmap,
|
||||
template: require('./index.html')
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
import './index';
|
||||
|
||||
describe('Item', () => {
|
||||
describe('Component vnItemType', () => {
|
||||
let controller;
|
||||
|
||||
beforeEach(ngModule('item'));
|
||||
|
||||
beforeEach(inject($componentController => {
|
||||
const $element = angular.element('<vn-item-type></vn-item-type>');
|
||||
controller = $componentController('vnItemType', {$element});
|
||||
}));
|
||||
|
||||
describe('exprBuilder()', () => {
|
||||
it('should return a filter based on a search by id', () => {
|
||||
const filter = controller.exprBuilder('search', '123');
|
||||
|
||||
expect(filter).toEqual({id: '123'});
|
||||
});
|
||||
|
||||
it('should return a filter based on a search by name or code', () => {
|
||||
const filter = controller.exprBuilder('search', 'Alstroemeria');
|
||||
|
||||
expect(filter).toEqual({or: [
|
||||
{name: {like: '%Alstroemeria%'}},
|
||||
{code: {like: '%Alstroemeria%'}},
|
||||
]});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Search roadmap by id or trunk: Buscar troncales por id o troncal
|
|
@ -0,0 +1,74 @@
|
|||
<div class="search-panel">
|
||||
<form id="manifold-form" ng-submit="$ctrl.onSearch()">
|
||||
<vn-horizontal class="vn-px-lg vn-pt-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="General search"
|
||||
ng-model="filter.search"
|
||||
info="Search routes by id"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<section class="vn-px-md">
|
||||
<vn-horizontal class="manifold-panel vn-pa-md">
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="From"
|
||||
ng-model="filter.from">
|
||||
</vn-date-picker>
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="To"
|
||||
ng-model="filter.to">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
</section>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Tractor plate"
|
||||
ng-model="filter.tractorPlate">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Trailer plate"
|
||||
ng-model="filter.trailerPlate">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.supplierFk"
|
||||
url="Suppliers"
|
||||
show-field="nickname"
|
||||
search-function="{or: [{id: $search}, {nickname: {like: '%'+ $search +'%'}}]}"
|
||||
value-field="id"
|
||||
order="nickname"
|
||||
label="Carrier">
|
||||
<tpl-item>
|
||||
{{::id}} - {{::nickname}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
vn-one
|
||||
label="Price"
|
||||
ng-model="filter.price">
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Driver name"
|
||||
ng-model="filter.driverName">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Phone"
|
||||
ng-model="filter.phone">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-px-lg vn-pb-lg vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
import ngModule from '../../module';
|
||||
import SearchPanel from 'core/components/searchbar/search-panel';
|
||||
|
||||
ngModule.component('vnRoadmapSearchPanel', {
|
||||
template: require('./index.html'),
|
||||
controller: SearchPanel
|
||||
});
|
|
@ -0,0 +1,71 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="ExpeditionTrucks"
|
||||
where="{roadmapFk: $ctrl.$params.id}"
|
||||
order="eta ASC"
|
||||
data="$ctrl.expeditionTrucks"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.expeditionTrucks"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form class="vn-w-md" name="form" ng-submit="$ctrl.onSubmit()">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="expeditionTruck in $ctrl.expeditionTrucks">
|
||||
<vn-autocomplete vn-one
|
||||
label="Warehouse"
|
||||
ng-model="expeditionTruck.warehouseFk"
|
||||
url="Warehouses"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
vn-focus
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-date-picker vn-one
|
||||
label="ETA date"
|
||||
ng-model="expeditionTruck.eta"
|
||||
rule>
|
||||
</vn-date-picker>
|
||||
<vn-input-time
|
||||
vn-one
|
||||
label="ETA hour"
|
||||
ng-model="expeditionTruck.eta">
|
||||
</vn-input-time>
|
||||
<vn-textArea
|
||||
vn-one
|
||||
label="Description"
|
||||
ng-model="expeditionTruck.description"
|
||||
rule>
|
||||
</vn-textArea>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove stop"
|
||||
icon="delete"
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add stop"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit
|
||||
disabled="!watcher.dataChanged()"
|
||||
label="Save">
|
||||
</vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-confirm
|
||||
vn-id="confirm"
|
||||
question="Delete stop?"
|
||||
on-accept="$ctrl.removeTicketFromRoute($index)">
|
||||
</vn-confirm>
|
|
@ -0,0 +1,39 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
add() {
|
||||
const filter = {
|
||||
fields: ['etd']
|
||||
};
|
||||
this.$http.get(`Roadmaps/${this.$params.id}`, {filter})
|
||||
.then(res => {
|
||||
this.roadmap = res.data;
|
||||
|
||||
const eta = new Date(this.roadmap.etd);
|
||||
eta.setDate(eta.getDate() + 1);
|
||||
|
||||
this.$.model.insert({
|
||||
roadmapFk: this.$params.id,
|
||||
eta: eta
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
this.$.watcher.notifySaved();
|
||||
this.$.watcher.updateOriginalData();
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnRoadmapStops', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
roadmap: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,4 @@
|
|||
Remove stop: Eliminar parada
|
||||
Add stop: Añadir parada
|
||||
ETA date: Fecha ETA
|
||||
ETA hour: Hora ETA
|
|
@ -0,0 +1,113 @@
|
|||
<vn-card class="summary">
|
||||
<h5>
|
||||
<span>{{summary.id}} - {{summary.name}}</span>
|
||||
</h5>
|
||||
<vn-horizontal class="vn-pa-md">
|
||||
<vn-one>
|
||||
<vn-label-value label="Carrier">
|
||||
<span ng-click="supplierDescriptor.show($event, summary.supplier.id)" class="link">
|
||||
{{summary.supplier.nickname}}
|
||||
</span>
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="ETD"
|
||||
value="{{summary.etd | date:'dd/MM/yyyy HH:mm'}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Tractor plate"
|
||||
value="{{summary.tractorPlate}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Trailer plate"
|
||||
value="{{summary.trailerPlate}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-label-value
|
||||
label="Phone"
|
||||
value="{{summary.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Worker"
|
||||
value="{{summary.worker.firstName}} {{summary.worker.lastName}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Observations"
|
||||
value="{{summary.observations}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-auto>
|
||||
<h4>
|
||||
<a
|
||||
ui-sref="route.roadmap.card.stops({id:summary.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Stops</span>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add stop"
|
||||
icon="add_circle"
|
||||
vn-click-stop="addExpeditionTruck.show()">
|
||||
</vn-icon-button>
|
||||
</a>
|
||||
</h4>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th>Wharehouse</vn-th>
|
||||
<vn-th>ETA</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="expeditionTruck in summary.expeditionTruck">
|
||||
<vn-td>{{expeditionTruck.warehouse.name}}</vn-td>
|
||||
<vn-td expand>{{expeditionTruck.eta | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-auto>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-supplier-descriptor-popover
|
||||
vn-id="supplierDescriptor">
|
||||
</vn-supplier-descriptor-popover>
|
||||
|
||||
<vn-dialog
|
||||
vn-id="addExpeditionTruck"
|
||||
on-open="$ctrl.getETD()"
|
||||
on-accept="$ctrl.onAddAccept()">
|
||||
<tpl-body>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
label="Warehouse"
|
||||
ng-model="$ctrl.expeditionTruck.warehouseFk"
|
||||
url="Warehouses"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
vn-focus
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
label="ETA date"
|
||||
ng-model="$ctrl.expeditionTruck.eta"
|
||||
rule>
|
||||
</vn-date-picker>
|
||||
<vn-input-time
|
||||
label="ETA hour"
|
||||
ng-model="$ctrl.expeditionTruck.eta">
|
||||
</vn-input-time>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textArea
|
||||
label="Description"
|
||||
ng-model="$ctrl.expeditionTruck.description"
|
||||
rule>
|
||||
</vn-textArea>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Confirm</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -0,0 +1,68 @@
|
|||
import ngModule from '../../module';
|
||||
import Component from 'core/lib/component';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Component {
|
||||
set roadmap(value) {
|
||||
this._roadmap = value;
|
||||
this.$.summary = null;
|
||||
if (!value) return;
|
||||
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
get roadmap() {
|
||||
return this._roadmap;
|
||||
}
|
||||
|
||||
loadData() {
|
||||
const filter = {
|
||||
include: [
|
||||
{relation: 'supplier'},
|
||||
{relation: 'worker'},
|
||||
{relation: 'expeditionTruck',
|
||||
scope: {
|
||||
include: [
|
||||
{relation: 'warehouse'}
|
||||
]
|
||||
}}
|
||||
]
|
||||
};
|
||||
this.$http.get(`Roadmaps/${this.roadmap.id}`, {filter})
|
||||
.then(res => this.$.summary = res.data);
|
||||
}
|
||||
|
||||
getETD() {
|
||||
const eta = new Date(this.roadmap.etd);
|
||||
eta.setDate(eta.getDate() + 1);
|
||||
|
||||
this.expeditionTruck = {eta: eta};
|
||||
}
|
||||
|
||||
onAddAccept() {
|
||||
try {
|
||||
const data = {
|
||||
roadmapFk: this.roadmap.id,
|
||||
warehouseFk: this.expeditionTruck.warehouseFk,
|
||||
eta: this.expeditionTruck.eta,
|
||||
description: this.expeditionTruck.description
|
||||
};
|
||||
|
||||
this.$http.post(`ExpeditionTrucks`, data)
|
||||
.then(() => {
|
||||
this.loadData();
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnRoadmapSummary', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
roadmap: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
Stops: Paradas
|
||||
Wharehouse: Almacén
|
||||
You must fill all the fields: Debes rellenar todos los campos
|
|
@ -0,0 +1,12 @@
|
|||
@import "variables";
|
||||
|
||||
|
||||
vn-roadmap-summary .summary {
|
||||
a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 18.328px;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,12 +7,17 @@
|
|||
"menus": {
|
||||
"main": [
|
||||
{"state": "route.index", "icon": "icon-delivery"},
|
||||
{"state": "route.agencyTerm.index", "icon": "icon-agency-term"}
|
||||
{"state": "route.agencyTerm.index", "icon": "icon-agency-term"},
|
||||
{"state": "route.roadmap", "icon": "icon-trailer"}
|
||||
],
|
||||
"card": [
|
||||
{"state": "route.card.basicData", "icon": "settings"},
|
||||
{"state": "route.card.tickets", "icon": "icon-ticket"},
|
||||
{"state": "route.card.log", "icon": "history"}
|
||||
],
|
||||
"roadmap": [
|
||||
{"state": "route.roadmap.card.basicData", "icon": "settings"},
|
||||
{"state": "route.roadmap.card.stops", "icon": "icon-lines"}
|
||||
]
|
||||
},
|
||||
"routes": [
|
||||
|
@ -90,6 +95,46 @@
|
|||
"route": "$ctrl.route"
|
||||
},
|
||||
"acl": ["delivery"]
|
||||
}, {
|
||||
"url": "/roadmap?q",
|
||||
"state": "route.roadmap",
|
||||
"component": "vn-roadmap",
|
||||
"description": "Roadmaps"
|
||||
}, {
|
||||
"url": "/create",
|
||||
"state": "route.roadmap.create",
|
||||
"component": "vn-roadmap-create",
|
||||
"description": "Create roadmap"
|
||||
},{
|
||||
"url": "/:id",
|
||||
"state": "route.roadmap.card",
|
||||
"component": "vn-roadmap-card",
|
||||
"abstract": true,
|
||||
"description": "Detail"
|
||||
},{
|
||||
"url": "/summary",
|
||||
"state": "route.roadmap.card.summary",
|
||||
"component": "vn-roadmap-summary",
|
||||
"description": "Summary",
|
||||
"params": {
|
||||
"roadmap": "$ctrl.roadmap"
|
||||
}
|
||||
},{
|
||||
"url": "/basic-data",
|
||||
"state": "route.roadmap.card.basicData",
|
||||
"component": "vn-roadmap-basic-data",
|
||||
"description": "Basic data",
|
||||
"params": {
|
||||
"roadmap": "$ctrl.roadmap"
|
||||
}
|
||||
}, {
|
||||
"url": "/stops",
|
||||
"state": "route.roadmap.card.stops",
|
||||
"component": "vn-roadmap-stops",
|
||||
"description": "Stops",
|
||||
"params": {
|
||||
"route": "$ctrl.roadmap"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
ng-click="deleteShelving.show()"
|
||||
name="deleteShelving"
|
||||
translate>
|
||||
Delete
|
||||
Delete shelving
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
|
@ -32,7 +32,7 @@
|
|||
</slot-body>
|
||||
</vn-descriptor-content>
|
||||
<vn-confirm
|
||||
vn-id="delete-shelving"
|
||||
vn-id="deleteShelving"
|
||||
on-accept="$ctrl.onDelete()"
|
||||
question="Are you sure you want to continue?"
|
||||
message="Shelving will be removed">
|
||||
|
@ -40,6 +40,6 @@
|
|||
<vn-popup vn-id="summary">
|
||||
<vn-shelving-summary shelving="$ctrl.shelving"></vn-shelving-summary>
|
||||
</vn-popup>
|
||||
<vn-worker-descriptor-popover
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
</vn-worker-descriptor-popover>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Delete shelving: Eliminar carro
|
||||
Shelving will be removed: El carro será eliminado
|
||||
Shelving removed: Carro eliminado
|
|
@ -38,7 +38,7 @@
|
|||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Code"
|
||||
label="Worker code"
|
||||
ng-model="$ctrl.worker.code"
|
||||
maxLength="3"
|
||||
on-change="$ctrl.worker.code = $ctrl.worker.code.toUpperCase()"
|
||||
|
|
|
@ -2,7 +2,7 @@ Firstname: Nombre
|
|||
Lastname: Apellidos
|
||||
Fi: DNI/NIF/NIE
|
||||
Birth: Fecha de nacimiento
|
||||
Code: Código de trabajador
|
||||
Worker code: Código de trabajador
|
||||
Province: Provincia
|
||||
City: Población
|
||||
ProfileType: Tipo de perfil
|
||||
|
|
Loading…
Reference in New Issue