From 188f4ae3bf9620f75f4d9f575417928405f7a26f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 21 Oct 2019 11:08:41 +0200 Subject: [PATCH] mark item diary line --- modules/item/front/diary/index.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index a15c32644..e128369a2 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -52,24 +52,31 @@ class Controller { get freeLineIndex() { let lines = this.$scope.model.data; - let currentDate = new Date(); - currentDate.setHours(0, 0, 0); + let minDate = new Date(); + minDate.setHours(0, 0, 0, 0); + + let maxDate = new Date(); + maxDate.setHours(23, 59, 59, 59); + for (let i = 0; i < lines.length; i++) { - let isFutureDate = new Date(lines[i].date) >= currentDate; + const dated = new Date(lines[i].date); - if (isFutureDate) + let isForFuture = dated > maxDate; + let isForToday = (dated >= minDate && dated <= maxDate); + + if (isForFuture || isForToday) return i; } } get onPreparationLineIndex() { let lines = this.$scope.model.data; - for (let i = this.freeLineIndex; i >= 0; i--) { let line = lines[i]; + let currentDate = new Date(); - currentDate.setHours(0, 0, 0); + currentDate.setHours(0, 0, 0, 0); let isPastDate = new Date(lines[i].date) < currentDate; let isPicked = line.alertLevel == 1 && line.isPicked; @@ -95,6 +102,7 @@ class Controller { let selectedTicketLineIndex = this.givenTicketIndex; let lineIndex = this.onPreparationLineIndex; + let lines = body.querySelector('vn-tbody').children; if (lineIndex == undefined || !lines.length) return; @@ -120,7 +128,6 @@ class Controller { offsetTop = onPreparationLine.offsetTop - headerHeight; this.$window.scrollTo(0, offsetTop); - this.ticketFk = null; }