diff --git a/src/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-modal.js b/src/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-modal.js
deleted file mode 100644
index 51ee66038..000000000
--- a/src/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-modal.js
+++ /dev/null
@@ -1,309 +0,0 @@
-import tainacan from '../../api-client/axios.js';
-import axios from 'axios';
-
-const { __ } = wp.i18n;
-
-const { TextControl, Button, Modal, CheckboxControl, Spinner } = wp.components;
-
-export default class TermsModal extends React.Component {
- constructor(props) {
- super(props);
-
- // Initialize state
- this.state = {
- searchTermName: '',
- termsRequestSource: undefined,
- terms: [],
- temporarySelectedTerms: [],
- isLoadingTerms: false,
- modalTerms: [],
- totalModalTerms: 0,
- termsPerPage: 24,
- termsPage: 1,
- };
-
- // Bind events
- this.selectTemporaryTerm = this.selectTemporaryTerm.bind(this);
- this.removeTemporaryTermOfId = this.removeTemporaryTermOfId.bind(this);
- this.applySelectedTerms = this.applySelectedTerms.bind(this);
- this.isTemporaryTermSelected = this.isTemporaryTermSelected.bind(this);
- this.toggleSelectTemporaryTerm = this.toggleSelectTemporaryTerm.bind(this);
- this.cancelSelection = this.cancelSelection.bind(this);
- this.selectTerm = this.selectTerm.bind(this);
- this.fetchModalTerms = this.fetchModalTerms.bind(this);
- this.fetchTerms = this.fetchTerms.bind(this);
- }
-
- componentWillMount() {
-
- this.fetchModalTerms();
-
- this.setState( {
- terms: [],
- termsPage: 1,
- temporarySelectedTerms: JSON.parse(JSON.stringify(this.props.selectedTermsObject))
- } );
- }
-
- selectTemporaryTerm(term) {
- let existingTermIndex = this.state.temporarySelectedTerms.findIndex((existingTerm) => existingTerm.id == term.id);
-
- if (existingTermIndex < 0) {
- let aTemporarySelectedTerms = this.state.temporarySelectedTerms;
- aTemporarySelectedTerms.push({
- id: term.id,
- name: term.name,
- url: term.url,
- thumbnail: term.thumbnail
- });
- this.setState({ temporarySelectedTerms: aTemporarySelectedTerms });
- }
- }
-
- removeTemporaryTermOfId(termId) {
-
- let existingTermIndex = this.state.temporarySelectedTerms.findIndex((existingTerm) => existingTerm.id == termId);
-
- if (existingTermIndex >= 0) {
- let aTemporarySelectedTerms = this.state.temporarySelectedTerms;
- aTemporarySelectedTerms.splice(existingTermIndex, 1);
- this.setState({ temporarySelectedTerms: aTemporarySelectedTerms });
- }
- }
-
- applySelectedTerms() {
- let aSelectedTermsObject = JSON.parse(JSON.stringify(this.state.temporarySelectedTerms));
- this.props.onApplySelection(aSelectedTermsObject);
- }
-
- isTemporaryTermSelected(termId) {
- return this.state.temporarySelectedTerms.findIndex(term => term.id == termId) >= 0;
- }
-
- toggleSelectTemporaryTerm(term, isChecked) {
- if (isChecked)
- this.selectTemporaryTerm(term);
- else
- this.removeTemporaryTermOfId(term.id);
- }
-
- cancelSelection() {
-
- this.setState({
- termsPage: 1,
- modalTerms: []
- });
-
- this.props.onCancelSelection();
- }
-
- selectTerm(selectedTermId) {
-
- this.setState({
- termId: selectedTermId
- });
- this.fetchTerm();
- this.fetchModalTerms();
- }
-
- fetchModalTerms() {
-
- let currentModalTerms = this.state.modalTerms;
- if (this.state.termsPage <= 1)
- currentModalTerms = [];
-
- let endpoint = '/terms/?orderby=title&order=asc&perpage=' + this.state.termsPerPage + '&paged=' + this.state.termsPage;
-
- this.setState({
- isLoadingTerms: true,
- modalTerms: currentModalTerms,
- });
-
- tainacan.get(endpoint)
- .then(response => {
-
- for (let term of response.data) {
- currentModalTerms.push({
- name: term.name,
- id: term.id,
- url: term.url,
- thumbnail: [{
- src: term.thumbnail['tainacan-medium'] != undefined ? term.thumbnail['tainacan-medium'][0] : term.thumbnail['medium'][0],
- alt: term.name
- }]
- });
- }
-
- this.setState({
- termsPage: this.state.termsPage + 1,
- isLoadingTerms: false,
- modalTerms: currentModalTerms,
- totalModalTerms: response.headers['x-wp-total']
- });
-
- return currentModalTerms;
- })
- .catch(error => {
- console.log('Error trying to fetch terms: ' + error);
- });
- }
-
- fetchTerms(name) {
- if (this.state.termsRequestSource != undefined)
- this.state.termsRequestSource.cancel('Previous terms search canceled.');
-
- let aTermRequestSource = axios.CancelToken.source();
- this.setState({
- termsRequestSource: aTermRequestSource,
- isLoadingTerms: true
- });
-
- let endpoint = '/terms/?orderby=title&order=asc&perpage=' + this.state.termsPerPage;
-
- if (name != undefined && name != '')
- endpoint += '&search=' + name;
-
- tainacan.get(endpoint, { cancelToken: aTermRequestSource.token })
- .then(response => {
-
- let someTerms = this.state.terms;
- someTerms = response.data.map((term) => ({
- name: term.name,
- id: term.id,
- url: term.url,
- thumbnail: [{
- src: term.thumbnail['tainacan-medium'] != undefined ? term.thumbnail['tainacan-medium'][0] : term.thumbnail['medium'][0],
- alt: term.name
- }]
- }));
-
- this.setState({
- isLoadingTerms: false,
- terms: someTerms
- });
-
- return someTerms;
- })
- .catch(error => {
- console.log('Error trying to fetch terms: ' + error);
- });
- }
-
- render() {
- return (
- { __('Sorry, no terms found.', 'tainacan') } { __('Showing', 'tainacan') + " " + this.state.modalTerms.length + " " + __('of', 'tainacan') + " " + this.state.totalModalTerms + " " + __('terms', 'tainacan') + "."} { __('Sorry, no terms found.', 'tainacan') }
- {
- this.state.terms.map((term) =>
-
- { this.state.isLoadingTerms ?
- {
- this.state.modalTerms.map((term) =>
-
-