Blocks loading collection and taxonomy edition form if user has no permission. #274.

This commit is contained in:
Mateus Machado Luna 2019-12-05 15:08:33 -03:00
parent 79f52ec24e
commit dbb3f951a2
7 changed files with 35 additions and 12 deletions

View File

@ -5,7 +5,7 @@
<tainacan-title
:bread-crumb-items="[{ path: '', label: $i18n.get('collection') }]"/>
<form
v-if="collection != null && collection != undefined"
v-if="collection != null && collection != undefined && ((isNewCollection && $userCaps.hasCapability('tnc_rep_edit_collections')) || (!isNewCollection && collection.current_user_can_edit))"
class="tainacan-form"
label-width="120px">
@ -456,14 +456,14 @@
style="margin-left: auto;"
class="control">
<button
v-if="isNewCollection"
v-if="isNewCollection && $userCaps.hasCapability('tnc_rep_edit_metadata')"
id="button-submit-goto-metadata"
@click.prevent="onSubmit('metadata')"
class="button is-secondary">{{ $i18n.get('label_save_goto_metadata') }}</button>
</div>
<div class="control">
<button
v-if="isNewCollection"
v-if="isNewCollection && $userCaps.hasCapability('tnc_rep_edit_metadata')"
id="button-submit-goto-filter"
@click.prevent="onSubmit('filters')"
class="button is-secondary">{{ $i18n.get('label_save_goto_filter') }}</button>
@ -478,6 +478,17 @@
<p class="help is-danger">{{ formErrorMessage }}</p>
</form>
<div v-if="!isLoading && ((isNewCollection && !$userCaps.hasCapability('tnc_rep_edit_collections')) || (!isNewCollection && collection && collection.current_user_can_edit != undefined && collection.current_user_can_edit == false))">
<section class="section">
<div class="content has-text-grey has-text-centered">
<span class="icon">
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-collection"/>
</span>
<p>{{ $i18n.get('info_can_not_edit_collection') }}</p>
</div>
</section>
</div>
<b-loading
:active.sync="isLoading"
:can-cancel="false"/>

View File

@ -9,10 +9,9 @@
<b-tabs
@change="onChangeTab($event)"
v-model="tabIndex">
<b-tab-item
v-if="taxonomy != null && taxonomy != undefined && taxonomy.current_user_can_edit"
:label="$i18n.get('taxonomy')">
<b-tab-item :label="$i18n.get('taxonomy')">
<form
v-if="taxonomy != null && taxonomy != undefined && (($route.name == 'TaxonomyCreationForm' && $userCaps.hasCapability('tnc_rep_edit_taxonomies')) || ($route.name == 'TaxonomyEditionForm' && taxonomy.current_user_can_edit))"
class="tainacan-form"
label-width="120px">
<div class="columns">
@ -194,6 +193,18 @@
</div>
<p class="help is-danger">{{ formErrorMessage }}</p>
</form>
<div v-if="!isLoading && (($route.name == 'TaxonomyCreationForm' && !$userCaps.hasCapability('tnc_rep_edit_taxonomies')) || ($route.name == 'TaxonomyCreationForm' && taxonomy.current_user_can_edit != undefined && !taxonomy.current_user_can_edit))">
<section class="section">
<div class="content has-text-grey has-text-centered">
<span class="icon">
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-taxonomies"/>
</span>
<p>{{ $i18n.get('info_can_not_edit_taxonomies') }}</p>
</div>
</section>
</div>
</b-tab-item>
<b-tab-item :label="$i18n.get('terms')">

View File

@ -48,7 +48,7 @@
</router-link>
</li>
<li class="separator"/>
<li>
<li v-if="$userCaps.hasCapability('tnc_rep_edit_metadata')">
<router-link
tag="a"
to="/metadata"
@ -67,7 +67,7 @@
<span class="menu-text">{{ $i18n.get('metadata') }}</span>
</router-link>
</li>
<li>
<li v-if="$userCaps.hasCapability('tnc_rep_edit_filters')">
<router-link
tag="a"
to="/filters"

View File

@ -149,7 +149,7 @@
</router-link>
</li>
<li
v-if="$userPrefs('tnc_rep_read_logs')"
v-if="$userCaps.hasCapability('tnc_rep_read_logs')"
:class="activeRoute == 'CollectionActivitiesPage' ? 'is-active':''"
class="level-item"
v-tooltip="{

View File

@ -381,7 +381,7 @@
@keyframes appear-from-right {
from {
right: -100%;
opacity: 0;
opacity: 0.5;
}
to {
right: 0;
@ -397,7 +397,6 @@
.notice {
position: relative;
float: right;
animation: appear-from-right 0.8s ease-in;
}
#role-name-input {
min-width: 200px;

View File

@ -686,6 +686,8 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_final_value' => __( 'Final value', 'tainacan' ),
'info_show_interval_on_tag' => __( 'Show applied interval on tags', 'tainacan' ),
'info_title_mapping' => __( 'The title is the most relevant metadata, that shall identify your item on lists for different view modes. Select the title source metadata first, or skip to run importer as it is.', 'taincan'),
'info_can_not_edit_collection' => __( 'You are not allowed to edit this collection.', 'tainacan' ),
'info_can_not_edit_taxonomies' => __( 'You are not allowed to edit taxonomies.', 'tainacan' ),
// Datepicker months
'datepicker_month_january' => __( 'January', 'tainacan' ),