Implement ItemDeleteEvent handling
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2021-07-29 08:21:25 +02:00
parent 1b000c6112
commit 52e3117771

View File

@ -507,6 +507,30 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
v.push(a.layervalue);
return tassign(state,{layerValues:v});
}
case commonActions.ITEMDELETEDEVENT:{
let a= action as commonActions.ItemDeletedEvent;
if(state.selectedItem && state.selectedItem.code == a.itemCode) {
return tassign(state,{
selectedItem: null,
selectedItemLayer: null,
features:[]
});
}
if(state.features.length>0) {
var index = -1;
for (var i = 0; i < state.features.length; i++) {
if (state.features[i].getId() == a.itemCode ) {
index=i;
}
}
if(index>=0) {
let newFeatures = state.features.slice(0);
newFeatures.splice(index,1);
return tassign(state,{features:newFeatures});
}
}
return state;
}
default: {
return state;
}