Refactor edit_in_editor
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-04-16 17:05:07 +02:00
parent 0b32153489
commit e30d95ff09
2 changed files with 23 additions and 18 deletions

View File

@ -132,7 +132,27 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
this.selectedFeatures$.next(null); this.selectedFeatures$.next(null);
this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{ this.query$.pipe(withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{
if(setStateCount>0) { if(setStateCount>0) {
this.replaceUrl(mapState,queryState,false); let newQueryState = tassign(mapReducers.initialQueryState);
let urlparts=[];
if (queryState.itemCode && queryState.itemCode != "") {
if(queryState.itemType && queryState.itemType!= "") {
let itemType = this.itemTypeService.itemTypes[queryState.itemType];
if (itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) {
urlparts.push('/editor');
urlparts.push(itemType.editor);
urlparts.push('item');
urlparts.push(queryState.itemCode);
}
}
} else {
newQueryState= queryState;
}
if(urlparts.length==0 ) {
newQueryState.itemCode = queryState.itemCode;
this.replaceUrl(mapState,newQueryState,false);
} else {
this.router.navigate(urlparts);
}
} }
}); });
this.mapState$.pipe(withLatestFrom(this.queryState$),withLatestFrom(this.setStateCount$)).subscribe(([[mapState,queryState],setStateCount]) =>{ this.mapState$.pipe(withLatestFrom(this.queryState$),withLatestFrom(this.setStateCount$)).subscribe(([[mapState,queryState],setStateCount]) =>{

View File

@ -257,22 +257,7 @@ export class MapEffects {
switchMap((action: mapActions.SetQueryState) => { switchMap((action: mapActions.SetQueryState) => {
var newAction:Action; var newAction:Action;
if (action.queryState.itemCode && action.queryState.itemCode != "") { if (action.queryState.itemCode && action.queryState.itemCode != "") {
let urlparts=[]; newAction= new mapActions.SelectItem(action.queryState.itemCode);
if(action.queryState.itemType && action.queryState.itemType!= "") {
let itemType = this.itemTypeService$.itemTypes[action.queryState.itemType];
if (itemType.viewer == "edit_in_editor" && itemType.editor) {
urlparts.push('/editor');
urlparts.push(itemType.editor);
urlparts.push('item');
urlparts.push(action.queryState.itemCode);
}
}
if(urlparts.length==0 ) {
newAction= new mapActions.SelectItem(action.queryState.itemCode);
} else {
this.router$.navigate(urlparts);
return [];
}
} else { } else {
newAction= new mapActions.StartSearch(action.queryState); newAction= new mapActions.StartSearch(action.queryState);
} }