43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { Component, OnInit, Injectable } from '@angular/core';
|
|
import { Input } from '@angular/core';
|
|
import { Store } from '@ngrx/store';
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
|
import { commonReducers, ItemTypeService, ItemService, IListItem } from '@farmmaps/common';
|
|
import { AbstractItemListItemComponent } from '../item-list-item/item-list-item.component'
|
|
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
|
import { ForSourceTask } from '../for-item/for-sourcetask.decorator';
|
|
|
|
@ForItemType("vnd.farmmaps.itemtype.shape.processed")
|
|
@ForSourceTask("vnd.farmmaps.task.bofek")
|
|
@Injectable()
|
|
@Component({
|
|
selector: 'item-list-item-bofek',
|
|
templateUrl: './item-list-item-bofek.component.html',
|
|
styleUrls: ['./item-list-item-bofek.component.css']
|
|
})
|
|
export class ItemListItemBofekComponent extends AbstractItemListItemComponent implements OnInit {
|
|
@Input() item: IListItem;
|
|
feature;
|
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, private itemService$: ItemService) {
|
|
super(store, itemTypeService);
|
|
}
|
|
ngOnInit() {
|
|
this.itemService$.getItem(this.item.code).subscribe(i => {
|
|
this.itemService$.getChildItemList(i.parentCode, "vnd.farmmaps.itemtype.trijntje").subscribe(t => {
|
|
if (t.length > 0) {
|
|
var data = t[0].data;
|
|
var bofekId = data["wwl-yieldloss-data"]["feature-with-largest-area"];
|
|
var features = data["wwl-yieldloss-data"]["features"];
|
|
for (var i = 0; i < features.length; i++) {
|
|
if (features[i]["bodem"] == bofekId) {
|
|
this.feature = features[i];
|
|
return;
|
|
}
|
|
}
|
|
};
|
|
})
|
|
})
|
|
};
|
|
}
|