fix(webui): disable some UI elements for non-admins

This commit is contained in:
Gauthier Roebroeck 2021-07-02 16:30:26 +08:00
parent 2449ec4697
commit ada1438921
7 changed files with 24 additions and 18 deletions

View file

@ -103,7 +103,7 @@
v-else v-else
:items.sync="series" :items.sync="series"
:selected.sync="selectedSeries" :selected.sync="selectedSeries"
:edit-function="editSingleSeries" :edit-function="isAdmin ? editSingleSeries : undefined"
:draggable="editElements && collection.ordered" :draggable="editElements && collection.ordered"
:deletable="editElements" :deletable="editElements"
/> />

View file

@ -42,9 +42,9 @@
<item-browser <item-browser
:items="collections" :items="collections"
selectable :selectable="isAdmin"
:selected.sync="selectedCollections" :selected.sync="selectedCollections"
:edit-function="editSingleCollection" :edit-function="isAdmin ? editSingleCollection : undefined"
/> />
<v-pagination <v-pagination

View file

@ -89,7 +89,7 @@
<item-browser <item-browser
:items="series" :items="series"
:selected.sync="selectedSeries" :selected.sync="selectedSeries"
:edit-function="editSingleSeries" :edit-function="isAdmin ? editSingleSeries : undefined"
/> />
<v-pagination <v-pagination

View file

@ -42,9 +42,9 @@
<item-browser <item-browser
:items="readLists" :items="readLists"
selectable :selectable="isAdmin"
:selected.sync="selectedReadLists" :selected.sync="selectedReadLists"
:edit-function="editSingle" :edit-function="isAdmin ? editSingle : undefined"
/> />
<v-pagination <v-pagination

View file

@ -356,7 +356,7 @@
<item-browser :items="books" <item-browser :items="books"
:selected.sync="selectedBooks" :selected.sync="selectedBooks"
:edit-function="editSingleBook" :edit-function="isAdmin ? editSingleBook : undefined"
/> />
<v-pagination <v-pagination

View file

@ -55,7 +55,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="inProgressBooks" <item-browser :items="inProgressBooks"
nowrap nowrap
:edit-function="singleEditBook" :edit-function="isAdmin ? singleEditBook : undefined"
:selected.sync="selectedBooks" :selected.sync="selectedBooks"
:selectable="selectedSeries.length === 0" :selectable="selectedSeries.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -70,7 +70,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="onDeckBooks" <item-browser :items="onDeckBooks"
nowrap nowrap
:edit-function="singleEditBook" :edit-function="isAdmin ? singleEditBook : undefined"
:selected.sync="selectedBooks" :selected.sync="selectedBooks"
:selectable="selectedSeries.length === 0" :selectable="selectedSeries.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -85,7 +85,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="latestBooks" <item-browser :items="latestBooks"
nowrap nowrap
:edit-function="singleEditBook" :edit-function="isAdmin ? singleEditBook : undefined"
:selected.sync="selectedBooks" :selected.sync="selectedBooks"
:selectable="selectedSeries.length === 0" :selectable="selectedSeries.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -100,7 +100,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="newSeries" <item-browser :items="newSeries"
nowrap nowrap
:edit-function="singleEditSeries" :edit-function="isAdmin ? singleEditSeries : undefined"
:selected.sync="selectedSeries" :selected.sync="selectedSeries"
:selectable="selectedBooks.length === 0" :selectable="selectedBooks.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -115,7 +115,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="updatedSeries" <item-browser :items="updatedSeries"
nowrap nowrap
:edit-function="singleEditSeries" :edit-function="isAdmin ? singleEditSeries : undefined"
:selected.sync="selectedSeries" :selected.sync="selectedSeries"
:selectable="selectedBooks.length === 0" :selectable="selectedBooks.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -226,6 +226,9 @@ export default Vue.extend({
}, },
}, },
computed: { computed: {
isAdmin(): boolean {
return this.$store.getters.meAdmin
},
fixedCardWidth(): number { fixedCardWidth(): number {
return this.$vuetify.breakpoint.name === 'xs' ? 120 : 150 return this.$vuetify.breakpoint.name === 'xs' ? 120 : 150
}, },

View file

@ -59,7 +59,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="series" <item-browser :items="series"
nowrap nowrap
:edit-function="singleEditSeries" :edit-function="isAdmin ? singleEditSeries : undefined"
:selected.sync="selectedSeries" :selected.sync="selectedSeries"
:selectable="selectedBooks.length === 0 && selectedCollections.length === 0 && selectedReadLists.length === 0" :selectable="selectedBooks.length === 0 && selectedCollections.length === 0 && selectedReadLists.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -74,7 +74,7 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="books" <item-browser :items="books"
nowrap nowrap
:edit-function="singleEditBook" :edit-function="isAdmin ? singleEditBook : undefined"
:selected.sync="selectedBooks" :selected.sync="selectedBooks"
:selectable="selectedSeries.length === 0 && selectedCollections.length === 0 && selectedReadLists.length === 0" :selectable="selectedSeries.length === 0 && selectedCollections.length === 0 && selectedReadLists.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
@ -89,9 +89,9 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="collections" <item-browser :items="collections"
nowrap nowrap
:edit-function="singleEditCollection" :edit-function="isAdmin ? singleEditCollection : undefined"
:selected.sync="selectedCollections" :selected.sync="selectedCollections"
:selectable="selectedSeries.length === 0 && selectedBooks.length === 0 && selectedReadLists.length === 0" :selectable="isAdmin && selectedSeries.length === 0 && selectedBooks.length === 0 && selectedReadLists.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
/> />
</template> </template>
@ -104,9 +104,9 @@
<template v-slot:content> <template v-slot:content>
<item-browser :items="readLists" <item-browser :items="readLists"
nowrap nowrap
:edit-function="singleEditReadList" :edit-function="isAdmin ? singleEditReadList : undefined"
:selected.sync="selectedReadLists" :selected.sync="selectedReadLists"
:selectable="selectedSeries.length === 0 && selectedBooks.length === 0 && selectedCollections.length === 0" :selectable="isAdmin && selectedSeries.length === 0 && selectedBooks.length === 0 && selectedCollections.length === 0"
:fixed-item-width="fixedCardWidth" :fixed-item-width="fixedCardWidth"
/> />
</template> </template>
@ -219,6 +219,9 @@ export default Vue.extend({
}, },
}, },
computed: { computed: {
isAdmin(): boolean {
return this.$store.getters.meAdmin
},
fixedCardWidth (): number { fixedCardWidth (): number {
return this.$vuetify.breakpoint.name === 'xs' ? 120 : 150 return this.$vuetify.breakpoint.name === 'xs' ? 120 : 150
}, },