Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 1980-models_Thermograph

This commit is contained in:
Bernat Exposito Domenech 2020-01-09 10:17:23 +01:00
commit 99f5fbec3c
18 changed files with 230 additions and 57 deletions

View File

@ -11,11 +11,9 @@
.vn-droppable,
[vn-droppable] {
display: block;
&.dropping {
background-color: $color-hover-cd;
border-color: $color-bg-dark;
border-color: $color-font-secondary;
}
}

View File

@ -7,7 +7,7 @@ vn-app {
ui-view {
display: block;
box-sizing: border-box;
height: inherit;
height: 100%;
&.ng-enter {
animation-name: nothing, slideIn;

View File

@ -87,6 +87,8 @@ vn-layout {
& > * {
display: block;
padding: $spacing-md;
box-sizing: border-box;
height: 100%
}
&.ng-enter {
vn-side-menu {

View File

@ -11,7 +11,6 @@
transition: all 0.5s;
padding: $spacing-sm;
position: relative;
opacity: 0.7;
width: 28em;
.image {
@ -20,6 +19,7 @@
0 1px 5px 0 rgba(0,0,0,.12);
background: no-repeat center center fixed;
background-size: cover !important;
border: 2px solid transparent;
overflow: hidden;
cursor: zoom-in;
height: 100%;
@ -34,7 +34,7 @@
top: 1em
}
}
.photo:hover {
opacity: 1
.photo:hover .image {
border: 2px solid $color-primary
}
}

View File

@ -5,31 +5,28 @@
data="$ctrl.photos">
</vn-crud-model>
<section class="drop-zone" vn-droppable="$ctrl.onDrop($event)">
<section><vn-icon icon="add_circle"></vn-icon></section>
<section translate>Drag & Drop files here...</section>
</section>
<vn-data-viewer
model="model"
class="vn-w-xl">
<vn-horizontal class="photo-list">
<section class="photo" ng-repeat="photo in $ctrl.photos">
<section class="image vn-shadow" on-error-src
ng-style="{'background': 'url(/api/dms/' + photo.dmsFk + '/downloadFile?access_token=' + $ctrl.accessToken + ')'}"
zoom-image="/api/dms/{{::photo.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
</section>
<section class="actions">
<vn-button
class="round"
ng-click="$ctrl.showDeleteConfirm($index)"
title="{{'Remove file' | translate}}"
tabindex="-1"
icon="delete">
</vn-button>
</section>
<vn-horizontal class="photo-list drop-zone" vn-droppable="$ctrl.onDrop($event)">
<section class="empty-rows" ng-if="!$ctrl.photos.length">
<section><vn-icon icon="image"></vn-icon></section>
<section translate>Drag & Drop photos here...</section>
</section>
<section class="photo" ng-repeat="photo in $ctrl.photos">
<section class="image vn-shadow" on-error-src
ng-style="{'background': 'url(/api/dms/' + photo.dmsFk + '/downloadFile?access_token=' + $ctrl.accessToken + ')'}"
zoom-image="/api/dms/{{::photo.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
</section>
</vn-horizontal>
</vn-data-viewer>
<section class="actions">
<vn-button
class="round"
ng-click="$ctrl.showDeleteConfirm($index)"
title="{{'Remove file' | translate}}"
tabindex="-1"
icon="delete">
</vn-button>
</section>
</section>
</vn-horizontal>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
@ -38,4 +35,10 @@
message="This file will be deleted"
question="Are you sure you want to continue?"
on-response="$ctrl.deleteDms($response)">
</vn-confirm>
</vn-confirm>
<vn-float-button fixed-bottom-right
icon="add"
vn-tooltip="Select photo"
vn-bind="+"
ng-click="$ctrl.openUploadDialog()">
</vn-float-button>

View File

@ -68,6 +68,19 @@ class Controller {
});
}
openUploadDialog() {
const element = document.createElement('input');
element.setAttribute('type', 'file');
element.setAttribute('multiple', true);
element.click();
element.addEventListener('change', () =>
this.setDefaultParams().then(() => {
this.dms.files = element.files;
this.create();
})
);
}
create() {
const query = `claims/${this.claim.id}/uploadFile`;

View File

@ -2,13 +2,16 @@
vn-claim-dms-index {
.drop-zone {
border: 2px dashed $color-font-secondary;
color: $color-font-secondary;
box-sizing: border-box;
padding: 2em $spacing-md;
border-radius: 0.5em;
text-align: center;
font-size: 1.4em;
min-height: 100%;
.empty-rows {
padding: 5em $spacing-md;
font-size: 1.4em
}
vn-icon {
font-size: 3em

View File

@ -1,2 +0,0 @@
FileDescription: Ticket id {{ticketId}} from client {{clientName}} id {{clientId}}
ContentTypesInfo: Allowed file types {{allowedContentTypes}}

View File

@ -1,4 +1,5 @@
Are you sure you want to continue?: ¿Seguro que quieres continuar?
Drag & Drop files here...: Arrastra y suelta archivos aquí...
Drag & Drop photos here...: Arrastra y suelta fotos aquí...
Photo deleted: Foto eliminada
Photo uploaded!: Foto subida!
Photo uploaded!: Foto subida!
Select photo: Seleccionar foto

View File

@ -1,12 +1,10 @@
@import "./variables";
vn-claim-summary {
.photo {
height: 15.5em;
section.photo {
height: 15.5em
}
.photo .image {
border: 2px solid $color-bg-dark;
border-radius: 0.2em;
.photo .image {
border-radius: 0.2em
}
}

View File

@ -43,7 +43,7 @@
</vn-one>
<vn-auto>
<h4 translate>Entries</h4>
<vn-table model="model">
<vn-table>
<vn-thead>
<vn-tr>
<vn-th shrink>Confirmed</vn-th>
@ -51,8 +51,8 @@
<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 cost</vn-th>
<vn-th shrink>Package cost</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>
@ -61,16 +61,18 @@
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="entry in $ctrl.entries">
<vn-check
value="{{entry.isConfirmed}}"
disabled="true">
</vn-check>
<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}}</vn-td>
<vn-td shrink>{{entry.packageValue}}</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>
@ -81,13 +83,28 @@
icon="insert_drive_file">
</vn-icon>
<vn-icon
ng-if="entry.notes.length"
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-horizontal>

View File

@ -5,6 +5,7 @@ class Controller {
constructor($scope, $http) {
this.$ = $scope;
this.$http = $http;
this.entries = [];
}
get travel() {
@ -31,6 +32,15 @@ class Controller {
this.entries = response.data;
});
}
total(field) {
let total = 0;
for (let entry of this.entries)
total += entry[field];
return total;
}
}
Controller.$inject = ['$scope', '$http'];

View File

@ -58,4 +58,18 @@ describe('component vnTravelSummary', () => {
expect(controller.entries).toEqual('I am the entries');
});
});
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

@ -12,6 +12,6 @@ Confirmed: Confirmada
Entry Id: Entrada Id
Supplier: Proveedor
Pallet: Pallet
Freight cost: Coste porte
Package cost: Coste embalaje
Freight: Porte
Package: Embalaje
Half box: Media caja

View File

@ -0,0 +1,8 @@
const Stylesheet = require(`${appPath}/core/stylesheet`);
module.exports = new Stylesheet([
`${appPath}/common/css/spacing.css`,
`${appPath}/common/css/misc.css`,
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`])
.mergeStyles();

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html v-bind:lang="locale">
<head>
<meta name="viewport" content="width=device-width">
<meta name="format-detection" content="telephone=no">
<title>{{ $t('subject') }}</title>
</head>
<body>
<table class="grid">
<tbody>
<tr>
<td>
<!-- Empty block -->
<div class="grid-row">
<div class="grid-block empty"></div>
</div>
<!-- Header block -->
<div class="grid-row">
<div class="grid-block">
<email-header v-bind="$props"></email-header>
</div>
</div>
<!-- Block -->
<div class="grid-row">
<div class="grid-block vn-pa-lg">
<h1>{{ $t('title') }}</h1>
<p>{{$t('dear')}},</p>
<p v-html="$t('description', [dated])"></p>
</div>
</div>
<!-- Block -->
<div class="grid-row">
<div class="grid-block vn-pa-lg">
<table class="column-oriented">
<thead>
<tr>
<th>{{$t('buyer')}}</th>
<th class="number">{{$t('percentage')}}</th>
<th class="number">{{$t('dwindle')}}</th>
<th class="number">{{$t('total')}}</th>
</tr>
</thead>
<tbody>
<tr v-for="waste in wastes" v-bind:key="waste.buyer">
<td class="font gray">{{waste.buyer}}</td>
<td class="number">{{(waste.percentage / 100) | percentage(4, 4, locale)}}</td>
<td class="number">{{waste.dwindle | currency('EUR', locale)}}</td>
<td class="number">{{waste.total | currency('EUR', locale)}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Footer block -->
<div class="grid-row">
<div class="grid-block">
<email-footer v-bind="$props"></email-footer>
</div>
</div>
<!-- Empty block -->
<div class="grid-row">
<div class="grid-block empty"></div>
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,31 @@
const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
module.exports = {
name: 'buyer-week-waste',
async serverPrefetch() {
this.wastes = await this.fetchWastes();
if (!this.wastes)
throw new Error('Something went wrong');
},
computed: {
dated: function() {
const filters = this.$options.filters;
return filters.date(new Date(), '%d-%m-%Y');
}
},
methods: {
fetchWastes() {
return db.findOne(`CALL bs.weekWaste()`);
}
},
components: {
'email-header': emailHeader.build(),
'email-footer': emailFooter.build()
},
props: {}
};

View File

@ -0,0 +1,8 @@
subject: Merma semanal
title: Merma semanal
dear: Hola
description: A continuación se muestra la merma semanal a fecha de <strong>{0}</strong>.
buyer: Comprador
percentage: Porcentaje
weakening: Mermas
total: Total