Major Advanced Search refactor #321.
This commit is contained in:
parent
61f138fd33
commit
d95871e254
|
@ -750,12 +750,11 @@ class REST_Items_Controller extends REST_Controller {
|
|||
private function get_items_permissions_check_for_taxonomy($taxonomies) {
|
||||
|
||||
foreach ($taxonomies as $tax) {
|
||||
if( !isset($tax['taxonomy']) )
|
||||
return false;
|
||||
if ( isset($tax['taxonomy']) ) {
|
||||
$taxonomy = \tainacan_taxonomies()->fetch_by_db_identifier( $tax['taxonomy'] );
|
||||
|
||||
if( $taxonomy instanceof Entities\Taxonomy ) {
|
||||
if(!$taxonomy->can_read()) {
|
||||
if ( $taxonomy instanceof Entities\Taxonomy ) {
|
||||
if (!$taxonomy->can_read())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -429,7 +429,6 @@
|
|||
this.isUpdating = false;
|
||||
this.closedByForm = true;
|
||||
|
||||
this.$root.$emit('metadatumUpdated', this.isRepositoryLevel);
|
||||
this.$emit('onEditionFinished');
|
||||
})
|
||||
.catch((errors) => {
|
||||
|
@ -468,7 +467,6 @@
|
|||
this.isUpdating = false;
|
||||
this.closedByForm = true;
|
||||
|
||||
this.$root.$emit('metadatumUpdated', this.isRepositoryLevel);
|
||||
this.$emit('onEditionFinished');
|
||||
})
|
||||
.catch((errors) => {
|
||||
|
|
|
@ -59,38 +59,12 @@
|
|||
icon-right="magnify"
|
||||
icon-right-clickable
|
||||
@icon-right-click="updateSearch()" />
|
||||
<b-dropdown
|
||||
<router-link
|
||||
v-if="!$adminOptions.hideTainacanHeaderAdvancedSearch"
|
||||
ref="advancedSearchShortcut"
|
||||
class="advanced-search-header-dropdown"
|
||||
position="is-bottom-left"
|
||||
aria-role="list"
|
||||
trap-focus>
|
||||
<a
|
||||
class="advanced-search-text"
|
||||
slot="trigger">
|
||||
:to="$routerHelper.getItemsPath({ advancedSearch: true })">
|
||||
{{ $i18n.get('advanced_search') }}
|
||||
</a>
|
||||
<b-dropdown-item aria-role="listitem">
|
||||
<div :style="{'height': '25px'}">
|
||||
<p class="is-pulled-left advanced-search-text-di">{{ $i18n.get('advanced_search') }}</p>
|
||||
<span
|
||||
style="margin-top: 5px; margin-right: -2px;"
|
||||
class="icon is-pulled-right">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-arrowup has-text-secondary"/>
|
||||
</span>
|
||||
</div>
|
||||
<hr class="advanced-search-hr">
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item
|
||||
style="padding-left: 0 !important; padding-right: 0 !important;"
|
||||
:custom="true"
|
||||
aria-role="listitem">
|
||||
<advanced-search
|
||||
:is-repository-level="true"
|
||||
:is-header="true"/>
|
||||
</b-dropdown-item>
|
||||
</b-dropdown>
|
||||
</router-link>
|
||||
|
||||
</div>
|
||||
<button
|
||||
|
@ -130,13 +104,11 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import AdvancedSearch from '../search/advanced-search.vue';
|
||||
import ProcessesPopup from '../other/processes-popup.vue';
|
||||
|
||||
export default {
|
||||
name: 'TainacanHeader',
|
||||
components: {
|
||||
AdvancedSearch,
|
||||
ProcessesPopup
|
||||
},
|
||||
data() {
|
||||
|
@ -150,41 +122,22 @@
|
|||
}
|
||||
},
|
||||
created(){
|
||||
this.$root.$on('closeAdvancedSearchShortcut', () => {
|
||||
if (this.$refs.advancedSearchShortcut)
|
||||
this.$refs.advancedSearchShortcut.toggle();
|
||||
});
|
||||
this.$root.$on('openProcessesPopup', () => {
|
||||
this.showProcesses = true;
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('closeAdvancedSearchShortcut');
|
||||
this.$root.$off('openProcessesPopup');
|
||||
},
|
||||
methods: {
|
||||
// toItemsPage() {
|
||||
// if(this.$route.path == '/items') {
|
||||
// this.$root.$emit('openAdvancedSearch', true);
|
||||
// }
|
||||
//
|
||||
// if(this.$route.path != '/items') {
|
||||
// this.$router.push({
|
||||
// path: '/items',
|
||||
// query: {
|
||||
// advancedSearch: true
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
updateSearch() {
|
||||
if (this.$route.path != '/items') {
|
||||
if (this.$route.path !== '/items') {
|
||||
this.$router.push({
|
||||
path: '/items',
|
||||
});
|
||||
}
|
||||
|
||||
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -273,6 +226,10 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 28px;
|
||||
.advanced-search-text {
|
||||
font-size: 0.75em;
|
||||
margin-left: 12px;
|
||||
}
|
||||
.control {
|
||||
.search-header {
|
||||
border: 1px solid var(--tainacan-gray2);
|
||||
|
|
|
@ -1,57 +1,38 @@
|
|||
<template>
|
||||
<div>
|
||||
<section
|
||||
:style="{ position: relative }"
|
||||
v-if="!metadata || metadata.length <= 0"
|
||||
class="field is-grouped-centered section">
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
:active.sync="metadataIsLoading"/>
|
||||
<div
|
||||
v-if="!metadataIsLoading"
|
||||
class="content has-text-gray has-text-centered">
|
||||
<p>
|
||||
<span class="icon is-large">
|
||||
<i class="tainacan-icon tainacan-icon-36px tainacan-icon-metadata"/>
|
||||
</span>
|
||||
</p>
|
||||
<p>{{ isRepositoryLevel ?
|
||||
$i18n.get('info_there_are_no_metadata_in_repository_level' ) :
|
||||
$i18n.get('info_there_are_no_metadata_to_search' ) }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<div
|
||||
v-else
|
||||
:style="advancedSearchResults ? { 'padding-top': '0' } : { 'padding-top': '1.25em' }"
|
||||
:class="{ 'padding-in-header': isHeader, 'padding-regular': !isHeader }"
|
||||
class="tnc-advanced-search-container">
|
||||
|
||||
<div
|
||||
v-show="!advancedSearchResults"
|
||||
<div class="tnc-advanced-search-container">
|
||||
<transition-group name="filter-item">
|
||||
<b-field
|
||||
v-for="searchCriterion in searchCriteria"
|
||||
:key="searchCriterion"
|
||||
class="field is-12 tainacan-form">
|
||||
|
||||
<b-field
|
||||
class="columns"
|
||||
grouped>
|
||||
grouped
|
||||
class="tainacan-form">
|
||||
|
||||
<!-- Metadata (Search criteria) -->
|
||||
<b-field
|
||||
:class="{'is-3': isHeader}"
|
||||
class="column">
|
||||
<b-field class="column">
|
||||
<b-select
|
||||
:loading="isLoadingMetadata"
|
||||
:placeholder="$i18n.get('instruction_select_a_metadatum')"
|
||||
:disabled="advancedSearchQuery.taxquery[searchCriterion] ||
|
||||
advancedSearchQuery.metaquery[searchCriterion] ? true : false"
|
||||
:value="advancedSearchQuery.metaquery[searchCriterion] ?
|
||||
advancedSearchQuery.metaquery[searchCriterion].originalMeta :
|
||||
(advancedSearchQuery.taxquery[searchCriterion] ? advancedSearchQuery.taxquery[searchCriterion].originalMeta : undefined)"
|
||||
@input="addToAdvancedSearchQuery($event, 'metadatum', searchCriterion)">
|
||||
<template v-for="(metadatum, metadatumIndex) in metadata">
|
||||
:disabled="(advancedSearchQuery.taxquery[searchCriterion] || advancedSearchQuery.metaquery[searchCriterion]) ? true : false"
|
||||
:value="(
|
||||
advancedSearchQuery.metaquery[searchCriterion] ? advancedSearchQuery.metaquery[searchCriterion].key : null
|
||||
) || (
|
||||
advancedSearchQuery.taxquery[searchCriterion] ? advancedSearchQuery.taxquery[searchCriterion].key : null
|
||||
)"
|
||||
@input="addMetadatumToAdvancedSearchQuery(
|
||||
{
|
||||
metadatumId: $event,
|
||||
type: (metadataAsObject[$event] && metadataAsObject[$event].metadata_type_object) ? metadataAsObject[$event].metadata_type_object.primitive_type : '',
|
||||
taxonomy: (metadataAsObject[$event] && metadataAsObject[$event].metadata_type_options) ? metadataAsObject[$event].metadata_type_options.taxonomy : ''
|
||||
},
|
||||
searchCriterion
|
||||
)">
|
||||
<template v-for="(metadatum, metadatumIndex) in metadataAsArray">
|
||||
<option
|
||||
v-if="metadatum.metadata_type_object.component !== 'tainacan-user' && metadatum.metadata_type_object.component !== 'tainacan-relationship' && metadatum.metadata_type_object.component !== 'tainacan-compound' && metadatum.parent <= 0"
|
||||
:value="`${metadatum.id}-${metadatum.metadata_type_options.taxonomy}-${metadatum.metadata_type_object.primitive_type}`"
|
||||
v-if="metadatum.metadata_type_object.component !== 'tainacan-user' &&
|
||||
metadatum.metadata_type_object.component !== 'tainacan-relationship' &&
|
||||
metadatum.metadata_type_object.component !== 'tainacan-compound' &&
|
||||
metadatum.parent <= 0"
|
||||
:value="metadatum.id"
|
||||
:key="metadatumIndex">
|
||||
{{ metadatum.name }}
|
||||
</option>
|
||||
|
@ -62,7 +43,7 @@
|
|||
<option
|
||||
v-for="(childMetadatum, childIndex) of metadatum.metadata_type_options.children_objects"
|
||||
:key="childIndex"
|
||||
:value="`${childMetadatum.id}-${childMetadatum.metadata_type_options.taxonomy}-${childMetadatum.metadata_type_object.primitive_type}`">
|
||||
:value="childMetadatum.id">
|
||||
{{ childMetadatum.name }}
|
||||
</option>
|
||||
</optgroup>
|
||||
|
@ -73,48 +54,13 @@
|
|||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<!-- Inputs -->
|
||||
<b-field
|
||||
:class="{'is-half': !isHeader}"
|
||||
class="column">
|
||||
<b-input
|
||||
v-if="advancedSearchQuery.metaquery[searchCriterion] &&
|
||||
advancedSearchQuery.metaquery[searchCriterion].ptype != 'date'"
|
||||
:type="advancedSearchQuery.metaquery[searchCriterion].ptype == 'int' ||
|
||||
advancedSearchQuery.metaquery[searchCriterion].ptype == 'float' ? 'number' : 'text'"
|
||||
step="any"
|
||||
@input="addValueToAdvancedSearchQuery($event, 'value', searchCriterion)"
|
||||
:value="advancedSearchQuery.metaquery[searchCriterion].value"
|
||||
/>
|
||||
<input
|
||||
v-else-if="advancedSearchQuery.metaquery[searchCriterion] &&
|
||||
advancedSearchQuery.metaquery[searchCriterion].ptype == 'date'"
|
||||
class="input"
|
||||
:value="parseValidDateToNavigatorLanguage(advancedSearchQuery.metaquery[searchCriterion].value)"
|
||||
v-mask="dateMask"
|
||||
@focus="addValueToAdvancedSearchQueryWithoutDelay($event, '', searchCriterion)"
|
||||
@input="addValueToAdvancedSearchQueryWithoutDelay($event, 'value', searchCriterion)"
|
||||
:placeholder="dateFormat"
|
||||
type="text" >
|
||||
<b-input
|
||||
v-else-if="advancedSearchQuery.taxquery[searchCriterion]"
|
||||
:value="advancedSearchQuery.taxquery[searchCriterion].terms"
|
||||
@input="addValueToAdvancedSearchQuery($event, 'term_value', searchCriterion)"
|
||||
type="text" />
|
||||
<b-input
|
||||
v-else
|
||||
type="text"
|
||||
disabled />
|
||||
</b-field>
|
||||
|
||||
<!-- Comparators -->
|
||||
<b-field
|
||||
:class="{'is-3': isHeader}"
|
||||
class="column">
|
||||
<b-field class="column">
|
||||
<b-select
|
||||
:loading="isLoadingMetadata"
|
||||
v-if="advancedSearchQuery.taxquery[searchCriterion] ||
|
||||
advancedSearchQuery.metaquery[searchCriterion] ? true : false"
|
||||
@input="addToAdvancedSearchQuery($event, 'comparator', searchCriterion)"
|
||||
@input="addComparatorToAdvancedSearchQuery($event, searchCriterion)"
|
||||
:value="advancedSearchQuery.taxquery[searchCriterion] ?
|
||||
advancedSearchQuery.taxquery[searchCriterion].operator :
|
||||
(advancedSearchQuery.metaquery[searchCriterion] ? advancedSearchQuery.metaquery[searchCriterion].compare : '')">
|
||||
|
@ -131,11 +77,38 @@
|
|||
disabled />
|
||||
</b-field>
|
||||
|
||||
<!-- Inputs -->
|
||||
<b-field class="column is-half">
|
||||
<b-input
|
||||
v-if="advancedSearchQuery.metaquery[searchCriterion] && getAdvancedSearchQueryCriterionMetadataType(searchCriterion) != 'date'"
|
||||
:type="(getAdvancedSearchQueryCriterionMetadataType(searchCriterion) == 'int' || getAdvancedSearchQueryCriterionMetadataType(searchCriterion) == 'float') ? 'number' : 'text'"
|
||||
step="any"
|
||||
@input="addValueToAdvancedSearchQuery($event, searchCriterion)"
|
||||
:value="advancedSearchQuery.metaquery[searchCriterion].value"
|
||||
/>
|
||||
<input
|
||||
v-else-if="getAdvancedSearchQueryCriterionMetadataType(searchCriterion) == 'date'"
|
||||
class="input"
|
||||
:value="parseValidDateToNavigatorLanguage(advancedSearchQuery.metaquery[searchCriterion].value)"
|
||||
v-mask="dateMask"
|
||||
@input="addValueToAdvancedSearchQuery($event.target.value, searchCriterion)"
|
||||
:placeholder="dateFormat"
|
||||
type="text" >
|
||||
<b-input
|
||||
v-else-if="advancedSearchQuery.taxquery[searchCriterion]"
|
||||
:value="advancedSearchQuery.taxquery[searchCriterion].terms"
|
||||
@input="addValueToAdvancedSearchQuery($event, searchCriterion)"
|
||||
type="text" />
|
||||
<b-input
|
||||
v-else
|
||||
type="text"
|
||||
disabled />
|
||||
</b-field>
|
||||
|
||||
<div class="field">
|
||||
<button
|
||||
@click="removeThis(searchCriterion)"
|
||||
:class="{'has-text-blue4': isHeader, 'has-text-secondary': !isHeader,}"
|
||||
class="button is-white is-pulled-right">
|
||||
@click="removeCriterion(searchCriterion)"
|
||||
class="button is-white is-pulled-right has-text-secondary">
|
||||
<span
|
||||
v-tooltip="{
|
||||
content: $i18n.get('remove_search_criterion'),
|
||||
|
@ -143,19 +116,16 @@
|
|||
placement: 'auto-end'
|
||||
}"
|
||||
class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-close"/>
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-cancel"/>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
</b-field>
|
||||
</transition-group>
|
||||
|
||||
<!-- Add button -->
|
||||
<div
|
||||
v-show="!advancedSearchResults"
|
||||
:class="{'add-link-advanced-search-header': isHeader, 'add-link-advanced-search': !isHeader }"
|
||||
class="field column is-12">
|
||||
<div class="add-link-advanced-search">
|
||||
<a
|
||||
@click="addSearchCriteria"
|
||||
style="font-size: 0.75em;">
|
||||
|
@ -169,64 +139,41 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Tags -->
|
||||
<div
|
||||
v-show="advancedSearchResults"
|
||||
class="column is-12">
|
||||
<b-field
|
||||
grouped
|
||||
group-multiline>
|
||||
<div
|
||||
v-for="searchCriterion in searchCriteria"
|
||||
:key="searchCriterion"
|
||||
class="control taginput-container">
|
||||
<b-tag
|
||||
v-if="advancedSearchQuery.taxquery[searchCriterion] && advancedSearchQuery.taxquery[searchCriterion].terms"
|
||||
type="is-white"
|
||||
class="is-rounded"
|
||||
@close="removeThis(searchCriterion); searchAdvanced();"
|
||||
attached
|
||||
closable>
|
||||
{{ advancedSearchQuery.taxquery[searchCriterion].terms }}
|
||||
</b-tag>
|
||||
<b-tag
|
||||
v-else-if="advancedSearchQuery.metaquery[searchCriterion] && advancedSearchQuery.metaquery[searchCriterion].value"
|
||||
type="is-white"
|
||||
class="is-rounded"
|
||||
@close="removeThis(searchCriterion); searchAdvanced();"
|
||||
attached
|
||||
:loading="isFetching"
|
||||
closable>
|
||||
{{ advancedSearchQuery.metaquery[searchCriterion].value }}
|
||||
</b-tag>
|
||||
</div>
|
||||
</b-field>
|
||||
</div>
|
||||
|
||||
<!-- Clear and search button -->
|
||||
<div v-show="!advancedSearchResults">
|
||||
<div class="field is-grouped is-pulled-right">
|
||||
<div class="field is-grouped is-justify-content-flex-end">
|
||||
<p
|
||||
v-if="Object.keys(advancedSearchQuery.taxquery).length > 0 ||
|
||||
Object.keys(advancedSearchQuery.metaquery).length > 0"
|
||||
v-if="Object.keys(advancedSearchQuery.taxquery).length > 0 || Object.keys(advancedSearchQuery.metaquery).length > 0"
|
||||
class="control">
|
||||
<button
|
||||
@click="clearSearch"
|
||||
@click="clearSearch(); performAdvancedSearch();"
|
||||
class="button is-outlined">{{ $i18n.get('clear_search') }}</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<button
|
||||
@click="searchAdvanced"
|
||||
class="button is-success">{{ $i18n.get('search') }}</button>
|
||||
@click="performAdvancedSearch()"
|
||||
class="button is-success">{{ $i18n.get('apply') }}</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section
|
||||
v-if="!isLoadingMetadata && metadataAsArray && metadataAsArray.length <= 0"
|
||||
class="field is-grouped-centered section">
|
||||
<div class="content has-text-gray has-text-centered">
|
||||
<p>
|
||||
<span class="icon is-large">
|
||||
<i class="tainacan-icon tainacan-icon-36px tainacan-icon-metadata"/>
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
{{ isRepositoryLevel ? $i18n.get('info_there_are_no_metadata_in_repository_level' ) : $i18n.get('info_there_are_no_metadata_to_search' ) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { mapActions } from 'vuex';
|
||||
import { dateInter } from '../../js/mixins.js';
|
||||
import moment from 'moment';
|
||||
|
@ -236,10 +183,7 @@
|
|||
mixins: [ dateInter ],
|
||||
props: {
|
||||
isRepositoryLevel: false,
|
||||
isHeader: false,
|
||||
advancedSearchResults: false,
|
||||
openFormAdvancedSearch: false,
|
||||
isDoingSearch: false,
|
||||
hasAdvancedSearchResults: false,
|
||||
collectionId: ''
|
||||
},
|
||||
data() {
|
||||
|
@ -268,54 +212,14 @@
|
|||
metaquery: {},
|
||||
taxquery: {}
|
||||
},
|
||||
metadataIsLoading: false,
|
||||
metadata: [],
|
||||
isLoadingMetadata: false,
|
||||
metadataAsObject: {},
|
||||
metadataAsArray: [],
|
||||
metadataSearchCancel: undefined
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isDoingSearch() {
|
||||
if (this.isDoingSearch)
|
||||
this.searchAdvanced();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
this.$root.$on('metadatumUpdated', (isRepositoryLevel) => {
|
||||
|
||||
if (isRepositoryLevel) {
|
||||
this.metadataIsLoading = true;
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.isRepositoryLevel ? false : this.collectionId,
|
||||
isRepositoryLevel: this.isRepositoryLevel,
|
||||
isContextEdit: false,
|
||||
includeDisabled: false,
|
||||
isAdvancedSearch: true,
|
||||
parent: 'any'
|
||||
}).then((resp) => {
|
||||
resp.request
|
||||
.then((metadata) => {
|
||||
this.metadata = metadata;
|
||||
this.metadataIsLoading = false;
|
||||
}).catch(() => {
|
||||
this.metadataIsLoading = false;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
})
|
||||
.catch(() => this.metadataIsLoading = false);
|
||||
}
|
||||
});
|
||||
},
|
||||
created() {
|
||||
|
||||
this.metadataIsLoading = true;
|
||||
this.isLoadingMetadata = true;
|
||||
|
||||
this.fetchMetadata({
|
||||
collectionId: this.isRepositoryLevel ? false : this.collectionId,
|
||||
|
@ -327,67 +231,26 @@
|
|||
}).then((resp) => {
|
||||
resp.request
|
||||
.then((metadata) => {
|
||||
this.metadata = metadata;
|
||||
this.metadataIsLoading = false;
|
||||
}).catch(() => {
|
||||
this.metadataIsLoading = false;
|
||||
// We create and object keyed by IDs to easily match the query params,
|
||||
// but keep an array version to use the order in the select
|
||||
this.metadataAsArray = metadata;
|
||||
metadata.forEach(metadatum => {
|
||||
this.metadataAsObject[metadatum.id] = metadatum;
|
||||
});
|
||||
|
||||
// Search Request Token for cancelling
|
||||
this.metadataSearchCancel = resp.source;
|
||||
|
||||
this.buildAdvancedSearchQueryFromRoute();
|
||||
|
||||
this.isLoadingMetadata = false;
|
||||
}).catch(() => {
|
||||
this.isLoadingMetadata = false;
|
||||
});
|
||||
})
|
||||
.catch(() => this.metadataIsLoading = false);
|
||||
|
||||
if ((this.$route.query.metaquery && Object.keys(this.$route.query.metaquery).length > 0) ||
|
||||
(this.$route.query.taxquery && Object.keys(this.$route.query.taxquery).length > 0) ) {
|
||||
this.searchCriteria = [];
|
||||
}
|
||||
|
||||
if (this.$route.query.metaquery && Object.keys(this.$route.query.metaquery).length > 0) {
|
||||
|
||||
let metaquery = this.$route.query.metaquery;
|
||||
|
||||
for(let meta in metaquery)
|
||||
this.$set(this.advancedSearchQuery.metaquery, `${meta}`, metaquery[meta]);
|
||||
|
||||
let keys = Object.keys(this.advancedSearchQuery.metaquery);
|
||||
|
||||
let relationIndex = keys.findIndex((element) => element == 'relation');
|
||||
|
||||
if (relationIndex != -1)
|
||||
keys.splice(relationIndex, 1);
|
||||
|
||||
for(let k of keys)
|
||||
this.searchCriteria.push(k);
|
||||
|
||||
}
|
||||
|
||||
if (this.$route.query.taxquery && Object.keys(this.$route.query.taxquery).length > 0) {
|
||||
let taxquery = this.$route.query.taxquery;
|
||||
|
||||
for(let tax in taxquery)
|
||||
this.$set(this.advancedSearchQuery.taxquery, `${tax}`, taxquery[tax]);
|
||||
|
||||
let keys = Object.keys(this.advancedSearchQuery.taxquery);
|
||||
|
||||
let relationIndex = keys.findIndex((element) => element == 'relation');
|
||||
|
||||
if (relationIndex != -1)
|
||||
keys.splice(relationIndex, 1);
|
||||
|
||||
for (let k of keys)
|
||||
this.searchCriteria.push(k);
|
||||
}
|
||||
|
||||
// If we're coming from a preset advanced search, execute it!
|
||||
if (this.searchCriteria.length && !this.isHeader) {
|
||||
this.$eventBusSearch.updateStoreFromURL();
|
||||
this.searchAdvanced();
|
||||
}
|
||||
.catch(() => this.isLoadingMetadata = false);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$off('metadatumUpdated');
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.metadataSearchCancel != undefined)
|
||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||
|
@ -401,25 +264,77 @@
|
|||
if (this.advancedSearchQuery.taxquery[searchCriterion]) {
|
||||
return this.taxqueryOperators;
|
||||
} else if (this.advancedSearchQuery.metaquery[searchCriterion]) {
|
||||
if (this.advancedSearchQuery.metaquery[searchCriterion].ptype == 'int' ||
|
||||
this.advancedSearchQuery.metaquery[searchCriterion].ptype == 'float' ||
|
||||
this.advancedSearchQuery.metaquery[searchCriterion].ptype == 'date') {
|
||||
const metadataType = this.getAdvancedSearchQueryCriterionMetadataType(searchCriterion);
|
||||
if (metadataType == 'date' || metadataType == 'int' || metadataType == 'float')
|
||||
return this.metaqueryOperatorsForInterval;
|
||||
} else{
|
||||
else
|
||||
return this.metaqueryOperatorsRegular;
|
||||
}
|
||||
},
|
||||
buildAdvancedSearchQueryFromRoute() {
|
||||
if (
|
||||
(this.$route.query.metaquery && Object.keys(this.$route.query.metaquery).length > 0) ||
|
||||
(this.$route.query.taxquery && Object.keys(this.$route.query.taxquery).length > 0)
|
||||
) {
|
||||
this.searchCriteria = [];
|
||||
}
|
||||
|
||||
if (this.$route.query.metaquery && Object.keys(this.$route.query.metaquery).length > 0) {
|
||||
|
||||
let metaquery = this.$route.query.metaquery;
|
||||
|
||||
for (let meta in metaquery) {
|
||||
if ( this.metaqueryOperatorsRegular.hasOwnProperty(metaquery[meta]['operator']) || this.metaqueryOperatorsForInterval.hasOwnProperty(metaquery[meta]['operator']) )
|
||||
this.$set(this.advancedSearchQuery.metaquery, `${meta}`, metaquery[meta]);
|
||||
}
|
||||
|
||||
let metakeys = Object.keys(this.advancedSearchQuery.metaquery);
|
||||
|
||||
let relationIndex = metakeys.findIndex((element) => element == 'relation');
|
||||
|
||||
if (relationIndex != -1)
|
||||
metakeys.splice(relationIndex, 1);
|
||||
|
||||
for (let metakey of metakeys)
|
||||
this.searchCriteria.push(metakey);
|
||||
|
||||
}
|
||||
|
||||
if (this.$route.query.taxquery && Object.keys(this.$route.query.taxquery).length > 0) {
|
||||
let taxquery = this.$route.query.taxquery;
|
||||
|
||||
for (let tax in taxquery) {
|
||||
if ( this.taxqueryOperators.hasOwnProperty(taxquery[tax]['operator']) )
|
||||
this.$set(this.advancedSearchQuery.taxquery, `${tax}`, taxquery[tax]);
|
||||
}
|
||||
|
||||
let taxkeys = Object.keys(this.advancedSearchQuery.taxquery);
|
||||
|
||||
let relationIndex = taxkeys.findIndex((element) => element == 'relation');
|
||||
|
||||
if (relationIndex != -1)
|
||||
taxkeys.splice(relationIndex, 1);
|
||||
|
||||
for (let taxkey of taxkeys)
|
||||
this.searchCriteria.push(taxkey);
|
||||
}
|
||||
|
||||
// If we're coming from a preset advanced search, execute it!
|
||||
if (this.searchCriteria.length) {
|
||||
this.$eventBusSearch.updateStoreFromURL();
|
||||
this.performAdvancedSearch();
|
||||
}
|
||||
},
|
||||
removeThis(searchCriterion) {
|
||||
removeCriterion(searchCriterion) {
|
||||
let criteriaIndex = this.searchCriteria.findIndex((element) => element == searchCriterion);
|
||||
|
||||
if (criteriaIndex >= 0)
|
||||
this.searchCriteria.splice(criteriaIndex, 1);
|
||||
|
||||
if (this.advancedSearchQuery.taxquery[searchCriterion])
|
||||
delete this.advancedSearchQuery.taxquery[searchCriterion];
|
||||
else if (this.advancedSearchQuery.metaquery[searchCriterion])
|
||||
delete this.advancedSearchQuery.metaquery[searchCriterion];
|
||||
|
||||
},
|
||||
addSearchCriteria() {
|
||||
let aleatoryKey = Math.floor(Math.random() * (1000 - 2 + 1)) + 2;
|
||||
|
@ -442,34 +357,72 @@
|
|||
convertDateToMatchInDB(dateValue) {
|
||||
return moment(dateValue, this.dateFormat).toISOString().split('T')[0];
|
||||
},
|
||||
addValueToAdvancedSearchQueryWithoutDelay($event, type, searchCriterion) {
|
||||
if (type == '') {
|
||||
this.$set($event.target, 'value', '');
|
||||
this.addToAdvancedSearchQuery('', 'value', searchCriterion);
|
||||
} else {
|
||||
this.addToAdvancedSearchQuery($event.target.value, type, searchCriterion);
|
||||
}
|
||||
parseValidDateToNavigatorLanguage(date) {
|
||||
if (date && date.length === this.dateMask.length)
|
||||
return (
|
||||
moment(date, this.dateFormat).toISOString(true) &&
|
||||
moment(date, this.dateFormat).toISOString(true).split('T') &&
|
||||
moment(date, this.dateFormat).toISOString(true).split('T')[0]
|
||||
) ? this.parseDateToNavigatorLanguage(moment(date, this.dateFormat).toISOString(true).split('T')[0]) : this.parseDateToNavigatorLanguage(date);
|
||||
else
|
||||
return date;
|
||||
},
|
||||
addValueToAdvancedSearchQuery: _.debounce(function(value, type, searchCriterion) {
|
||||
this.addToAdvancedSearchQuery(value, type, searchCriterion);
|
||||
}, 900),
|
||||
searchAdvanced() {
|
||||
addMetadatumToAdvancedSearchQuery({ metadatumId, type, taxonomy }, index) {
|
||||
if (!metadatumId)
|
||||
return;
|
||||
|
||||
if (this.isHeader) {
|
||||
this.$root.$emit('closeAdvancedSearchShortcut', true);
|
||||
|
||||
if (this.$route.path == '/items')
|
||||
this.$root.$emit('openAdvancedSearch', true);
|
||||
|
||||
if (this.$route.path != '/items') {
|
||||
this.$router.push({
|
||||
path: '/items',
|
||||
if (type === 'term') {
|
||||
// Was selected a taxonomy criteria
|
||||
this.advancedSearchQuery.taxquery = Object.assign({}, this.advancedSearchQuery.taxquery, {
|
||||
[`${index}`]: {
|
||||
key: metadatumId,
|
||||
taxonomy: taxonomy,
|
||||
operator: 'LIKE'
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Was selected a metadatum criteria
|
||||
if (type != 'date' && type != 'int' && type != 'float') {
|
||||
this.advancedSearchQuery.metaquery = Object.assign({}, this.advancedSearchQuery.metaquery, {
|
||||
[`${index}`]: {
|
||||
key: metadatumId,
|
||||
compare: 'LIKE'
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.advancedSearchQuery.metaquery = Object.assign({}, this.advancedSearchQuery.metaquery, {
|
||||
[`${index}`]: {
|
||||
key: metadatumId,
|
||||
compare: '='
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
addValueToAdvancedSearchQuery(value, index) {
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
if (Object.keys(this.advancedSearchQuery.taxquery).length > 0 &&
|
||||
Object.keys(this.advancedSearchQuery.metaquery).length > 0) {
|
||||
if (this.advancedSearchQuery.metaquery[index])
|
||||
this.$set(this.advancedSearchQuery.metaquery[index], 'value', value);
|
||||
else if (this.advancedSearchQuery.taxquery[index])
|
||||
this.$set(this.advancedSearchQuery.taxquery[index], 'terms', value);
|
||||
},
|
||||
addComparatorToAdvancedSearchQuery(comparator, index) {
|
||||
if (!comparator)
|
||||
return;
|
||||
|
||||
if (this.advancedSearchQuery.metaquery[index])
|
||||
this.$set(this.advancedSearchQuery.metaquery[index], 'compare', comparator);
|
||||
else if (this.advancedSearchQuery.taxquery[index])
|
||||
this.$set(this.advancedSearchQuery.taxquery[index], 'operator', comparator);
|
||||
},
|
||||
performAdvancedSearch() {
|
||||
|
||||
if (
|
||||
Object.keys(this.advancedSearchQuery.taxquery).length > 0 &&
|
||||
Object.keys(this.advancedSearchQuery.metaquery).length > 0
|
||||
) {
|
||||
this.advancedSearchQuery.relation = 'AND';
|
||||
}
|
||||
|
||||
|
@ -482,7 +435,7 @@
|
|||
if (Object.keys(this.advancedSearchQuery.metaquery).length > 0) {
|
||||
|
||||
for (let metaquery in this.advancedSearchQuery.metaquery) {
|
||||
if (this.advancedSearchQuery.metaquery[metaquery].ptype == 'date') {
|
||||
if (this.getAdvancedSearchQueryCriterionMetadataType(metaquery) == 'date') {
|
||||
let value = this.advancedSearchQuery.metaquery[metaquery].value;
|
||||
|
||||
if (value.includes('/'))
|
||||
|
@ -499,81 +452,31 @@
|
|||
if (this.advancedSearchQuery.hasOwnProperty('relation') && Object.keys(this.advancedSearchQuery).length <= 3)
|
||||
delete this.advancedSearchQuery.relation;
|
||||
|
||||
|
||||
if (Object.keys(this.advancedSearchQuery.metaquery).length > 0) {
|
||||
|
||||
for (let metaquery in this.advancedSearchQuery.metaquery) {
|
||||
if (this.advancedSearchQuery.metaquery[metaquery].ptype == 'date') {
|
||||
if (this.getAdvancedSearchQueryCriterionMetadataType(metaquery) == 'date') {
|
||||
let value = this.advancedSearchQuery.metaquery[metaquery].value;
|
||||
|
||||
setTimeout(() => {
|
||||
if (value.includes('-'))
|
||||
this.$set(this.advancedSearchQuery.metaquery[metaquery], 'value', this.parseValidDateToNavigatorLanguage(value));
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.$eventBusSearch.$emit('searchAdvanced', this.advancedSearchQuery);
|
||||
|
||||
this.$eventBusSearch.$emit('performAdvancedSearch', this.advancedSearchQuery);
|
||||
},
|
||||
parseValidDateToNavigatorLanguage(date) {
|
||||
if (date && date.length === this.dateMask.length) {
|
||||
return (moment(date, this.dateFormat).toISOString() && moment(date, this.dateFormat).toISOString().split('T') && moment(date, this.dateFormat).toISOString().split('T')[0]) ? this.parseDateToNavigatorLanguage(moment(date, this.dateFormat).toISOString().split('T')[0]) : this.parseDateToNavigatorLanguage(date);
|
||||
} else
|
||||
return date;
|
||||
},
|
||||
addToAdvancedSearchQuery(value, type, searchCriterion) {
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
if (type == 'metadatum') {
|
||||
const criteriaKey = value.split('-');
|
||||
|
||||
if (criteriaKey[1] != 'undefined') {
|
||||
// Was selected a taxonomy criteria
|
||||
this.advancedSearchQuery.taxquery = Object.assign({}, this.advancedSearchQuery.taxquery, {
|
||||
[`${searchCriterion}`]: {
|
||||
taxonomy: criteriaKey[1],
|
||||
operator: 'LIKE',
|
||||
originalMeta: value,
|
||||
taxonomy_id: Number(criteriaKey[1].match(/[\d]+/)),
|
||||
isFetching: 0,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Was selected a metadatum criteria
|
||||
if (criteriaKey[2] != 'date' && criteriaKey[2] != 'int' && criteriaKey[2] != 'float') {
|
||||
this.advancedSearchQuery.metaquery = Object.assign({}, this.advancedSearchQuery.metaquery, {
|
||||
[`${searchCriterion}`]: {
|
||||
key: criteriaKey[0],
|
||||
compare: 'LIKE',
|
||||
originalMeta: value,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.advancedSearchQuery.metaquery = Object.assign({}, this.advancedSearchQuery.metaquery, {
|
||||
[`${searchCriterion}`]: {
|
||||
key: Number(criteriaKey[0]),
|
||||
compare: '=',
|
||||
originalMeta: value,
|
||||
}
|
||||
});
|
||||
getAdvancedSearchQueryCriterionMetadataType(searchCriterion) {
|
||||
if (this.advancedSearchQuery.metaquery[searchCriterion] &&
|
||||
this.advancedSearchQuery.metaquery[searchCriterion].key &&
|
||||
this.metadataAsObject[this.advancedSearchQuery.metaquery[searchCriterion].key] &&
|
||||
this.metadataAsObject[this.advancedSearchQuery.metaquery[searchCriterion].key].metadata_type_object
|
||||
) {
|
||||
return this.metadataAsObject[this.advancedSearchQuery.metaquery[searchCriterion].key].metadata_type_object.primitive_type
|
||||
}
|
||||
|
||||
this.$set(this.advancedSearchQuery.metaquery[searchCriterion], 'ptype', criteriaKey[2]);
|
||||
return '';
|
||||
}
|
||||
} else if (type == "term_value") {
|
||||
this.$set(this.advancedSearchQuery.taxquery[searchCriterion], 'terms', value);
|
||||
} else if (type == 'value') {
|
||||
this.$set(this.advancedSearchQuery.metaquery[searchCriterion], 'value', value);
|
||||
} else if (type == 'comparator') {
|
||||
if (this.advancedSearchQuery.taxquery[searchCriterion])
|
||||
this.$set(this.advancedSearchQuery.taxquery[searchCriterion], 'operator', value);
|
||||
else if (this.advancedSearchQuery.metaquery[searchCriterion])
|
||||
this.$set(this.advancedSearchQuery.metaquery[searchCriterion], 'compare', value);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -581,23 +484,16 @@
|
|||
<style lang="scss">
|
||||
|
||||
#advanced-search-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.loading-overlay {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.padding-in-header {
|
||||
padding: 1.5em;
|
||||
}
|
||||
|
||||
.padding-regular {
|
||||
padding-right: var(--tainacan-one-column);
|
||||
padding-left: var(--tainacan-one-column);
|
||||
width: calc(100% - (2 * var(--tainacan-one-column)));
|
||||
margin: 0.5em var(--tainacan-one-column) 0.875em;
|
||||
background: var(--tainacan-input-background-color);
|
||||
border: 1px solid var(--tainacan-input-border-color);
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.tnc-advanced-search-container {
|
||||
padding: 1em;
|
||||
padding-top: 3.5em;
|
||||
|
||||
.column {
|
||||
padding: 0 0.5em 0.75em !important;
|
||||
|
@ -613,32 +509,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.taginput-container {
|
||||
min-height: 32px !important;
|
||||
|
||||
.tags {
|
||||
margin-bottom: calc(0.275em - 1px) !important;
|
||||
|
||||
.tag {
|
||||
height: 2em !important;
|
||||
padding-left: 0.75em !important;
|
||||
padding-right: 0.75em !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.add-link-advanced-search {
|
||||
margin-top: -15px !important;
|
||||
padding-left: 8px !important;
|
||||
}
|
||||
|
||||
.add-link-advanced-search-header {
|
||||
margin-top: -20px !important;
|
||||
padding: 0 !important;
|
||||
margin-left: -5px !important;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.is-12>.columns {
|
||||
flex-wrap: wrap;
|
||||
|
@ -651,82 +525,4 @@
|
|||
|
||||
}
|
||||
|
||||
.advanced-search-header-dropdown {
|
||||
height: 27px !important;
|
||||
|
||||
a, .has-text-secondary {
|
||||
color: var(--tainacan-blue4) !important;
|
||||
}
|
||||
|
||||
.select:not(.is-multiple)::after {
|
||||
color: var(--tainacan-blue3) !important;
|
||||
|
||||
option:checked, option:hover {
|
||||
background-color: var(--tainacan-gray2) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
font-size: 1.15em;
|
||||
width: 800px !important;
|
||||
padding-bottom: 1.25em !important;
|
||||
}
|
||||
|
||||
.field.is-grouped .field.column {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.field.is-grouped .field + .field {
|
||||
margin-left: 0.25em;
|
||||
}
|
||||
|
||||
.autocomplete {
|
||||
.dropdown-menu {
|
||||
top: auto !important;
|
||||
min-width: 100% !important;
|
||||
|
||||
.dropdown-content {
|
||||
width: auto !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
.dropdown-item {
|
||||
padding: 0.375em 1.5em !important;
|
||||
}
|
||||
.dropdown-item:hover {
|
||||
background-color: unset !important;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1087px) {
|
||||
.dropdown-menu {
|
||||
top: -2px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
span.icon:not(.is-right) {
|
||||
position: relative !important;
|
||||
}
|
||||
}
|
||||
|
||||
.advanced-search-text {
|
||||
margin: 0 12px;
|
||||
font-size: 0.75em;
|
||||
color: var(--tainacan-gray5);
|
||||
}
|
||||
|
||||
.advanced-search-text-di {
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
color: var(--tainacan-gray5);
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.advanced-search-hr {
|
||||
height: 1px;
|
||||
margin: 4px 0;
|
||||
background-color: var(--tainacan-blue3);
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
|
@ -26,12 +26,12 @@ export default {
|
|||
this.$root.$on('closeAdvancedSearch', () => {
|
||||
this.$store.dispatch('search/setPage', 1);
|
||||
|
||||
this.searchAdvanced({});
|
||||
this.performAdvancedSearch({});
|
||||
});
|
||||
|
||||
this.$root.$on('searchAdvanced', advancedSearchQuery => {
|
||||
this.$root.$on('performAdvancedSearch', advancedSearchQuery => {
|
||||
this.$store.dispatch('search/setPage', 1);
|
||||
this.searchAdvanced(advancedSearchQuery);
|
||||
this.performAdvancedSearch(advancedSearchQuery);
|
||||
|
||||
this.updateURLQueries();
|
||||
});
|
||||
|
@ -177,7 +177,7 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
searchAdvanced(data) {
|
||||
performAdvancedSearch(data) {
|
||||
this.$store.dispatch('search/set_advanced_query', data);
|
||||
this.updateURLQueries();
|
||||
},
|
||||
|
@ -385,9 +385,8 @@ export default {
|
|||
this.$emit( 'isLoadingItems', false);
|
||||
this.$emit( 'hasFiltered', res.hasFiltered);
|
||||
|
||||
if (res.advancedSearchResults){
|
||||
this.$emit('advancedSearchResults', res.advancedSearchResults);
|
||||
}
|
||||
if (res.hasAdvancedSearchResults)
|
||||
this.$emit('hasAdvancedSearchResults', res.hasAdvancedSearchResults);
|
||||
})
|
||||
.catch(() => {
|
||||
this.$emit( 'isLoadingItems', false);
|
||||
|
|
|
@ -25,7 +25,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
|
||||
// Sets a flag to inform components that an empty sate is or not due to filtering
|
||||
let hasFiltered = false;
|
||||
let advancedSearchResults = false;
|
||||
let hasAdvancedSearchResults = false;
|
||||
|
||||
// We mark as filtered if there is a metaquery, taxquery or a postin
|
||||
if (
|
||||
|
@ -43,7 +43,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
hasFiltered = true;
|
||||
|
||||
if (postQueries.advancedSearch)
|
||||
advancedSearchResults = postQueries.advancedSearch;
|
||||
hasAdvancedSearchResults = postQueries.advancedSearch;
|
||||
}
|
||||
|
||||
// Admin default tab should load publish, private and draft statuses
|
||||
|
@ -93,7 +93,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
'itemsListTemplate': res.data.template,
|
||||
'total': res.headers['x-wp-total'],
|
||||
hasFiltered: hasFiltered,
|
||||
advancedSearchResults: advancedSearchResults,
|
||||
hasAdvancedSearchResults: hasAdvancedSearchResults,
|
||||
itemsPerPage: res.headers['x-wp-itemperpage']});
|
||||
} else {
|
||||
commit('setItems', items);
|
||||
|
@ -102,7 +102,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
'total': res.headers['x-wp-total'],
|
||||
totalPages: res.headers['x-wp-totalpages'],
|
||||
hasFiltered: hasFiltered,
|
||||
advancedSearchResults: advancedSearchResults ,
|
||||
hasAdvancedSearchResults: hasAdvancedSearchResults ,
|
||||
itemsPerPage: res.headers['x-wp-itemperpage'] });
|
||||
}
|
||||
dispatch('search/setTotalItems', res.headers['x-wp-total'], { root: true } );
|
||||
|
|
|
@ -9,27 +9,8 @@
|
|||
|
||||
<!-- PAGE TITLE --------------------- -->
|
||||
<tainacan-title
|
||||
v-if="!$adminOptions.hideItemsListPageTitle && !openAdvancedSearch"
|
||||
v-if="!$adminOptions.hideItemsListPageTitle"
|
||||
:bread-crumb-items="[{ path: '', label: this.$i18n.get('items') }]"/>
|
||||
<div
|
||||
v-else-if="openAdvancedSearch"
|
||||
class="tnc-advanced-search-close">
|
||||
<div class="advanced-search-criteria-title">
|
||||
<div class="is-flex">
|
||||
<h1>{{ $i18n.get('info_search_criteria') }}</h1>
|
||||
<div
|
||||
:style="{'margin-bottom': 'auto'}"
|
||||
class="field is-grouped">
|
||||
<a
|
||||
class="back-link"
|
||||
@click="openAdvancedSearch = false">
|
||||
{{ $i18n.get('back') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SEARCH CONTROL ------------------------- -->
|
||||
<h3
|
||||
|
@ -41,7 +22,6 @@
|
|||
aria-labelledby="search-control-landmark"
|
||||
role="region"
|
||||
ref="search-control"
|
||||
v-if="((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
|
||||
class="search-control"
|
||||
:style="( $adminOptions.itemsSingleSelectionMode || $adminOptions.itemsMultipleSelectionMode || $adminOptions.itemsSearchSelectionMode ) ? '--tainacan-container-padding: 6px;' : ''">
|
||||
|
||||
|
@ -75,9 +55,7 @@
|
|||
</button>
|
||||
|
||||
<!-- Text simple search -->
|
||||
<div
|
||||
v-if="!openAdvancedSearch"
|
||||
class="search-control-item">
|
||||
<div class="search-control-item">
|
||||
<div
|
||||
role="search"
|
||||
class="search-area">
|
||||
|
@ -95,15 +73,19 @@
|
|||
<a
|
||||
v-if="!$adminOptions.hideItemsListAdvancedSearch"
|
||||
@click="openAdvancedSearch = !openAdvancedSearch; $eventBusSearch.clearAllFilters();"
|
||||
style="font-size: 0.75em;"
|
||||
class="has-text-secondary is-pulled-right">{{ $i18n.get('advanced_search') }}</a>
|
||||
class="advanced-search-toggle has-text-secondary"
|
||||
:class="openAdvancedSearch ? 'is-open' : 'is-closed'">
|
||||
{{ $i18n.get('advanced_search') }}
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-search" />
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item Creation Dropdown (or button, if few options are available) -->
|
||||
<div
|
||||
v-if="!$adminOptions.hideItemsListCreationDropdown &&
|
||||
!openAdvancedSearch &&
|
||||
collection &&
|
||||
collection.current_user_can_edit_items"
|
||||
class="search-control-item">
|
||||
|
@ -478,6 +460,7 @@
|
|||
@mousemove="handleMouseMoveOverList">
|
||||
|
||||
<!-- ADVANCED SEARCH -->
|
||||
<transition name="item-appear">
|
||||
<div
|
||||
id="advanced-search-container"
|
||||
role="search"
|
||||
|
@ -486,33 +469,13 @@
|
|||
<advanced-search
|
||||
:collection-id="collectionId"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
:advanced-search-results="advancedSearchResults"
|
||||
:open-form-advanced-search="openFormAdvancedSearch"
|
||||
:is-doing-search="isDoingSearch"/>
|
||||
|
||||
<div class="advanced-search-form-submit">
|
||||
<p
|
||||
v-if="advancedSearchResults"
|
||||
class="control">
|
||||
<button
|
||||
aria-controls="items-list-results"
|
||||
@click="advancedSearchResults = !advancedSearchResults"
|
||||
class="button is-outlined">{{ $i18n.get('edit_search') }}</button>
|
||||
</p>
|
||||
<p
|
||||
v-if="advancedSearchResults"
|
||||
class="control">
|
||||
<button
|
||||
aria-controls="items-list-results"
|
||||
@click="isDoingSearch = !isDoingSearch"
|
||||
class="button is-success">{{ $i18n.get('search') }}</button>
|
||||
</p>
|
||||
</div>
|
||||
:has-advanced-search-results="hasAdvancedSearchResults" />
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<!-- STATUS TABS, only on Admin -------- -->
|
||||
<items-status-tabs
|
||||
v-if="!openAdvancedSearch && !$adminOptions.hideItemsListStatusTabs"
|
||||
v-if="!$adminOptions.hideItemsListStatusTabs"
|
||||
:is-repository-level="isRepositoryLevel"/>
|
||||
|
||||
<!-- FILTERS TAG LIST-->
|
||||
|
@ -557,7 +520,7 @@
|
|||
v-if="hasAnOpenAlert &&
|
||||
isSortingByCustomMetadata &&
|
||||
!showLoading &&
|
||||
((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
|
||||
((openAdvancedSearch && hasAdvancedSearchResults) || !openAdvancedSearch)"
|
||||
class="metadata-alert">
|
||||
<p class="text">
|
||||
{{
|
||||
|
@ -584,7 +547,7 @@
|
|||
<items-list
|
||||
v-if="!showLoading &&
|
||||
totalItems > 0 &&
|
||||
((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
|
||||
((openAdvancedSearch && hasAdvancedSearchResults) || !openAdvancedSearch)"
|
||||
:collection-id="collectionId"
|
||||
:displayed-metadata="displayedMetadata"
|
||||
:items="items"
|
||||
|
@ -634,7 +597,7 @@
|
|||
<div ref="items-pagination">
|
||||
<pagination
|
||||
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
|
||||
v-if="totalItems > 0 && (advancedSearchResults || !openAdvancedSearch)"/>
|
||||
v-if="totalItems > 0 && (hasAdvancedSearchResults || !openAdvancedSearch)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -679,9 +642,7 @@
|
|||
localDisplayedMetadata: [],
|
||||
registeredViewModes: tainacan_plugin.registered_view_modes,
|
||||
openAdvancedSearch: false,
|
||||
openFormAdvancedSearch: false,
|
||||
advancedSearchResults: false,
|
||||
isDoingSearch: false,
|
||||
hasAdvancedSearchResults: false,
|
||||
sortingMetadata: [],
|
||||
isFiltersModalActive: false,
|
||||
hasAnOpenModal: false,
|
||||
|
@ -746,7 +707,7 @@
|
|||
openAdvancedSearch(newValue) {
|
||||
if (newValue == false){
|
||||
this.$eventBusSearch.$emit('closeAdvancedSearch');
|
||||
this.advancedSearchResults = false;
|
||||
this.hasAdvancedSearchResults = false;
|
||||
this.isFiltersModalActive = true;
|
||||
} else {
|
||||
this.isFiltersModalActive = false;
|
||||
|
@ -790,8 +751,8 @@
|
|||
this.hasFiltered = hasFiltered;
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('advancedSearchResults', advancedSearchResults => {
|
||||
this.advancedSearchResults = advancedSearchResults;
|
||||
this.$eventBusSearch.$on('hasAdvancedSearchResults', hasAdvancedSearchResults => {
|
||||
this.hasAdvancedSearchResults = hasAdvancedSearchResults;
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', () => {
|
||||
|
@ -1327,7 +1288,7 @@
|
|||
// $eventBusSearch
|
||||
this.$eventBusSearch.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$off('hasFiltered');
|
||||
this.$eventBusSearch.$off('advancedSearchResults');
|
||||
this.$eventBusSearch.$off('hasAdvancedSearchResults');
|
||||
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
|
||||
}
|
||||
}
|
||||
|
@ -1373,7 +1334,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
.advanced-search-results-title {
|
||||
.has-advanced-search-results-title {
|
||||
margin-bottom: 40px;
|
||||
margin: 0 var(--tainacan-one-column) 42px var(--tainacan-one-column);
|
||||
|
||||
|
@ -1516,7 +1477,7 @@
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
.search-area .is-pulled-right {
|
||||
.search-area .advanced-search-toggle {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
@ -1538,7 +1499,7 @@
|
|||
padding-right: 0;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
.is-pulled-right {
|
||||
.advanced-search-toggle.is-closed {
|
||||
position: relative;
|
||||
right: 0px !important;
|
||||
}
|
||||
|
@ -1627,15 +1588,43 @@
|
|||
width: 100%;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.is-pulled-right {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 100%;
|
||||
}
|
||||
a {
|
||||
a.advanced-search-toggle {
|
||||
margin-left: 12px;
|
||||
white-space: nowrap;
|
||||
position: absolute;
|
||||
transition: font-size 0.2s ease, right 0.3s ease, left 0.3s ease, top 0.4s ease;
|
||||
|
||||
.icon {
|
||||
transition: opacity 0.2s ease, max-width 0.2s ease;
|
||||
}
|
||||
|
||||
&.is-closed {
|
||||
font-size: 0.75em;
|
||||
right: 15px;
|
||||
left: unset;
|
||||
top: 100%;
|
||||
|
||||
.icon {
|
||||
display: 0;
|
||||
opacity: 0.0;
|
||||
max-width: 0;
|
||||
}
|
||||
}
|
||||
&.is-open {
|
||||
font-size: 1em;
|
||||
right: unset;
|
||||
left: 15px;
|
||||
top: 6.125em;
|
||||
z-index: 9;
|
||||
|
||||
.icon {
|
||||
display: inline;
|
||||
opacity: 1.0;
|
||||
max-width: 1.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -560,8 +560,6 @@ export default {
|
|||
.then(() => {
|
||||
if (!this.isRepositoryLevel)
|
||||
this.updateMetadataOrder();
|
||||
else
|
||||
this.$root.$emit('metadatumUpdated', this.isRepositoryLevel);
|
||||
})
|
||||
.catch(() => {
|
||||
this.$console.log("Error deleting metadatum.")
|
||||
|
|
|
@ -9,57 +9,6 @@
|
|||
}"
|
||||
aria-live="polite">
|
||||
|
||||
<!-- ADVANCED SEARCH -->
|
||||
<div
|
||||
id="advanced-search-container"
|
||||
role="search"
|
||||
v-if="openAdvancedSearch && !hideAdvancedSearch">
|
||||
|
||||
<div class="tnc-advanced-search-close">
|
||||
<div class="advanced-search-criteria-title">
|
||||
<div class="is-flex">
|
||||
<h1>{{ $i18n.get('info_search_criteria') }}</h1>
|
||||
<div
|
||||
:style="{'margin-bottom': 'auto'}"
|
||||
class="field is-grouped">
|
||||
<a
|
||||
class="back-link"
|
||||
@click="openAdvancedSearch = false">
|
||||
{{ $i18n.get('back') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<advanced-search
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
:collection-id="collectionId"
|
||||
:advanced-search-results="advancedSearchResults"
|
||||
:open-form-advanced-search="openFormAdvancedSearch"
|
||||
:is-doing-search="isDoingSearch"/>
|
||||
|
||||
<div class="advanced-search-form-submit">
|
||||
<p
|
||||
v-if="advancedSearchResults"
|
||||
class="control">
|
||||
<button
|
||||
aria-controls="items-list-results"
|
||||
@click="advancedSearchResults = !advancedSearchResults"
|
||||
class="button is-outlined">{{ $i18n.get('edit_search') }}</button>
|
||||
</p>
|
||||
<p
|
||||
v-if="advancedSearchResults"
|
||||
class="control">
|
||||
<button
|
||||
aria-controls="items-list-results"
|
||||
@click="isDoingSearch = !isDoingSearch"
|
||||
class="button is-success">{{ $i18n.get('search') }}</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SEARCH CONTROL ------------------------- -->
|
||||
<h3
|
||||
id="search-control-landmark"
|
||||
|
@ -70,7 +19,7 @@
|
|||
:aria-label="$i18n.get('label_sort_visualization')"
|
||||
role="region"
|
||||
ref="search-control"
|
||||
v-if="!(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen) && ((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
|
||||
v-if="!(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen)"
|
||||
class="search-control">
|
||||
|
||||
<!-- <b-loading
|
||||
|
@ -433,6 +382,18 @@
|
|||
ref="items-list-area"
|
||||
class="items-list-area">
|
||||
|
||||
<!-- ADVANCED SEARCH -->
|
||||
<div
|
||||
id="advanced-search-container"
|
||||
role="search"
|
||||
v-if="openAdvancedSearch && !hideAdvancedSearch">
|
||||
|
||||
<advanced-search
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
:collection-id="collectionId"
|
||||
:has-advanced-search-results="hasAdvancedSearchResults" />
|
||||
</div>
|
||||
|
||||
<!-- FILTERS TAG LIST-->
|
||||
<filters-tags-list
|
||||
class="filter-tags-list"
|
||||
|
@ -484,7 +445,7 @@
|
|||
v-if="hasAnOpenAlert &&
|
||||
isSortingByCustomMetadata &&
|
||||
!showLoading &&
|
||||
((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
|
||||
((openAdvancedSearch && hasAdvancedSearchResults) || !openAdvancedSearch)"
|
||||
class="metadata-alert">
|
||||
<p class="text">
|
||||
{{
|
||||
|
@ -509,7 +470,7 @@
|
|||
|
||||
<!-- Theme View Modes -->
|
||||
<div
|
||||
v-if="((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch) &&
|
||||
v-if="((openAdvancedSearch && hasAdvancedSearchResults) || !openAdvancedSearch) &&
|
||||
!showLoading &&
|
||||
registeredViewModes[viewMode] != undefined &&
|
||||
registeredViewModes[viewMode].type == 'template'"
|
||||
|
@ -518,7 +479,7 @@
|
|||
<component
|
||||
v-if="registeredViewModes[viewMode] != undefined &&
|
||||
registeredViewModes[viewMode].type == 'component' &&
|
||||
((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch)"
|
||||
((openAdvancedSearch && hasAdvancedSearchResults) || !openAdvancedSearch)"
|
||||
:collection-id="collectionId"
|
||||
:displayed-metadata="displayedMetadata"
|
||||
:items="items"
|
||||
|
@ -535,7 +496,7 @@
|
|||
:is-sorting-by-custom-metadata="isSortingByCustomMetadata"
|
||||
v-if="totalItems > 0 &&
|
||||
((registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].show_pagination)) &&
|
||||
(advancedSearchResults || !openAdvancedSearch)"
|
||||
(hasAdvancedSearchResults || !openAdvancedSearch)"
|
||||
:hide-items-per-page-button="hideItemsPerPageButton"
|
||||
:hide-go-to-page-button="hideGoToPageButton"/>
|
||||
|
||||
|
@ -613,9 +574,7 @@
|
|||
localDisplayedMetadata: [],
|
||||
registeredViewModes: tainacan_plugin.registered_view_modes,
|
||||
openAdvancedSearch: false,
|
||||
openFormAdvancedSearch: false,
|
||||
advancedSearchResults: false,
|
||||
isDoingSearch: false,
|
||||
hasAdvancedSearchResults: false,
|
||||
sortingMetadata: [],
|
||||
isFiltersModalActive: false,
|
||||
hasAnOpenModal: false,
|
||||
|
@ -681,7 +640,7 @@
|
|||
openAdvancedSearch(newValue){
|
||||
if (newValue == false){
|
||||
this.$eventBusSearch.$emit('closeAdvancedSearch');
|
||||
this.advancedSearchResults = false;
|
||||
this.hasAdvancedSearchResults = false;
|
||||
this.isFiltersModalActive = !this.startWithFiltersHidden;
|
||||
} else {
|
||||
this.isFiltersModalActive = false;
|
||||
|
@ -739,8 +698,8 @@
|
|||
});
|
||||
|
||||
if (!this.hideAdvancedSearch) {
|
||||
this.$eventBusSearch.$on('advancedSearchResults', advancedSearchResults => {
|
||||
this.advancedSearchResults = advancedSearchResults;
|
||||
this.$eventBusSearch.$on('hasAdvancedSearchResults', hasAdvancedSearchResults => {
|
||||
this.hasAdvancedSearchResults = hasAdvancedSearchResults;
|
||||
});
|
||||
|
||||
if (this.$route.query && this.$route.query.advancedSearch) {
|
||||
|
@ -1209,7 +1168,7 @@
|
|||
this.$eventBusSearch.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$off('hasFiltered');
|
||||
if (!this.hideAdvancedSearch)
|
||||
this.$eventBusSearch.$off('advancedSearchResults');
|
||||
this.$eventBusSearch.$off('hasAdvancedSearchResults');
|
||||
this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters');
|
||||
|
||||
},
|
||||
|
@ -1279,7 +1238,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
.advanced-search-results-title {
|
||||
.has-advanced-search-results-title {
|
||||
margin-bottom: 40px;
|
||||
margin: 0 var(--tainacan-one-column) 42px var(--tainacan-one-column);
|
||||
|
||||
|
|
Loading…
Reference in New Issue