From 073f12f14ea441eff2fd9ac1eb48b08101f7ac00 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Sun, 14 Jun 2020 19:48:03 +0200 Subject: [PATCH] Fix edit link visibility, fixes #125 --- index.php | 2 +- js/src/mapviewmodel.js | 2 +- js/src/trackviewmodel.js | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index cbf0743..b2ebcc3 100644 --- a/index.php +++ b/index.php @@ -138,7 +138,7 @@ - + diff --git a/js/src/mapviewmodel.js b/js/src/mapviewmodel.js index a8e3e22..e178d34 100644 --- a/js/src/mapviewmodel.js +++ b/js/src/mapviewmodel.js @@ -193,7 +193,7 @@ export default class MapViewModel extends ViewModel { const pos = this.state.currentTrack.positions[id]; const count = this.state.currentTrack.length; const user = this.state.currentTrack.user; - const isEditable = auth.user && (auth.isAdmin || auth.user === user); + const isEditable = auth.user && (auth.isAdmin || auth.user.id === user.id); let date = '–––'; let time = '–––'; if (pos.timestamp > 0) { diff --git a/js/src/trackviewmodel.js b/js/src/trackviewmodel.js index 7318546..61b34ac 100644 --- a/js/src/trackviewmodel.js +++ b/js/src/trackviewmodel.js @@ -98,7 +98,10 @@ export default class TrackViewModel extends ViewModel { this.state.onChanged('currentUser', (user) => { if (user) { this.loadTrackList(); - TrackViewModel.setMenuVisible(this.editEl, true); + const isEditable = auth.user && (auth.isAdmin || auth.user.id === user.id); + if (isEditable) { + TrackViewModel.setMenuVisible(this.editEl, true); + } } else { this.model.currentTrackId = ''; this.model.trackList = [];