summary
gitea/salix/2056-entry_descriptor There was a failure building this commit Details

This commit is contained in:
Bernat Exposito Domenech 2020-02-04 09:34:31 +01:00
parent 711e973c23
commit fac93bd74c
7 changed files with 323 additions and 4 deletions

View File

@ -5,7 +5,4 @@ import './index/';
import './search-panel'; import './search-panel';
import './descriptor'; import './descriptor';
import './card'; import './card';
// import './summary'; import './summary';
// import './basic-data';
// import './log';
// import './create';

View File

@ -27,6 +27,14 @@
"state": "entry.card", "state": "entry.card",
"abstract": true, "abstract": true,
"component": "vn-entry-card" "component": "vn-entry-card"
}, {
"url": "/summary",
"state": "entry.card.summary",
"component": "vn-entry-summary",
"description": "Summary",
"params": {
"entry": "$ctrl.entry"
}
} }
] ]
} }

View File

@ -0,0 +1,140 @@
<vn-card class="summary">
<h5>{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}</h5>
<vn-horizontal>
<vn-one>
<vn-label-value label="Shipped"
value="{{$ctrl.travelData.shipped | date: 'dd/MM/yyyy'}}">
</vn-label-value>
<vn-label-value label="Warehouse Out"
value="{{$ctrl.travelData.warehouseOut.name}}">
</vn-label-value>
<vn-check
label="Delivered"
value="{{$ctrl.travelData.isDelivered}}"
disabled="true">
</vn-check>
</vn-one>
<vn-one>
<vn-label-value label="Landed"
value="{{$ctrl.travelData.landed | date: 'dd/MM/yyyy'}}">
</vn-label-value>
<vn-label-value label="Warehouse In"
value="{{$ctrl.travelData.warehouseIn.name}}">
</vn-label-value>
<vn-check
label="Received"
value="{{$ctrl.travelData.isReceived}}"
disabled="true">
</vn-check>
</vn-one>
<vn-one>
<vn-label-value label="Agency"
value="{{$ctrl.travelData.agency.name}}">
</vn-label-value>
<vn-label-value label="Reference"
value="{{$ctrl.travelData.ref}}">
</vn-label-value>
<vn-label-value label="m3"
value="{{$ctrl.travelData.m3}}">
</vn-label-value>
<vn-label-value label="Total entries"
value="{{$ctrl.travelData.totalEntries}}">
</vn-label-value>
</vn-one>
<vn-auto>
<h4 translate>Entries</h4>
<vn-table>
<vn-thead>
<vn-tr>
<vn-th shrink>Confirmed</vn-th>
<vn-th shrink>Entry Id</vn-th>
<vn-th shrink>Supplier</vn-th>
<vn-th shrink>Reference</vn-th>
<vn-th shrink title="Half box">HB</vn-th>
<vn-th shrink>Freight</vn-th>
<vn-th shrink>Package</vn-th>
<vn-th shrink>CC</vn-th>
<vn-th shrink>Pallet</vn-th>
<vn-th shrink>m3</vn-th>
<vn-th shrink></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="entry in $ctrl.entries">
<vn-td shrink>
<vn-check
value="{{entry.isConfirmed}}"
disabled="true">
</vn-check>
</vn-td>
<vn-td shrink>{{entry.id}} </vn-td>
<vn-td shrink>{{entry.supplierName}}</vn-td>
<vn-td shrink>{{entry.ref}}</vn-td>
<vn-td shrink>{{entry.hb}}</vn-td>
<vn-td shrink>{{entry.freightValue | currency: 'EUR': 2}}</vn-td>
<vn-td shrink>{{entry.packageValue | currency: 'EUR': 2}}</vn-td>
<vn-td shrink>{{entry.cc}}</vn-td>
<vn-td shrink>{{entry.pallet}}</vn-td>
<vn-td shrink>{{entry.m3}}</vn-td>
<vn-td shrink>
<vn-icon
ng-if="entry.notes.length"
vn-tooltip="{{entry.notes}}"
icon="insert_drive_file">
</vn-icon>
<vn-icon
ng-if="entry.observation.length"
vn-tooltip="{{entry.observation}}"
icon="insert_drive_file">
</vn-icon>
</vn-td>
</vn-tr>
</vn-tbody>
<vn-tfoot>
<vn-tr>
<vn-td></vn-td>
<vn-td></vn-td>
<vn-td></vn-td>
<vn-td></vn-td>
<vn-td shrink><strong>{{$ctrl.total('hb')}}</strong></vn-td>
<vn-td shrink><strong>{{$ctrl.total('freightValue') | currency: 'EUR': 2}}</strong></vn-td>
<vn-td shrink><strong>{{$ctrl.total('packageValue') | currency: 'EUR': 2}}</strong></vn-td>
<vn-td shrink><strong>{{$ctrl.total('cc')}}</strong></vn-td>
<vn-td shrink><strong>{{$ctrl.total('pallet')}}</strong></vn-td>
<vn-td shrink><strong>{{$ctrl.total('m3')}}</strong></vn-td>
<vn-td></vn-td>
</vn-tr>
</vn-tfoot>
</vn-table>
</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-card>
<vn-ticket-descriptor-popover
vn-id="ticketDescriptor">
</vn-ticket-descriptor-popover>
<vn-client-descriptor-popover
vn-id="clientDescriptor">
</vn-client-descriptor-popover>

