Removes unecessary term traversal 't' library.
This commit is contained in:
parent
8024cd3a68
commit
e7db054401
|
@ -3356,9 +3356,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apexcharts": {
|
"apexcharts": {
|
||||||
"version": "3.37.1",
|
"version": "3.39.0",
|
||||||
"resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.37.1.tgz",
|
"resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.39.0.tgz",
|
||||||
"integrity": "sha512-fmQ5Updeb/LASl+S1+mIxXUFxzY0Fa7gexfCs4o+OPP9f2NEBNjvybOtPrah44N4roK7U5o5Jis906QeEQu0cA==",
|
"integrity": "sha512-GRvdTg+ZaD55P7/jxqEXpbdCMZQOaej9qE9f7zKkN/oWAbBuuE3mnSCi44UkGMS2X249uEOEXWx0A96jjP3lcA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"svg.draggable.js": "^2.2.2",
|
"svg.draggable.js": "^2.2.2",
|
||||||
"svg.easing.js": "^2.0.0",
|
"svg.easing.js": "^2.0.0",
|
||||||
|
@ -4039,9 +4039,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"countup.js": {
|
"countup.js": {
|
||||||
"version": "2.5.0",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/countup.js/-/countup.js-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/countup.js/-/countup.js-2.6.0.tgz",
|
||||||
"integrity": "sha512-/59H8Q6wzu6VfHeqGUgXoyh6kgboGr5mALmRKi8YA11DlcaXSnT1PZG6mTyBRLco4ZjExKlmfNHeMbQgZvis9Q=="
|
"integrity": "sha512-GeORCrCcaFUHP3RNf0/dWK+XQX+fsdtrMO31mNvsbKXNNG+DMTcgZ4dWpIG9BnOS8t5+iJbaRXgaaG9oLs0N4g=="
|
||||||
},
|
},
|
||||||
"cross-env": {
|
"cross-env": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
|
@ -6491,9 +6491,9 @@
|
||||||
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
|
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
|
||||||
},
|
},
|
||||||
"photoswipe": {
|
"photoswipe": {
|
||||||
"version": "5.3.6",
|
"version": "5.3.7",
|
||||||
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.3.7.tgz",
|
||||||
"integrity": "sha512-v7e8iMfaPUujTACYsK5HBCCtFoW9n2dMZmjIlbvFS2oSpTQmPrfc3PrWnGx8OGY3jNOKho8JC8L277+m+9ag9Q=="
|
"integrity": "sha512-zsyLsTTLFrj0XR1m4/hO7qNooboFKUrDy+Zt5i2d6qjFPAtBjzaj/Xtydso4uxzcXpcqbTmyxDibb3BcSISseg=="
|
||||||
},
|
},
|
||||||
"picocolors": {
|
"picocolors": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -7699,11 +7699,6 @@
|
||||||
"ssr-window": "^4.0.2"
|
"ssr-window": "^4.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"t": {
|
|
||||||
"version": "0.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/t/-/t-0.5.1.tgz",
|
|
||||||
"integrity": "sha1-fZGSIB7X+Lv2FZisc2YNj/zDtXg="
|
|
||||||
},
|
|
||||||
"tapable": {
|
"tapable": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production"
|
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"apexcharts": "^3.37.1",
|
"apexcharts": "^3.39.0",
|
||||||
"axios": "^1.1.3",
|
"axios": "^1.1.3",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"buefy": "^0.9.23",
|
"buefy": "^0.9.23",
|
||||||
"bulma": "^0.9.4",
|
"bulma": "^0.9.4",
|
||||||
"conditioner-core": "^2.3.3",
|
"conditioner-core": "^2.3.3",
|
||||||
"countup.js": "^2.5.0",
|
"countup.js": "^2.6.0",
|
||||||
"css-vars-ponyfill": "^2.4.8",
|
"css-vars-ponyfill": "^2.4.8",
|
||||||
"floating-vue": "^1.0.0-beta.19",
|
"floating-vue": "^1.0.0-beta.19",
|
||||||
"leaflet": "^1.9.3",
|
"leaflet": "^1.9.3",
|
||||||
|
@ -22,12 +22,11 @@
|
||||||
"masonry-layout": "^4.2.2",
|
"masonry-layout": "^4.2.2",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"node-sass": "^7.0.3",
|
"node-sass": "^7.0.3",
|
||||||
"photoswipe": "^5.3.6",
|
"photoswipe": "^5.3.7",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"swiper": "^8.4.5",
|
"swiper": "^8.4.5",
|
||||||
"t": "^0.5.1",
|
|
||||||
"vue": "^2.6.14",
|
"vue": "^2.6.14",
|
||||||
"vue-apexcharts": "^1.6.2",
|
"vue-apexcharts": "^1.6.2",
|
||||||
"vue-blurhash": "^0.1.4",
|
"vue-blurhash": "^0.1.4",
|
||||||
|
|
|
@ -68,7 +68,7 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
'default' => '1'
|
'default' => '1'
|
||||||
],
|
],
|
||||||
'delete_child_terms' => [
|
'delete_child_terms' => [
|
||||||
'description' => __('Delete all childs term.'),
|
'description' => __('Delete all child terms.'),
|
||||||
'default' => false
|
'default' => false
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
|
@ -161,7 +161,7 @@
|
||||||
:title="$i18n.get('terms')"
|
:title="$i18n.get('terms')"
|
||||||
:message="$i18n.get('info_taxonomy_terms_list')"
|
:message="$i18n.get('info_taxonomy_terms_list')"
|
||||||
extra-classes="tainacan-repository-tooltip"/>
|
extra-classes="tainacan-repository-tooltip"/>
|
||||||
<new-terms-list
|
<terms-list
|
||||||
:key="shouldReloadTermsList ? 'termslistreloaded' : 'termslist'"
|
:key="shouldReloadTermsList ? 'termslistreloaded' : 'termslist'"
|
||||||
:taxonomy-id="taxonomyId"
|
:taxonomy-id="taxonomyId"
|
||||||
:current-user-can-edit-taxonomy="taxonomy ? taxonomy.current_user_can_edit : false"/>
|
:current-user-can-edit-taxonomy="taxonomy ? taxonomy.current_user_can_edit : false"/>
|
||||||
|
@ -250,13 +250,13 @@
|
||||||
<script>
|
<script>
|
||||||
import { wpAjax, formHooks } from "../../js/mixins";
|
import { wpAjax, formHooks } from "../../js/mixins";
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
import NewTermsList from '../lists/new-terms-list.vue';
|
import TermsList from '../lists/terms-list.vue';
|
||||||
import CustomDialog from '../other/custom-dialog.vue';
|
import CustomDialog from '../other/custom-dialog.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TaxonomyEditionForm',
|
name: 'TaxonomyEditionForm',
|
||||||
components: {
|
components: {
|
||||||
NewTermsList
|
TermsList
|
||||||
},
|
},
|
||||||
mixins: [ wpAjax, formHooks ],
|
mixins: [ wpAjax, formHooks ],
|
||||||
beforeRouteLeave( to, from, next ) {
|
beforeRouteLeave( to, from, next ) {
|
||||||
|
|
|
@ -1,268 +0,0 @@
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
style="width: 100%;">
|
|
||||||
<div
|
|
||||||
class="term-item"
|
|
||||||
:class="{
|
|
||||||
'opened-term': term.opened
|
|
||||||
}">
|
|
||||||
<span
|
|
||||||
class="term-name"
|
|
||||||
:class="{'is-danger': formWithErrors == term.id }"
|
|
||||||
v-html="term.hierarchy_path ? (`<span class='term-name-hierarchy-path'>${term.hierarchy_path}</span>${term.name}`) : term.name" />
|
|
||||||
<span
|
|
||||||
v-if="term.id != undefined"
|
|
||||||
class="label-details">
|
|
||||||
<span
|
|
||||||
class="not-saved"
|
|
||||||
v-if="term.id == 'new'">
|
|
||||||
{{ $i18n.get('info_not_saved') }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="currentUserCanEditTaxonomy"
|
|
||||||
class="controls"
|
|
||||||
:class="{'is-disabled': isEditingTerm}">
|
|
||||||
<a
|
|
||||||
@click.prevent="editTerm()">
|
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: $i18n.get('edit'),
|
|
||||||
autoHide: true,
|
|
||||||
placement: 'auto',
|
|
||||||
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip']
|
|
||||||
}"
|
|
||||||
class="icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-edit"/>
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
<a @click.prevent="tryToRemoveTerm()">
|
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: $i18n.get('delete'),
|
|
||||||
autoHide: true,
|
|
||||||
placement: 'auto',
|
|
||||||
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip']
|
|
||||||
}"
|
|
||||||
class="icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-delete"/>
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapActions } from 'vuex';
|
|
||||||
import CustomDialog from '../other/custom-dialog.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'BasicTermItem',
|
|
||||||
props: {
|
|
||||||
term: Object,
|
|
||||||
index: Number,
|
|
||||||
taxonomyId: Number,
|
|
||||||
order: String,
|
|
||||||
currentUserCanEditTaxonomy: Boolean
|
|
||||||
},
|
|
||||||
data(){
|
|
||||||
return {
|
|
||||||
isLoadingTerms: false,
|
|
||||||
isEditingTerm: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.$eventBusTermsList.$on('editTerm', this.eventOnEditTerm);
|
|
||||||
this.$eventBusTermsList.$on('termEditionSaved', this.eventOnTermEditionSaved);
|
|
||||||
this.$eventBusTermsList.$on('termEditionCanceled', this.eventOnTermEditionCanceled);
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.$eventBusTermsList.$off('editTerm', this.eventOnEditTerm);
|
|
||||||
this.$eventBusTermsList.$off('termEditionSaved', this.eventOnTermEditionSaved);
|
|
||||||
this.$eventBusTermsList.$off('termEditionCanceled', this.eventOnTermEditionCanceled);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapActions('taxonomy', [
|
|
||||||
'updateTerm',
|
|
||||||
'deleteTerm'
|
|
||||||
]),
|
|
||||||
editTerm() {
|
|
||||||
this.$emit('onUpdateTermOpenedState', !this.term.opened);
|
|
||||||
this.$eventBusTermsList.onEditTerm(this.term);
|
|
||||||
},
|
|
||||||
tryToRemoveTerm() {
|
|
||||||
|
|
||||||
// Checks if user is deleting a term with unsaved info.
|
|
||||||
if (this.term.id == 'new') {
|
|
||||||
this.$buefy.modal.open({
|
|
||||||
parent: this,
|
|
||||||
component: CustomDialog,
|
|
||||||
props: {
|
|
||||||
icon: 'alert',
|
|
||||||
title: this.$i18n.get('label_warning'),
|
|
||||||
message: this.$i18n.get('info_warning_terms_not_saved'),
|
|
||||||
onConfirm: () => { this.removeTerm(); },
|
|
||||||
},
|
|
||||||
trapFocus: true,
|
|
||||||
customClass: 'tainacan-modal',
|
|
||||||
closeButtonAriaLabel: this.$i18n.get('close')
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.removeTerm();
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
removeTerm() {
|
|
||||||
|
|
||||||
this.$buefy.modal.open({
|
|
||||||
parent: this,
|
|
||||||
component: CustomDialog,
|
|
||||||
props: {
|
|
||||||
icon: 'alert',
|
|
||||||
title: this.$i18n.get('label_warning'),
|
|
||||||
message: this.$i18n.get('info_warning_selected_term_delete'),
|
|
||||||
onConfirm: () => {
|
|
||||||
// If all checks passed, term can be deleted
|
|
||||||
this.$eventBusTermsList.onDeleteBasicTermItem(this.term);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
trapFocus: true,
|
|
||||||
customClass: 'tainacan-modal',
|
|
||||||
closeButtonAriaLabel: this.$i18n.get('close')
|
|
||||||
});
|
|
||||||
},
|
|
||||||
eventOnEditTerm() {
|
|
||||||
this.isEditingTerm = true;
|
|
||||||
},
|
|
||||||
eventOnTermEditionSaved() {
|
|
||||||
this.isEditingTerm = false;
|
|
||||||
this.$emit('onUpdateTermOpenedState', false);
|
|
||||||
},
|
|
||||||
eventOnTermEditionCanceled() {
|
|
||||||
this.isEditingTerm = false;
|
|
||||||
this.$emit('onUpdateTermOpenedState', false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
// Term Item
|
|
||||||
.term-item {
|
|
||||||
padding: 0 0 0 1.75em;
|
|
||||||
min-height: 2.5em;
|
|
||||||
display: flex;
|
|
||||||
position: relative;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
border-left: 1px solid transparent;
|
|
||||||
visibility: visible;
|
|
||||||
opacity: 1;
|
|
||||||
transition: display 0.3s, visibility 0.3s, opacity 0.3s;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&:first-child:hover {
|
|
||||||
background-color: var(--tainacan-gray1) !important;
|
|
||||||
.controls {
|
|
||||||
visibility: visible;
|
|
||||||
opacity: 1.0;
|
|
||||||
}
|
|
||||||
&::before {
|
|
||||||
border-color: transparent transparent transparent var(--tainacan-gray2) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.term-name {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
overflow-x: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
margin-left: 0.4em;
|
|
||||||
margin-right: 0.4em;
|
|
||||||
display: inline-block;
|
|
||||||
max-width: 73%;
|
|
||||||
color: var(--tainacan-gray5);
|
|
||||||
|
|
||||||
&.is-danger {
|
|
||||||
color: var(--tainacan-danger) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/deep/ .term-name-hierarchy-path {
|
|
||||||
color: var(--tainacan-gray-4);
|
|
||||||
}
|
|
||||||
.label-details {
|
|
||||||
font-weight: normal;
|
|
||||||
color: var(--tainacan-gray3);
|
|
||||||
margin-right: auto;
|
|
||||||
}
|
|
||||||
.not-saved {
|
|
||||||
font-style: italic;
|
|
||||||
font-weight: bold;
|
|
||||||
color: var(--tainacan-danger);
|
|
||||||
}
|
|
||||||
.controls {
|
|
||||||
height: 3.125em;
|
|
||||||
visibility: hidden;
|
|
||||||
opacity: 0.0;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
background-color: var(--tainacan-gray2);
|
|
||||||
padding: 0.65em 0.875em;
|
|
||||||
|
|
||||||
a {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin: 0 0.375em;
|
|
||||||
.icon {
|
|
||||||
bottom: 1px;
|
|
||||||
position: relative;
|
|
||||||
i, i:before { font-size: 1.25em; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.controls.is-disabled a {
|
|
||||||
color: var(--tainacan-info-color) !important;
|
|
||||||
cursor: not-allowed !important;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.opened-term:first-child {
|
|
||||||
cursor: default;
|
|
||||||
background-color: var(--tainacan-blue1);
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
left: 100%;
|
|
||||||
right: -20px;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: transparent transparent transparent var(--tainacan-blue1);
|
|
||||||
border-left-width: 24px;
|
|
||||||
border-top-width: 1.55em;
|
|
||||||
border-bottom-width: 1.55em;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
&:hover:before {
|
|
||||||
border-color: transparent transparent transparent var(--tainacan-gray1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.collapsed-term {
|
|
||||||
display: none;
|
|
||||||
visibility: hidden;
|
|
||||||
opacity: 0;
|
|
||||||
transition: display 0.3s, visibility 0.3s, opacity 0.3s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.view-more-terms {
|
|
||||||
font-size: 0.875em;
|
|
||||||
margin: 0 0 0 1.75em !important;
|
|
||||||
padding: 0.5em 0 0.5em 1.75em;
|
|
||||||
display: flex;
|
|
||||||
border-top: 1px solid var(--tainacan-gray1);
|
|
||||||
}
|
|
||||||
</style>
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,461 +0,0 @@
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
style="width: 100%;">
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="term-item"
|
|
||||||
:style="{
|
|
||||||
'border-left-color': term.parent > 0 ? 'var(--tainacan-gray1)' : 'transparent'
|
|
||||||
}"
|
|
||||||
:class="{
|
|
||||||
'opened-term': term.opened
|
|
||||||
}">
|
|
||||||
<span
|
|
||||||
v-if="term.parent != 0 && index == 0"
|
|
||||||
class="icon children-icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-nextlevel"/>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: $i18n.get('label_show_children_terms'),
|
|
||||||
autoHide: true,
|
|
||||||
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
|
|
||||||
placement: 'bottom'
|
|
||||||
}"
|
|
||||||
class="children-dropdown icon">
|
|
||||||
<i
|
|
||||||
:class="{
|
|
||||||
'tainacan-icon-arrowright': !showChildren,
|
|
||||||
'tainacan-icon-arrowdown': showChildren,
|
|
||||||
'is-disabled': isEditingTerm }"
|
|
||||||
class="tainacan-icon tainacan-icon-36px"
|
|
||||||
v-if="term.total_children > 0"
|
|
||||||
@click.prevent="toggleShowChildren()"/>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="term-name"
|
|
||||||
:class="{'is-danger': formWithErrors == term.id, 'is-italic': !term.name }">
|
|
||||||
{{ term.name ? term.name : $i18n.get('label_term_without_name') }}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="term.id == 'new'"
|
|
||||||
class="label-details">
|
|
||||||
<span class="not-saved" >
|
|
||||||
{{ $i18n.get('info_not_saved') }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="children-counter"
|
|
||||||
v-if="term.total_children > 0">
|
|
||||||
<span>{{ term.total_children + ' ' + $i18n.get('label_children_terms') }}</span>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="currentUserCanEditTaxonomy"
|
|
||||||
class="controls"
|
|
||||||
:class="{'is-disabled': isEditingTerm}">
|
|
||||||
<a @click="addNewChildTerm(term, index)">
|
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: $i18n.get('label_new_child'),
|
|
||||||
autoHide: true,
|
|
||||||
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
|
|
||||||
placement: 'bottom'
|
|
||||||
}"
|
|
||||||
class="icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-add"/>
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
@click.prevent="editTerm()">
|
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: $i18n.get('edit'),
|
|
||||||
autoHide: true,
|
|
||||||
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
|
|
||||||
placement: 'bottom'
|
|
||||||
}"
|
|
||||||
class="icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-edit"/>
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
<a @click.prevent="tryToRemoveTerm()">
|
|
||||||
<span
|
|
||||||
v-tooltip="{
|
|
||||||
content: $i18n.get('delete'),
|
|
||||||
autoHide: true,
|
|
||||||
popperClass: ['tainacan-tooltip', 'tooltip', 'tainacan-repository-tooltip'],
|
|
||||||
placement: 'bottom'
|
|
||||||
}"
|
|
||||||
class="icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-delete"/>
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<transition-group
|
|
||||||
class="children-area"
|
|
||||||
name="filter-item">
|
|
||||||
<div
|
|
||||||
class="term-item"
|
|
||||||
:style="{
|
|
||||||
'border-left-color': term.parent > 0 && childTerm.parent > 0 ? 'var(--tainacan-gray1)' : 'transparent'
|
|
||||||
}"
|
|
||||||
:class="{
|
|
||||||
'opened-term': childTerm.opened,
|
|
||||||
}"
|
|
||||||
v-for="(childTerm, childIndex) in term.children"
|
|
||||||
:key="childTerm.id"
|
|
||||||
v-if="showChildren">
|
|
||||||
|
|
||||||
<recursive-term-item
|
|
||||||
:term="childTerm"
|
|
||||||
:index="childIndex"
|
|
||||||
:taxonomy-id="taxonomyId"
|
|
||||||
:order="order"
|
|
||||||
:current-user-can-edit-taxonomy="currentUserCanEditTaxonomy"
|
|
||||||
@onUpdateTermOpenedState="(state) => childTerm.opened = state"/>
|
|
||||||
</div>
|
|
||||||
</transition-group>
|
|
||||||
<a
|
|
||||||
class="view-more-terms"
|
|
||||||
:class="{'is-disabled': isEditingTerm}"
|
|
||||||
@click="offset = offset + maxTerms; loadChildTerms(term.id)"
|
|
||||||
v-if="showChildren && term.children != undefined && (totalTerms > term.children.length)">
|
|
||||||
{{ $i18n.get('label_view_more') + ' (' + Number(totalTerms - term.children.length) + ' ' + $i18n.get('terms') + ')' }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapActions } from 'vuex';
|
|
||||||
import CustomDialog from '../other/custom-dialog.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'RecursiveTermItem',
|
|
||||||
props: {
|
|
||||||
term: Object,
|
|
||||||
index: Number,
|
|
||||||
taxonomyId: Number,
|
|
||||||
order: String,
|
|
||||||
currentUserCanEditTaxonomy: Boolean
|
|
||||||
},
|
|
||||||
data(){
|
|
||||||
return {
|
|
||||||
isLoadingTerms: false,
|
|
||||||
isEditingTerm: false,
|
|
||||||
searchQuery: '',
|
|
||||||
showChildren: false,
|
|
||||||
maxTerms: 100,
|
|
||||||
offset: 0,
|
|
||||||
totalTerms: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
this.$root.$on('onChildTermDeleted', this.eventOnChildTermDeleted);
|
|
||||||
this.$eventBusTermsList.$on('editTerm', this.eventOnEditTerm);
|
|
||||||
this.$eventBusTermsList.$on('termEditionSaved', this.eventOnTermEditionSaved);
|
|
||||||
this.$eventBusTermsList.$on('termEditionCanceled', this.eventOnTermEditionCanceled);
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.$root.$off('onChildTermDeleted', this.eventOnChildTermDeleted);
|
|
||||||
this.$eventBusTermsList.$off('editTerm', this.eventOnEditTerm);
|
|
||||||
this.$eventBusTermsList.$off('termEditionSaved', this.eventOnTermEditionSaved);
|
|
||||||
this.$eventBusTermsList.$off('termEditionCanceled', this.eventOnTermEditionCanceled);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapActions('taxonomy', [
|
|
||||||
'updateChildTerm',
|
|
||||||
'deleteChildTerm',
|
|
||||||
'fetchChildTerms',
|
|
||||||
'clearTerms',
|
|
||||||
'updateChildTermLocal'
|
|
||||||
]),
|
|
||||||
teste() {
|
|
||||||
this.totalTerms = this.totalTerms - 1;
|
|
||||||
},
|
|
||||||
addNewChildTerm() {
|
|
||||||
this.showChildren = true;
|
|
||||||
this.$eventBusTermsList.onAddNewChildTerm(this.term.id);
|
|
||||||
},
|
|
||||||
toggleShowChildren() {
|
|
||||||
if (!this.isLoadingTerms && (this.term.children == undefined || this.term.children.length <= 0)) {
|
|
||||||
this.loadChildTerms(this.term.id);
|
|
||||||
} else {
|
|
||||||
this.showChildren = !this.showChildren;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
loadChildTerms(parentId) {
|
|
||||||
|
|
||||||
this.isLoadingTerms = true;
|
|
||||||
|
|
||||||
let search = (this.searchQuery != undefined && this.searchQuery != '') ? { searchterm: this.searchQuery } : '';
|
|
||||||
this.fetchChildTerms({
|
|
||||||
parentId: parentId,
|
|
||||||
taxonomyId: this.taxonomyId,
|
|
||||||
fetchOnly: '',
|
|
||||||
search: search,
|
|
||||||
all: '',
|
|
||||||
order: this.order,
|
|
||||||
offset: this.offset,
|
|
||||||
number: this.maxTerms
|
|
||||||
})
|
|
||||||
.then((resp) => {
|
|
||||||
this.isLoadingTerms = false;
|
|
||||||
this.showChildren = true;
|
|
||||||
this.totalTerms = resp.total;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.isLoadingTerms = false;
|
|
||||||
this.$console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
editTerm() {
|
|
||||||
|
|
||||||
this.$emit('onUpdateTermOpenedState', !this.term.opened);
|
|
||||||
|
|
||||||
this.$eventBusTermsList.onEditTerm(this.term);
|
|
||||||
|
|
||||||
},
|
|
||||||
tryToRemoveTerm() {
|
|
||||||
|
|
||||||
// Checks if user is deleting a term with unsaved info.
|
|
||||||
if (this.term.id == 'new') {
|
|
||||||
this.$buefy.modal.open({
|
|
||||||
parent: this,
|
|
||||||
component: CustomDialog,
|
|
||||||
props: {
|
|
||||||
icon: 'alert',
|
|
||||||
title: this.$i18n.get('label_warning'),
|
|
||||||
message: this.$i18n.get('info_warning_terms_not_saved'),
|
|
||||||
onConfirm: () => { this.removeTerm(); },
|
|
||||||
},
|
|
||||||
trapFocus: true,
|
|
||||||
customClass: 'tainacan-modal',
|
|
||||||
closeButtonAriaLabel: this.$i18n.get('close')
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.removeTerm();
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
removeTerm() {
|
|
||||||
|
|
||||||
this.$buefy.modal.open({
|
|
||||||
parent: this,
|
|
||||||
component: CustomDialog,
|
|
||||||
props: {
|
|
||||||
icon: 'alert',
|
|
||||||
title: this.$i18n.get('label_warning'),
|
|
||||||
message: this.$i18n.get('info_warning_selected_term_delete'),
|
|
||||||
onConfirm: () => {
|
|
||||||
|
|
||||||
// If all checks passed, term can be deleted
|
|
||||||
this.deleteChildTerm({
|
|
||||||
taxonomyId: this.taxonomyId,
|
|
||||||
termId: this.term.id,
|
|
||||||
parent: this.term.parent })
|
|
||||||
.then(() => {
|
|
||||||
this.$root.$emit('onChildTermDeleted', this.term.parent);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.$console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Updates parent IDs for orphans
|
|
||||||
if (this.term.children != undefined && this.term.children.length > 0) {
|
|
||||||
for (let orphanTerm of this.term.children) {
|
|
||||||
this.updateChildTermLocal({
|
|
||||||
term: orphanTerm,
|
|
||||||
parent: this.term.parent,
|
|
||||||
oldParent: this.term.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
trapFocus: true,
|
|
||||||
customClass: 'tainacan-modal',
|
|
||||||
closeButtonAriaLabel: this.$i18n.get('close')
|
|
||||||
});
|
|
||||||
},
|
|
||||||
eventOnChildTermDeleted(parentTermId) {
|
|
||||||
if (this.term.id == parentTermId && this.totalTerms > 0) {
|
|
||||||
this.totalTerms--;
|
|
||||||
this.loadChildTerms(parentTermId);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
eventOnEditTerm() {
|
|
||||||
this.isEditingTerm = true;
|
|
||||||
},
|
|
||||||
eventOnTermEditionSaved($event) {
|
|
||||||
if (this.term.id == $event.term.id) {
|
|
||||||
this.$set(this.term, 'description', $event.term.description);
|
|
||||||
this.$set(this.term, 'header_image', $event.term.header_image);
|
|
||||||
this.$set(this.term, 'header_image_id', $event.term.header_image_id);
|
|
||||||
this.$set(this.term, 'name', $event.term.name);
|
|
||||||
this.$set(this.term, 'parent', $event.term.parent);
|
|
||||||
this.$set(this.term, 'id', $event.term.id);
|
|
||||||
} else if (this.term.children != undefined) {
|
|
||||||
for (let i = 0; i < this.term.children.length; i++) {
|
|
||||||
if (this.term.children[i].id == $event.term.id) {
|
|
||||||
this.$set(this.term.children[i], 'description', $event.term.description);
|
|
||||||
this.$set(this.term.children[i], 'header_image', $event.term.header_image);
|
|
||||||
this.$set(this.term.children[i], 'header_image_id', $event.term.header_image_id);
|
|
||||||
this.$set(this.term.children[i], 'name', $event.term.name);
|
|
||||||
this.$set(this.term.children[i], 'parent', $event.term.parent);
|
|
||||||
this.$set(this.term.children[i], 'id', $event.term.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isEditingTerm = false;
|
|
||||||
this.$emit('onUpdateTermOpenedState', false);
|
|
||||||
},
|
|
||||||
eventOnTermEditionCanceled() {
|
|
||||||
this.isEditingTerm = false;
|
|
||||||
this.$emit('onUpdateTermOpenedState', false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
// Term Item
|
|
||||||
.term-item {
|
|
||||||
padding: 0 0 0 1.75em;
|
|
||||||
min-height: 2.5em;
|
|
||||||
display: flex;
|
|
||||||
position: relative;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
border-left: 1px solid transparent;
|
|
||||||
visibility: visible;
|
|
||||||
opacity: 1;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
& .term-item:first-child:hover {
|
|
||||||
background-color: var(--tainacan-gray1) !important;
|
|
||||||
.controls {
|
|
||||||
visibility: visible;
|
|
||||||
opacity: 1.0;
|
|
||||||
}
|
|
||||||
&::before {
|
|
||||||
border-color: transparent transparent transparent var(--tainacan-gray2) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.children-icon {
|
|
||||||
color: var(--tainacan-blue2);
|
|
||||||
position: absolute;
|
|
||||||
left: -1.3125em;
|
|
||||||
top: 1px;
|
|
||||||
font-size: 1.5em;
|
|
||||||
}
|
|
||||||
.children-dropdown {
|
|
||||||
color: var(--tainacan-blue4);
|
|
||||||
position: absolute;
|
|
||||||
left: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.term-name {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
overflow-x: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
margin-left: 0.4em;
|
|
||||||
margin-right: 0.4em;
|
|
||||||
display: inline-block;
|
|
||||||
max-width: 73%;
|
|
||||||
|
|
||||||
&.is-danger {
|
|
||||||
color: var(--tainacan-danger) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.label-details {
|
|
||||||
font-weight: normal;
|
|
||||||
color: var(--tainacan-gray3);
|
|
||||||
margin-left: 1em;
|
|
||||||
margin-right: auto;
|
|
||||||
}
|
|
||||||
.children-counter {
|
|
||||||
margin-left: 1em;
|
|
||||||
margin-right: auto;
|
|
||||||
color: var(--tainacan-info-color);
|
|
||||||
padding-right: 1em;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.not-saved {
|
|
||||||
font-style: italic;
|
|
||||||
font-weight: bold;
|
|
||||||
color: var(--tainacan-danger);
|
|
||||||
}
|
|
||||||
.controls {
|
|
||||||
height: 3.125em;
|
|
||||||
visibility: hidden;
|
|
||||||
opacity: 0.0;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
background-color: var(--tainacan-gray2);
|
|
||||||
padding: 0.65em 0.875em;
|
|
||||||
|
|
||||||
a {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin: 0 0.375em;
|
|
||||||
.icon {
|
|
||||||
bottom: 1px;
|
|
||||||
position: relative;
|
|
||||||
i, i:before { font-size: 1.25em; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.controls.is-disabled a, .children-dropdown i.is-disabled {
|
|
||||||
color: var(--tainacan-info-color) !important;
|
|
||||||
cursor: not-allowed !important;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.opened-term>div:first-child>div {
|
|
||||||
cursor: default;
|
|
||||||
background-color: var(--tainacan-gray1);
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
left: 100%;
|
|
||||||
right: -20px;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: transparent transparent transparent var(--tainacan-gray1);
|
|
||||||
border-left-width: 24px;
|
|
||||||
border-top-width: 1.55em;
|
|
||||||
border-bottom-width: 1.55em;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
&:hover:before {
|
|
||||||
border-color: transparent transparent transparent var(--tainacan-gray1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.collapsed-term {
|
|
||||||
display: none;
|
|
||||||
visibility: hidden;
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.view-more-terms {
|
|
||||||
font-size: 0.875em;
|
|
||||||
margin: 0 0 0 1.75em !important;
|
|
||||||
padding: 0.5em 0 0.5em 1.75em;
|
|
||||||
display: flex;
|
|
||||||
border-top: 1px solid var(--tainacan-gray1);
|
|
||||||
}
|
|
||||||
</style>
|
|
File diff suppressed because it is too large
Load Diff
|
@ -58,9 +58,6 @@ import FormGeoCoordinate from '../components/metadata-types/geocoordinate/FormGe
|
||||||
// Term edition form must be imported here so that it is not necessary on item-submission bundle
|
// Term edition form must be imported here so that it is not necessary on item-submission bundle
|
||||||
import TermEditionForm from '../components/edition/term-edition-form.vue';
|
import TermEditionForm from '../components/edition/term-edition-form.vue';
|
||||||
|
|
||||||
// Term Recursive item component needs to be imported here, otherwise would cause ciruclar dependency
|
|
||||||
import RecursiveTermItem from '../components/lists/recursive-term-item.vue';
|
|
||||||
|
|
||||||
import FormFilterNumeric from '../components/filter-types/numeric/FormNumeric.vue';
|
import FormFilterNumeric from '../components/filter-types/numeric/FormNumeric.vue';
|
||||||
import FormFilterNumericInterval from '../components/filter-types/numeric-interval/FormNumericInterval.vue';
|
import FormFilterNumericInterval from '../components/filter-types/numeric-interval/FormNumericInterval.vue';
|
||||||
import FormFilterNumericListInterval from '../components/filter-types/numeric-list-interval/FormNumericListInterval.vue';
|
import FormFilterNumericListInterval from '../components/filter-types/numeric-list-interval/FormNumericListInterval.vue';
|
||||||
|
@ -224,7 +221,6 @@ export default (element) => {
|
||||||
Vue.component('tainacan-form-item', TainacanFormItem);
|
Vue.component('tainacan-form-item', TainacanFormItem);
|
||||||
|
|
||||||
/* Others */
|
/* Others */
|
||||||
Vue.component('recursive-term-item', RecursiveTermItem);
|
|
||||||
Vue.component('help-button', HelpButton);
|
Vue.component('help-button', HelpButton);
|
||||||
Vue.component('draggable', draggable);
|
Vue.component('draggable', draggable);
|
||||||
Vue.component('tainacan-title', TainacanTitle);
|
Vue.component('tainacan-title', TainacanTitle);
|
||||||
|
|
|
@ -207,7 +207,7 @@ export const fetchTerms = ({ commit }, {taxonomyId, fetchOnly, search, all, orde
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.tainacan.get(`/taxonomy/${taxonomyId}/terms${query}`)
|
axios.tainacan.get(`/taxonomy/${taxonomyId}/terms${query}`)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let terms = res.data;
|
const terms = res.data;
|
||||||
commit('setTerms', terms);
|
commit('setTerms', terms);
|
||||||
resolve({ terms: terms, total: res.headers['x-wp-total'] });
|
resolve({ terms: terms, total: res.headers['x-wp-total'] });
|
||||||
})
|
})
|
||||||
|
@ -217,48 +217,11 @@ export const fetchTerms = ({ commit }, {taxonomyId, fetchOnly, search, all, orde
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hierarchy usage of terms list -----------------
|
|
||||||
export const fetchChildTerms = ({ commit }, { parentId, taxonomyId, fetchOnly, search, all, order, offset, number }) => {
|
|
||||||
|
|
||||||
let query = '';
|
|
||||||
if (order == undefined) {
|
|
||||||
order = 'asc';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fetchOnly && search && !all ){
|
|
||||||
query = `?order=${order}&${qs.stringify(fetchOnly)}&${qs.stringify(search)}`;
|
|
||||||
} else if(fetchOnly && search && all ){
|
|
||||||
query = `?hideempty=0&order=${order}&${qs.stringify(fetchOnly)}&${qs.stringify(search)}`;
|
|
||||||
} else if(search && !all && !fetchOnly){
|
|
||||||
query = `?hideempty=0&order=${order}&${qs.stringify(search)}`;
|
|
||||||
} else {
|
|
||||||
query =`?hideempty=0&order=${order}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
query += '&parent=' + parentId;
|
|
||||||
|
|
||||||
if (offset != undefined && number != undefined)
|
|
||||||
query += '&offset=' + offset + '&number=' + number;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.tainacan.get(`/taxonomy/${taxonomyId}/terms${query}`)
|
|
||||||
.then(res => {
|
|
||||||
let terms = res.data;
|
|
||||||
commit('setChildTerms', { terms: terms, parent: parentId });
|
|
||||||
resolve({ terms: terms, total: res.headers['x-wp-total'] });
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const sendChildTerm = ({ commit }, { taxonomyId, term }) => {
|
export const sendChildTerm = ({ commit }, { taxonomyId, term }) => {
|
||||||
return new Promise(( resolve, reject ) => {
|
return new Promise(( resolve, reject ) => {
|
||||||
axios.tainacan.post(`/taxonomy/${taxonomyId}/terms/`, term)
|
axios.tainacan.post(`/taxonomy/${taxonomyId}/terms/`, term)
|
||||||
.then( res => {
|
.then( res => {
|
||||||
let newTerm = res.data;
|
const newTerm = res.data;
|
||||||
commit('addChildTerm', {term: newTerm, parent: term.parent });
|
|
||||||
resolve( newTerm );
|
resolve( newTerm );
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
@ -271,9 +234,8 @@ export const updateChildTerm = ({ commit }, { taxonomyId, term }) => {
|
||||||
return new Promise(( resolve, reject ) => {
|
return new Promise(( resolve, reject ) => {
|
||||||
axios.tainacan.patch(`/taxonomy/${taxonomyId}/terms/${term.id}`, term)
|
axios.tainacan.patch(`/taxonomy/${taxonomyId}/terms/${term.id}`, term)
|
||||||
.then( res => {
|
.then( res => {
|
||||||
let updatedTerm = res.data;
|
const updatedTerm = res.data;
|
||||||
commit('updateChildTerm', { term: updatedTerm, parent: updatedTerm.parent, oldParent: term.parent });
|
resolve( updatedTerm );
|
||||||
resolve( term );
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
||||||
|
@ -286,9 +248,9 @@ export const updateChildTermLocal = ({ commit }, { term, parent, oldParent }) =>
|
||||||
commit('updateChildTerm', { term: term, parent: parent, oldParent: oldParent });
|
commit('updateChildTerm', { term: term, parent: parent, oldParent: oldParent });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteChildTerm = ({ commit }, { taxonomyId, termId, parent }) => {
|
export const deleteChildTerm = ({ commit }, { taxonomyId, termId, parent, deleteChildTerms = false }) => {
|
||||||
return new Promise(( resolve, reject ) => {
|
return new Promise(( resolve, reject ) => {
|
||||||
axios.tainacan.delete(`/taxonomy/${taxonomyId}/terms/${termId}?permanently=1`)
|
axios.tainacan.delete(`/taxonomy/${taxonomyId}/terms/${termId}?permanently=1&delete_child_terms=${deleteChildTerms}`)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let term = res.data;
|
let term = res.data;
|
||||||
commit('deleteChildTerm', { termId: termId, parent: parent });
|
commit('deleteChildTerm', { termId: termId, parent: parent });
|
||||||
|
@ -300,11 +262,6 @@ export const deleteChildTerm = ({ commit }, { taxonomyId, termId, parent }) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const clearTerms = ({ commit }) => {
|
|
||||||
commit('clearTerms');
|
|
||||||
};
|
|
||||||
|
|
||||||
// Used only on Term Edit form, for autocomplete search for parents
|
// Used only on Term Edit form, for autocomplete search for parents
|
||||||
export const fetchPossibleParentTerms = ({ commit }, { taxonomyId, termId, search, offset } ) => {
|
export const fetchPossibleParentTerms = ({ commit }, { taxonomyId, termId, search, offset } ) => {
|
||||||
|
|
||||||
|
@ -333,6 +290,7 @@ export const fetchPossibleParentTerms = ({ commit }, { taxonomyId, termId, searc
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchParentName = ({ commit }, { taxonomyId, parentId } ) => {
|
export const fetchParentName = ({ commit }, { taxonomyId, parentId } ) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.tainacan.get('/taxonomy/' + taxonomyId + '/terms/' + parentId + '?fetch_only=name')
|
axios.tainacan.get('/taxonomy/' + taxonomyId + '/terms/' + parentId + '?fetch_only=name')
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import t from 't';
|
|
||||||
|
|
||||||
export const setRepositoryTotalTaxonomies = (state, repositoryTotalTaxonomies) => {
|
export const setRepositoryTotalTaxonomies = (state, repositoryTotalTaxonomies) => {
|
||||||
state.repositoryTotalTaxonomies = repositoryTotalTaxonomies;
|
state.repositoryTotalTaxonomies = repositoryTotalTaxonomies;
|
||||||
|
@ -30,11 +29,10 @@ export const deleteTaxonomy = ( state, taxonomy ) => {
|
||||||
export const setSingleTerm = (state, term) => {
|
export const setSingleTerm = (state, term) => {
|
||||||
|
|
||||||
let index = state.terms.findIndex(updatedTerm => updatedTerm.id === term.id);
|
let index = state.terms.findIndex(updatedTerm => updatedTerm.id === term.id);
|
||||||
if ( index >= 0){
|
if ( index >= 0 )
|
||||||
Vue.set( state.terms, index, term );
|
Vue.set( state.terms, index, term );
|
||||||
} else {
|
else
|
||||||
state.terms.push( term );
|
state.terms.push( term );
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setTerms = (state, terms) => {
|
export const setTerms = (state, terms) => {
|
||||||
|
@ -49,124 +47,6 @@ export const setTerms = (state, terms) => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clearTerms = (state) => {
|
|
||||||
state.terms = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
// Hierarchy usage of terms list -----------------
|
|
||||||
export const setChildTerms = (state, { terms, parent }) => {
|
|
||||||
|
|
||||||
if (parent > 0 ) {
|
|
||||||
for (let i = 0; i < state.terms.length; i++) {
|
|
||||||
let parentTerm = t.find(state.terms[i], [], (node, par) => { return node.id == parent; });
|
|
||||||
if (parentTerm != undefined) {
|
|
||||||
if (parentTerm['children'] == undefined)
|
|
||||||
Vue.set(parentTerm, 'children', []);
|
|
||||||
|
|
||||||
for (let term of terms){
|
|
||||||
let existingTermIndex = parentTerm['children'].findIndex(aTerm => aTerm.id == term.id);
|
|
||||||
if (existingTermIndex < 0)
|
|
||||||
parentTerm['children'].push(term);
|
|
||||||
else
|
|
||||||
Vue.set(parentTerm['children'], existingTermIndex, term);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (state.terms != undefined) {
|
|
||||||
for (let term of terms) {
|
|
||||||
let existingTermIndex = state.terms.findIndex(aTerm => aTerm.id == term.id);
|
|
||||||
if (existingTermIndex < 0)
|
|
||||||
state.terms.push(term);
|
|
||||||
else
|
|
||||||
Vue.set(state.terms, existingTermIndex, term);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state.terms = terms;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const addChildTerm = (state, { term, parent }) => {
|
|
||||||
|
|
||||||
if (parent > 0 ) {
|
|
||||||
for (let aTerm of state.terms) {
|
|
||||||
let parentTerm = t.find(aTerm, [], (node, par) => { return node.id == parent; });
|
|
||||||
if (parentTerm != undefined) {
|
|
||||||
if (parentTerm['children'] == undefined) {
|
|
||||||
Vue.set(parentTerm, 'children', []);
|
|
||||||
}
|
|
||||||
parentTerm['children'].unshift(term);
|
|
||||||
parentTerm.total_children = parentTerm.children.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (state.terms != undefined) {
|
|
||||||
let existingTermIndex = state.terms.findIndex(aTerm => aTerm.id == term.id);
|
|
||||||
if (existingTermIndex >= 0)
|
|
||||||
Vue.set(state.terms, existingTermIndex, term);
|
|
||||||
else
|
|
||||||
state.terms.unshift(term);
|
|
||||||
} else {
|
|
||||||
state.terms = []
|
|
||||||
state.terms.unshift(term);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const updateChildTerm = (state, { term, parent, oldParent }) => {
|
|
||||||
|
|
||||||
if (oldParent == undefined) {
|
|
||||||
if (parent > 0 ) {
|
|
||||||
for (let aTerm of state.terms) {
|
|
||||||
let childTerm = t.find(aTerm, [], (node, par) => { return node.id == term.id; });
|
|
||||||
if (childTerm != undefined) {
|
|
||||||
childTerm = term;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (state.terms != undefined) {
|
|
||||||
for (let i = 0; i < state.terms.length; i++) {
|
|
||||||
if (state.terms[i].id == term.id)
|
|
||||||
Vue.set(state.terms, i, term);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state.terms = []
|
|
||||||
state.terms.push(term);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Removes from old parent
|
|
||||||
deleteChildTerm(term.id, oldParent)
|
|
||||||
// Adds it to new one
|
|
||||||
addChildTerm(term, parent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const deleteChildTerm = ( state, {termId, parent} ) => {
|
|
||||||
|
|
||||||
if (parent > 0 ) {
|
|
||||||
for (let i = 0; i < state.terms.length; i++) {
|
|
||||||
let parentTerm = t.find(state.terms[i], [], (node, par) => { return node.id == parent; });
|
|
||||||
if (parentTerm != undefined) {
|
|
||||||
let index = parentTerm.children.findIndex(deletedTerm => deletedTerm.id == termId);
|
|
||||||
if (index >= 0) {
|
|
||||||
parentTerm.children.splice(index, 1);
|
|
||||||
parentTerm.total_children = parentTerm.children.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (state.terms != undefined) {
|
|
||||||
for (let i = 0; i < state.terms.length; i++) {
|
|
||||||
if (state.terms[i].id == termId)
|
|
||||||
state.terms.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const deleteTerm = ( state, termId ) => {
|
export const deleteTerm = ( state, termId ) => {
|
||||||
let index = state.terms.findIndex(deletedTerm => deletedTerm.id === termId);
|
let index = state.terms.findIndex(deletedTerm => deletedTerm.id === termId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
|
|
@ -983,6 +983,8 @@ return apply_filters( 'tainacan-i18n', [
|
||||||
'info_no_value_compound_metadata' => __( 'No value has been added to this compound metadata.', 'tainacan' ),
|
'info_no_value_compound_metadata' => __( 'No value has been added to this compound metadata.', 'tainacan' ),
|
||||||
/* translators: Refers to the hierarchy of compound metadata. Like in 'Metadata X (child of Metadata Y) */
|
/* translators: Refers to the hierarchy of compound metadata. Like in 'Metadata X (child of Metadata Y) */
|
||||||
'info_child_of' => __( 'child of', 'tainacan' ),
|
'info_child_of' => __( 'child of', 'tainacan' ),
|
||||||
|
/* translators: Refers to the hierarchy of taxonomy terms. Like in 'Macro (child of Photography) */
|
||||||
|
'info_children_of_%s' => __( 'Children of %s', 'tainacan' ),
|
||||||
'info_slides_help_introduction' => __( 'Use the following commands to navigate through the items', 'tainacan' ),
|
'info_slides_help_introduction' => __( 'Use the following commands to navigate through the items', 'tainacan' ),
|
||||||
'info_slides_previous_item' => __( 'to go to the previous item', 'tainacan' ),
|
'info_slides_previous_item' => __( 'to go to the previous item', 'tainacan' ),
|
||||||
'info_slides_next_item' => __( 'to go to the next item', 'tainacan' ),
|
'info_slides_next_item' => __( 'to go to the next item', 'tainacan' ),
|
||||||
|
|
Loading…
Reference in New Issue