From 28d4adc571ac2f8a2c0ce9ad43b8a961c94437ee Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Tue, 23 Jun 2020 15:39:30 +0200 Subject: [PATCH] AW-1330 --- .../selected-item-cropfield.component.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts b/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts index 5617547..c6da727 100644 --- a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts +++ b/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts @@ -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); + })); } }