remove edit elements if user is not owner
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<button @click="showExportDialog = true" class="export-button-small" :title="$t('export.title')">
|
||||
📄
|
||||
</button>
|
||||
<button @click="showVisibilityDialog = true" class="export-button-small" :title="$t('visibility.title')">
|
||||
<button v-if="isOwner" @click="showVisibilityDialog = true" class="export-button-small" :title="$t('visibility.title')">
|
||||
{{ character.public ? '🌐' : '🔒' }}
|
||||
</button>
|
||||
<h2>{{ $t('char') }}: {{ character.name }} ({{ $t(currentView) }})</h2>
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
<!-- Submenu Content -->
|
||||
<!-- <div class="character-aspect"> -->
|
||||
<component :is="currentView" :character="character" @character-updated="refreshCharacter"/>
|
||||
<component :is="currentView" :character="character" :isOwner="isOwner" @character-updated="refreshCharacter"/>
|
||||
<!-- </div> -->
|
||||
|
||||
<!-- Submenu -->
|
||||
@@ -64,6 +64,7 @@
|
||||
|
||||
<script>
|
||||
import API from '../utils/api'
|
||||
import { useUserStore } from '../stores/userStore'
|
||||
import ExportDialog from "./ExportDialog.vue";
|
||||
import VisibilityDialog from "./VisibilityDialog.vue";
|
||||
import DatasheetView from "./DatasheetView.vue"; // Component for character stats
|
||||
@@ -111,6 +112,12 @@ export default {
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isOwner() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.currentUser && this.character.user_id === userStore.currentUser.id
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
const token = localStorage.getItem('token')
|
||||
const response = await API.get(`/api/characters/${this.id}`, {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<template>
|
||||
<div class="cd-view">
|
||||
<p>Are you sure you want to delete {{ character.name }}?</p>
|
||||
<button @click="deleteCharacter" class="btn btn-danger">Yes, Delete</button>
|
||||
<button @click="$emit('cancel')" class="btn btn-secondary">Cancel</button>
|
||||
<div v-if="!isOwner" class="error-message">
|
||||
<p>{{ $t('deleteChar.notAuthorized') }}</p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p>Are you sure you want to delete {{ character.name }}?</p>
|
||||
<button @click="deleteCharacter" class="btn btn-danger">Yes, Delete</button>
|
||||
<button @click="$emit('cancel')" class="btn btn-secondary">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -16,6 +21,10 @@ export default {
|
||||
character: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isOwner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="fullwidth-container">
|
||||
<div class="header-section">
|
||||
<h2>{{ $t('EquipmentView') }}</h2>
|
||||
<button @click="openAddEquipmentDialog" class="btn-add-equipment">
|
||||
<button v-if="isOwner" @click="openAddEquipmentDialog" class="btn-add-equipment">
|
||||
{{ $t('equipment.add') }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -18,7 +18,7 @@
|
||||
<th>{{ $t('equipment.amount') }}</th>
|
||||
<th>{{ $t('equipment.contained_in') }}</th>
|
||||
<th>{{ $t('equipment.bonus') }}</th>
|
||||
<th>{{ $t('equipment.actions') }}</th>
|
||||
<th v-if="isOwner">{{ $t('equipment.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -31,7 +31,7 @@
|
||||
<td>{{ equipment.anzahl || '-' }}</td>
|
||||
<td>{{ equipment.beinhaltet_in || '-' }}</td>
|
||||
<td>{{ equipment.bonus || '-' }}</td>
|
||||
<td class="action-cell">
|
||||
<td v-if="isOwner" class="action-cell">
|
||||
<button @click="deleteEquipment(equipment)" class="btn-delete" title="Löschen">
|
||||
🗑️
|
||||
</button>
|
||||
@@ -126,6 +126,24 @@
|
||||
.cd-table th {
|
||||
background-color: #1da766;
|
||||
}
|
||||
|
||||
/* Fix modal footer visibility */
|
||||
.modal-fullscreen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: calc(100vh - 50px);
|
||||
}
|
||||
|
||||
.modal-fullscreen .modal-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.modal-fullscreen .modal-header,
|
||||
.modal-fullscreen .modal-footer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
@@ -137,6 +155,10 @@ name: "EquipmentView",
|
||||
character: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isOwner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="resource-amount">{{ character.erfahrungsschatz?.ep || 0 }} EP</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row control-row">
|
||||
<div v-if="isOwner" class="form-row control-row">
|
||||
<div class="form-group">
|
||||
<input
|
||||
v-model.number="experienceAmount"
|
||||
@@ -51,7 +51,7 @@
|
||||
<div class="resource-amount">{{ character.vermoegen?.goldstücke || 0 }} GS</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row control-row">
|
||||
<div v-if="isOwner" class="form-row control-row">
|
||||
<div class="form-group">
|
||||
<input
|
||||
v-model.number="goldAmount"
|
||||
@@ -147,6 +147,10 @@ export default {
|
||||
character: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isOwner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="table-wrapper-left">
|
||||
<div class="header-section">
|
||||
<!-- Lernmodus Toggle Button -->
|
||||
<div class="learning-mode-controls">
|
||||
<div v-if="isOwner" class="learning-mode-controls">
|
||||
<!-- Ressourcen-Anzeige (nur sichtbar wenn Lernmodus aktiv) -->
|
||||
<div v-if="learningMode" class="resources-display">
|
||||
<div class="resource-item">
|
||||
@@ -68,7 +68,7 @@
|
||||
<td>{{ skill.fertigkeitswert || '-' }}</td>
|
||||
<td>{{ skill.bonus || '0' }}</td>
|
||||
<td class="pp-cell">
|
||||
<div class="pp-container">
|
||||
<div v-if="isOwner" class="pp-container">
|
||||
<button
|
||||
@click="decreasePP(skill)"
|
||||
class="pp-btn pp-btn-minus"
|
||||
@@ -86,6 +86,7 @@
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
<span v-else>{{ skill.pp || '0' }}</span>
|
||||
</td>
|
||||
<td>{{ skill.bemerkung || '-' }}</td>
|
||||
<td v-if="learningMode" class="action-cell">
|
||||
@@ -109,7 +110,7 @@
|
||||
<td>{{ skill.fertigkeitswert || '-' }}</td>
|
||||
<td>{{ skill.bonus || '0' }}</td>
|
||||
<td class="pp-cell">
|
||||
<div class="pp-container">
|
||||
<div v-if="isOwner" class="pp-container">
|
||||
<button
|
||||
@click="decreaseWeaponPP(skill)"
|
||||
class="pp-btn pp-btn-minus"
|
||||
@@ -127,6 +128,7 @@
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
<span v-else>{{ skill.pp || '0' }}</span>
|
||||
</td>
|
||||
<td>{{ skill.bemerkung || '-' }}</td>
|
||||
<td v-if="learningMode" class="action-cell">
|
||||
@@ -290,6 +292,10 @@ export default {
|
||||
character: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isOwner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="fullwidth-container">
|
||||
<!-- Header mit Lernmodus-Kontrollen -->
|
||||
<div class="page-header header-section">
|
||||
<div v-if="isOwner" class="page-header header-section">
|
||||
<div class="learning-mode-controls">
|
||||
<!-- Lernmodus Toggle Button -->
|
||||
<button
|
||||
@@ -99,6 +99,10 @@ export default {
|
||||
character: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isOwner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="cd-view">
|
||||
<div class="header-section">
|
||||
<h2>{{ $t('WeaponView') }}</h2>
|
||||
<button @click="openAddWeaponDialog" class="btn-add-weapon">
|
||||
<button v-if="isOwner" @click="openAddWeaponDialog" class="btn-add-weapon">
|
||||
{{ $t('weapon.add') }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -18,7 +18,7 @@
|
||||
<th>{{ $t('weapon.amount') }}</th>
|
||||
<th>{{ $t('weapon.contained_in') }}</th>
|
||||
<th>{{ $t('weapon.bonus') }}</th>
|
||||
<th>{{ $t('weapon.actions') }}</th>
|
||||
<th v-if="isOwner">{{ $t('weapon.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -31,7 +31,7 @@
|
||||
<td>{{ weapon.anzahl || '-' }}</td>
|
||||
<td>{{ weapon.beinhaltet_in || '-' }}</td>
|
||||
<td>{{ weapon.anb || '-' }}/{{ weapon.abwb || '-' }}</td>
|
||||
<td class="action-cell">
|
||||
<td v-if="isOwner" class="action-cell">
|
||||
<button @click="editWeapon(weapon)" class="btn-edit" title="Bearbeiten">
|
||||
✏️
|
||||
</button>
|
||||
@@ -378,6 +378,10 @@ name: "WeaponView",
|
||||
character: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isOwner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -86,6 +86,9 @@ export default {
|
||||
Characters:'Charaktere',
|
||||
Admin:'Administration',
|
||||
},
|
||||
deleteChar: {
|
||||
notAuthorized: 'Sie sind nicht berechtigt, diesen Charakter zu löschen. Nur der Besitzer kann diese Aktion durchführen.'
|
||||
},
|
||||
landing:{
|
||||
title:'BaMoRT - Charakterverwaltung für mein Lieblingsrollenspielsystem',
|
||||
description:'BaMoRT ist ein Werkzeug zur Charakterverwaltung für Rollenspiele. Es bietet Funktionen zur Charaktererstellung, -entwicklung und -verwaltung mit Unterstützung für Fertigkeiten, Zauber, Ausrüstung und mehr. Viele Ausrüstungsteile, Fertikeiten und Zauber fehlen noch, da das Projekt noch in der Entwicklung ist.',
|
||||
|
||||
@@ -85,6 +85,9 @@ export default {
|
||||
Characters:'Characters',
|
||||
Admin:'Administration',
|
||||
},
|
||||
deleteChar: {
|
||||
notAuthorized: 'You are not authorized to delete this character. Only the owner can perform this action.'
|
||||
},
|
||||
landing:{
|
||||
title:'BaMoRT - Character Management for Role-Playing Games',
|
||||
description:'BaMoRT is a modern character management tool for role-playing games. It provides comprehensive features for character creation, development, and management with support for skills, spells, equipment, and more.',
|
||||
|
||||
Reference in New Issue
Block a user