Checks max values on taginput for user and taxonomy metadata type.

This commit is contained in:
mateuswetah 2021-09-23 17:15:03 -03:00
parent 6df6af44ff
commit 1515f1cdac
3 changed files with 58 additions and 49 deletions

View File

@ -31,9 +31,8 @@
:is-checkbox="getComponent == 'tainacan-taxonomy-checkbox'"
@input="(selected) => valueComponent = selected"
/>
<div
v-if="displayCreateNewTerm && !isTermCreationPanelOpen"
v-if="displayCreateNewTerm && !isTermCreationPanelOpen && (maxMultipleValues !== undefined ? (maxMultipleValues > valueComponent.length) : true)"
class="add-new-term">
<a
@click="openTermCreationModal"

View File

@ -1,5 +1,4 @@
<template>
<div class="block">
<b-taginput
expanded
:disabled="disabled"
@ -11,6 +10,7 @@
@remove="emitRemove"
v-model="selected"
:data="labels"
:maxtags="maxtags"
field="label"
:remove-on-keys="[]"
:dropdown-position="isLastMetadatum ? 'top' :'auto'"
@ -45,7 +45,6 @@
</a>
</template>
</b-taginput>
</div>
</template>
<script>

View File

@ -10,7 +10,7 @@
@input="onInput"
@blur="onBlur"
:data="options"
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? 100 : 1)"
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? (maxMultipleValues !== undefined ? maxMultipleValues : null) : 1)"
autocomplete
attached
:placeholder="$i18n.get('instruction_type_search_users')"
@ -72,6 +72,17 @@ export default {
totalUsers: 0
}
},
computed: {
maxMultipleValues() {
return (
this.itemMetadatum &&
this.itemMetadatum.metadatum &&
this.itemMetadatum.metadatum.cardinality &&
!isNaN(this.itemMetadatum.metadatum.cardinality) &&
this.itemMetadatum.metadatum.cardinality > 1
) ? this.itemMetadatum.metadatum.cardinality : undefined;
}
},
created() {
this.loadCurrentUsers();
},