Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
71c11b8ed3
|
@ -416,9 +416,11 @@
|
|||
</transition>
|
||||
<footer class="footer">
|
||||
<!-- Sequence Progress -->
|
||||
<div class="sequence-progress-background"/>
|
||||
<div
|
||||
v-if="itemPosition != undefined && group != null && group.items_count != undefined"
|
||||
v-if="isOnSequenceEdit"
|
||||
class="sequence-progress-background"/>
|
||||
<div
|
||||
v-if="isOnSequenceEdit && itemPosition != undefined && group != null && group.items_count != undefined"
|
||||
:style="{ width: (itemPosition/group.items_count)*100 + '%' }"
|
||||
class="sequence-progress"/>
|
||||
|
||||
|
|
|
@ -187,8 +187,7 @@
|
|||
<!-- Title -->
|
||||
<div
|
||||
:style="{
|
||||
'padding-left': !collectionId ? '0.5rem !important' : '2.75rem',
|
||||
'margin-left': !collectionId ? '0 !important' : '24px'
|
||||
'padding-left': !collectionId ? '0 !important' : '1rem'
|
||||
}"
|
||||
@click="onClickItem($event, item, index)"
|
||||
class="metadata-title">
|
||||
|
|
|
@ -417,7 +417,7 @@
|
|||
|
||||
this.getOptions(0);
|
||||
}
|
||||
}, 300),
|
||||
}, 500),
|
||||
highlightHierarchyPath(){
|
||||
for(let [index, el] of this.hierarchicalPath.entries()){
|
||||
let htmlEl = this.$refs[`${el.column}.${el.element}-tainacan-li-checkbox-model`][0].$el;
|
||||
|
|
|
@ -1235,6 +1235,11 @@
|
|||
beforeDestroy() {
|
||||
this.$off();
|
||||
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.$eventBusSearch.searchCancel != undefined)
|
||||
this.$eventBusSearch.searchCancel.cancel('Item search Canceled.');
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
});
|
||||
this.selectedValues();
|
||||
},
|
||||
search( query ){
|
||||
search: _.debounce( function(query) {
|
||||
if (query != '') {
|
||||
let promise = null;
|
||||
this.options = [];
|
||||
|
@ -117,7 +117,7 @@
|
|||
} else {
|
||||
this.cleanSearch();
|
||||
}
|
||||
},
|
||||
}, 500),
|
||||
selectedValues(){
|
||||
const instance = this;
|
||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
search( query ){
|
||||
search: _.debounce( function(query) {
|
||||
let promise = null;
|
||||
this.options = [];
|
||||
let valuesToIgnore = [];
|
||||
|
@ -155,7 +155,7 @@
|
|||
.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
});
|
||||
},
|
||||
}, 500),
|
||||
selectedValues(){
|
||||
const instance = this;
|
||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
search( query ){
|
||||
search: _.debounce( function(query) {
|
||||
this.isLoading = true;
|
||||
this.options = [];
|
||||
|
||||
|
@ -161,7 +161,7 @@
|
|||
this.isLoading = false;
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
}, 500),
|
||||
selectedValues( taxonomy ){
|
||||
if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) )
|
||||
return false;
|
||||
|
|
|
@ -117,7 +117,9 @@ class Old_Tainacan extends Importer{
|
|||
foreach ($this->get_repo_metadata() as $metadata) {
|
||||
|
||||
if (isset($metadata->slug) && strpos($metadata->slug, 'socialdb_property_fixed') === false) {
|
||||
$metadatum_id = $this->create_metadata( $metadata );
|
||||
$metadatum_id = $this->create_metadata( $metadata );
|
||||
} elseif ( strpos($metadata->slug, 'socialdb_property_fixed_tags') !== false ){
|
||||
$metadatum_id = $this->create_metadata( $metadata );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -150,6 +152,14 @@ class Old_Tainacan extends Importer{
|
|||
$map[$metadatum_id] = $metadatum_old->id;
|
||||
}
|
||||
|
||||
} else if( isset($metadatum_old->slug) && strpos($metadatum_old->slug, 'socialdb_property_fixed_tags') !== false
|
||||
&& isset($metadatum_old->type) && strpos($metadatum_old->type, 'checkbox') !== false
|
||||
){
|
||||
$metadatum_id = $this->create_metadata( $metadatum_old, $collection_id );
|
||||
$this->add_log('Creating tag');
|
||||
if( $metadatum_id ){
|
||||
$map[$metadatum_id] = $metadatum_old->id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -383,10 +393,6 @@ class Old_Tainacan extends Importer{
|
|||
$value = $values;
|
||||
}
|
||||
|
||||
if( is_array($value) ){
|
||||
$value = array_filter($value);
|
||||
}
|
||||
|
||||
$item_metadata->set_value($value);
|
||||
|
||||
} else if( $metadatum->type === 'item' ){ // RELATIONSHIPS
|
||||
|
@ -711,6 +717,8 @@ class Old_Tainacan extends Importer{
|
|||
* @return int $metadatum_id
|
||||
*/
|
||||
protected function create_metadata( $node_metadata_old, $collection_id = null){
|
||||
$this->add_log('Creating metadata' . $meta->name);
|
||||
|
||||
$newMetadatum = new Entities\Metadatum();
|
||||
$meta = $node_metadata_old;
|
||||
|
||||
|
@ -841,7 +849,7 @@ class Old_Tainacan extends Importer{
|
|||
$type = "Numeric";
|
||||
} else if(strcmp($type, 'item') === 0) {
|
||||
$type = "Relationship";
|
||||
} else if(strcmp($type, 'tree') === 0 || strcmp($type, 'selectbox')) {
|
||||
} else if(strcmp($type, 'tree') === 0 || strcmp($type, 'selectbox') || strcmp($type, 'checkbox')) {
|
||||
$type = "Taxonomy";
|
||||
} else if(strcmp($type, 'compound') === 0) {
|
||||
$type = "Compound";
|
||||
|
|
|
@ -12,4 +12,6 @@ export const wp = axios.create({
|
|||
|
||||
wp.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce;
|
||||
|
||||
export default { tainacan, wp };
|
||||
export const CancelToken = axios.CancelToken;
|
||||
|
||||
export default { tainacan, wp, CancelToken };
|
|
@ -11,7 +11,8 @@ export default {
|
|||
query: {},
|
||||
collectionId: undefined,
|
||||
taxonomy: undefined,
|
||||
termId: undefined
|
||||
termId: undefined,
|
||||
searchCancel: undefined
|
||||
},
|
||||
created(){
|
||||
|
||||
|
@ -304,24 +305,37 @@ export default {
|
|||
// Forces fetch_only to be filled before any search happens
|
||||
if (this.$store.getters['search/getPostQuery']['fetch_only'] == undefined) {
|
||||
this.$emit( 'hasToPrepareMetadataAndFilters', to);
|
||||
} else {
|
||||
} else {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.searchCancel != undefined)
|
||||
this.searchCancel.cancel('Item search Canceled.');
|
||||
|
||||
this.$store.dispatch('collection/fetchItems', {
|
||||
'collectionId': this.collectionId,
|
||||
'isOnTheme': (this.$route.name == null),
|
||||
'termId': this.termId,
|
||||
'taxonomy': this.taxonomy
|
||||
})
|
||||
.then((res) => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
this.$emit( 'hasFiltered', res.hasFiltered);
|
||||
}).then((resp) => {
|
||||
|
||||
if(res.advancedSearchResults){
|
||||
this.$emit('advancedSearchResults', res.advancedSearchResults);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
// The actual fetch item request
|
||||
resp.request.then((res) => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
this.$emit( 'hasFiltered', res.hasFiltered);
|
||||
|
||||
if(res.advancedSearchResults){
|
||||
this.$emit('advancedSearchResults', res.advancedSearchResults);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.searchCancel = resp.source;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -1,97 +1,110 @@
|
|||
import axios from '../../../axios/axios';
|
||||
import axios, { CancelToken } from '../../../axios/axios';
|
||||
import qs from 'qs';
|
||||
|
||||
// THE ITEMS SEARCH
|
||||
export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, isOnTheme, termId, taxonomy }) => {
|
||||
commit('cleanItems');
|
||||
|
||||
return new Promise ((resolve, reject) => {
|
||||
|
||||
// Adds queries for filtering
|
||||
let postQueries = JSON.parse(JSON.stringify(rootGetters['search/getPostQuery']));
|
||||
const source = CancelToken.source();
|
||||
|
||||
// Sets a flag to inform components that an empty sate is or not due to filtering
|
||||
let hasFiltered = false;
|
||||
let advancedSearchResults = false;
|
||||
return new Object({
|
||||
request: new Promise ((resolve, reject) => {
|
||||
|
||||
// Adds queries for filtering
|
||||
let postQueries = JSON.parse(JSON.stringify(rootGetters['search/getPostQuery']));
|
||||
|
||||
if ( (postQueries.metaquery != undefined &&
|
||||
(Object.keys(postQueries.metaquery).length > 0 ||
|
||||
postQueries.metaquery.length > 0)) || (postQueries.taxquery != undefined &&
|
||||
(Object.keys(postQueries.taxquery).length > 0 ||
|
||||
postQueries.taxquery.length > 0)) ) {
|
||||
|
||||
hasFiltered = true;
|
||||
// Sets a flag to inform components that an empty sate is or not due to filtering
|
||||
let hasFiltered = false;
|
||||
let advancedSearchResults = false;
|
||||
|
||||
if(postQueries.advancedSearch){
|
||||
advancedSearchResults = postQueries.advancedSearch;
|
||||
if ( (postQueries.metaquery != undefined &&
|
||||
(Object.keys(postQueries.metaquery).length > 0 ||
|
||||
postQueries.metaquery.length > 0)) || (postQueries.taxquery != undefined &&
|
||||
(Object.keys(postQueries.taxquery).length > 0 ||
|
||||
postQueries.taxquery.length > 0)) ) {
|
||||
|
||||
hasFiltered = true;
|
||||
|
||||
if(postQueries.advancedSearch){
|
||||
advancedSearchResults = postQueries.advancedSearch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
if (qs.stringify(postQueries.fetch_only) == ''){
|
||||
dispatch('search/add_fetchonly', {}, { root: true });
|
||||
}
|
||||
|
||||
if (qs.stringify(postQueries.fetch_only['meta']) == ''){
|
||||
dispatch('search/add_fetchonly_meta', 0, { root: true });
|
||||
}
|
||||
|
||||
// Differentiates between repository level and collection level queries
|
||||
let endpoint = '/collection/'+ collectionId +'/items?';
|
||||
|
||||
if (collectionId == undefined){
|
||||
endpoint = '/items?';
|
||||
}
|
||||
|
||||
if (!isOnTheme){
|
||||
if (postQueries.view_mode != undefined)
|
||||
postQueries.view_mode = null;
|
||||
|
||||
endpoint = endpoint + 'context=edit&'
|
||||
} else {
|
||||
if (postQueries.admin_view_mode != undefined)
|
||||
postQueries.admin_view_mode = null;
|
||||
}
|
||||
|
||||
axios.tainacan.get(endpoint+query)
|
||||
.then(res => {
|
||||
|
||||
let items = res.data;
|
||||
let viewModeObject = tainacan_plugin.registered_view_modes[postQueries.view_mode];
|
||||
// Sets term query in case it's on a term items page
|
||||
if (termId != undefined && taxonomy != undefined) {
|
||||
|
||||
if (isOnTheme && viewModeObject != undefined && viewModeObject.type == 'template') {
|
||||
commit('setItemsListTemplate', items);
|
||||
resolve({'itemsListTemplate': items, 'total': res.headers['x-wp-total'], hasFiltered: hasFiltered, advancedSearchResults: advancedSearchResults});
|
||||
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
|
||||
if (qs.stringify(postQueries.fetch_only) == ''){
|
||||
dispatch('search/add_fetchonly', {}, { root: true });
|
||||
}
|
||||
|
||||
if (qs.stringify(postQueries.fetch_only['meta']) == ''){
|
||||
dispatch('search/add_fetchonly_meta', 0, { root: true });
|
||||
}
|
||||
|
||||
// Differentiates between repository level and collection level queries
|
||||
let endpoint = '/collection/'+ collectionId +'/items?';
|
||||
|
||||
if (collectionId == undefined){
|
||||
endpoint = '/items?';
|
||||
}
|
||||
|
||||
if (!isOnTheme){
|
||||
if (postQueries.view_mode != undefined)
|
||||
postQueries.view_mode = null;
|
||||
|
||||
endpoint = endpoint + 'context=edit&'
|
||||
} else {
|
||||
commit('setItems', items);
|
||||
resolve({
|
||||
'items': items,
|
||||
'total': res.headers['x-wp-total'],
|
||||
totalPages: res.headers['x-wp-totalpages'],
|
||||
hasFiltered: hasFiltered,
|
||||
advancedSearchResults: advancedSearchResults });
|
||||
}
|
||||
dispatch('search/setTotalItems', res.headers['x-wp-total'], { root: true } );
|
||||
dispatch('search/setTotalPages', res.headers['x-wp-totalpages'], { root: true } );
|
||||
})
|
||||
.catch(error => reject(error));
|
||||
if (postQueries.admin_view_mode != undefined)
|
||||
postQueries.admin_view_mode = null;
|
||||
}
|
||||
|
||||
axios.tainacan.get(endpoint+query, {
|
||||
cancelToken: source.token
|
||||
})
|
||||
.then(res => {
|
||||
|
||||
let items = res.data;
|
||||
let viewModeObject = tainacan_plugin.registered_view_modes[postQueries.view_mode];
|
||||
|
||||
if (isOnTheme && viewModeObject != undefined && viewModeObject.type == 'template') {
|
||||
commit('setItemsListTemplate', items);
|
||||
resolve({'itemsListTemplate': items, 'total': res.headers['x-wp-total'], hasFiltered: hasFiltered, advancedSearchResults: advancedSearchResults});
|
||||
} else {
|
||||
commit('setItems', items);
|
||||
resolve({
|
||||
'items': items,
|
||||
'total': res.headers['x-wp-total'],
|
||||
totalPages: res.headers['x-wp-totalpages'],
|
||||
hasFiltered: hasFiltered,
|
||||
advancedSearchResults: advancedSearchResults });
|
||||
}
|
||||
dispatch('search/setTotalItems', res.headers['x-wp-total'], { root: true } );
|
||||
dispatch('search/setTotalPages', res.headers['x-wp-totalpages'], { root: true } );
|
||||
})
|
||||
.catch((thrown) => {
|
||||
if (axios.isCancel(thrown)) {
|
||||
console.log('Request canceled: ', thrown.message);
|
||||
} else {
|
||||
reject(thrown);
|
||||
}
|
||||
});
|
||||
}),
|
||||
source: source
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
export const deleteItem = ({ commit }, { itemId, isPermanently }) => {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<p>{{ $i18n.get('info_no_item_found') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<!-- RECORDS VIEW MODE -->
|
||||
<!-- MASONRY VIEW MODE -->
|
||||
<masonry
|
||||
:cols="{default: 7, 1919: 6, 1407: 5, 1215: 4, 1023: 3, 767: 2, 343: 1}"
|
||||
:gutter="25"
|
||||
|
|
Loading…
Reference in New Issue