import { Component, Input, Output, OnInit, EventEmitter } from "@angular/core"; import { SchadulerPivot, Cell, Item, Row } from "sigma-ng/schaduler"; import { HotkeysService, Hotkey } from "angular2-hotkeys"; @Component({ selector: 'schaduler-pivot', templateUrl: './pivot.component.html', styleUrls: ['./pivot.component.css'], }) export class SchadulerPivotComponent implements OnInit { @Input() schaduler: SchadulerPivot; @Output() onnextColumns: EventEmitter = new EventEmitter; @Output() onprevColumns: EventEmitter = new EventEmitter; @Output() onnextRows: EventEmitter = new EventEmitter; @Output() onprevRows: EventEmitter = new EventEmitter; @Output() onselectItem: EventEmitter = new EventEmitter; @Output() onrowNameClick: EventEmitter = new EventEmitter; constructor(private hotkeyService: HotkeysService) {} ngOnInit(): void { this.hotkeyService.add(new Hotkey('up',(event) => { if(this.schaduler.position.y > 0) this.schaduler.position.y--; else this.onprevRows.emit(); return false; })); this.hotkeyService.add(new Hotkey('down',(event) => { if(this.schaduler.position.y < this.schaduler.rows.length - 1) this.schaduler.position.y++; else this.onnextRows.emit(); return false; })); this.hotkeyService.add(new Hotkey('right',(event) => { if(this.schaduler.options.rtl) { if(this.schaduler.position.x > 0) this.schaduler.position.x--; else this.onprevColumns.emit(); } else { if(this.schaduler.position.x < this.schaduler.columns.length - 1) this.schaduler.position.x++; else this.onnextColumns.emit(); } return false; })); this.hotkeyService.add(new Hotkey('left',(event) => { if(this.schaduler.options.rtl) { if(this.schaduler.position.x < this.schaduler.columns.length - 1) this.schaduler.position.x++; else this.onnextColumns.emit(); } else { if(this.schaduler.position.x > 0) this.schaduler.position.x--; else this.onprevColumns.emit(); } return false; })); this.hotkeyService.add(new Hotkey('enter',(event) => { this.onselectItem.emit(this.schaduler.SelectedItem); return false; })); } clickItem(x:number, y: number) { this.schaduler.position.x = x; this.schaduler.position.y = y; this.onselectItem.emit(this.schaduler.SelectedItem); } }