Hide edit controls from ready-only users

This commit is contained in:
D. Berge
2021-05-16 19:55:31 +02:00
parent 0d9f7ac4ec
commit 418f1a00b8
4 changed files with 220 additions and 183 deletions

View File

@@ -16,7 +16,7 @@
</v-card-title>
<v-card-text>
<v-menu
<v-menu v-if="writeaccess"
v-model="contextMenuShow"
:position-x="contextMenuX"
:position-y="contextMenuY"
@@ -139,8 +139,9 @@
@click:append-outer="edit = null"
>
</v-text-field>
<div v-else v-html="$options.filters.markdownInline(item.remarks)">
<v-btn v-if="edit === null"
<div v-else>
<span v-html="$options.filters.markdownInline(item.remarks)"></span>
<v-btn v-if="writeaccess && edit === null"
icon
small
title="Edit"
@@ -246,7 +247,7 @@ export default {
},
computed: {
...mapGetters(['user', 'loading', 'serverEvent'])
...mapGetters(['user', 'writeaccess', 'loading', 'serverEvent'])
},
watch: {

View File

@@ -33,7 +33,7 @@
</span>
</v-toolbar-title>
<dougal-event-edit-dialog
<dougal-event-edit-dialog v-if="writeaccess"
v-model="eventDialog"
:allowed-labels="userLabels"
:preset-remarks="presetRemarks"
@@ -108,6 +108,7 @@
</template>
<template v-slot:item.remarks="{item}">
<template v-if="writeaccess">
<v-edit-dialog v-if="item.items"
large
@save="rowEditorSave"
@@ -243,6 +244,10 @@
></v-text-field>
</template>
</v-edit-dialog>
</template>
<template v-else>
<div v-html="$options.filters.markdownInline(item.items.map(i => i.remarks).join('<br/>'))"></div>
</template>
</template>
@@ -400,7 +405,7 @@ export default {
}
},
...mapGetters(['user', 'loading', 'online', 'sequence', 'line', 'point', 'lineName', 'serverEvent']),
...mapGetters(['user', 'writeaccess', 'loading', 'online', 'sequence', 'line', 'point', 'lineName', 'serverEvent']),
...mapState({projectSchema: state => state.project.projectSchema})
},
@@ -527,14 +532,19 @@ export default {
},
async saveEvent (event) {
function callback (err, res) {
if (!err && res.ok) {
this.showSnack(["New event saved", "success"]);
this.queuedReload = true;
this.getEvents({cache: "reload"});
}
}
const url = `/project/${this.$route.params.project}/event`;
await this.api([url, {
method: "POST",
body: event
}]);
this.showSnack(["New event saved", "success"]);
this.queuedReload = true;
this.getEvents({cache: "reload"});
}, callback]);
},
rowEditorOpen (row) {

View File

@@ -83,13 +83,13 @@
small
:color="labels[label] && labels[label].view.colour"
:title="labels[label] && labels[label].view.description"
:close="label == 'QCAccepted'"
:close="writeaccess && label == 'QCAccepted'"
@click:close="unaccept(item)">
{{label}}
</v-chip>
<template v-if="!item.labels || !item.labels.includes('QCAccepted')">
<v-hover v-slot:default="{hover}">
<v-hover v-slot:default="{hover}" v-if="writeaccess">
<span v-if="item.children && item.children.length">
<v-btn
:class="{'text--disabled': !hover}"
@@ -226,7 +226,7 @@ export default {
return values;
},
...mapGetters(['loading'])
...mapGetters(['writeaccess', 'loading'])
},
watch: {

View File

@@ -28,10 +28,10 @@
offset-y
>
<v-list dense v-if="contextMenuItem">
<v-list-item @click="addToPlan(false); contextMenuShow=false">
<v-list-item @click="addToPlan(false); contextMenuShow=false" v-if="writeaccess">
<v-list-item-title>Reshoot</v-list-item-title>
</v-list-item>
<v-list-item @click="addToPlan(true); contextMenuShow=false">
<v-list-item @click="addToPlan(true); contextMenuShow=false" v-if="writeaccess">
<v-list-item-title>Reshoot with overlap</v-list-item-title>
</v-list-item>
<v-list-group>
@@ -102,8 +102,19 @@
<v-card outlined class="flex-grow-1">
<v-card-title>
Acquisition remarks
<v-btn v-if="edit && edit.sequence == item.sequence && edit.key == 'remarks'"
<template v-if="writeaccess">
<template v-if="edit && edit.sequence == item.sequence && edit.key == 'remarks'">
<v-btn
class="ml-3"
icon
small
title="Cancel edit"
:disabled="loading"
@click="edit.value = item.remarks; edit = null"
>
<v-icon small>mdi-close</v-icon>
</v-btn>
<v-btn v-if="edit.value != item.remarks"
icon
small
title="Save edits"
@@ -112,6 +123,7 @@
>
<v-icon small>mdi-content-save-edit-outline</v-icon>
</v-btn>
</template>
<v-btn v-else-if="edit === null"
class="ml-3"
icon
@@ -122,6 +134,7 @@
>
<v-icon small>mdi-square-edit-outline</v-icon>
</v-btn>
</template>
</v-card-title>
<v-card-subtitle>
</v-card-subtitle>
@@ -141,8 +154,19 @@
<v-card outlined class="flex-grow-1" v-if="item.remarks_final !== null">
<v-card-title>
Processing remarks
<v-btn v-if="edit && edit.sequence == item.sequence && edit.key == 'remarks_final'"
<template v-if="writeaccess">
<template v-if="edit && edit.sequence == item.sequence && edit.key == 'remarks_final'">
<v-btn
class="ml-3"
icon
small
title="Cancel edit"
:disabled="loading"
@click="edit.value = item.remarks_final; edit = null"
>
<v-icon small>mdi-close</v-icon>
</v-btn>
<v-btn v-if="edit.value != item.remarks_final"
icon
small
title="Save edits"
@@ -151,6 +175,7 @@
>
<v-icon small>mdi-content-save-edit-outline</v-icon>
</v-btn>
</template>
<v-btn v-else-if="edit === null"
class="ml-3"
icon
@@ -161,6 +186,7 @@
>
<v-icon small>mdi-square-edit-outline</v-icon>
</v-btn>
</template>
</v-card-title>
<v-card-subtitle>
</v-card-subtitle>
@@ -455,7 +481,7 @@ export default {
},
computed: {
...mapGetters(['user', 'loading', 'serverEvent'])
...mapGetters(['user', 'writeaccess', 'loading', 'serverEvent'])
},
watch: {