Adds tag to represent terms that are not created yet. #573

This commit is contained in:
mateuswetah 2021-08-19 11:33:12 -03:00
parent 2d618712f3
commit a289a755f5
5 changed files with 35 additions and 23 deletions

View File

@ -182,7 +182,11 @@
},
addTermToBeCreated(term) {
this.isTermCreationPanelOpen = false;
this.valueComponent = term.parent ? (term.parent + '>' + term.name) : term.name;
if (this.itemMetadatum.metadatum.multiple === 'no')
this.valueComponent = term.parent ? (term.parent + '>' + term.name) : term.name;
else
this.valueComponent.push(term.parent ? (term.parent + '>' + term.name) : term.name);
},
openTermCreationModal(newTerm) {
this.newTermName = newTerm.name;

View File

@ -279,7 +279,7 @@
closable
class="is-small"
@close="selected instanceof Array ? selected.splice(index, 1) : selected = ''">
<span v-html="(isTaxonomy || metadatum_type === 'Tainacan\\Metadata_Types\\Relationship') ? selectedTagsName[term] : term" />
<span v-html="(isTaxonomy || metadatum_type === 'Tainacan\\Metadata_Types\\Relationship') ? selectedTagsName[term] : term" />
</b-tag>
</div>
</b-field>
@ -427,23 +427,33 @@
},
fetchSelectedLabels() {
let selected = this.selected instanceof Array ? this.selected : [this.selected];
let allSelected = this.selected instanceof Array ? this.selected : [this.selected];
if (this.taxonomy_id && selected.length) {
// If a new item was added from item submission block, the value will be a string, and the term does not exists yet.
let selected = allSelected.filter((aValue) => !isNaN(aValue));
let selectedFromItemSubmission = allSelected.filter((aValue) => isNaN(aValue));
this.isSelectedTermsLoading = true;
if (this.taxonomy_id) {
axios.get(`/taxonomy/${this.taxonomy_id}/terms/?${qs.stringify({ hideempty: 0, include: selected})}`)
.then((res) => {
for (const term of res.data)
this.saveSelectedTagName(term.id, term.name, term.url);
if (selected.length) {
this.isSelectedTermsLoading = true;
axios.get(`/taxonomy/${this.taxonomy_id}/terms/?${qs.stringify({ hideempty: 0, include: selected})}`)
.then((res) => {
for (const term of res.data)
this.saveSelectedTagName(term.id, term.name, term.url);
this.isSelectedTermsLoading = false;
})
.catch((error) => {
this.$console.log(error);
this.isSelectedTermsLoading = false;
});
this.isSelectedTermsLoading = false;
})
.catch((error) => {
this.$console.log(error);
this.isSelectedTermsLoading = false;
});
}
if (selectedFromItemSubmission) {
for (const term of selectedFromItemSubmission)
this.saveSelectedTagName(term, term.split('>')[term.split('>').length - 1], '');
}
} else if (this.metadatum_type === 'Tainacan\\Metadata_Types\\Relationship' && selected.length) {
this.isSelectedTermsLoading = true;

View File

@ -67,7 +67,7 @@ export default {
padding: 0.8em 0.8em 0em 0.8em;
h5 {
font-size: 0.875em;
font-size: 0.875em !important;
font-weight: bold;
color: var(--tainacan-secondary);
margin-bottom: 0;

View File

@ -108,7 +108,7 @@ export default {
padding: 0.8em 0.8em 0em 0.8em;
h5 {
font-size: 0.875em;
font-size: 0.875em !important;
font-weight: bold;
color: var(--tainacan-red2);
margin-bottom: 0;

View File

@ -174,7 +174,7 @@
this.$emit('onEditionCanceled', this.editForm);
},
clearErrors(attributes) {
if(attributes instanceof Object){
if (attributes instanceof Object){
for(let attribute in attributes){
this.formErrors[attribute] = undefined;
}
@ -202,7 +202,6 @@
if (this.parentTermSearchOffset > 0 && this.parentTerms.length >= this.totalTerms)
return
this.isFetchingParentTerms = true;
this.fetchPossibleParentTerms({
@ -228,11 +227,10 @@
}, 250),
onToggleSwitch() {
if (this.editForm.parent == 0) {
if (this.editForm.parent == 0)
this.hasChangedParent = this.hasParent;
} else {
else
this.hasChangedParent = !this.hasParent;
}
this.showCheckboxesWarning = true;
this.clearErrors('parent');
@ -253,7 +251,7 @@
padding-top: 6px;
h4 {
font-size: 0.875em;
font-size: 0.875em !important;
}
&>div {
padding: 0 16px 16px;