diff --git a/src/admin/admin.vue b/src/admin/admin.vue index ca8034f6a..cceda24f5 100644 --- a/src/admin/admin.vue +++ b/src/admin/admin.vue @@ -73,7 +73,7 @@ } .is-main-content { - padding: 0px; + padding: 0px !important; margin: 0 auto; position: relative; overflow-y: auto; @@ -89,8 +89,8 @@ } .is-secondary-content { - padding: 0px; - margin: 94px auto 0 auto; + padding: 0px !important; + margin: 106px auto 0 auto; position: relative; overflow-y: hidden; height: calc(100% - 94px); diff --git a/src/admin/js/theme-main.js b/src/admin/js/theme-main.js index 48152e17d..0c03e8ad9 100644 --- a/src/admin/js/theme-main.js +++ b/src/admin/js/theme-main.js @@ -31,6 +31,7 @@ import FilterTaxonomySelectbox from '../../classes/filter-types/taxonomy/Selectb import TaincanFormItem from '../../classes/metadata-types/tainacan-form-item.vue'; import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue'; import ItemsPage from '../pages/lists/items-page.vue'; +import TermItemsPage from '../pages/lists/term-items-page.vue'; import ViewModeTable from '../../theme-helper/view-mode-table.vue'; import ViewModeCards from '../../theme-helper/view-mode-cards.vue'; import ViewModeRecords from '../../theme-helper/view-mode-records.vue'; @@ -83,6 +84,7 @@ Vue.component('tainacan-filter-taxonomy-selectbox', FilterTaxonomySelectbox); Vue.component('help-button', HelpButton); Vue.component('draggable', draggable); Vue.component('items-page', ItemsPage); +Vue.component('term-items-page', TermItemsPage); // Oficial view modes Vue.component('view-mode-table', ViewModeTable); @@ -95,11 +97,13 @@ Vue.use(eventBusSearch, { store: store, router: routerTheme}); // THEME ITEMS LIST (COLLECTIONS) import ThemeItemsList from '../theme-items-list.vue'; -new Vue({ +export const ThemeItemsListing = new Vue({ el: '#tainacan-items-page', store, router: routerTheme, data: { + termId: '', + taxonomy: '', collectionId: '', defaultViewMode: '', enabledViewModes: {} @@ -114,32 +118,10 @@ new Vue({ if (this.$el.attributes['enabled-view-modes'] != undefined) this.enabledViewModes = this.$el.attributes['enabled-view-modes'].value.split(','); - } - -}); - -// THEME ITEMS LIST (TERMS) -import ThemeTermItemsList from '../theme-term-items-list.vue'; - -new Vue({ - el: '#tainacan-term-items-page', - store, - router: routerTheme, - data: { - termId: '', - defaultViewMode: '', - enabledViewModes: {} - }, - render: h => h(ThemeTermItemsList), - beforeMount () { - if (this.$el.attributes['term-id'] != undefined) this.termId = this.$el.attributes['term-id'].value; - if (this.$el.attributes['default-view-mode'] != undefined) - this.defaultViewMode = this.$el.attributes['default-view-mode'].value; - if (this.$el.attributes['enabled-view-modes'] != undefined) - this.enabledViewModes = this.$el.attributes['enabled-view-modes'].value.split(','); - + if (this.$el.attributes['taxonomy'] != undefined) + this.taxonomy = this.$el.attributes['taxonomy'].value; } }); \ No newline at end of file diff --git a/src/admin/pages/lists/term-items-page.vue b/src/admin/pages/lists/term-items-page.vue index c02487843..9abc81d17 100644 --- a/src/admin/pages/lists/term-items-page.vue +++ b/src/admin/pages/lists/term-items-page.vue @@ -680,8 +680,9 @@ } }, props: { - collectionId: Number, + // collectionId: Number, termId: Number, + taxonomy: String, defaultViewMode: String, // Used only on theme enabledViewModes: Object // Used only on theme }, @@ -1031,12 +1032,13 @@ } }, created() { - + this.isOnTheme = (this.$route.name === null); this.isRepositoryLevel = (this.collectionId === undefined); - this.$eventBusSearch.setCollectionId(this.collectionId); + // this.$eventBusSearch.setCollectionId(this.collectionId); + this.$eventBusSearch.setTerm(this.termId, this.taxonomy); this.$eventBusSearch.updateStoreFromURL(); this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => { diff --git a/src/admin/scss/_tabs.scss b/src/admin/scss/_tabs.scss index 2f2d74cdd..5894a1c6e 100644 --- a/src/admin/scss/_tabs.scss +++ b/src/admin/scss/_tabs.scss @@ -2,7 +2,7 @@ .tabs { a { font-size: 13px; - margin-bottom: -3px; + margin-bottom: -3px !important; &:hover{ border-bottom-color: transparent; text-decoration: none; diff --git a/src/admin/theme-items-list.vue b/src/admin/theme-items-list.vue index 9701bbb12..233172b5d 100644 --- a/src/admin/theme-items-list.vue +++ b/src/admin/theme-items-list.vue @@ -1,9 +1,19 @@ - - - diff --git a/src/js/event-bus-search.js b/src/js/event-bus-search.js index 2203c9027..2416dfb33 100644 --- a/src/js/event-bus-search.js +++ b/src/js/event-bus-search.js @@ -9,7 +9,9 @@ export default { componentsTag: [], errors : [], query: {}, - collectionId: undefined + collectionId: undefined, + taxonomy: undefined, + termId: undefined }, created(){ @@ -305,13 +307,15 @@ export default { } else { this.$emit( 'isLoadingItems', true); - + this.$store.dispatch('collection/fetchItems', { 'collectionId': this.collectionId, - 'isOnTheme': (this.$route.name == null) + 'isOnTheme': (this.$route.name == null), + 'termId': this.termId, + 'taxonomy': this.taxonomy }) .then((res) => { - + this.$emit( 'isLoadingItems', false); this.$emit( 'hasFiltered', res.hasFiltered); @@ -324,10 +328,15 @@ export default { this.$emit( 'isLoadingItems', false); }); } + }, setCollectionId(collectionId) { this.collectionId = collectionId; }, + setTerm(termId, taxonomy) { + this.termId = termId; + this.taxonomy = taxonomy; + }, clearAllFilters() { this.$store.dispatch('search/cleanFilterTags'); this.$store.dispatch('search/cleanMetaQueries'); diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js index bb08fa145..bd1783e78 100644 --- a/src/js/store/modules/collection/actions.js +++ b/src/js/store/modules/collection/actions.js @@ -1,13 +1,13 @@ import axios from '../../../axios/axios'; import qs from 'qs'; -export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, isOnTheme }) => { +export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, isOnTheme, termId, taxonomy }) => { commit('cleanItems'); return new Promise ((resolve, reject) => { // Adds queries for filtering - let postQueries = rootGetters['search/getPostQuery']; + let postQueries = JSON.parse(JSON.stringify(rootGetters['search/getPostQuery'])); // Sets a flag to inform components that an empty sate is or not due to filtering let hasFiltered = false; @@ -26,6 +26,19 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is } } + // Sets term query in case it's on a term items page + if (termId != undefined && taxonomy != undefined) { + + if (postQueries.taxquery == undefined) + postQueries.taxquery = []; + + postQueries.taxquery.push({ + taxonomy: taxonomy, + terms:[ termId ], + compare: 'IN' + }); + } + let query = qs.stringify(postQueries); // Guarantees at least empty fetch_only are passed in case none is found @@ -52,7 +65,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is } else { if (postQueries.admin_view_mode != undefined) postQueries.admin_view_mode = null; - } + } axios.tainacan.get(endpoint+query) .then(res => { diff --git a/src/theme-helper/class-tainacan-theme-helper.php b/src/theme-helper/class-tainacan-theme-helper.php index 7985733d6..ed5b32bfe 100644 --- a/src/theme-helper/class-tainacan-theme-helper.php +++ b/src/theme-helper/class-tainacan-theme-helper.php @@ -81,11 +81,11 @@ class Theme_Helper { public function enqueue_scripts($force = false) { global $TAINACAN_BASE_URL; - if ( $force || is_post_type_archive( \Tainacan\Repositories\Repository::get_collections_db_identifiers() ) ) { + // if ( $force || is_post_type_archive( \Tainacan\Repositories\Repository::get_collections_db_identifiers() ) ) { //\Tainacan\Admin::get_instance()->add_admin_js(); wp_enqueue_script('tainacan-search', $TAINACAN_BASE_URL . '/assets/user_search-components.js' , [] , null, true); wp_localize_script('tainacan-search', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params()); - } + // } } public function is_post_an_item(\WP_Post $post) { @@ -305,7 +305,7 @@ class Theme_Helper { $atts = shortcode_atts( array( 'collection-id' => '', - 'term' => '', + 'term-id' => '', ), $atts ); @@ -314,6 +314,9 @@ class Theme_Helper { if (isset($atts['collection-id'])) { $params = "collection-id=" . $atts['collection-id']; } + if (isset($atts['term-id'])) { + $params = "term-id=" . $atts['term-id']; + } $this->enqueue_scripts(true); diff --git a/src/theme-helper/template-tags.php b/src/theme-helper/template-tags.php index b1f1e6b6a..c210a19ea 100644 --- a/src/theme-helper/template-tags.php +++ b/src/theme-helper/template-tags.php @@ -198,7 +198,7 @@ function tainacan_the_faceted_search() { if ($term) { $props .= 'term-id="' . $term->term_id . '" '; $props .= 'taxonomy="' . $term->taxonomy . '" '; - $id = 'tainacan-term-items-page'; + $id = 'tainacan-items-page'; } echo "
";