diff --git a/modules/travel/back/models/travel-thermograph.json b/modules/travel/back/models/travel-thermograph.json index 31fe1b6d6..18e632d02 100644 --- a/modules/travel/back/models/travel-thermograph.json +++ b/modules/travel/back/models/travel-thermograph.json @@ -1,6 +1,9 @@ { "name": "TravelThermograph", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"TravelLog" + }, "options": { "mysql": { "table": "travelThermograph" diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js index 02bbb997b..4bf935a8c 100644 --- a/modules/travel/front/index.js +++ b/modules/travel/front/index.js @@ -9,3 +9,5 @@ import './summary'; import './basic-data'; import './log'; import './create'; +import './thermograph'; + diff --git a/modules/travel/front/locale/es.yml b/modules/travel/front/locale/es.yml index 0986729f8..31e4e452b 100644 --- a/modules/travel/front/locale/es.yml +++ b/modules/travel/front/locale/es.yml @@ -15,4 +15,5 @@ Search travels by id: Buscar envíos por identificador New travel: Nuevo envío # Sections Travels: Envíos -Log: Historial \ No newline at end of file +Log: Historial +Thermographs: Termómetros \ No newline at end of file diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index d9b520816..d7d5b52df 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -10,7 +10,8 @@ ], "card": [ {"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": [ @@ -57,6 +58,15 @@ "state": "travel.create", "component": "vn-travel-create", "description": "New travel" + }, { + "url" : "/thermograph", + "state": "travel.card.thermograph", + "component": "vn-travel-thermograph", + "description": "Thermographs", + "params": { + "travel": "$ctrl.travel" + }, + "acl": ["buyer"] } ] } \ No newline at end of file diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html index 51b73ac06..5397c72ca 100644 --- a/modules/travel/front/summary/index.html +++ b/modules/travel/front/summary/index.html @@ -107,6 +107,29 @@ + +

Thermographs

+ + + + Code + Temperature + State + Destination + Created + + + + + {{thermograph.thermographFk}} + {{thermograph.temperature}} + {{thermograph.result}} + {{thermograph.warehouse.name}} + {{thermograph.created | date: 'dd/MM/yyyy'}} + + + +
{ + this.travelThermographs = res.data; + }); + } + total(field) { let total = 0; @@ -43,7 +66,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$http']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnTravelSummary', { template: require('./index.html'), diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index ec5beb053..5411d8a0d 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -3,15 +3,20 @@ import './index'; describe('component vnTravelSummary', () => { let controller; let $httpBackend; - + let $scope; + let $element; + let $httpParamSerializer; beforeEach(angular.mock.module('travel', $translateProvider => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnTravelSummary'); + $httpParamSerializer = _$httpParamSerializer_; + $scope = $rootScope.$new(); + $element = angular.element(``); + controller = $componentController('vnTravelSummary', {$element, $scope}); })); describe('travel setter/getter', () => { @@ -24,12 +29,14 @@ describe('component vnTravelSummary', () => { it('should return the travel and then call both getTravel() and getEntries()', () => { spyOn(controller, 'getTravel'); spyOn(controller, 'getEntries'); + spyOn(controller, 'getThermographs'); controller.travel = {id: 99}; expect(controller._travel.id).toEqual(99); expect(controller.getTravel).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()', () => { it('should calculate the total amount of a given property for every row', () => { controller.entries = [ diff --git a/modules/travel/front/thermograph/index.html b/modules/travel/front/thermograph/index.html new file mode 100644 index 000000000..67d836d73 --- /dev/null +++ b/modules/travel/front/thermograph/index.html @@ -0,0 +1,50 @@ + + + +
+ + + + + Code + Temperature + State + Destination + Created + + + + + + {{thermograph.thermographFk}} + {{thermograph.temperature}} + {{thermograph.result}} + {{thermograph.warehouse.name}} + {{thermograph.created | date: 'dd/MM/yyyy'}} + + + + + + + + +
+
+ + + diff --git a/modules/travel/front/thermograph/index.js b/modules/travel/front/thermograph/index.js new file mode 100644 index 000000000..394bebdb8 --- /dev/null +++ b/modules/travel/front/thermograph/index.js @@ -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: '<' + } +}); diff --git a/modules/travel/front/thermograph/locale/es.yml b/modules/travel/front/thermograph/locale/es.yml new file mode 100644 index 000000000..9f5e04b72 --- /dev/null +++ b/modules/travel/front/thermograph/locale/es.yml @@ -0,0 +1,6 @@ +Code: Código +Temperature: Temperatura +State: Estado +Destination: Destino +Created: Creado +Remove thermograph: Eliminar termómetro \ No newline at end of file diff --git a/modules/travel/front/thermograph/style.scss b/modules/travel/front/thermograph/style.scss new file mode 100644 index 000000000..2c287ed9d --- /dev/null +++ b/modules/travel/front/thermograph/style.scss @@ -0,0 +1,6 @@ +@import "variables"; + +vn-route-tickets form{ + margin: 0 auto; + max-width: $width-lg; +} \ No newline at end of file