#1776 travel.basicData
This commit is contained in:
parent
eb384425f2
commit
5547193a31
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Travel",
|
"name": "Travel",
|
||||||
"base": "VnModel",
|
"base": "Loggable",
|
||||||
|
"log": {
|
||||||
|
"model":"TravelLog"
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "travel"
|
"table": "travel"
|
||||||
|
@ -32,12 +35,18 @@
|
||||||
},
|
},
|
||||||
"m3": {
|
"m3": {
|
||||||
"type": "Number"
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"agencyModeFk": {
|
||||||
|
"type": "Number",
|
||||||
|
"mysql": {
|
||||||
|
"columnName": "agencyFk"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"agency": {
|
"agency": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Agency",
|
"model": "AgencyMode",
|
||||||
"foreignKey": "agencyFk"
|
"foreignKey": "agencyFk"
|
||||||
},
|
},
|
||||||
"warehouseIn": {
|
"warehouseIn": {
|
||||||
|
|
|
@ -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>
|
|
@ -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'
|
||||||
|
}
|
||||||
|
});
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1 @@
|
||||||
|
Undo changes: Deshacer cambios
|
|
@ -6,16 +6,6 @@ export default class Controller {
|
||||||
this.$stateParams = $stateParams;
|
this.$stateParams = $stateParams;
|
||||||
this.travel = null;
|
this.travel = null;
|
||||||
this.filter = {
|
this.filter = {
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'ref',
|
|
||||||
'warehouseInFk',
|
|
||||||
'warehouseOutFk',
|
|
||||||
'shipped',
|
|
||||||
'landed',
|
|
||||||
'totalEntries'
|
|
||||||
],
|
|
||||||
|
|
||||||
where: {id: $stateParams.id},
|
where: {id: $stateParams.id},
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,3 +5,5 @@ import './search-panel';
|
||||||
import './descriptor';
|
import './descriptor';
|
||||||
import './card';
|
import './card';
|
||||||
import './summary';
|
import './summary';
|
||||||
|
import './basic-data';
|
||||||
|
import './log';
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
"name": "Travels",
|
"name": "Travels",
|
||||||
"validations": true,
|
"validations": true,
|
||||||
"dependencies": ["worker"],
|
"dependencies": ["worker"],
|
||||||
|
"menu": [
|
||||||
|
{"state": "travel.card.basicData", "icon": "settings"},
|
||||||
|
{"state": "travel.card.log", "icon": "history"}],
|
||||||
"routes": [
|
"routes": [
|
||||||
{
|
{
|
||||||
"url": "/travel",
|
"url": "/travel",
|
||||||
|
@ -29,6 +32,20 @@
|
||||||
"params": {
|
"params": {
|
||||||
"travel": "$ctrl.travel"
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue