AW-6046 Angular improvement
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit,Input,ViewChild,OnChanges,ChangeDetectorRef,Output, EventEmitter,SimpleChanges } from '@angular/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import {NgbPopover} from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
export interface TimeSpan {
|
||||
startDate:Date;
|
||||
@@ -73,7 +73,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
canvas.width = this.elementWidth * this.ratio;
|
||||
}
|
||||
|
||||
getPosibleUnits(scale:number):number[] {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getPosibleUnits(_scale:number):number[] {
|
||||
const posibleUnits = [];
|
||||
for(const u of [3,4,6,8]) {
|
||||
if((this.unitScale <=u) )
|
||||
@@ -119,7 +120,6 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
getStartEndCaption(date:Date,otherDate:Date,unitScale:number,suffix = false,extended=true):string {
|
||||
const showSuffix = false;
|
||||
otherDate=new Date(otherDate.getTime()-1); // fix year edge case
|
||||
if(unitScale == 3) {
|
||||
let format="HH:00";
|
||||
@@ -234,9 +234,6 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
getNextTick(viewStartDate:Date, tick:number,step:number,unitScale:number):number {
|
||||
const unitTextWidth = this.getUnitTextWidth(unitScale);
|
||||
const dateOffset =this.getUnitDateOffset(viewStartDate,unitScale,tick);
|
||||
const date = new Date(viewStartDate.getTime() + dateOffset);
|
||||
let nextTick=tick+step+Math.trunc(step/2);
|
||||
const nextDateOffset =this.getUnitDateOffset(viewStartDate,unitScale,nextTick);
|
||||
const nextDate = new Date(viewStartDate.getTime() + nextDateOffset);
|
||||
@@ -347,7 +344,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
this.caption=this.getCaption(startDate,endDate,this.unitScale);
|
||||
}
|
||||
|
||||
snapToUnit(date:Date,unitScale:number):Date {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
snapToUnit(date:Date,_unitScale:number):Date {
|
||||
const d = new Date(date.getTime() + (this.unitScales[this.unitScale]/2));
|
||||
const offsetInMilliseconds =this.getUnitDateOffset(d,this.unitScale,0)
|
||||
return new Date(d.getTime()+offsetInMilliseconds);
|
||||
@@ -417,14 +415,14 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleRightGripMouseEnter(event:MouseEvent) {
|
||||
handleRightGripMouseEnter() {
|
||||
this.mouseX=-1;
|
||||
this.mouseY=-1;
|
||||
this.redraw();
|
||||
if(!this.rangeGripMove && !this.leftGripMove && !this.rightGripMove) this.popoverEnd.open(this.endCaption);
|
||||
}
|
||||
|
||||
handleRightGripMouseLeave(event:MouseEvent) {
|
||||
handleRightGripMouseLeave() {
|
||||
if(!this.rightGripMove) this.popoverEnd.close();
|
||||
}
|
||||
|
||||
@@ -435,18 +433,18 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleLeftGripMouseEnter(event:MouseEvent|TouchEvent) {
|
||||
handleLeftGripMouseEnter() {
|
||||
this.mouseX=-1;
|
||||
this.mouseY=-1;
|
||||
this.redraw();
|
||||
if(!this.rangeGripMove && !this.leftGripMove && !this.rightGripMove) this.popoverStart.open(this.startCaption);
|
||||
}
|
||||
|
||||
handleLeftGripMouseLeave(event:MouseEvent) {
|
||||
handleLeftGripMouseLeave() {
|
||||
if(!this.leftGripMove) this.popoverStart.close();
|
||||
}
|
||||
|
||||
handleRangeGripMouseEnter(event:MouseEvent) {
|
||||
handleRangeGripMouseEnter() {
|
||||
this.mouseX=-1;
|
||||
this.mouseY=-1;
|
||||
this.redraw();
|
||||
@@ -464,7 +462,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleMouseUp(event:MouseEvent|TouchEvent) {
|
||||
handleMouseUp() {
|
||||
//this.updateControl(event);
|
||||
this.startDate = this.getStartDate(this.lastOffsetInPixels);
|
||||
this.endDate = this.getEndDate(this.lastOffsetInPixels);
|
||||
@@ -498,7 +496,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
handleCanvasMouseLeave(event:MouseEvent) {
|
||||
handleCanvasMouseLeave() {
|
||||
this.mouseX = -1;
|
||||
this.mouseY = -1;
|
||||
this.redraw();
|
||||
@@ -510,7 +508,6 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
return true;
|
||||
} else {
|
||||
nextScale*=1.1;
|
||||
const canZoom=false;
|
||||
const oneUnit = (this.getUnitDateOffset(this.viewMinDate,8,1)- this.getUnitDateOffset(this.viewMinDate,8,0)) / nextScale;
|
||||
const unitTextWidth=this.getUnitTextWidth(8);
|
||||
const steps=this.getSteps(8);
|
||||
@@ -565,7 +562,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
this.updateStyle(this.startDate,this.endDate);
|
||||
}
|
||||
|
||||
handleResize(event:any) {
|
||||
handleResize() {
|
||||
if(this.initialized) {
|
||||
this.setCanvasSize();
|
||||
this.updateStyle(this.startDate,this.endDate);
|
||||
@@ -573,7 +570,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges (changes: SimpleChanges) {
|
||||
ngOnChanges() {
|
||||
if(this.initialized) {
|
||||
this.setCanvasSize();
|
||||
this.updateStyle(this.startDate,this.endDate);
|
||||
|
Reference in New Issue
Block a user