AW-1330
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit Details

2022.01
Willem Dantuma 2020-06-23 15:39:30 +02:00
parent 925af1e645
commit 28d4adc571
1 changed files with 22 additions and 2 deletions

View File

@ -7,9 +7,10 @@ import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderServic
import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router';
import { ForItemType } from '../for-item/for-itemtype.decorator';
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
import { Observable } from 'rxjs';
import { Observable,of } from 'rxjs';
import {GeoJSON} from 'ol/format';
import {getArea} from 'ol/sphere';
import { withLatestFrom,switchMap,combineLatest } from 'rxjs/operators';
@ForItemType("vnd.farmmaps.itemtype.cropfield")
@ -38,6 +39,25 @@ export class SelectedItemCropfieldComponent extends AbstractSelectedItemComponen
}
ngOnInit() {
this. items = this.folderService$.getItems(this.item.code, 0, 1000);
var childItems = this.folderService$.getItems(this.item.code, 0, 1000);
var atLocationItems = this.itemService$.getItemList(null,null,null,this.item.code,true);
this.items = childItems.pipe(
combineLatest(atLocationItems),
switchMap(([ci,ali]) => {
let retVal:IListItem[] = [];
let codes = {};
ci.forEach((listItem) => {
retVal.push(listItem);
codes[listItem.code]=listItem;
});
ali.forEach((atlocationitem) => {
let listItem = atlocationitem as IListItem;
let allowedItemTypes = "vnd.farmmaps.itemtype.device.senml"; // this is a hack
if(!codes[listItem.code] && allowedItemTypes.indexOf(listItem.itemType) >= 0) {
retVal.push(listItem);
}
});
return of(retVal);
}));
}
}