Implement next and preious temporal

feature/MinimizeSolution
Willem Dantuma 2020-03-02 09:22:16 +01:00
parent be885ce917
commit 60c741d935
2 changed files with 59 additions and 0 deletions

View File

@ -18,6 +18,9 @@ export const SELECTFEATURE = '[Map] SelectFeature';
export const SELECTITEM = '[Map] SelectItem';
export const SELECTITEMSUCCESS = '[Map] SelectItemSuccess';
export const SELECTTEMPORALITEMSSUCCESS = '[Map] SelectTemporalItemsSuccess';
export const NEXTTEMPORAL = '[Map] NextTemporal';
export const PREVIOUSTEMPORAL = '[Map] PreviousTemporal';
export const SELECTTEMPORAL = '[Map] SelectTemporal';
export const ADDFEATURESUCCESS = '[Map] AddFeatureSuccess';
export const UPDATEFEATURESUCCESS = '[Map] UpdateFeatureSuccess';
export const EXPANDSEARCH = '[Map] ExpandSearch';
@ -105,6 +108,24 @@ export class SelectTemporalItemsSuccess implements Action {
constructor(public temporalItems: IItem[]) { }
}
export class NextTemporal implements Action {
readonly type = NEXTTEMPORAL;
constructor() { }
}
export class PreviousTemporal implements Action {
readonly type = PREVIOUSTEMPORAL;
constructor() { }
}
export class SelectTemporal implements Action {
readonly type = SELECTTEMPORAL;
constructor(item:IItem) { }
}
export class AddFeatureSuccess implements Action {
readonly type = ADDFEATURESUCCESS;
@ -233,6 +254,9 @@ export type Actions = SetMapState
| SelectItem
| SelectItemSuccess
| SelectTemporalItemsSuccess
| NextTemporal
| PreviousTemporal
| SelectTemporal
| AddFeatureSuccess
| UpdateFeatureSuccess
| ExpandSearch

View File

@ -186,6 +186,41 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
selectedItemLayer.nextItemLayer = null;
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)});
}
case mapActions.NEXTTEMPORAL: {
let temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
if(index == (temporalLayer.temporalItems.length-1)) {
return state;
} else {
temporalLayer.previousItemLayer = temporalLayer.selectedItemLayer;
temporalLayer.selectedItemLayer = temporalLayer.nextItemLayer;
temporalLayer.nextItemLayer = index+1 < temporalLayer.temporalItems.length? new ItemLayer(temporalLayer.temporalItems[index+1]):null;
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,temporalLayer as ItemLayer)});
}
} else {
return state;
}
}
case mapActions.PREVIOUSTEMPORAL: {
let temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
if(index == 0) {
return state;
} else {
temporalLayer.nextItemLayer = temporalLayer.selectedItemLayer;
temporalLayer.selectedItemLayer = temporalLayer.previousItemLayer;
temporalLayer.previousItemLayer = index-1 >=0? new ItemLayer(temporalLayer.temporalItems[index-1]):null;
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,temporalLayer as ItemLayer)});
}
} else {
return state;
}
}
case mapActions.SELECTTEMPORAL:{
//todo implement
}
case mapActions.STARTSEARCH: {
let a = action as mapActions.StartSearch;
return tassign(state, {