From c39db598ac71542001f4a1e97d4026a8574e5639 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 3 Sep 2018 08:09:56 +0200 Subject: [PATCH] Item diary select correct position #619 --- client/item/src/diary/index.js | 18 +++++++++++------- client/item/src/diary/locale/es.yml | 3 +++ client/item/src/locale/es.yml | 2 -- 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 client/item/src/diary/locale/es.yml diff --git a/client/item/src/diary/index.js b/client/item/src/diary/index.js index 675b35c5f..75a7efd53 100644 --- a/client/item/src/diary/index.js +++ b/client/item/src/diary/index.js @@ -2,11 +2,12 @@ import ngModule from '../module'; import './style.scss'; class Controller { - constructor($scope, $http, $state, $window) { + constructor($scope, $http, $state, $window, $translate) { this.$scope = $scope; this.$http = $http; this.$state = $state; this.$window = $window; + this.$translate = $translate; } $postLink() { @@ -56,9 +57,8 @@ class Controller { let lines = this.$scope.model.data; for (let i = 0; i < lines.length; i++) { let isFutureDate = new Date(lines[i].date) > new Date(); - let isGenreOut = lines[i].alertLevel != 0; - if (!isFutureDate && !isGenreOut) + if (isFutureDate) return i; } } @@ -68,10 +68,14 @@ class Controller { for (let i = this.freeLineIndex; i > 0; i--) { let line = lines[i]; + let currentDate = new Date(); + currentDate.setHours(0, 0, 0); - if (line.alertLevel == 1 && line.isPicked || line.alertLevel > 1) { + let isPastDate = new Date(lines[i].date) < currentDate; + let isPicked = line.alertLevel == 1 && line.isPicked; + + if ((isPicked) || line.alertLevel > 1 || isPastDate) return i; - } } } @@ -86,7 +90,7 @@ class Controller { let balance = onPreparationLine.querySelector('.balance'); balance.classList.add('counter'); - balance.title = 'Visible quantity'; + balance.title = this.$translate.instant('Visible quantity'); let headerOffset = body.querySelector('header').getBoundingClientRect(); let headerHeight = headerOffset.height; @@ -126,7 +130,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', '$state', '$window']; +Controller.$inject = ['$scope', '$http', '$state', '$window', '$translate']; ngModule.component('vnItemDiary', { template: require('./index.html'), diff --git a/client/item/src/diary/locale/es.yml b/client/item/src/diary/locale/es.yml new file mode 100644 index 000000000..c2d7c4683 --- /dev/null +++ b/client/item/src/diary/locale/es.yml @@ -0,0 +1,3 @@ +In: Entrada +Out: Salida +Visible quantity: Cantidad visible \ No newline at end of file diff --git a/client/item/src/locale/es.yml b/client/item/src/locale/es.yml index dd49f3d90..6c1ea804d 100644 --- a/client/item/src/locale/es.yml +++ b/client/item/src/locale/es.yml @@ -25,8 +25,6 @@ Intrastat code: Código intrastat Warehouse: Almacén Code: Código State: Estado -In: Entrada -Out: Salida Species: Especie Add tag: Añadir etiqueta Remove tag: Quitar etiqueta