Removes edit buttons and multiple deletion from items and collection lists when user doesn't have permission. Removes edit, fields and filters tab from subheader when user doesn't have permission. Goes to correct links when user clicks in item on table that has link.
This commit is contained in:
parent
358ecfc89e
commit
9843d98b98
|
@ -4,7 +4,7 @@
|
|||
grouped
|
||||
group-multiline>
|
||||
<button
|
||||
v-if="selectedCollections.length > 0"
|
||||
v-if="selectedCollections.length > 0 && collections.length > 0 && collections[0].current_user_can_edit"
|
||||
class="button field is-danger"
|
||||
@click="deleteSelectedCollections()">
|
||||
<span>{{ $i18n.get('instruction_delete_selected_collections') }} </span>
|
||||
|
@ -86,6 +86,7 @@
|
|||
|
||||
<b-table-column
|
||||
tabindex="0"
|
||||
v-if="props.row.current_user_can_edit"
|
||||
:label="$i18n.get('label_actions')"
|
||||
width="78"
|
||||
:aria-label="$i18n.get('label_actions')">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
grouped
|
||||
group-multiline>
|
||||
<button
|
||||
v-if="selectedItems.length > 0"
|
||||
v-if="selectedItems.length > 0 && items.length > 0 && items[0].current_user_can_edit"
|
||||
class="button field is-danger"
|
||||
@click="deleteSelectedItems()">
|
||||
<span>{{ $i18n.get('instruction_delete_selected_items') }} </span><b-icon icon="delete"/>
|
||||
|
@ -24,6 +24,7 @@
|
|||
<template slot-scope="props">
|
||||
<b-table-column
|
||||
v-for="(column, index) in tableFields"
|
||||
v-if="column.field != 'row_actions' || (column.field == 'row_actions' && props.row.current_user_can_edit)"
|
||||
:key="index"
|
||||
:custom-key="column.slug"
|
||||
:label="column.name"
|
||||
|
@ -31,12 +32,17 @@
|
|||
:class="column.field == 'row_creation' ? 'row-creation' : ''"
|
||||
:width="column.field == 'row_actions' ? 78 : column.field == 'row_thumbnail' ? 55 : undefined ">
|
||||
|
||||
<template>
|
||||
<template v-if="column.field != 'row_thumbnail' && column.field != 'row_actions' && column.field != 'row_creation'">
|
||||
<span
|
||||
class="clickable-row"
|
||||
class="clickable-row"
|
||||
v-if="props.row.metadata[column.slug].value_as_html == props.row.metadata[column.slug].value_as_string"
|
||||
@click.prevent="goToItemPage(props.row.id)"
|
||||
v-if="column.field != 'row_thumbnail' && column.field != 'row_actions' && column.field != 'row_creation'"
|
||||
v-html="renderMetadata( props.row.metadata[column.slug] )" />
|
||||
v-html="renderMetadata( props.row.metadata[column.slug] )" />
|
||||
<span
|
||||
class="clickable-row"
|
||||
v-if="props.row.metadata[column.slug].value_as_html != props.row.metadata[column.slug].value_as_string"
|
||||
v-html="renderMetadata( props.row.metadata[column.slug] )" />
|
||||
|
||||
</template>
|
||||
|
||||
<template v-if="column.field == 'row_thumbnail'">
|
||||
|
|
|
@ -25,61 +25,74 @@
|
|||
</div>
|
||||
</div>
|
||||
<ul class="menu-list level-right">
|
||||
<li class="level-item"><router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionItemsPath(id, '') }"
|
||||
:class="activeRoute == 'ItemPage' || activeRoute == 'CollectionItemsPage' || activeRoute == 'ItemEditionForm' || activeRoute == 'ItemCreatePage' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_items')">
|
||||
<b-icon
|
||||
<li class="level-item">
|
||||
<router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionItemsPath(id, '') }"
|
||||
:class="activeRoute == 'ItemPage' || activeRoute == 'CollectionItemsPage' || activeRoute == 'ItemEditionForm' || activeRoute == 'ItemCreatePage' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_items')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="folder-outline"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.getFrom('collections', 'singular_name') }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="level-item">
|
||||
<router-link
|
||||
v-if="currentUserCanEdit"
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionEditPath(id) }"
|
||||
:class="activeRoute == 'CollectionEditionForm' ? 'is-active':''"
|
||||
:aria-label="$i18n.getFrom('collections','edit_item')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="pencil"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.get('edit') }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="level-item">
|
||||
<router-link
|
||||
v-if="currentUserCanEdit"
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionFieldsPath(id) }"
|
||||
:class="activeRoute == 'FieldsList' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_fields')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="folder-outline"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.getFrom('collections', 'singular_name') }}</span>
|
||||
</router-link></li>
|
||||
<li class="level-item"><router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionEditPath(id) }"
|
||||
:class="activeRoute == 'CollectionEditionForm' ? 'is-active':''"
|
||||
:aria-label="$i18n.getFrom('collections','edit_item')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="pencil"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.get('edit') }}</span>
|
||||
</router-link></li>
|
||||
<li class="level-item"><router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionFieldsPath(id) }"
|
||||
:class="activeRoute == 'FieldsList' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_fields')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="format-list-bulleted-type"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.getFrom('fields', 'name') }}</span>
|
||||
</router-link></li>
|
||||
<li class="level-item"><router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionFiltersPath(id) }"
|
||||
:class="activeRoute == 'FiltersList' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_filters')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="filter"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.getFrom('filters', 'name') }}</span>
|
||||
</router-link></li>
|
||||
<li class="level-item"><router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionEventsPath(id) }"
|
||||
:class="activeRoute == 'CollectionEventsPage' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_events')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="calendar-range"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.get('events') }}</span>
|
||||
</router-link></li>
|
||||
icon="format-list-bulleted-type"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.getFrom('fields', 'name') }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="level-item">
|
||||
<router-link
|
||||
v-if="currentUserCanEdit"
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionFiltersPath(id) }"
|
||||
:class="activeRoute == 'FiltersList' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_filters')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="filter"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.getFrom('filters', 'name') }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="level-item">
|
||||
<router-link
|
||||
tag="a"
|
||||
:to="{ path: $routerHelper.getCollectionEventsPath(id) }"
|
||||
:class="activeRoute == 'CollectionEventsPage' ? 'is-active':''"
|
||||
:aria-label="$i18n.get('label_collection_events')">
|
||||
<b-icon
|
||||
size="is-small"
|
||||
icon="calendar-range"/>
|
||||
<br>
|
||||
<span class="menu-text">{{ $i18n.get('events') }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -100,7 +113,8 @@ export default {
|
|||
}
|
||||
},
|
||||
props: {
|
||||
id: Number
|
||||
id: Number,
|
||||
currentUserCanEdit: false
|
||||
},
|
||||
watch: {
|
||||
'$route' (to) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<template>
|
||||
<div class="columns is-fullheight">
|
||||
<section class="column is-secondary-content">
|
||||
<tainacan-subheader :id="collectionId"/>
|
||||
<tainacan-subheader
|
||||
:current-user-can-edit="currentUserCanEdit"
|
||||
:id="collectionId"/>
|
||||
<router-view
|
||||
:collection-id="collectionId"
|
||||
class="page-container page-container-small"/>
|
||||
|
@ -11,20 +13,29 @@
|
|||
|
||||
<script>
|
||||
import TainacanSubheader from '../../components/navigation/tainacan-subheader.vue';
|
||||
import {mapActions} from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'CollectionPage',
|
||||
data(){
|
||||
return {
|
||||
collectionId: Number
|
||||
collectionId: Number,
|
||||
currentUserCanEdit: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
TainacanSubheader
|
||||
},
|
||||
methods: {
|
||||
...mapActions('collection', [
|
||||
'fetchCollection'
|
||||
]),
|
||||
},
|
||||
created(){
|
||||
this.collectionId = parseInt(this.$route.params.collectionId);
|
||||
this.$eventBusSearch.setCollectionId(this.collectionId);
|
||||
|
||||
this.fetchCollection(this.collectionId).then((collection) => this.currentUserCanEdit = collection.current_user_can_edit);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, collectionId) => {
|
|||
hasFiltered = true;
|
||||
|
||||
// Differentiates between repository level and collection level queries
|
||||
let endpoint = '/collection/'+collectionId+'/items?'
|
||||
let endpoint = '/collection/'+collectionId+'/items?context=edit&'
|
||||
|
||||
if (collectionId == undefined)
|
||||
endpoint = '/items?'
|
||||
endpoint = '/items?context=edit&'
|
||||
|
||||
axios.tainacan.get(endpoint + qs.stringify(postQueries) )
|
||||
.then(res => {
|
||||
|
@ -46,7 +46,7 @@ export const deleteItem = ({ commit }, item_id ) => {
|
|||
export const fetchCollections = ({commit} , { page, collectionsPerPage }) => {
|
||||
commit('cleanCollections');
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get('/collections?paged='+page+'&perpage='+collectionsPerPage)
|
||||
axios.tainacan.get('/collections?paged='+page+'&perpage='+collectionsPerPage+'&context=edit')
|
||||
.then(res => {
|
||||
let collections = res.data;
|
||||
commit('setCollections', collections);
|
||||
|
|
Loading…
Reference in New Issue