FarmMapsLib/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.comp...

65 lines
2.3 KiB
TypeScript
Raw Normal View History

2020-03-02 12:48:10 +00:00
import { Component, Injectable } from '@angular/core';
2021-01-29 11:00:59 +00:00
import { Location } from '@angular/common';
2020-03-02 12:48:10 +00:00
import { Store } from '@ngrx/store';
import * as mapReducers from '../../reducers/map.reducer';
2021-01-29 11:00:59 +00:00
import { commonReducers, ItemTypeService, IItem } from '@farmmaps/common';
2020-03-02 12:48:10 +00:00
import { Router } from '@angular/router';
import { ForItemType } from '../for-item/for-itemtype.decorator';
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
import { ITemporalItemLayer} from '../../models/item.layer';
import * as mapActions from '../../actions/map.actions';
2021-01-29 10:33:22 +00:00
import { IItemLayer } from '../../models/item.layer';
2021-01-29 11:00:59 +00:00
import {TemporalService} from '../../services/temporal.service';
2020-03-02 12:48:10 +00:00
@ForItemType("vnd.farmmaps.itemtype.temporal")
@Injectable()
@Component({
selector: 'fm-map-selected-item-temporal',
templateUrl: './selected-item-temporal.component.html',
styleUrls: ['./selected-item-temporal.component.scss']
})
export class SelectedItemTemporalComponent extends AbstractSelectedItemComponent {
2021-01-29 11:00:59 +00:00
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router,public temporalService:TemporalService) {
2020-03-02 12:48:10 +00:00
super(store, itemTypeService,location,router);
}
onLayerChanged(layerIndex: number) {
this.store.dispatch(new mapActions.SetLayerIndex(layerIndex));
}
2021-01-29 10:25:37 +00:00
currentItemLayer():IItemLayer {
return (this.itemLayer as ITemporalItemLayer)?.selectedItemLayer
}
2021-01-29 11:00:59 +00:00
2020-03-03 09:21:24 +00:00
2020-03-02 12:48:10 +00:00
handleNextTemporal(event:MouseEvent) {
this.store.dispatch(new mapActions.NextTemporal());
event.preventDefault();
}
handlePreviousTemporal(event:MouseEvent) {
this.store.dispatch(new mapActions.PreviousTemporal());
event.preventDefault();
}
2020-03-03 09:21:24 +00:00
selectedItem():IItem {
2023-03-06 13:04:14 +00:00
const temporalItemLayer = this.itemLayer as ITemporalItemLayer;
2020-03-03 09:21:24 +00:00
if(temporalItemLayer && temporalItemLayer.selectedItemLayer) {
return temporalItemLayer.selectedItemLayer.item;
}
return null;
}
2020-03-03 18:43:17 +00:00
layer(layers:any,layerIndex:number) {
return layers.find(l => l.index == layerIndex);
}
2020-03-03 20:06:39 +00:00
handleGoToChart(item: IItem) {
2020-07-07 07:37:17 +00:00
this.router.navigate(['/viewer', 'temporal', 'item', item.parentCode, new Date(Date.parse(item.dataDate)).getUTCFullYear()]);
2020-03-03 20:06:39 +00:00
return false;
}
2020-03-02 12:48:10 +00:00
}