route.basicData validations
gitea/salix/2124-route_basic_data This commit looks good Details

This commit is contained in:
Bernat Exposito Domenech 2020-02-18 12:51:29 +01:00
parent af51c2632e
commit bfb8c5e138
4 changed files with 24 additions and 4 deletions

View File

@ -126,5 +126,6 @@
"MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})", "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})",
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})",
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto" "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000"
} }

View File

@ -5,4 +5,21 @@ module.exports = Self => {
require('../methods/route/guessPriority')(Self); require('../methods/route/guessPriority')(Self);
require('../methods/route/updateVolume')(Self); require('../methods/route/updateVolume')(Self);
require('../methods/route/getDeliveryPoint')(Self); require('../methods/route/getDeliveryPoint')(Self);
Self.validate('kmStart', validateDistance, {
message: 'Distance must be lesser than 1000'
});
Self.validate('kmEnd', validateDistance, {
message: 'Distance must be lesser than 1000'
});
function validateDistance(err) {
const routeTotalKm = this.kmEnd - this.kmStart;
const routeMaxKm = 1000;
if ( routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
err();
}
}; };

View File

@ -1,8 +1,10 @@
import ngModule from '../module'; import ngModule from '../module';
class Controller { class Controller {
constructor($scope) { constructor($scope, vnApp, $translate) {
this.$ = $scope; this.$ = $scope;
this.vnApp = vnApp;
this.$translate = $translate;
} }
onSubmit() { onSubmit() {
@ -11,7 +13,7 @@ class Controller {
}); });
} }
} }
Controller.$inject = ['$scope']; Controller.$inject = ['$scope', 'vnApp', '$translate'];
ngModule.component('vnRouteBasicData', { ngModule.component('vnRouteBasicData', {
template: require('./index.html'), template: require('./index.html'),