Skip to content

Commit

Permalink
Fix issue with menu context while deleting georeference
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Aug 20, 2020
1 parent 307be8e commit 952b0a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/app/components/menu-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ipcRenderer = typeof window !== 'undefined' ? window.require('electron').i
const remote = typeof window !== 'undefined' ? window.require('electron').remote : require('electron').remote;


type MenuContext = 'default'|'docedit'|'modal'|'projects'|'geometryEdit';
type MenuContext = 'default'|'docedit'|'modal'|'projects'|'geometryEdit'|'georeferenceEdit';


export module MenuContext {
Expand All @@ -15,6 +15,7 @@ export module MenuContext {
export const MODAL = 'modal';
export const PROJECTS = 'projects';
export const GEOMETRY_EDIT = 'geometryEdit';
export const GEOREFERENCE_EDIT = 'georeferenceEdit';
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {M} from '../../messages/m';
import {readWldFile, Errors} from '../../../core/images/wld/wld-import';
import {downloadWldFile} from '../../../core/images/wld/wld-export';
import {Messages} from '../../messages/messages';
import {MenuContext, MenuService} from '../../menu-service';


@Component({
Expand All @@ -23,16 +24,16 @@ export class GeoreferenceViewComponent {

@Output() onSectionToggled: EventEmitter<string|undefined> = new EventEmitter<string|undefined>();

@ViewChild('worldfileInput', {static: false}) worldfileInput: ElementRef;
@ViewChild('worldfileInput', { static: false }) worldfileInput: ElementRef;

public shown: boolean = false;

constructor(
private persistenceManager: PersistenceManager,
private messages: Messages,
private modalService: NgbModal,
private usernameProvider: UsernameProvider
) {}

constructor(private persistenceManager: PersistenceManager,
private messages: Messages,
private modalService: NgbModal,
private usernameProvider: UsernameProvider,
private menuService: MenuService) {}


public exportWldFile = () => downloadWldFile(this.document);
Expand Down Expand Up @@ -76,8 +77,16 @@ export class GeoreferenceViewComponent {

public async openDeleteModal(modal: any) {

const result = await this.modalService.open(modal).result;
if (result == 'delete') await this.deleteGeoreference();
this.menuService.setContext(MenuContext.GEOREFERENCE_EDIT);

try {
const result = await this.modalService.open(modal).result;
if (result == 'delete') await this.deleteGeoreference();
} catch (err) {
// Modal has been canceled
} finally {
this.menuService.setContext(MenuContext.MODAL);
}
}


Expand Down

0 comments on commit 952b0a8

Please sign in to comment.