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