Fix edit link visibility, fixes #125

This commit is contained in:
Bartek Fabiszewski 2020-06-14 19:48:03 +02:00
parent 8aaf4b527d
commit 073f12f14e
3 changed files with 6 additions and 3 deletions

View File

@ -138,7 +138,7 @@
<a id="adduser" class="menu-link" data-bind="onUserAdd"><?= $lang['adduser'] ?></a>
<a id="edituser" class="menu-link" data-bind="onUserEdit"><?= $lang['edituser'] ?></a>
<?php endif; ?>
<a id="edittrack" class="menu-link" data-bind="onTrackEdit"><?= $lang['edittrack'] ?></a>
<a id="edittrack" class="menu-link menu-hidden" data-bind="onTrackEdit"><?= $lang['edittrack'] ?></a>
</div>
<?php endif; ?>

View File

@ -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) {

View File

@ -98,7 +98,10 @@ export default class TrackViewModel extends ViewModel {
this.state.onChanged('currentUser', (user) => {
if (user) {
this.loadTrackList();
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 = [];