View File

@ -0,0 +1,56 @@
import ngModule from '../module';
import './style.scss';
import Component from 'core/lib/component';
class Controller extends Component {
constructor($element, $, $httpParamSerializer) {
super($element, $);
this.entries = [];
this.$httpParamSerializer = $httpParamSerializer;
}
get entry() {
return this._entry;
}
set entry(value) {
this._entry = value;
// if (value && value.id) {
// this.getTravel();
// this.getEntries();
// this.getThermographs();
// }
}
// getTravel() {
// return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => {
// this.travelData = response.data;
// });
// }
// getEntries() {
// return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => {
// this.entries = response.data;
// });
// }
// total(field) {
// let total = 0;
// for (let entry of this.entries)
// total += entry[field];
// return total;
// }
}
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
ngModule.component('vnEntrySummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
entry: '<'
}
});

View File

@ -0,0 +1,108 @@
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, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
$httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_;
$scope = $rootScope.$new();
$element = angular.element(`<vn-travel-summary></vn-travel-summary>`);
controller = $componentController('vnTravelSummary', {$element, $scope});
}));
describe('travel setter/getter', () => {
it('should return the travel', () => {
controller.travel = {id: null};
expect(controller.travel).toEqual(jasmine.any(Object));
});
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();
});
});
describe('getTravel()', () => {
it('should perform a get and then store data on the controller', () => {
controller._travel = {id: 999};
const query = `/api/Travels/${controller._travel.id}/getTravel`;
$httpBackend.expectGET(query).respond('I am the travelData');
controller.getTravel();
$httpBackend.flush();
expect(controller.travelData).toEqual('I am the travelData');
});
});
describe('getEntries()', () => {
it('should call the getEntries method to get the entries data', () => {
controller._travel = {id: 999};
const query = `/api/Travels/${controller._travel.id}/getEntries`;
$httpBackend.expectGET(query).respond('I am the entries');
controller.getEntries();
$httpBackend.flush();
expect(controller.entries).toEqual('I am the entries');
});
});
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 = [
{id: 1, freightValue: 1, packageValue: 2, cc: 0.01},
{id: 2, freightValue: 1, packageValue: 2, cc: 0.01},
{id: 3, freightValue: 1, packageValue: 2, cc: 0.01}
];
expect(controller.total('freightValue')).toEqual(3);
expect(controller.total('packageValue')).toEqual(6);
expect(controller.total('cc')).toEqual(0.03);
});
});
});

View File

@ -0,0 +1,10 @@
@import "variables";
vn-travel-summary .summary {
max-width: $width-lg;
vn-icon[icon=insert_drive_file]{
color: $color-font-secondary;
}
}