new section thermograph
gitea/salix/1981-travel_thermograph This commit looks good
Details
gitea/salix/1981-travel_thermograph This commit looks good
Details
This commit is contained in:
parent
456845dbd6
commit
f4e3649d9e
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "TravelThermograph",
|
"name": "TravelThermograph",
|
||||||
"base": "VnModel",
|
"base": "Loggable",
|
||||||
|
"log": {
|
||||||
|
"model":"TravelLog"
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "travelThermograph"
|
"table": "travelThermograph"
|
||||||
|
|
|
@ -9,3 +9,5 @@ import './summary';
|
||||||
import './basic-data';
|
import './basic-data';
|
||||||
import './log';
|
import './log';
|
||||||
import './create';
|
import './create';
|
||||||
|
import './thermograph';
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,5 @@ Search travels by id: Buscar envíos por identificador
|
||||||
New travel: Nuevo envío
|
New travel: Nuevo envío
|
||||||
# Sections
|
# Sections
|
||||||
Travels: Envíos
|
Travels: Envíos
|
||||||
Log: Historial
|
Log: Historial
|
||||||
|
Thermographs: Termómetros
|
|
@ -10,7 +10,8 @@
|
||||||
],
|
],
|
||||||
"card": [
|
"card": [
|
||||||
{"state": "travel.card.basicData", "icon": "settings"},
|
{"state": "travel.card.basicData", "icon": "settings"},
|
||||||
{"state": "travel.card.log", "icon": "history"}
|
{"state": "travel.card.log", "icon": "history"},
|
||||||
|
{"state": "travel.card.thermograph", "icon": "icon-thermometer"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"routes": [
|
"routes": [
|
||||||
|
@ -57,6 +58,15 @@
|
||||||
"state": "travel.create",
|
"state": "travel.create",
|
||||||
"component": "vn-travel-create",
|
"component": "vn-travel-create",
|
||||||
"description": "New travel"
|
"description": "New travel"
|
||||||
|
}, {
|
||||||
|
"url" : "/thermograph",
|
||||||
|
"state": "travel.card.thermograph",
|
||||||
|
"component": "vn-travel-thermograph",
|
||||||
|
"description": "Thermographs",
|
||||||
|
"params": {
|
||||||
|
"travel": "$ctrl.travel"
|
||||||
|
},
|
||||||
|
"acl": ["buyer"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -107,6 +107,29 @@
|
||||||
</vn-tfoot>
|
</vn-tfoot>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
|
<vn-auto>
|
||||||
|
<h4 translate>Thermographs</h4>
|
||||||
|
<vn-table>
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th>Code</vn-th>
|
||||||
|
<vn-th>Temperature</vn-th>
|
||||||
|
<vn-th expand>State</vn-th>
|
||||||
|
<vn-th>Destination</vn-th>
|
||||||
|
<vn-th>Created</vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="thermograph in $ctrl.travelThermographs">
|
||||||
|
<vn-td>{{thermograph.thermographFk}} </vn-td>
|
||||||
|
<vn-td>{{thermograph.temperature}}</vn-td>
|
||||||
|
<vn-td>{{thermograph.result}}</vn-td>
|
||||||
|
<vn-td>{{thermograph.warehouse.name}}</vn-td>
|
||||||
|
<vn-td>{{thermograph.created | date: 'dd/MM/yyyy'}}</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
</vn-table>
|
||||||
|
</vn-auto>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-ticket-descriptor-popover
|
<vn-ticket-descriptor-popover
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
import Component from 'core/lib/component';
|
||||||
|
|
||||||
class Controller {
|
class Controller extends Component {
|
||||||
constructor($scope, $http) {
|
constructor($element, $, $httpParamSerializer) {
|
||||||
this.$ = $scope;
|
super($element, $);
|
||||||
this.$http = $http;
|
|
||||||
this.entries = [];
|
this.entries = [];
|
||||||
|
this.$httpParamSerializer = $httpParamSerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
get travel() {
|
get travel() {
|
||||||
|
@ -18,6 +19,7 @@ class Controller {
|
||||||
if (value && value.id) {
|
if (value && value.id) {
|
||||||
this.getTravel();
|
this.getTravel();
|
||||||
this.getEntries();
|
this.getEntries();
|
||||||
|
this.getThermographs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +35,27 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getThermographs() {
|
||||||
|
const params = {
|
||||||
|
filter: {
|
||||||
|
include: {
|
||||||
|
relation: 'warehouse',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
travelFk: this.travel.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const serializedParams = this.$httpParamSerializer(params);
|
||||||
|
return this.$http.get(`TravelThermographs?${serializedParams}`).then(res => {
|
||||||
|
this.travelThermographs = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
total(field) {
|
total(field) {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
|
@ -43,7 +66,7 @@ class Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$scope', '$http'];
|
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
||||||
|
|
||||||
ngModule.component('vnTravelSummary', {
|
ngModule.component('vnTravelSummary', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -3,15 +3,20 @@ import './index';
|
||||||
describe('component vnTravelSummary', () => {
|
describe('component vnTravelSummary', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
let $scope;
|
||||||
|
let $element;
|
||||||
|
let $httpParamSerializer;
|
||||||
|
|
||||||
beforeEach(angular.mock.module('travel', $translateProvider => {
|
beforeEach(angular.mock.module('travel', $translateProvider => {
|
||||||
$translateProvider.translations('en', {});
|
$translateProvider.translations('en', {});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
controller = $componentController('vnTravelSummary');
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$element = angular.element(`<vn-travel-summary></vn-travel-summary>`);
|
||||||
|
controller = $componentController('vnTravelSummary', {$element, $scope});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('travel setter/getter', () => {
|
describe('travel setter/getter', () => {
|
||||||
|
@ -24,12 +29,14 @@ describe('component vnTravelSummary', () => {
|
||||||
it('should return the travel and then call both getTravel() and getEntries()', () => {
|
it('should return the travel and then call both getTravel() and getEntries()', () => {
|
||||||
spyOn(controller, 'getTravel');
|
spyOn(controller, 'getTravel');
|
||||||
spyOn(controller, 'getEntries');
|
spyOn(controller, 'getEntries');
|
||||||
|
spyOn(controller, 'getThermographs');
|
||||||
controller.travel = {id: 99};
|
controller.travel = {id: 99};
|
||||||
|
|
||||||
|
|
||||||
expect(controller._travel.id).toEqual(99);
|
expect(controller._travel.id).toEqual(99);
|
||||||
expect(controller.getTravel).toHaveBeenCalledWith();
|
expect(controller.getTravel).toHaveBeenCalledWith();
|
||||||
expect(controller.getEntries).toHaveBeenCalledWith();
|
expect(controller.getEntries).toHaveBeenCalledWith();
|
||||||
|
expect(controller.getThermographs).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,6 +66,32 @@ describe('component vnTravelSummary', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getThermographs()', () => {
|
||||||
|
it('should call the getThermographs method to get the thermographs', () => {
|
||||||
|
controller._travel = {id: 2};
|
||||||
|
const params = {
|
||||||
|
filter: {
|
||||||
|
include: {
|
||||||
|
relation: 'warehouse',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
travelFk: controller._travel.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const serializedParams = $httpParamSerializer(params);
|
||||||
|
const query = `TravelThermographs?${serializedParams}`;
|
||||||
|
$httpBackend.expectGET(query).respond('I am the thermographs');
|
||||||
|
controller.getThermographs();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.travelThermographs).toEqual('I am the thermographs');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('total()', () => {
|
describe('total()', () => {
|
||||||
it('should calculate the total amount of a given property for every row', () => {
|
it('should calculate the total amount of a given property for every row', () => {
|
||||||
controller.entries = [
|
controller.entries = [
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<vn-crud-model
|
||||||
|
vn-id="model"
|
||||||
|
url="TravelThermographs"
|
||||||
|
data="$ctrl.travelThermographs"
|
||||||
|
order="created"
|
||||||
|
link="{travelFk: $ctrl.$params.id}"
|
||||||
|
filter="$ctrl.filter"
|
||||||
|
auto-load="true">
|
||||||
|
</vn-crud-model>
|
||||||
|
<vn-data-viewer model="model">
|
||||||
|
<form name="form">
|
||||||
|
<vn-card class="vn-mt-md">
|
||||||
|
<vn-table model="model" auto-load="false">
|
||||||
|
<vn-thead>
|
||||||
|
<vn-tr>
|
||||||
|
<vn-th>Code</vn-th>
|
||||||
|
<vn-th>Temperature</vn-th>
|
||||||
|
<vn-th expand>State</vn-th>
|
||||||
|
<vn-th>Destination</vn-th>
|
||||||
|
<vn-th>Created</vn-th>
|
||||||
|
<vn-th shrink></vn-th>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-thead>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="thermograph in $ctrl.travelThermographs">
|
||||||
|
<vn-td>{{thermograph.thermographFk}} </vn-td>
|
||||||
|
<vn-td>{{thermograph.temperature}} </vn-td>
|
||||||
|
<vn-td expand>{{thermograph.result}}</vn-td>
|
||||||
|
<vn-td>{{thermograph.warehouse.name}}</vn-td>
|
||||||
|
<vn-td>{{thermograph.created | date: 'dd/MM/yyyy'}}</vn-td>
|
||||||
|
<vn-td shrink>
|
||||||
|
<vn-icon-button
|
||||||
|
icon="delete"
|
||||||
|
ng-click="$ctrl.showDeleteConfirm($index)"
|
||||||
|
title="{{'Remove thermograph' | translate}}"
|
||||||
|
tabindex="-1">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
</vn-table>
|
||||||
|
</vn-card>
|
||||||
|
</form>
|
||||||
|
</vn-data-viewer>
|
||||||
|
|
||||||
|
<vn-confirm
|
||||||
|
vn-id="confirm"
|
||||||
|
question="Delete thermograph from travel?"
|
||||||
|
on-response="$ctrl.removeThermographFromTravel($response)">
|
||||||
|
</vn-confirm>
|
|
@ -0,0 +1,28 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
import Component from 'core/lib/component';
|
||||||
|
|
||||||
|
class Controller extends Component {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.filter = {
|
||||||
|
include:
|
||||||
|
{relation: 'warehouse',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngModule.component('vnTravelThermograph', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
require: {
|
||||||
|
card: '^vnTravelCard'
|
||||||
|
},
|
||||||
|
bindings: {
|
||||||
|
travel: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,6 @@
|
||||||
|
Code: Código
|
||||||
|
Temperature: Temperatura
|
||||||
|
State: Estado
|
||||||
|
Destination: Destino
|
||||||
|
Created: Creado
|
||||||
|
Remove thermograph: Eliminar termómetro
|
|
@ -0,0 +1,6 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
|
vn-route-tickets form{
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: $width-lg;
|
||||||
|
}
|
Loading…
Reference in New Issue