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); + })); } }