51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import {Component, Injectable, Input, OnInit} from '@angular/core';
|
|
import {Store} from '@ngrx/store';
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
|
import {commonReducers, IItem, IListItem, ItemService, ItemTypeService} from '@farmmaps/common';
|
|
import {ForItemType} from '../for-item/for-itemtype.decorator';
|
|
import {ForSourceTask} from '../for-item/for-sourcetask.decorator';
|
|
import {AbstractItemListItemComponent} from '../item-list-item/item-list-item.component'
|
|
import {Observable} from "rxjs";
|
|
import {Router} from "@angular/router";
|
|
|
|
@ForItemType("vnd.farmmaps.itemtype.tipstar")
|
|
@ForSourceTask("vnd.farmmaps.task.tipstar")
|
|
@Injectable()
|
|
@Component({
|
|
selector: 'item-list-item-tipstar',
|
|
templateUrl: './item-list-item-tipstar.component.html',
|
|
styleUrls: ['./item-list-item-tipstar.component.scss']
|
|
})
|
|
export class ItemListItemTipstarComponent extends AbstractItemListItemComponent implements OnInit {
|
|
@Input() item: IListItem;
|
|
|
|
item$: Observable<IItem>;
|
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,
|
|
private itemService$: ItemService, private router: Router) {
|
|
super(store, itemTypeService);
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.item$ = this.itemService$.getItem(this.item.code);
|
|
}
|
|
|
|
onWidgetClicked(event: MouseEvent) {
|
|
event.stopPropagation();
|
|
this.router.navigate(['viewer/tipstar/item', this.item.code]);
|
|
}
|
|
|
|
getLastDailyOutput(item) {
|
|
if (item == null || item.data == null) {
|
|
return null;
|
|
}
|
|
|
|
const itemData = item.data;
|
|
if (itemData.dailyOutput == null) {
|
|
return null;
|
|
}
|
|
|
|
return itemData.dailyOutput[itemData.dailyOutput.length - 1]
|
|
}
|
|
}
|