Merge branch '1776travel.basic-data' of verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

lgtm
This commit is contained in:
Bernat Exposito 2019-10-25 11:44:53 +00:00 committed by Gitea
commit b415adff41
21 changed files with 299 additions and 26 deletions

View File

@ -0,0 +1,18 @@
CREATE TABLE `vn`.`travelLog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`originFk` int(10) unsigned NOT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
`action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL,
`creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`description` text CHARACTER SET utf8,
`changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`oldInstance` text COLLATE utf8_unicode_ci,
`newInstance` text COLLATE utf8_unicode_ci,
`changedModelId` int(11) DEFAULT NULL,
`changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `originFk` (`originFk`),
KEY `userFk` (`userFk`),
CONSTRAINT `travelLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `travelLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

View File

@ -20,7 +20,7 @@ describe('Agency Component vnZoneIndex', () => {
expect(result).toEqual({id: 1});
});
it('should return a formated object with the warehouseFk in case of agencyModeFk', () => {
it('should return a formated object with the agencyModeFk in case of agencyModeFk', () => {
let param = 'agencyModeFk';
let value = 'My Delivery';
let result = controller.exprBuilder(param, value);

View File

@ -73,7 +73,7 @@
ng-model="$ctrl.route.description"
rule
vn-focus>
</vn-textfield>
</vn-textArea>
</vn-horizontal>
</vn-card>
<vn-button-bar>

View File

@ -1,17 +1,18 @@
import ngModule from '../module';
class Controller {
constructor($scope, $state) {
this.$scope = $scope;
this.$state = $state;
constructor($scope) {
this.$ = $scope;
}
onSubmit() {
this.$scope.watcher.submit().then(() => {
this.$.watcher.submit().then(() => {
this.card.reload();
});
}
}
Controller.$inject = ['$scope'];
ngModule.component('vnRouteBasicData', {
template: require('./index.html'),
controller: Controller,

View File

@ -3,5 +3,7 @@
"dataSource": "vn"
},"Entry": {
"dataSource": "vn"
},"TravelLog": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,58 @@
{
"name": "TravelLog",
"base": "VnModel",
"options": {
"mysql": {
"table": "travelLog"
}
},
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"originFk": {
"type": "Number",
"required": true
},
"userFk": {
"type": "Number"
},
"action": {
"type": "String",
"required": true
},
"changedModel": {
"type": "String"
},
"oldInstance": {
"type": "Object"
},
"newInstance": {
"type": "Object"
},
"creationDate": {
"type": "Date"
},
"changedModelId": {
"type": "Number"
},
"changedModelValue": {
"type": "String"
},
"description": {
"type": "String"
}
},
"relations": {
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
}
},
"scope": {
"order": ["creationDate DESC", "id DESC"]
}
}

View File

@ -1,6 +1,9 @@
{
"name": "Travel",
"base": "VnModel",
"base": "Loggable",
"log": {
"model":"TravelLog"
},
"options": {
"mysql": {
"table": "travel"
@ -32,12 +35,18 @@
},
"m3": {
"type": "Number"
},
"agencyModeFk": {
"type": "Number",
"mysql": {
"columnName": "agencyFk"
}
}
},
"relations": {
"agency": {
"type": "belongsTo",
"model": "Agency",
"model": "AgencyMode",
"foreignKey": "agencyFk"
},
"warehouseIn": {

View File

@ -0,0 +1,72 @@
<mg-ajax path="api/Travels/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.travel"
form="form"
save="patch">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-textfield
vn-one
label="Reference"
ng-model="$ctrl.travel.ref">
</vn-textfield>
<vn-autocomplete
vn-one
ng-model="$ctrl.travel.agencyModeFk"
url="api/AgencyModes"
show-field="name"
value-field="id"
label="Agency">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Shipped"
ng-model="$ctrl.travel.shipped">
</vn-date-picker>
<vn-date-picker
vn-one
label="Landed"
ng-model="$ctrl.travel.landed">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
ng-model="$ctrl.travel.warehouseOutFk"
url="api/Warehouses"
show-field="name"
value-field="id"
label="Warehouse Out">
</vn-autocomplete>
<vn-autocomplete
vn-one
ng-model="$ctrl.travel.warehouseInFk"
url="api/Warehouses"
show-field="name"
value-field="id"
label="Warehouse In">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-check
vn-one
label="Delivered"
ng-model="$ctrl.travel.isDelivered">
</vn-check>
<vn-check
vn-one
label="Received"
ng-model="$ctrl.travel.isReceived">
</vn-check>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -0,0 +1,25 @@
import ngModule from '../module';
class Controller {
constructor($scope) {
this.$ = $scope;
}
onSubmit() {
return this.$.watcher.submit().then(() => {
this.card.reload();
});
}
}
Controller.$inject = ['$scope'];
ngModule.component('vnTravelBasicData', {
template: require('./index.html'),
controller: Controller,
bindings: {
travel: '<'
},
require: {
card: '^vnTravelCard'
}
});

View File

@ -0,0 +1,28 @@
import './index.js';
describe('Travel Component vnTravelBasicData', () => {
let controller;
let $scope;
beforeEach(angular.mock.module('travel', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
controller = $componentController('vnTravelBasicData', $scope);
controller.card = {reload: () => {}};
controller.$.watcher = {submit: () => {}};
}));
describe('onSubmit()', () => {
it('should call the card reload method after the watcher submits', done => {
spyOn(controller.card, 'reload');
spyOn(controller.$.watcher, 'submit').and.returnValue(Promise.resolve());
controller.onSubmit().then(() => {
expect(controller.card.reload).toHaveBeenCalledWith();
done();
}).catch(done.fail);
});
});
});

View File

@ -0,0 +1 @@
Undo changes: Deshacer cambios

View File

@ -6,16 +6,6 @@ export default class Controller {
this.$stateParams = $stateParams;
this.travel = null;
this.filter = {
fields: [
'id',
'ref',
'warehouseInFk',
'warehouseOutFk',
'shipped',
'landed',
'totalEntries'
],
where: {id: $stateParams.id},
include: [
{

View File

@ -5,3 +5,5 @@ import './search-panel';
import './descriptor';
import './card';
import './summary';
import './basic-data';
import './log';

View File

@ -41,10 +41,10 @@
<vn-td number>{{::travel.id}}</vn-td>
<vn-td expand>{{::travel.ref}}</vn-td>
<vn-td expand>{{::travel.agency.name}}</vn-td>
<vn-td center>{{::travel.warehouseOut.name}}</vn-td>
<vn-td expand>{{::travel.warehouseOut.name}}</vn-td>
<vn-td center>{{::travel.shipped | date:'dd/MM/yyyy'}}</vn-td>
<vn-td><vn-check ng-model="travel.isDelivered" disabled="true"></vn-check></vn-td>
<vn-td>{{::travel.warehouseIn.name}}</vn-td>
<vn-td expand>{{::travel.warehouseIn.name}}</vn-td>
<vn-td center>{{::travel.landed | date:'dd/MM/yyyy'}}</vn-td>
<vn-td center><vn-check ng-model="travel.isReceived" disabled="true"></vn-check></vn-td>
<vn-td>

View File

@ -40,7 +40,7 @@ export default class Controller {
case 'landed':
return {landed: {gte: value}};
case 'id':
case 'agencyFk':
case 'agencyModeFk':
case 'warehouseOutFk':
case 'warehouseInFk':
case 'totalEntries':

View File

@ -0,0 +1,33 @@
import './index.js';
describe('Travel Component vnTravelIndex', () => {
let $componentController;
let controller;
beforeEach(angular.mock.module('travel', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_;
controller = $componentController('vnTravelIndex');
}));
describe('exprBuilder()', () => {
it('should return a formated object with the travel id in case of search', () => {
let param = 'search';
let value = 2;
let result = controller.exprBuilder(param, value);
expect(result).toEqual({id: 2});
});
it('should return a formated object with the warehouseInFk in case of warehouseInFk', () => {
let param = 'warehouseInFk';
let value = 3;
let result = controller.exprBuilder(param, value);
expect(result).toEqual({warehouseInFk: 3});
});
});
});

View File

@ -10,4 +10,5 @@ Travel id: Id envío
Search travels by id: Buscar envios por identificador
# Sections
Travels: Envíos
Travels: Envíos
Log: Historial

View File

@ -0,0 +1 @@
<vn-log url="api/TravelLogs" origin-id="$ctrl.$stateParams.id"></vn-log>

View File

@ -0,0 +1,15 @@
import ngModule from '../module';
class Controller {
constructor($scope, $stateParams) {
this.$scope = $scope;
this.$stateParams = $stateParams;
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTravelLog', {
template: require('./index.html'),
controller: Controller,
});

View File

@ -3,6 +3,9 @@
"name": "Travels",
"validations": true,
"dependencies": ["worker"],
"menu": [
{"state": "travel.card.basicData", "icon": "settings"},
{"state": "travel.card.log", "icon": "history"}],
"routes": [
{
"url": "/travel",
@ -29,6 +32,20 @@
"params": {
"travel": "$ctrl.travel"
}
}, {
"url": "/basic-data",
"state": "travel.card.basicData",
"component": "vn-travel-basic-data",
"description": "Basic data",
"acl": ["buyer","logistic"],
"params": {
"travel": "$ctrl.travel"
}
}, {
"url" : "/log",
"state": "travel.card.log",
"component": "vn-travel-log",
"description": "Log"
}
]
}

View File

@ -19,8 +19,8 @@
<vn-th field="changedModel" class="expendable">Model</vn-th>
<vn-th field="action" class="expendable">Action</vn-th>
<vn-th field="changedModelValue" class="expendable">Name</vn-th>
<vn-th>Before</vn-th>
<vn-th>After</vn-th>
<vn-th expand>Before</vn-th>
<vn-th expand>After</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
@ -66,7 +66,7 @@
<vn-td class="expendable">
{{::log.changedModelValue}}
</vn-td>
<vn-td class="before">
<vn-td expand class="before">
<vn-one ng-repeat="old in log.oldProperties">
<div>
<span translate class="label">{{::old.key}}</span><span class="label">: </span>
@ -74,7 +74,7 @@
</div>
</vn-one>
</vn-td>
<vn-td class="after">
<vn-td expand class="after">
<vn-one
ng-repeat="new in log.newProperties"
ng-if="!log.description"